Fix alias-for-target-table-of-UPDATE-or-DELETE patch so that alias can

be any ColId other than 'SET', rather than only IDENT as originally.
Per discussion.
This commit is contained in:
Tom Lane 2006-01-22 20:03:16 +00:00
parent 1d763d9107
commit 2647ad6583
1 changed files with 25 additions and 8 deletions

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.523 2006/01/22 05:20:33 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.524 2006/01/22 20:03:16 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -429,6 +429,7 @@ static void doNegateFloat(Value *v);
%token <ival> ICONST PARAM
/* precedence: lowest to highest */
%nonassoc SET /* see relation_expr_opt_alias */
%left UNION EXCEPT
%left INTERSECT
%left OR
@ -5880,11 +5881,27 @@ relation_expr:
;
relation_expr_opt_alias: relation_expr
/*
* Given "UPDATE foo set set ...", we have to decide without looking any
* further ahead whether the first "set" is an alias or the UPDATE's SET
* keyword. Since "set" is allowed as a column name both interpretations
* are feasible. We resolve the shift/reduce conflict by giving the first
* relation_expr_opt_alias production a higher precedence than the SET token
* has, causing the parser to prefer to reduce, in effect assuming that the
* SET is not an alias.
*/
relation_expr_opt_alias: relation_expr %prec UMINUS
{
$$ = $1;
}
| relation_expr opt_as IDENT
| relation_expr ColId
{
Alias *alias = makeNode(Alias);
alias->aliasname = $2;
$1->alias = alias;
$$ = $1;
}
| relation_expr AS ColId
{
Alias *alias = makeNode(Alias);
alias->aliasname = $3;
@ -6843,7 +6860,7 @@ a_expr: c_expr { $$ = $1; }
else
$$ = (Node *) makeA_Expr(AEXPR_OP_ALL, $2, $1, $5);
}
| UNIQUE select_with_parens %prec Op
| UNIQUE select_with_parens
{
/* Not sure how to get rid of the parentheses
* but there are lots of shift/reduce errors without them.