Hello

        I add doc and removed words symmetric and asymmetric from 
keywords. Corrected boolean expression too. This patch don't solve some 
problems: multiple evaluation of arguments, but its trivial and work with 
bitmap indexes.

Regards
Pavel Stehule
diff -c -r --new-file pgsql.old/src/backend/parser/gram.y 
pgsql.new/src/backend/parser/gram.y
*** pgsql.old/src/backend/parser/gram.y 2005-05-07 04:22:46.000000000 +0200
--- pgsql.new/src/backend/parser/gram.y 2005-06-01 18:41:12.000000000 +0200
***************
*** 338,344 ****
  /* ordinary key words in alphabetical order */
  %token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
        AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
!       ASSERTION ASSIGNMENT AT AUTHORIZATION
  
        BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
        BOOLEAN_P BOTH BY
--- 338,344 ----
  /* ordinary key words in alphabetical order */
  %token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
        AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
!       ASSERTION ASSIGNMENT ASYMMETRIC AT AUTHORIZATION
  
        BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
        BOOLEAN_P BOTH BY
***************
*** 399,405 ****
        SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
        SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
        SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
!       STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYSID
  
        TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
        TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
--- 399,406 ----
        SAVEPOINT SCHEMA SCROLL SECOND_P SECURITY SELECT SEQUENCE
        SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
        SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
!       STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYMMETRIC
!       SYSID
  
        TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
        TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
***************
*** 6341,6358 ****
                                {
                                        $$ = (Node *) 
makeSimpleA_Expr(AEXPR_OF, "!=", $1, (Node *) $6);
                                }
!                       | a_expr BETWEEN b_expr AND b_expr                      
%prec BETWEEN
                                {
                                        $$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3),
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<=", $1, $5));
                                }
!                       | a_expr NOT BETWEEN b_expr AND b_expr          %prec 
BETWEEN
                                {
                                        $$ = (Node *) makeA_Expr(AEXPR_OR, NIL,
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<", $1, $4),
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">", $1, $6));
                                }
                        | a_expr IN_P in_expr
                                {
                                        /* in_expr returns a SubLink or a list 
of a_exprs */
--- 6342,6382 ----
                                {
                                        $$ = (Node *) 
makeSimpleA_Expr(AEXPR_OF, "!=", $1, (Node *) $6);
                                }
!                       | a_expr BETWEEN opt_asymmetric b_expr AND b_expr       
                %prec BETWEEN
                                {
                                        $$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4),
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6));
                                }
!                       | a_expr NOT BETWEEN opt_asymmetric b_expr AND b_expr   
        %prec BETWEEN
                                {
                                        $$ = (Node *) makeA_Expr(AEXPR_OR, NIL,
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<", $1, $5),
!                                               (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">", $1, $7));
                                }
+                               
+                       | a_expr BETWEEN SYMMETRIC b_expr AND b_expr            
        %prec BETWEEN
+                               {
+                                       $$ = (Node *) makeA_Expr(AEXPR_OR, NIL,
+                                               (Node *) makeA_Expr(AEXPR_AND, 
NIL,
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4),
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6)),
+                                               (Node *) makeA_Expr(AEXPR_AND, 
NIL,
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">=", $1, $6),
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<=", $1, $4)));                                     
   
+                               }
+                       | a_expr NOT BETWEEN SYMMETRIC b_expr AND b_expr        
        %prec BETWEEN
+                               {
+                                       $$ = (Node *) makeA_Expr(AEXPR_AND, NIL,
+                                               (Node *) makeA_Expr(AEXPR_OR, 
NIL,
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<", $1, $5),
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">", $1, $7)),
+                                               (Node *) makeA_Expr(AEXPR_OR, 
NIL,
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, "<", $1, $7),
+                                                   (Node *) 
makeSimpleA_Expr(AEXPR_OP, ">", $1, $5)));                                 
+                               }
+                               
+                               
                        | a_expr IN_P in_expr
                                {
                                        /* in_expr returns a SubLink or a list 
of a_exprs */
***************
*** 6451,6456 ****
--- 6475,6485 ----
                                }
                ;
  
