Skip to content

Commit 4efb2ff

Browse files
author
Thomas G. Lockhart
committed
Fix the omitted declarations to allow '^' and '|' as math operators.
Problem was introduced when precedence was added for these. How did *those* changes get into the stable tree in the first place??
1 parent b8e2e3f commit 4efb2ff

File tree

1 file changed

+97
-35
lines changed

1 file changed

+97
-35
lines changed

src/backend/parser/gram.y

Lines changed: 97 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.88.2.2 1999/09/14 06:07:35 thomas Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.88.2.3 1999/09/24 15:08:59 thomas Exp $
1414
*
1515
* HISTORY
1616
* AUTHOR DATE MAJOR EVENT
@@ -221,7 +221,6 @@ Oid param_type(int t); /* used in parse_expr.c */
221221
having_clause
222222
%type <list> row_descriptor, row_list, c_list, c_expr
223223
%type <node> row_expr
224-
%type <str> row_op
225224
%type <node> case_expr, case_arg, when_clause, case_default
226225
%type <list> when_clause_list
227226
%type <ival> sub_type
@@ -970,12 +969,14 @@ default_expr: AexprConst
970969
{ $$ = nconc( $1, lcons( makeString( "-"), $3)); }
971970
| default_expr '/' default_expr
972971
{ $$ = nconc( $1, lcons( makeString( "/"), $3)); }
973-
| default_expr '%' default_expr
974-
{ $$ = nconc( $1, lcons( makeString( "%"), $3)); }
975972
| default_expr '*' default_expr
976973
{ $$ = nconc( $1, lcons( makeString( "*"), $3)); }
974+
| default_expr '%' default_expr
975+
{ $$ = nconc( $1, lcons( makeString( "%"), $3)); }
977976
| default_expr '^' default_expr
978977
{ $$ = nconc( $1, lcons( makeString( "^"), $3)); }
978+
| default_expr '|' default_expr
979+
{ $$ = nconc( $1, lcons( makeString( "|"), $3)); }
979980
| default_expr '=' default_expr
980981
{ elog(ERROR,"boolean expressions not supported in DEFAULT"); }
981982
| default_expr '<' default_expr
@@ -1120,12 +1121,14 @@ constraint_expr: AexprConst
11201121
{ $$ = nconc( $1, lcons( makeString( "-"), $3)); }
11211122
| constraint_expr '/' constraint_expr
11221123
{ $$ = nconc( $1, lcons( makeString( "/"), $3)); }
1123-
| constraint_expr '%' constraint_expr
1124-
{ $$ = nconc( $1, lcons( makeString( "%"), $3)); }
11251124
| constraint_expr '*' constraint_expr
11261125
{ $$ = nconc( $1, lcons( makeString( "*"), $3)); }
1126+
| constraint_expr '%' constraint_expr
1127+
{ $$ = nconc( $1, lcons( makeString( "%"), $3)); }
11271128
| constraint_expr '^' constraint_expr
11281129
{ $$ = nconc( $1, lcons( makeString( "^"), $3)); }
1130+
| constraint_expr '|' constraint_expr
1131+
{ $$ = nconc( $1, lcons( makeString( "|"), $3)); }
11291132
| constraint_expr '=' constraint_expr
11301133
{ $$ = nconc( $1, lcons( makeString( "="), $3)); }
11311134
| constraint_expr '<' constraint_expr
@@ -2016,13 +2019,15 @@ RemoveOperStmt: DROP OPERATOR all_Op '(' oper_argtypes ')'
20162019

20172020
all_Op: Op | MathOp;
20182021

