Skip to content

Commit 8350aae

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 3e51859 commit 8350aae

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
@@ -12096,7 +12096,10 @@ c_expr: columnref { $$ = $1; }
1209612096
* AEXPR_PAREN nodes wrapping all explicitly
1209712097
* parenthesized subexpressions; this prevents bogus
1209812098
* warnings from being issued when the ordering has
12099-
* been forced by parentheses.
12099+
* been forced by parentheses. Take care that an
12100+
* AEXPR_PAREN node has the same exprLocation as its
12101+
* child, so as not to cause surprising changes in
12102+
* error cursor positioning.
1210012103
*
1210112104
* In principle we should not be relying on a GUC to
1210212105
* decide whether to insert AEXPR_PAREN nodes.
@@ -12105,7 +12108,8 @@ c_expr: columnref { $$ = $1; }
1210512108
* we'd just as soon not waste cycles on dummy parse
1210612109
* nodes if we don't have to.
1210712110
*/
12108-
$$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL, @1);
12111+
$$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL,
12112+
exprLocation($2));
1210912113
}
1211012114
else
1211112115
$$ = $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