Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28a61fc

Browse files
committed
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 wasreally just there to govern the behavior of target_el's "a_expr IDENT"production, which no longer ends with that terminal. However, it seemslike a good idea to continue to do so, because it provides a referencepoint for a precedence level that we can assign to other unreservedkeywords 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
1 parent8354e7b commit28a61fc

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

‎src/backend/parser/gram.y

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -744,22 +744,15 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
744744
%nonassocBETWEENIN_PLIKEILIKESIMILARNOT_LA
745745
%nonassocESCAPE/* ESCAPE must be just above LIKE/ILIKE/SIMILAR*/
746746
/*
747-
* To support target_el without AS, we must give IDENT an explicit priority
748-
* between ESCAPE and Op. We can safely assign the same priority to
749-
* various unreserved keywords as needed to resolve ambiguities (this can't
750-
* have any bad effects since obviously the keywords will still behave the
751-
* same as if they weren't keywords). We need to do this:
752-
* for PARTITION, RANGE, ROWS, GROUPS to support opt_existing_window_name;
753-
* for RANGE, ROWS, GROUPS so that they can follow a_expr without creating
754-
* postfix-operator problems;
755-
* for GENERATED so that it can follow b_expr;
756-
* and for NULL so that it can follow b_expr in ColQualList without creating
757-
* postfix-operator problems.
747+
* To support target_el without AS, it used to be necessary to assign IDENT an
748+
* explicit precedence just less than Op. While that's not really necessary
749+
* since we removed postfix operators, it's still helpful to do so because
750+
* there are some other unreserved keywords that need precedence assignments.
751+
* If those keywords have the same precedence as IDENT then they clearly act
752+
* the same as non-keywords, reducing the risk of unwanted precedence effects.
758753
*
759-
* To support CUBE and ROLLUP in GROUP BY without reserving them, we give them
760-
* an explicit priority lower than '(', so that a rule with CUBE '(' will shift
761-
* rather than reducing a conflicting rule that takes CUBE as a function name.
762-
* Using the same precedence as IDENT seems right for the reasons given above.
754+
* We need to do this for PARTITION, RANGE, ROWS, and GROUPS to support
755+
* opt_existing_window_name (see comment there).
763756
*
764757
* The frame_bound productions UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING
765758
* are even messier: since UNBOUNDED is an unreserved keyword (per spec!),
@@ -769,9 +762,14 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
769762
* appear to cause UNBOUNDED to be treated differently from other unreserved
770763
* keywords anywhere else in the grammar, but it's definitely risky. We can
771764
* blame any funny behavior of UNBOUNDED on the SQL standard, though.
765+
*
766+
* To support CUBE and ROLLUP in GROUP BY without reserving them, we give them
767+
* an explicit priority lower than '(', so that a rule with CUBE '(' will shift
768+
* rather than reducing a conflicting rule that takes CUBE as a function name.
769+
* Using the same precedence as IDENT seems right for the reasons given above.
772770
*/
773-
%nonassocUNBOUNDED/* ideallyshould have same precedence as IDENT*/
774-
%nonassocIDENTGENERATEDNULL_PPARTITIONRANGEROWSGROUPSPRECEDINGFOLLOWINGCUBEROLLUP
771+
%nonassocUNBOUNDED/* ideallywould have same precedence as IDENT*/
772+
%nonassocIDENTPARTITIONRANGEROWSGROUPSPRECEDINGFOLLOWINGCUBEROLLUP
775773
%leftOpOPERATOR/* multi-character ops and user-defined operators*/
776774
%left'+''-'
777775
%left'*''/''%'
@@ -792,8 +790,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
792790
* left-associativity among the JOIN rules themselves.
793791
*/
794792
%leftJOINCROSSLEFTFULLRIGHTINNER_PNATURAL
795-
/* kluge to keep xml_whitespace_option from causing shift/reduce conflicts*/
796-
%rightPRESERVESTRIP_P
797793

798794
%%
799795

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp