pgsql: Fix grammar's AND/OR flattening to work with operator_precedence

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix grammar's AND/OR flattening to work with operator_precedence
Date: 2016-06-03 23:12:37
Message-ID: E1b8yGb-0004Xm-Ve@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix grammar's AND/OR flattening to work with operator_precedence_warning.

It'd be good for "(x AND y) AND z" to produce a three-child AND node
whether or not operator_precedence_warning is on, but that failed to
happen when it's on because makeAndExpr() didn't look through the added
AEXPR_PAREN node. This has no effect on generated plans because prepqual.c
would flatten the AND nest anyway; but it does affect the number of parens
printed in ruleutils.c, for example. I'd already fixed some similar
hazards in parse_expr.c in commit abb164655, but didn't think to search
gram.y for problems of this ilk. Per gripe from Jean-Pierre Pelletier.

Report: <fa0535ec6d6428cfec40c7e8a6d11156(at)mail(dot)gmail(dot)com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/05104f693646c0a4ae446e79cb89057497da17e4

Modified Files
--------------
src/backend/parser/gram.y | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-06-04 04:49:49 pgsql: Update contrib/tsearch2/expected/tsearch2_1.out for phrase FTS.
Previous Message Tom Lane 2016-06-03 22:34:13 pgsql: Inline the easy cases in MakeExpandedObjectReadOnly().