diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-02-15 14:43:59 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-02-15 14:44:18 -0500 |
commit | 01e0cbc4f687325b825e7953f99f0b16a2bd4e96 (patch) | |
tree | 2109a9a031a5e1e6052d2dd44c558101f9d11dd4 /src | |
parent | 5262f7a4fc44f651241d2ff1fa688dd664a34874 (diff) | |
download | postgresql-01e0cbc4f687325b825e7953f99f0b16a2bd4e96.tar.gz postgresql-01e0cbc4f687325b825e7953f99f0b16a2bd4e96.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/parser/gram.y | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 5cb82977d5d..07cc81ee764 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -12764,7 +12764,10 @@ c_expr: columnref { $$ = $1; } * AEXPR_PAREN nodes wrapping all explicitly * parenthesized subexpressions; this prevents bogus * warnings from being issued when the ordering has - * been forced by parentheses. + * been forced by parentheses. Take care that an + * AEXPR_PAREN node has the same exprLocation as its + * child, so as not to cause surprising changes in + * error cursor positioning. * * In principle we should not be relying on a GUC to * decide whether to insert AEXPR_PAREN nodes. @@ -12773,7 +12776,8 @@ c_expr: columnref { $$ = $1; } * we'd just as soon not waste cycles on dummy parse * nodes if we don't have to. */ - $$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL, @1); + $$ = (Node *) makeA_Expr(AEXPR_PAREN, NIL, $2, NULL, + exprLocation($2)); } else $$ = $2; |