+ opt_asymmetric:               ASYMMETRIC                                      
                                {}
+                           | /*EMPTY*/                                         
                {}
+               ;
+ 
+ 
  /*
   * Restricted expressions
   *
***************
*** 7737,7742 ****
--- 7766,7772 ----
                        | ALTER
                        | ASSERTION
                        | ASSIGNMENT
+                       | ASYMMETRIC
                        | AT
                        | BACKWARD
                        | BEFORE
***************
*** 7883,7888 ****
--- 7913,7919 ----
                        | STDIN
                        | STDOUT
                        | STORAGE
+                       | SYMMETRIC
                        | SYSID
                        | STRICT_P
                        | TABLESPACE
diff -c -r --new-file pgsql.old/src/backend/parser/keywords.c 
pgsql.new/src/backend/parser/keywords.c
*** pgsql.old/src/backend/parser/keywords.c     2005-05-07 04:22:47.000000000 
+0200
--- pgsql.new/src/backend/parser/keywords.c     2005-05-31 22:39:44.000000000 
+0200
***************
*** 49,54 ****
--- 49,55 ----
        {"asc", ASC},
        {"assertion", ASSERTION},
        {"assignment", ASSIGNMENT},
+       {"asymmetric", ASYMMETRIC},
        {"at", AT},
        {"authorization", AUTHORIZATION},
        {"backward", BACKWARD},
***************
*** 296,301 ****
--- 297,303 ----
        {"storage", STORAGE},
        {"strict", STRICT_P},
        {"substring", SUBSTRING},
+       {"symmetric", SYMMETRIC},
        {"sysid", SYSID},
        {"table", TABLE},
        {"tablespace", TABLESPACE},
*** pgsql.old/doc/src/sgml/func.sgml    2005-05-23 03:50:01.000000000 +0200
--- pgsql.new/doc/src/sgml/func.sgml    2005-06-01 19:17:08.000000000 +0200
***************
*** 279,284 ****
--- 279,300 ----
  <synopsis>
  <replaceable>a</replaceable> &lt; <replaceable>x</replaceable> OR 
<replaceable>a</replaceable> &gt; <replaceable>y</replaceable>
  </synopsis>
+     There is special variant of this operator <indexterm><primary>BETWEEN 
SYMMETRIC</primary></indexterm>.
+     In this case isn't important <replaceable>x</replaceable> &lt;= 
<replaceable>y</replaceable> and
+     <replaceable>a</replaceable> BETWEEN SYMMETRIC 
<replaceable>x</replaceable> AND <replaceable>y</replaceable>
+     is equivalent to
+ <synopsis>
+ (<replaceable>a</replaceable> &gt;= <replaceable>x</replaceable> AND 
<replaceable>a</replaceable> &lt;= <replaceable>y</replaceable>) OR 
(<replaceable>a</replaceable> &gt;= <replaceable>y</replaceable> AND 
<replaceable>a</replaceable> &lt;= <replaceable>x</replaceable>)
+ </synopsis>
+     Similarly,
+ <synopsis>
+ <replaceable>a</replaceable> NOT BETWEEN SYMMETRIC 
<replaceable>x</replaceable> AND <replaceable>y</replaceable>
+ </synopsis>
+     is equivalent to
+ <synopsis>
+ (<replaceable>a</replaceable> &lt; <replaceable>x</replaceable> OR 
<replaceable>a</replaceable> &gt; <replaceable>y</replaceable>) OR 
(<replaceable>a</replaceable> &lt; <replaceable>y</replaceable> OR 
<replaceable>a</replaceable> &gt; <replaceable>x</replaceable>)
+ </synopsis>
+     
      There is no difference between the two respective forms apart from
      the <acronym>CPU</acronym> cycles required to rewrite the first one
      into the second one internally.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to