pgsql: Fix parse location tracking for lists that can be empty.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix parse location tracking for lists that can be empty.
Date: 2012-10-04 21:15:48
Message-ID: E1TJslo-0004IA-B7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix parse location tracking for lists that can be empty.

The previous coding of the YYLLOC_DEFAULT macro behaved strangely for empty
productions, assigning the previous nonterminal's location as the parse
location of the result. The usefulness of that was (at best) debatable
already, but the real problem is that in list-generating nonterminals like
OptFooList: /* EMPTY */ { ... } | OptFooList Foo { ... } ;
the initially-identified location would get copied up, so that even a
nonempty list would be given a bogus parse location. Document how to work
around that, and do so for OptSchemaEltList, so that the error condition
just added for CREATE SCHEMA IF NOT EXISTS produces a sane error cursor.
So far as I can tell, there are currently no other cases where the
situation arises, so we don't need other instances of this coding yet.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/707263542e571c9906549e196728ad39ecc0ca84

Modified Files
--------------
src/backend/parser/gram.y | 34 ++++++++++++++++++++++++++----
src/test/regress/expected/namespace.out | 4 +-
2 files changed, 31 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-10-04 21:55:02 pgsql: Make CREATE AGGREGATE complain if the initcond is invalid for th
Previous Message Tom Lane 2012-10-04 17:41:42 pgsql: Fix permissions explanations in CREATE DATABASE and CREATE SCHEM