pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow an alias to be attached to a JOIN ... USING
Date: Wed, 31 Mar 2021 15:27:40 +0000
Message-ID: <E1lRcku-0001yb-R7@gemulon.postgresql.org> (raw)

Allow an alias to be attached to a JOIN ... USING

This allows something like

    SELECT ... FROM t1 JOIN t2 USING (a, b, c) AS x

where x has the columns a, b, c and unlike a regular alias it does not
hide the range variables of the tables being joined t1 and t2.

Per SQL:2016 feature F404 "Range variable for common column names".

Reviewed-by: Vik Fearing <vik.fearing@2ndquadrant.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/454638cf-d563-ab76-a585-2564428062af@2ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/055fee7eb4dcc78e58672aef146334275e1cc40d

Modified Files
--------------
doc/src/sgml/ref/select.sgml              | 16 +++++++-
src/backend/catalog/sql_features.txt      |  2 +-
src/backend/nodes/copyfuncs.c             |  2 +
src/backend/nodes/equalfuncs.c            |  2 +
src/backend/nodes/outfuncs.c              |  2 +
src/backend/nodes/readfuncs.c             |  2 +
src/backend/optimizer/plan/setrefs.c      |  1 +
src/backend/optimizer/plan/subselect.c    |  2 +
src/backend/parser/analyze.c              |  1 +
src/backend/parser/gram.y                 | 60 +++++++++++++++++++++++-----
src/backend/parser/parse_clause.c         | 32 +++++++++++++++
src/backend/parser/parse_expr.c           | 65 ++++++++++++++++++++++++-------
src/backend/parser/parse_relation.c       |  8 ++++
src/backend/utils/adt/ruleutils.c         |  4 ++
src/include/nodes/parsenodes.h            |  7 ++++
src/include/nodes/primnodes.h             |  6 +++
src/include/parser/parse_node.h           |  5 ++-
src/include/parser/parse_relation.h       |  1 +
src/test/regress/expected/create_view.out | 52 ++++++++++++++++++++++++-
src/test/regress/expected/join.out        | 52 +++++++++++++++++++++++++
src/test/regress/sql/create_view.sql      | 11 ++++++
src/test/regress/sql/join.sql             | 11 ++++++
22 files changed, 315 insertions(+), 29 deletions(-)



Message-ID: <E1lRcku-0001yb-R7@gemulon.postgresql.org>
Permalink:  ../E1lRcku-0001yb-R7@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lRcku-0001yb-R7@gemulon.postgresql.org

 · 

reply

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: peter@eisentraut.org
  Subject: Re: pgsql: Allow an alias to be attached to a JOIN ... USING
  In-Reply-To: <E1lRcku-0001yb-R7@gemulon.postgresql.org>
  References: <E1lRcku-0001yb-R7@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