From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow most keywords to be used as column labels without requirin
Date: Fri, 18 Sep 2020 20:46:59 +0000
Message-ID: <E1kJNHX-0008GD-Be@gemulon.postgresql.org> (raw)
Allow most keywords to be used as column labels without requiring AS.
Up to now, if you tried to omit "AS" before a column label in a SELECT
list, it would only work if the column label was an IDENT, that is not
any known keyword. This is rather unfriendly considering that we have
so many keywords and are constantly growing more. In the wake of commit
1ed6b8956 it's possible to improve matters quite a bit.
We'd originally tried to make this work by having some of the existing
keyword categories be allowed without AS, but that didn't work too well,
because each category contains a few special cases that don't work
without AS. Instead, invent an entirely orthogonal keyword property
"can be bare column label", and mark all keywords that way for which
we don't get shift/reduce errors by doing so.
It turns out that of our 450 current keywords, all but 39 can be made
bare column labels, improving the situation by over 90%. This number
might move around a little depending on future grammar work, but it's
a pretty nice improvement.
Mark Dilger, based on work by myself and Robert Haas;
review by John Naylor
Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/06a7c3154f5bfad65549810cc84f0e3a77b408bf
Modified Files
--------------
doc/src/sgml/func.sgml | 13 +-
doc/src/sgml/generate-keywords-table.pl | 13 +-
doc/src/sgml/keywords.sgml | 24 +-
doc/src/sgml/queries.sgml | 26 +-
src/backend/parser/check_keywords.pl | 92 +++-
src/backend/parser/gram.y | 440 +++++++++++++++-
src/backend/parser/scan.l | 2 +-
src/backend/utils/adt/misc.c | 31 +-
src/common/keywords.c | 17 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 7 +-
src/include/common/keywords.h | 2 +
src/include/parser/kwlist.h | 904 ++++++++++++++++----------------
src/interfaces/ecpg/preproc/keywords.c | 2 +-
14 files changed, 1055 insertions(+), 520 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Allow most keywords to be used as column labels without requirin
In-Reply-To: <E1kJNHX-0008GD-Be@gemulon.postgresql.org>
References: <E1kJNHX-0008GD-Be@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox