Skip to content

Commit 01e0cbc

Browse files
committed
Fix YA unwanted behavioral difference with operator_precedence_warning.
Jeff Janes noted that the error cursor position shown for some errors would vary when operator_precedence_warning is turned on. We'd prefer that option to have no undocumented effects, so this isn't desirable. To fix, make sure that an AEXPR_PAREN node has the same exprLocation as its child node. (Note: it would be a little cheaper to use @2 here instead of an exprLocation call, but there are cases where that wouldn't produce the identical answer, so don't do it like that.) Back-patch to 9.5 where this feature was introduced. Discussion: https://postgr.es/m/CAMkU=1ykK+VhhcQ4Ky8KBo9FoaUJH3f3rDQB8TkTXi-ZsBRUkQ@mail.gmail.com
1 parent 5262f7a commit 01e0cbc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/parser/gram.y

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12764,7 +12764,10 @@ c_expr: columnref { $$ = $1; }
1276412764
* AEXPR_PAREN nodes wrapping all explicitly
1276512765
* parenthesized subexpressions; this prevents bogus
1276612766
* warnings from being issued when the ordering has
12767-
* been forced by parentheses.
12767+
* been forced by parentheses. Take care that an
12768+
* AEXPR_PAREN node has the same exprLocation as its
12769+
* child, so as not to cause surprising changes in
12770+
* error cursor positioning.
1276812771
*
1276912772
* In principle we should not be relying on a GUC to
1277012773
* decide whether to insert AEXPR_PAREN nodes.
@@ -12773,7 +12776,8 @@ c_expr: columnref { $$ = $1; }
1277312776
* we'd just as soon not waste cycles on dummy parse
1277412777
* nodes if we don't have to.
1277512778
*/
12776-
$$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL, @1);
12779+
$$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL,
12780+
exprLocation($2));
1277712781
}
1277812782
else
1277912783
$$ = $2;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy