mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Remove precedence hacks no longer needed without postfix operators.
It's no longer necessary to assign explicit precedences to GENERATED, NULL_P, PRESERVE, or STRIP_P. Actually, we don't need to assign precedence to IDENT either; that was really just there to govern the behavior of target_el's "a_expr IDENT" production, which no longer ends with that terminal. However, it seems like a good idea to continue to do so, because it provides a reference point for a precedence level that we can assign to other unreserved keywords that lack a natural precedence level. Research by Peter Eisentraut and John Naylor; comment rewrite by me. Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
This commit is contained in:
parent
8354e7b27e
commit
28a61fc6c5
@ -744,22 +744,15 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
|||||||
%nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
|
%nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
|
||||||
%nonassoc ESCAPE /* ESCAPE must be just above LIKE/ILIKE/SIMILAR */
|
%nonassoc ESCAPE /* ESCAPE must be just above LIKE/ILIKE/SIMILAR */
|
||||||
/*
|
/*
|
||||||
* To support target_el without AS, we must give IDENT an explicit priority
|
* To support target_el without AS, it used to be necessary to assign IDENT an
|
||||||
* between ESCAPE and Op. We can safely assign the same priority to
|
* explicit precedence just less than Op. While that's not really necessary
|
||||||
* various unreserved keywords as needed to resolve ambiguities (this can't
|
* since we removed postfix operators, it's still helpful to do so because
|
||||||
* have any bad effects since obviously the keywords will still behave the
|
* there are some other unreserved keywords that need precedence assignments.
|
||||||
* same as if they weren't keywords). We need to do this:
|
* If those keywords have the same precedence as IDENT then they clearly act
|
||||||
* for PARTITION, RANGE, ROWS, GROUPS to support opt_existing_window_name;
|
* the same as non-keywords, reducing the risk of unwanted precedence effects.
|
||||||
* for RANGE, ROWS, GROUPS so that they can follow a_expr without creating
|
|
||||||
* postfix-operator problems;
|
|
||||||
* for GENERATED so that it can follow b_expr;
|
|
||||||
* and for NULL so that it can follow b_expr in ColQualList without creating
|
|
||||||
* postfix-operator problems.
|
|
||||||
*
|
*
|
||||||
* To support CUBE and ROLLUP in GROUP BY without reserving them, we give them
|
* We need to do this for PARTITION, RANGE, ROWS, and GROUPS to support
|
||||||
* an explicit priority lower than '(', so that a rule with CUBE '(' will shift
|
* opt_existing_window_name (see comment there).
|
||||||
* rather than reducing a conflicting rule that takes CUBE as a function name.
|
|
||||||
* Using the same precedence as IDENT seems right for the reasons given above.
|
|
||||||
*
|
*
|
||||||
* The frame_bound productions UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING
|
* The frame_bound productions UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING
|
||||||
* are even messier: since UNBOUNDED is an unreserved keyword (per spec!),
|
* are even messier: since UNBOUNDED is an unreserved keyword (per spec!),
|
||||||
@ -769,9 +762,14 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
|||||||
* appear to cause UNBOUNDED to be treated differently from other unreserved
|
* appear to cause UNBOUNDED to be treated differently from other unreserved
|
||||||
* keywords anywhere else in the grammar, but it's definitely risky. We can
|
* keywords anywhere else in the grammar, but it's definitely risky. We can
|
||||||
* blame any funny behavior of UNBOUNDED on the SQL standard, though.
|
* blame any funny behavior of UNBOUNDED on the SQL standard, though.
|
||||||
|
*
|
||||||
|
* To support CUBE and ROLLUP in GROUP BY without reserving them, we give them
|
||||||
|
* an explicit priority lower than '(', so that a rule with CUBE '(' will shift
|
||||||
|
* rather than reducing a conflicting rule that takes CUBE as a function name.
|
||||||
|
* Using the same precedence as IDENT seems right for the reasons given above.
|
||||||
*/
|
*/
|
||||||
%nonassoc UNBOUNDED /* ideally should have same precedence as IDENT */
|
%nonassoc UNBOUNDED /* ideally would have same precedence as IDENT */
|
||||||
%nonassoc IDENT GENERATED NULL_P PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
|
%nonassoc IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
|
||||||
%left Op OPERATOR /* multi-character ops and user-defined operators */
|
%left Op OPERATOR /* multi-character ops and user-defined operators */
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/' '%'
|
%left '*' '/' '%'
|
||||||
@ -792,8 +790,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
|||||||
* left-associativity among the JOIN rules themselves.
|
* left-associativity among the JOIN rules themselves.
|
||||||
*/
|
*/
|
||||||
%left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
|
%left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
|
||||||
/* kluge to keep xml_whitespace_option from causing shift/reduce conflicts */
|
|
||||||
%right PRESERVE STRIP_P
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user