11
11
*
12
12
*
13
13
* IDENTIFICATION
14
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.523 2006/01/22 05: 20:33 neilc Exp $
14
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.524 2006/01/22 20:03:16 tgl Exp $
15
15
*
16
16
* HISTORY
17
17
* AUTHOR DATE MAJOR EVENT
@@ -429,6 +429,7 @@ static void doNegateFloat(Value *v);
429
429
%token <ival> ICONST PARAM
430
430
431
431
/* precedence: lowest to highest */
432
+ %nonassoc SET /* see relation_expr_opt_alias */
432
433
%left UNION EXCEPT
433
434
%left INTERSECT
434
435
%left OR
@@ -5880,11 +5881,27 @@ relation_expr:
5880
5881
;
5881
5882
5882
5883
5883
- relation_expr_opt_alias: relation_expr
5884
+ /*
5885
+ * Given "UPDATE foo set set ...", we have to decide without looking any
5886
+ * further ahead whether the first "set" is an alias or the UPDATE's SET
5887
+ * keyword. Since "set" is allowed as a column name both interpretations
5888
+ * are feasible. We resolve the shift/reduce conflict by giving the first
5889
+ * relation_expr_opt_alias production a higher precedence than the SET token
5890
+ * has, causing the parser to prefer to reduce, in effect assuming that the
5891
+ * SET is not an alias.
5892
+ */
5893
+ relation_expr_opt_alias: relation_expr %prec UMINUS
5884
5894
{
5885
5895
$$ = $1 ;
5886
5896
}
5887
- | relation_expr opt_as IDENT
5897
+ | relation_expr ColId
5898
+ {
5899
+ Alias *alias = makeNode(Alias);
5900
+ alias->aliasname = $2 ;
5901
+ $1 ->alias = alias;
5902
+ $$ = $1 ;
5903
+ }
5904
+ | relation_expr AS ColId
5888
5905
{
5889
5906
Alias *alias = makeNode(Alias);
5890
5907
alias->aliasname = $3 ;
@@ -6827,7 +6844,7 @@ a_expr: c_expr { $$ = $1; }
6827
6844
$$ = (Node *) makeSimpleA_Expr(AEXPR_IN, " <>" , $1 , $4 );
6828
6845
}
6829
6846
}
6830
- | a_expr subquery_Op sub_type select_with_parens %prec Op
6847
+ | a_expr subquery_Op sub_type select_with_parens %prec Op
6831
6848
{
6832
6849
SubLink *n = makeNode(SubLink);
6833
6850
n->subLinkType = $3 ;
@@ -6836,14 +6853,14 @@ a_expr: c_expr { $$ = $1; }
6836
6853
n->subselect = $4 ;
6837
6854
$$ = (Node *)n;
6838
6855
}
6839
- | a_expr subquery_Op sub_type ' (' a_expr ' )' %prec Op
6856
+ | a_expr subquery_Op sub_type ' (' a_expr ' )' %prec Op
6840
6857
{
6841
6858
if ($3 == ANY_SUBLINK)
6842
6859
$$ = (Node *) makeA_Expr(AEXPR_OP_ANY, $2 , $1 , $5 );
6843
6860
else
6844
6861
$$ = (Node *) makeA_Expr(AEXPR_OP_ALL, $2 , $1 , $5 );
6845
6862
}
6846
- | UNIQUE select_with_parens %prec Op
6863
+ | UNIQUE select_with_parens
6847
6864
{
6848
6865
/* Not sure how to get rid of the parentheses
6849
6866
* but there are lots of shift/reduce errors without them.
@@ -6901,7 +6918,7 @@ b_expr: c_expr
6901
6918
{ $$ = (Node *) makeA_Expr(AEXPR_OP, $1 , NULL , $2 ); }
6902
6919
| b_expr qual_Op %prec POSTFIXOP
6903
6920
{ $$ = (Node *) makeA_Expr(AEXPR_OP, $2 , $1 , NULL ); }
6904
- | b_expr IS DISTINCT FROM b_expr %prec IS
6921
+ | b_expr IS DISTINCT FROM b_expr %prec IS
6905
6922
{
6906
6923
$$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, " =" , $1 , $5 );
6907
6924
}
@@ -6910,7 +6927,7 @@ b_expr: c_expr
6910
6927
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL,
6911
6928
NULL , (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, " =" , $1 , $6 ));
6912
6929
}
6913
- | b_expr IS OF ' (' type_list ' )' %prec IS
6930
+ | b_expr IS OF ' (' type_list ' )' %prec IS
6914
6931
{
6915
6932
$$ = (Node *) makeSimpleA_Expr(AEXPR_OF, " =" , $1 , (Node *) $5 );
6916
6933
}
0 commit comments