2019-
MathOp: '+' { $$ = "+"; }
2022+
MathOp: '+' { $$ = "+"; }
20202023
| '-' { $$ = "-"; }
20212024
| '*' { $$ = "*"; }
20222025
| '/' { $$ = "/"; }
2023-
| '%' { $$ = "%"; }
20242026
| '<' { $$ = "<"; }
20252027
| '>' { $$ = ">"; }
2028+
| '%' { $$ = "%"; }
2029+
| '^' { $$ = "^"; }
2030+
| '|' { $$ = "|"; }
20262031
| '=' { $$ = "="; }
20272032
;
20282033

@@ -3528,7 +3533,7 @@ a_expr_or_null: a_expr
35283533
/* Expressions using row descriptors
35293534
* Define row_descriptor to allow yacc to break the reduce/reduce conflict
35303535
* with singleton expressions.
3531-
* Eliminated lots of code by defining row_op and sub_type clauses.
3536+
* Eliminated lots of code by defining sub_type clauses.
35323537
* However, can not consolidate EXPR_LINK case with others subselects
35333538
* due to shift/reduce conflict with the non-subselect clause (the parser
35343539
* would have to look ahead more than one token to resolve the conflict).
@@ -3554,7 +3559,7 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
35543559
n->subselect = $7;
35553560
$$ = (Node *)n;
35563561
}
3557-
| '(' row_descriptor ')' row_op sub_type '(' SubSelect ')'
3562+
| '(' row_descriptor ')' all_Op sub_type '(' SubSelect ')'
35583563
{
35593564
SubLink *n = makeNode(SubLink);
35603565
n->lefthand = $2;
@@ -3567,7 +3572,7 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
35673572
n->subselect = $7;
35683573
$$ = (Node *)n;
35693574
}
3570-
| '(' row_descriptor ')' row_op '(' SubSelect ')'
3575+
| '(' row_descriptor ')' all_Op '(' SubSelect ')'
35713576
{
35723577
SubLink *n = makeNode(SubLink);
35733578
n->lefthand = $2;
@@ -3580,7 +3585,7 @@ row_expr: '(' row_descriptor ')' IN '(' SubSelect ')'
35803585
n->subselect = $6;
35813586
$$ = (Node *)n;
35823587
}
3583-
| '(' row_descriptor ')' row_op '(' row_descriptor ')'
3588+
| '(' row_descriptor ')' all_Op '(' row_descriptor ')'
35843589
{
35853590
$$ = makeRowExpr($4, $2, $6);
35863591
}
@@ -3602,17 +3607,6 @@ row_list: row_list ',' a_expr
36023607
}
36033608
;
36043609

3605-
row_op: Op { $$ = $1; }
3606-
| '<' { $$ = "<"; }
3607-
| '=' { $$ = "="; }
3608-
| '>' { $$ = ">"; }
3609-
| '+' { $$ = "+"; }
3610-
| '-' { $$ = "-"; }
3611-
| '*' { $$ = "*"; }
3612-
| '/' { $$ = "/"; }
3613-
| '%' { $$ = "%"; }
3614-
;
3615-
36163610
sub_type: ANY { $$ = ANY_SUBLINK; }
36173611
| ALL { $$ = ALL_SUBLINK; }
36183612
;
@@ -3658,12 +3652,14 @@ a_expr: attr opt_indirection
36583652
{ $$ = makeA_Expr(OP, "-", $1, $3); }
36593653
| a_expr '/' a_expr
36603654
{ $$ = makeA_Expr(OP, "/", $1, $3); }
3661-
| a_expr '%' a_expr
3662-
{ $$ = makeA_Expr(OP, "%", $1, $3); }
36633655
| a_expr '*' a_expr
36643656
{ $$ = makeA_Expr(OP, "*", $1, $3); }
3657+
| a_expr '%' a_expr
3658+
{ $$ = makeA_Expr(OP, "%", $1, $3); }
36653659
| a_expr '^' a_expr
36663660
{ $$ = makeA_Expr(OP, "^", $1, $3); }
3661+
| a_expr '|' a_expr
3662+
{ $$ = makeA_Expr(OP, "|", $1, $3); }
36673663
| a_expr '<' a_expr
36683664
{ $$ = makeA_Expr(OP, "<", $1, $3); }
36693665
| a_expr '>' a_expr
@@ -4049,6 +4045,16 @@ a_expr: attr opt_indirection
40494045
n->subselect = $4;
40504046
$$ = (Node *)n;
40514047
}
4048+
| a_expr '*' '(' SubSelect ')'
4049+
{
4050+
SubLink *n = makeNode(SubLink);
4051+
n->lefthand = lcons($1, NULL);
4052+
n->oper = lcons("*",NIL);
4053+
n->useor = false;
4054+
n->subLinkType = EXPR_SUBLINK;
4055+
n->subselect = $4;
4056+
$$ = (Node *)n;
4057+
}
40524058
| a_expr '%' '(' SubSelect ')'
40534059
{
40544060
SubLink *n = makeNode(SubLink);
@@ -4059,11 +4065,21 @@ a_expr: attr opt_indirection
40594065
n->subselect = $4;
40604066
$$ = (Node *)n;
40614067
}
4062-
| a_expr '*' '(' SubSelect ')'
4068+
| a_expr '^' '(' SubSelect ')'
40634069
{
40644070
SubLink *n = makeNode(SubLink);
40654071
n->lefthand = lcons($1, NULL);
4066-
n->oper = lcons("*",NIL);
4072+
n->oper = lcons("^",NIL);
4073+
n->useor = false;
4074+
n->subLinkType = EXPR_SUBLINK;
4075+
n->subselect = $4;
4076+
$$ = (Node *)n;
4077+
}
4078+
| a_expr '|' '(' SubSelect ')'
4079+
{
4080+
SubLink *n = makeNode(SubLink);
4081+
n->lefthand = lcons($1, NULL);
4082+
n->oper = lcons("|",NIL);
40674083
n->useor = false;
40684084
n->subLinkType = EXPR_SUBLINK;
40694085
n->subselect = $4;
@@ -4139,6 +4155,16 @@ a_expr: attr opt_indirection
41394155
n->subselect = $5;
41404156
$$ = (Node *)n;
41414157
}
4158+
| a_expr '*' ANY '(' SubSelect ')'
4159+
{
4160+
SubLink *n = makeNode(SubLink);
4161+
n->lefthand = lcons($1,NIL);
4162+
n->oper = lcons("*",NIL);
4163+
n->useor = false;
4164+
n->subLinkType = ANY_SUBLINK;
4165+
n->subselect = $5;
4166+
$$ = (Node *)n;
4167+
}
41424168
| a_expr '%' ANY '(' SubSelect ')'
41434169
{
41444170
SubLink *n = makeNode(SubLink);
@@ -4149,11 +4175,21 @@ a_expr: attr opt_indirection
41494175
n->subselect = $5;
41504176
$$ = (Node *)n;
41514177
}
4152-
| a_expr '*' ANY '(' SubSelect ')'
4178+
| a_expr '^' ANY '(' SubSelect ')'
41534179
{
41544180
SubLink *n = makeNode(SubLink);
41554181
n->lefthand = lcons($1,NIL);
4156-
n->oper = lcons("*",NIL);
4182+
n->oper = lcons("^",NIL);
4183+
n->useor = false;
4184+
n->subLinkType = ANY_SUBLINK;
4185+
n->subselect = $5;
4186+
$$ = (Node *)n;
4187+
}
4188+
| a_expr '|' ANY '(' SubSelect ')'
4189+
{
4190+
SubLink *n = makeNode(SubLink);
4191+
n->lefthand = lcons($1,NIL);
4192+
n->oper = lcons("|",NIL);
41574193
n->useor = false;
41584194
n->subLinkType = ANY_SUBLINK;
41594195
n->subselect = $5;
@@ -4229,6 +4265,16 @@ a_expr: attr opt_indirection
42294265
n->subselect = $5;
42304266
$$ = (Node *)n;
42314267
}
4268+
| a_expr '*' ALL '(' SubSelect ')'
4269+
{
4270+
SubLink *n = makeNode(SubLink);
4271+
n->lefthand = lcons($1, NULL);
4272+
n->oper = lcons("*",NIL);
4273+
n->useor = false;
4274+
n->subLinkType = ALL_SUBLINK;
4275+
n->subselect = $5;
4276+
$$ = (Node *)n;
4277+
}
42324278
| a_expr '%' ALL '(' SubSelect ')'
42334279
{
42344280
SubLink *n = makeNode(SubLink);
@@ -4239,11 +4285,21 @@ a_expr: attr opt_indirection
42394285
n->subselect = $5;
42404286
$$ = (Node *)n;
42414287
}
4242-
| a_expr '*' ALL '(' SubSelect ')'
4288+
| a_expr '^' ALL '(' SubSelect ')'
42434289
{
42444290
SubLink *n = makeNode(SubLink);
42454291
n->lefthand = lcons($1, NULL);
4246-
n->oper = lcons("*",NIL);
4292+
n->oper = lcons("^",NIL);
4293+
n->useor = false;
4294+
n->subLinkType = ALL_SUBLINK;
4295+
n->subselect = $5;
4296+
$$ = (Node *)n;
4297+
}
4298+
| a_expr '|' ALL '(' SubSelect ')'
4299+
{
4300+
SubLink *n = makeNode(SubLink);
4301+
n->lefthand = lcons($1, NULL);
4302+
n->oper = lcons("|",NIL);
42474303
n->useor = false;
42484304
n->subLinkType = ALL_SUBLINK;
42494305
n->subselect = $5;
@@ -4325,12 +4381,14 @@ b_expr: attr opt_indirection
43254381
{ $$ = makeA_Expr(OP, "-", $1, $3); }
43264382
| b_expr '/' b_expr
43274383
{ $$ = makeA_Expr(OP, "/", $1, $3); }
4384+
| b_expr '*' b_expr
4385+
{ $$ = makeA_Expr(OP, "*", $1, $3); }
43284386
| b_expr '%' b_expr
43294387
{ $$ = makeA_Expr(OP, "%", $1, $3); }
43304388
| b_expr '^' b_expr
43314389
{ $$ = makeA_Expr(OP, "^", $1, $3); }
4332-
| b_expr '*' b_expr
4333-
{ $$ = makeA_Expr(OP, "*", $1, $3); }
4390+
| b_expr '|' b_expr
4391+
{ $$ = makeA_Expr(OP, "|", $1, $3); }
43344392
| ':' b_expr
43354393
{ $$ = makeA_Expr(OP, ":", NULL, $2); }
43364394
| ';' b_expr
@@ -4602,10 +4660,14 @@ position_expr: attr opt_indirection
46024660
{ $$ = makeA_Expr(OP, "-", $1, $3); }
46034661
| position_expr '/' position_expr
46044662
{ $$ = makeA_Expr(OP, "/", $1, $3); }
4605-
| position_expr '%' position_expr
4606-
{ $$ = makeA_Expr(OP, "%", $1, $3); }
46074663
| position_expr '*' position_expr
46084664
{ $$ = makeA_Expr(OP, "*", $1, $3); }
4665+
| position_expr '%' position_expr
4666+
{ $$ = makeA_Expr(OP, "%", $1, $3); }
4667+
| position_expr '^' position_expr
4668+
{ $$ = makeA_Expr(OP, "^", $1, $3); }
4669+
| position_expr '|' position_expr
4670+
{ $$ = makeA_Expr(OP, "|", $1, $3); }
46094671
| '|' position_expr
46104672
{ $$ = makeA_Expr(OP, "|", NULL, $2); }
46114673
| position_expr TYPECAST Typename

0 commit comments

Comments
 (0)