Re: PostgreSQL Upgrade Procedure - Mailing list pgsql-hackers

From Thomas Lockhart
Subject Re: PostgreSQL Upgrade Procedure
Date
Msg-id 37EB90C2.6935454A@alumni.caltech.edu
Whole thread Raw
List pgsql-hackers
> > > There is a parser bug someone introduced recently which we will fix
> > > for v6.5.3, but I can give you a patch file for this on v6.5.2. I'll
> > > develop it in the next couple of days.
> > Is it a showstopper??  Send the patch anyway, of course.

"showstopper" in the sense that it was not in v6.5.1? Apparently not.
But it causes a couple of math operators to not be recognized as
operators in some situations (like when defining a new operator :/

Here is a patch. *Not* tested under v6.5.1 or .2, but *all* of the
changes were tested under the current development tree. Since it
patches gram.y, it will cause gram.c to be rebuilt, which we usually
try to avoid but only because not everyone has bison/flex installed.
That isn't the case for your RH system.

                      - Thomas

--
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California*** gram.y.orig    Thu Sep 23 16:30:59 1999
--- gram.y    Fri Sep 24 14:42:53 1999
***************
*** 221,227 ****
                  having_clause
  %type <list>    row_descriptor, row_list, c_list, c_expr
  %type <node>    row_expr
- %type <str>        row_op
  %type <node>    case_expr, case_arg, when_clause, case_default
  %type <list>    when_clause_list
  %type <ival>    sub_type
--- 221,226 ----
***************
*** 970,981 ****
                  {    $$ = nconc( $1, lcons( makeString( "-"), $3)); }
              | default_expr '/' default_expr
                  {    $$ = nconc( $1, lcons( makeString( "/"), $3)); }
-             | default_expr '%' default_expr
-                 {    $$ = nconc( $1, lcons( makeString( "%"), $3)); }
              | default_expr '*' default_expr
                  {    $$ = nconc( $1, lcons( makeString( "*"), $3)); }
              | default_expr '^' default_expr
                  {    $$ = nconc( $1, lcons( makeString( "^"), $3)); }
              | default_expr '=' default_expr
                  {    elog(ERROR,"boolean expressions not supported in DEFAULT"); }
              | default_expr '<' default_expr
--- 969,982 ----
                  {    $$ = nconc( $1, lcons( makeString( "-"), $3)); }
              | default_expr '/' default_expr
                  {    $$ = nconc( $1, lcons( makeString( "/"), $3)); }
              | default_expr '*' default_expr
                  {    $$ = nconc( $1, lcons( makeString( "*"), $3)); }
+             | default_expr '%' default_expr
+                 {    $$ = nconc( $1, lcons( makeString( "%"), $3)); }
              | default_expr '^' default_expr
                  {    $$ = nconc( $1, lcons( makeString( "^"), $3)); }
+             | default_expr '|' default_expr
+                 {    $$ = nconc( $1, lcons( makeString( "|"), $3)); }
              | default_expr '=' default_expr
                  {    elog(ERROR,"boolean expressions not supported in DEFAULT"); }
              | default_expr '<' default_expr
***************
*** 1120,1131 ****
                  {    $$ = nconc( $1, lcons( makeString( "-"), $3)); }
              | constraint_expr '/' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "/"), $3)); }
-             | constraint_expr '%' constraint_expr
-                 {    $$ = nconc( $1, lcons( makeString( "%"), $3)); }
              | constraint_expr '*' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "*"), $3)); }
              | constraint_expr '^' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "^"), $3)); }
              | constraint_expr '=' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "="), $3)); }
              | constraint_expr '<' constraint_expr
--- 1121,1134 ----
                  {    $$ = nconc( $1, lcons( makeString( "-"), $3)); }
              | constraint_expr '/' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "/"), $3)); }
              | constraint_expr '*' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "*"), $3)); }
+             | constraint_expr '%' constraint_expr
+                 {    $$ = nconc( $1, lcons( makeString( "%"), $3)); }
              | constraint_expr '^' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "^"), $3)); }
+             | constraint_expr '|' constraint_expr
+                 {    $$ = nconc( $1, lcons( makeString( "|"), $3)); }
              | constraint_expr '=' constraint_expr
                  {    $$ = nconc( $1, lcons( makeString( "="), $3)); }
              | constraint_expr '<' constraint_expr
***************
*** 2016,2028 ****

  all_Op:  Op | MathOp;

