mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
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
This commit is contained in:
@@ -228,7 +228,10 @@ struct ParseState
|
||||
* An element of a namespace list.
|
||||
*
|
||||
* p_names contains the table name and column names exposed by this nsitem.
|
||||
* (Currently, it's always equal to p_rte->eref.)
|
||||
* (Typically it's equal to p_rte->eref, but for a JOIN USING alias it's
|
||||
* equal to p_rte->join_using_alias. Since the USING columns will be the
|
||||
* join's first N columns, the net effect is just that we expose only those
|
||||
* join columns via this nsitem.)
|
||||
*
|
||||
* p_rte and p_rtindex link to the underlying rangetable entry.
|
||||
*
|
||||
|
||||
@@ -88,6 +88,7 @@ extern ParseNamespaceItem *addRangeTableEntryForJoin(ParseState *pstate,
|
||||
List *aliasvars,
|
||||
List *leftcols,
|
||||
List *rightcols,
|
||||
Alias *joinalias,
|
||||
Alias *alias,
|
||||
bool inFromCl);
|
||||
extern ParseNamespaceItem *addRangeTableEntryForCTE(ParseState *pstate,
|
||||
|
||||
Reference in New Issue
Block a user