pgsql: Fix grammar for subscripting or field selection from a sub-SELEC

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix grammar for subscripting or field selection from a sub-SELEC
Date: 2013-01-30 19:18:26
Message-ID: E1U0dAw-0003eA-FZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix grammar for subscripting or field selection from a sub-SELECT result.

Such cases should work, but the grammar failed to accept them because of
our ancient precedence hacks to convince bison that extra parentheses
around a sub-SELECT in an expression are unambiguous. (Formally, they
*are* ambiguous, but we don't especially care whether they're treated as
part of the sub-SELECT or part of the expression. Bison cares, though.)
Fix by adding a redundant-looking production for this case.

This is a fine example of why fixing shift/reduce conflicts via
precedence declarations is more dangerous than it looks: you can easily
cause the parser to reject cases that should work.

This has been wrong since commit 3db4056e22b0c6b2adc92543baf8408d2894fe91
or maybe before, and apparently some people have been working around it
by inserting no-op casts. That method introduces a dump/reload hazard,
as illustrated in bug #7838 from Jan Mate. Hence, back-patch to all
active branches.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/969dc8cce922e58fa5dd6f945678ecd531fdb6a6

Modified Files
--------------
src/backend/parser/gram.y | 23 +++++++++++++
src/test/regress/expected/subselect.out | 55 +++++++++++++++++++++++++++++++
src/test/regress/sql/subselect.sql | 15 ++++++++
3 files changed, 93 insertions(+), 0 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-01-31 01:02:52 pgsql: Fix plpgsql's reporting of plan-time errors in possibly-simple e
Previous Message Simon Riggs 2013-01-30 17:26:26 Re: pgsql: Fast promote mode skips checkpoint at end of recovery.