! MathOp:    '+'                { $$ = "+"; }
          | '-'            { $$ = "-"; }
          | '*'            { $$ = "*"; }
          | '/'            { $$ = "/"; }
-         | '%'            { $$ = "%"; }
          | '<'            { $$ = "<"; }
          | '>'            { $$ = ">"; }
          | '='            { $$ = "="; }
          ;

--- 2019,2033 ----

  all_Op:  Op | MathOp;

! MathOp:  '+'            { $$ = "+"; }
          | '-'            { $$ = "-"; }
          | '*'            { $$ = "*"; }
          | '/'            { $$ = "/"; }
          | '<'            { $$ = "<"; }
          | '>'            { $$ = ">"; }
+         | '%'            { $$ = "%"; }
+         | '^'            { $$ = "^"; }
+         | '|'            { $$ = "|"; }
          | '='            { $$ = "="; }
          ;

***************
*** 3528,3534 ****
  /* Expressions using row descriptors
   * Define row_descriptor to allow yacc to break the reduce/reduce conflict
   *  with singleton expressions.
!  * Eliminated lots of code by defining row_op and sub_type clauses.
   * However, can not consolidate EXPR_LINK case with others subselects
   *  due to shift/reduce conflict with the non-subselect clause (the parser
   *  would have to look ahead more than one token to resolve the conflict).
--- 3533,3539 ----
  /* Expressions using row descriptors
   * Define row_descriptor to allow yacc to break the reduce/reduce conflict
   *  with singleton expressions.
!  * Eliminated lots of code by defining sub_type clauses.
   * However, can not consolidate EXPR_LINK case with others subselects
   *  due to shift/reduce conflict with the non-subselect clause (the parser
   *  would have to look ahead more than one token to resolve the conflict).
***************
*** 3554,3560 ****
                      n->subselect = $7;
                      $$ = (Node *)n;
                  }
!         | '(' row_descriptor ')' row_op sub_type '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = $2;
--- 3559,3565 ----
                      n->subselect = $7;
                      $$ = (Node *)n;
                  }
!         | '(' row_descriptor ')' all_Op sub_type '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = $2;
***************
*** 3567,3573 ****
                      n->subselect = $7;
                      $$ = (Node *)n;
                  }
!         | '(' row_descriptor ')' row_op '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = $2;
--- 3572,3578 ----
                      n->subselect = $7;
                      $$ = (Node *)n;
                  }
!         | '(' row_descriptor ')' all_Op '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = $2;
***************
*** 3580,3586 ****
                      n->subselect = $6;
                      $$ = (Node *)n;
                  }
!         | '(' row_descriptor ')' row_op '(' row_descriptor ')'
                  {
                      $$ = makeRowExpr($4, $2, $6);
                  }
--- 3585,3591 ----
                      n->subselect = $6;
                      $$ = (Node *)n;
                  }
!         | '(' row_descriptor ')' all_Op '(' row_descriptor ')'
                  {
                      $$ = makeRowExpr($4, $2, $6);
                  }
***************
*** 3602,3618 ****
                  }
          ;

- row_op:  Op                                    { $$ = $1; }
-         | '<'                                { $$ = "<"; }
-         | '='                                { $$ = "="; }
-         | '>'                                { $$ = ">"; }
-         | '+'                                { $$ = "+"; }
-         | '-'                                { $$ = "-"; }
-         | '*'                                { $$ = "*"; }
-         | '/'                                { $$ = "/"; }
-         | '%'                                { $$ = "%"; }
-         ;
-
  sub_type:  ANY                                { $$ = ANY_SUBLINK; }
          | ALL                                { $$ = ALL_SUBLINK; }
          ;
--- 3607,3612 ----
***************
*** 3658,3669 ****
                  {    $$ = makeA_Expr(OP, "-", $1, $3); }
          | a_expr '/' a_expr
                  {    $$ = makeA_Expr(OP, "/", $1, $3); }
-         | a_expr '%' a_expr
-                 {    $$ = makeA_Expr(OP, "%", $1, $3); }
          | a_expr '*' a_expr
                  {    $$ = makeA_Expr(OP, "*", $1, $3); }
          | a_expr '^' a_expr
                  {    $$ = makeA_Expr(OP, "^", $1, $3); }
          | a_expr '<' a_expr
                  {    $$ = makeA_Expr(OP, "<", $1, $3); }
          | a_expr '>' a_expr
--- 3652,3665 ----
                  {    $$ = makeA_Expr(OP, "-", $1, $3); }
          | a_expr '/' a_expr
                  {    $$ = makeA_Expr(OP, "/", $1, $3); }
          | a_expr '*' a_expr
                  {    $$ = makeA_Expr(OP, "*", $1, $3); }
+         | a_expr '%' a_expr
+                 {    $$ = makeA_Expr(OP, "%", $1, $3); }
          | a_expr '^' a_expr
                  {    $$ = makeA_Expr(OP, "^", $1, $3); }
+         | a_expr '|' a_expr
+                 {    $$ = makeA_Expr(OP, "|", $1, $3); }
          | a_expr '<' a_expr
                  {    $$ = makeA_Expr(OP, "<", $1, $3); }
          | a_expr '>' a_expr
***************
*** 4049,4054 ****
--- 4045,4060 ----
                      n->subselect = $4;
                      $$ = (Node *)n;
                  }
+         | a_expr '*' '(' SubSelect ')'
+                 {
+                     SubLink *n = makeNode(SubLink);
+                     n->lefthand = lcons($1, NULL);
+                     n->oper = lcons("*",NIL);
+                     n->useor = false;
+                     n->subLinkType = EXPR_SUBLINK;
+                     n->subselect = $4;
+                     $$ = (Node *)n;
+                 }
          | a_expr '%' '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
***************
*** 4059,4069 ****
                      n->subselect = $4;
                      $$ = (Node *)n;
                  }
!         | a_expr '*' '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = lcons($1, NULL);
!                     n->oper = lcons("*",NIL);
                      n->useor = false;
                      n->subLinkType = EXPR_SUBLINK;
                      n->subselect = $4;
--- 4065,4085 ----
                      n->subselect = $4;
                      $$ = (Node *)n;
                  }
!         | a_expr '^' '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = lcons($1, NULL);
!                     n->oper = lcons("^",NIL);
!                     n->useor = false;
!                     n->subLinkType = EXPR_SUBLINK;
!                     n->subselect = $4;
!                     $$ = (Node *)n;
!                 }
!         | a_expr '|' '(' SubSelect ')'
!                 {
!                     SubLink *n = makeNode(SubLink);
!                     n->lefthand = lcons($1, NULL);
!                     n->oper = lcons("|",NIL);
                      n->useor = false;
                      n->subLinkType = EXPR_SUBLINK;
                      n->subselect = $4;
***************
*** 4139,4144 ****
--- 4155,4170 ----
                      n->subselect = $5;
                      $$ = (Node *)n;
                  }
+         | a_expr '*' ANY '(' SubSelect ')'
+                 {
+                     SubLink *n = makeNode(SubLink);
+                     n->lefthand = lcons($1,NIL);
+                     n->oper = lcons("*",NIL);
+                     n->useor = false;
+                     n->subLinkType = ANY_SUBLINK;
+                     n->subselect = $5;
+                     $$ = (Node *)n;
+                 }
          | a_expr '%' ANY '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
***************
*** 4149,4159 ****
                      n->subselect = $5;
                      $$ = (Node *)n;
                  }
!         | a_expr '*' ANY '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = lcons($1,NIL);
!                     n->oper = lcons("*",NIL);
                      n->useor = false;
                      n->subLinkType = ANY_SUBLINK;
                      n->subselect = $5;
--- 4175,4195 ----
                      n->subselect = $5;
                      $$ = (Node *)n;
                  }
!         | a_expr '^' ANY '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = lcons($1,NIL);
!                     n->oper = lcons("^",NIL);
!                     n->useor = false;
!                     n->subLinkType = ANY_SUBLINK;
!                     n->subselect = $5;
!                     $$ = (Node *)n;
!                 }
!         | a_expr '|' ANY '(' SubSelect ')'
!                 {
!                     SubLink *n = makeNode(SubLink);
!                     n->lefthand = lcons($1,NIL);
!                     n->oper = lcons("|",NIL);
                      n->useor = false;
                      n->subLinkType = ANY_SUBLINK;
                      n->subselect = $5;
***************
*** 4229,4234 ****
--- 4265,4280 ----
                      n->subselect = $5;
                      $$ = (Node *)n;
                  }
+         | a_expr '*' ALL '(' SubSelect ')'
+                 {
+                     SubLink *n = makeNode(SubLink);
+                     n->lefthand = lcons($1, NULL);
+                     n->oper = lcons("*",NIL);
+                     n->useor = false;
+                     n->subLinkType = ALL_SUBLINK;
+                     n->subselect = $5;
+                     $$ = (Node *)n;
+                 }
          | a_expr '%' ALL '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
***************
*** 4239,4249 ****
                      n->subselect = $5;
                      $$ = (Node *)n;
                  }
!         | a_expr '*' ALL '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = lcons($1, NULL);
!                     n->oper = lcons("*",NIL);
                      n->useor = false;
                      n->subLinkType = ALL_SUBLINK;
                      n->subselect = $5;
--- 4285,4305 ----
                      n->subselect = $5;
                      $$ = (Node *)n;
                  }
!         | a_expr '^' ALL '(' SubSelect ')'
                  {
                      SubLink *n = makeNode(SubLink);
                      n->lefthand = lcons($1, NULL);
!                     n->oper = lcons("^",NIL);
!                     n->useor = false;
!                     n->subLinkType = ALL_SUBLINK;
!                     n->subselect = $5;
!                     $$ = (Node *)n;
!                 }
!         | a_expr '|' ALL '(' SubSelect ')'
!                 {
!                     SubLink *n = makeNode(SubLink);
!                     n->lefthand = lcons($1, NULL);
!                     n->oper = lcons("|",NIL);
                      n->useor = false;
                      n->subLinkType = ALL_SUBLINK;
                      n->subselect = $5;
***************
*** 4325,4336 ****
                  {    $$ = makeA_Expr(OP, "-", $1, $3); }
          | b_expr '/' b_expr
                  {    $$ = makeA_Expr(OP, "/", $1, $3); }
          | b_expr '%' b_expr
                  {    $$ = makeA_Expr(OP, "%", $1, $3); }
          | b_expr '^' b_expr
                  {    $$ = makeA_Expr(OP, "^", $1, $3); }
!         | b_expr '*' b_expr
!                 {    $$ = makeA_Expr(OP, "*", $1, $3); }
          | ':' b_expr
                  {    $$ = makeA_Expr(OP, ":", NULL, $2); }
          | ';' b_expr
--- 4381,4394 ----
                  {    $$ = makeA_Expr(OP, "-", $1, $3); }
          | b_expr '/' b_expr
                  {    $$ = makeA_Expr(OP, "/", $1, $3); }
+         | b_expr '*' b_expr
+                 {    $$ = makeA_Expr(OP, "*", $1, $3); }
          | b_expr '%' b_expr
                  {    $$ = makeA_Expr(OP, "%", $1, $3); }
          | b_expr '^' b_expr
                  {    $$ = makeA_Expr(OP, "^", $1, $3); }
!         | b_expr '|' b_expr
!                 {    $$ = makeA_Expr(OP, "|", $1, $3); }
          | ':' b_expr
                  {    $$ = makeA_Expr(OP, ":", NULL, $2); }
          | ';' b_expr
***************
*** 4602,4611 ****
                  {    $$ = makeA_Expr(OP, "-", $1, $3); }
          | position_expr '/' position_expr
                  {    $$ = makeA_Expr(OP, "/", $1, $3); }
-         | position_expr '%' position_expr
-                 {    $$ = makeA_Expr(OP, "%", $1, $3); }
          | position_expr '*' position_expr
                  {    $$ = makeA_Expr(OP, "*", $1, $3); }
          | '|' position_expr
                  {    $$ = makeA_Expr(OP, "|", NULL, $2); }
          | position_expr TYPECAST Typename
--- 4660,4673 ----
                  {    $$ = makeA_Expr(OP, "-", $1, $3); }
          | position_expr '/' position_expr
                  {    $$ = makeA_Expr(OP, "/", $1, $3); }
          | position_expr '*' position_expr
                  {    $$ = makeA_Expr(OP, "*", $1, $3); }
+         | position_expr '%' position_expr
+                 {    $$ = makeA_Expr(OP, "%", $1, $3); }
+         | position_expr '^' position_expr
+                 {    $$ = makeA_Expr(OP, "^", $1, $3); }
+         | position_expr '|' position_expr
+                 {    $$ = makeA_Expr(OP, "|", $1, $3); }
          | '|' position_expr
                  {    $$ = makeA_Expr(OP, "|", NULL, $2); }
          | position_expr TYPECAST Typename

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Frustration
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Re: [GENERAL] Update of bitmask type