Commit 3b43accb authored by Bruce Momjian's avatar Bruce Momjian

Have % operator have precedence like /.

parent ebfa6ab7
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.60 1999/03/15 22:20:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.61 1999/03/17 20:17:12 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -341,7 +341,7 @@ Oid param_type(int t); /* used in parse_expr.c */ ...@@ -341,7 +341,7 @@ Oid param_type(int t); /* used in parse_expr.c */
%nonassoc ISNULL %nonassoc ISNULL
%nonassoc IS %nonassoc IS
%left '+' '-' %left '+' '-'
%left '*' '/' %left '*' '/' '%'
%left '|' /* this is the relation union op, not logical or */ %left '|' /* this is the relation union op, not logical or */
/* Unary Operators */ /* Unary Operators */
%right ':' %right ':'
...@@ -957,6 +957,8 @@ default_expr: AexprConst ...@@ -957,6 +957,8 @@ default_expr: AexprConst
{ $$ = nconc( $1, lcons( makeString( "-"), $3)); } { $$ = nconc( $1, lcons( makeString( "-"), $3)); }
| default_expr '/' default_expr | default_expr '/' default_expr
{ $$ = nconc( $1, lcons( makeString( "/"), $3)); } { $$ = nconc( $1, lcons( makeString( "/"), $3)); }
| default_expr '%' default_expr
{ $$ = nconc( $1, lcons( makeString( "%"), $3)); }
| default_expr '*' default_expr | default_expr '*' default_expr
{ $$ = nconc( $1, lcons( makeString( "*"), $3)); } { $$ = nconc( $1, lcons( makeString( "*"), $3)); }
| default_expr '=' default_expr | default_expr '=' default_expr
...@@ -1103,6 +1105,8 @@ constraint_expr: AexprConst ...@@ -1103,6 +1105,8 @@ constraint_expr: AexprConst
{ $$ = nconc( $1, lcons( makeString( "-"), $3)); } { $$ = nconc( $1, lcons( makeString( "-"), $3)); }
| constraint_expr '/' constraint_expr | constraint_expr '/' constraint_expr
{ $$ = nconc( $1, lcons( makeString( "/"), $3)); } { $$ = nconc( $1, lcons( makeString( "/"), $3)); }
| constraint_expr '%' constraint_expr
{ $$ = nconc( $1, lcons( makeString( "%"), $3)); }
| constraint_expr '*' constraint_expr | constraint_expr '*' constraint_expr
{ $$ = nconc( $1, lcons( makeString( "*"), $3)); } { $$ = nconc( $1, lcons( makeString( "*"), $3)); }
| constraint_expr '=' constraint_expr | constraint_expr '=' constraint_expr
...@@ -1999,6 +2003,7 @@ MathOp: '+' { $$ = "+"; } ...@@ -1999,6 +2003,7 @@ MathOp: '+' { $$ = "+"; }
| '-' { $$ = "-"; } | '-' { $$ = "-"; }
| '*' { $$ = "*"; } | '*' { $$ = "*"; }
| '/' { $$ = "/"; } | '/' { $$ = "/"; }
| '%' { $$ = "%"; }
| '<' { $$ = "<"; } | '<' { $$ = "<"; }
| '>' { $$ = ">"; } | '>' { $$ = ">"; }
| '=' { $$ = "="; } | '=' { $$ = "="; }
...@@ -3657,6 +3662,7 @@ row_op: Op { $$ = $1; } ...@@ -3657,6 +3662,7 @@ row_op: Op { $$ = $1; }
| '-' { $$ = "-"; } | '-' { $$ = "-"; }
| '*' { $$ = "*"; } | '*' { $$ = "*"; }
| '/' { $$ = "/"; } | '/' { $$ = "/"; }
| '%' { $$ = "%"; }
; ;
sub_type: ANY { $$ = ANY_SUBLINK; } sub_type: ANY { $$ = ANY_SUBLINK; }
...@@ -3696,6 +3702,8 @@ a_expr: attr opt_indirection ...@@ -3696,6 +3702,8 @@ a_expr: attr opt_indirection
{ $$ = makeA_Expr(OP, "-", $1, $3); } { $$ = makeA_Expr(OP, "-", $1, $3); }
| a_expr '/' a_expr | a_expr '/' a_expr
{ $$ = makeA_Expr(OP, "/", $1, $3); } { $$ = makeA_Expr(OP, "/", $1, $3); }
| a_expr '%' a_expr
{ $$ = makeA_Expr(OP, "%", $1, $3); }
| a_expr '*' a_expr | a_expr '*' a_expr
{ $$ = makeA_Expr(OP, "*", $1, $3); } { $$ = makeA_Expr(OP, "*", $1, $3); }
| a_expr '<' a_expr | a_expr '<' a_expr
...@@ -4079,6 +4087,16 @@ a_expr: attr opt_indirection ...@@ -4079,6 +4087,16 @@ a_expr: attr opt_indirection
n->subselect = $4; n->subselect = $4;
$$ = (Node *)n; $$ = (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 ')' | a_expr '*' '(' SubSelect ')'
{ {
SubLink *n = makeNode(SubLink); SubLink *n = makeNode(SubLink);
...@@ -4159,6 +4177,16 @@ a_expr: attr opt_indirection ...@@ -4159,6 +4177,16 @@ a_expr: attr opt_indirection
n->subselect = $5; n->subselect = $5;
$$ = (Node *)n; $$ = (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 ')' | a_expr '*' ANY '(' SubSelect ')'
{ {
SubLink *n = makeNode(SubLink); SubLink *n = makeNode(SubLink);
...@@ -4239,6 +4267,16 @@ a_expr: attr opt_indirection ...@@ -4239,6 +4267,16 @@ a_expr: attr opt_indirection
n->subselect = $5; n->subselect = $5;
$$ = (Node *)n; $$ = (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 ')' | a_expr '*' ALL '(' SubSelect ')'
{ {
SubLink *n = makeNode(SubLink); SubLink *n = makeNode(SubLink);
...@@ -4317,6 +4355,8 @@ b_expr: attr opt_indirection ...@@ -4317,6 +4355,8 @@ b_expr: attr opt_indirection
{ $$ = makeA_Expr(OP, "-", $1, $3); } { $$ = makeA_Expr(OP, "-", $1, $3); }
| b_expr '/' b_expr | b_expr '/' b_expr
{ $$ = makeA_Expr(OP, "/", $1, $3); } { $$ = makeA_Expr(OP, "/", $1, $3); }
| b_expr '%' b_expr
{ $$ = makeA_Expr(OP, "%", $1, $3); }
| b_expr '*' b_expr | b_expr '*' b_expr
{ $$ = makeA_Expr(OP, "*", $1, $3); } { $$ = makeA_Expr(OP, "*", $1, $3); }
| ':' b_expr | ':' b_expr
...@@ -4590,6 +4630,8 @@ position_expr: attr opt_indirection ...@@ -4590,6 +4630,8 @@ position_expr: attr opt_indirection
{ $$ = makeA_Expr(OP, "-", $1, $3); } { $$ = makeA_Expr(OP, "-", $1, $3); }
| position_expr '/' position_expr | position_expr '/' position_expr
{ $$ = makeA_Expr(OP, "/", $1, $3); } { $$ = makeA_Expr(OP, "/", $1, $3); }
| position_expr '%' position_expr
{ $$ = makeA_Expr(OP, "%", $1, $3); }
| position_expr '*' position_expr | position_expr '*' position_expr
{ $$ = makeA_Expr(OP, "*", $1, $3); } { $$ = makeA_Expr(OP, "*", $1, $3); }
| '|' position_expr | '|' position_expr
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.46 1999/02/13 23:17:12 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.47 1999/03/17 20:17:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -145,8 +145,8 @@ identifier {letter}{letter_or_digit}* ...@@ -145,8 +145,8 @@ identifier {letter}{letter_or_digit}*
typecast "::" typecast "::"
self [,()\[\].;$\:\+\-\*\/\<\>\=\|] self [,()\[\].;$\:\+\-\*\/\%\<\>\=\|]
op_and_self [\~\!\@\#\%\^\&\|\`\?\$\:\+\-\*\/\<\>\=] op_and_self [\~\!\@\#\^\&\|\`\?\$\:\+\-\*\/\%\<\>\=]
operator {op_and_self}+ operator {op_and_self}+
xmstop - xmstop -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment