mirror of
https://github.com/postgres/postgres.git
synced 2025-11-29 23:43:17 +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:
@@ -2231,6 +2231,7 @@ _copyJoinExpr(const JoinExpr *from)
|
||||
COPY_NODE_FIELD(larg);
|
||||
COPY_NODE_FIELD(rarg);
|
||||
COPY_NODE_FIELD(usingClause);
|
||||
COPY_NODE_FIELD(join_using_alias);
|
||||
COPY_NODE_FIELD(quals);
|
||||
COPY_NODE_FIELD(alias);
|
||||
COPY_SCALAR_FIELD(rtindex);
|
||||
@@ -2442,6 +2443,7 @@ _copyRangeTblEntry(const RangeTblEntry *from)
|
||||
COPY_NODE_FIELD(joinaliasvars);
|
||||
COPY_NODE_FIELD(joinleftcols);
|
||||
COPY_NODE_FIELD(joinrightcols);
|
||||
COPY_NODE_FIELD(join_using_alias);
|
||||
COPY_NODE_FIELD(functions);
|
||||
COPY_SCALAR_FIELD(funcordinality);
|
||||
COPY_NODE_FIELD(tablefunc);
|
||||
|
||||
@@ -790,6 +790,7 @@ _equalJoinExpr(const JoinExpr *a, const JoinExpr *b)
|
||||
COMPARE_NODE_FIELD(larg);
|
||||
COMPARE_NODE_FIELD(rarg);
|
||||
COMPARE_NODE_FIELD(usingClause);
|
||||
COMPARE_NODE_FIELD(join_using_alias);
|
||||
COMPARE_NODE_FIELD(quals);
|
||||
COMPARE_NODE_FIELD(alias);
|
||||
COMPARE_SCALAR_FIELD(rtindex);
|
||||
@@ -2703,6 +2704,7 @@ _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
|
||||
COMPARE_NODE_FIELD(joinaliasvars);
|
||||
COMPARE_NODE_FIELD(joinleftcols);
|
||||
COMPARE_NODE_FIELD(joinrightcols);
|
||||
COMPARE_NODE_FIELD(join_using_alias);
|
||||
COMPARE_NODE_FIELD(functions);
|
||||
COMPARE_SCALAR_FIELD(funcordinality);
|
||||
COMPARE_NODE_FIELD(tablefunc);
|
||||
|
||||
@@ -1693,6 +1693,7 @@ _outJoinExpr(StringInfo str, const JoinExpr *node)
|
||||
WRITE_NODE_FIELD(larg);
|
||||
WRITE_NODE_FIELD(rarg);
|
||||
WRITE_NODE_FIELD(usingClause);
|
||||
WRITE_NODE_FIELD(join_using_alias);
|
||||
WRITE_NODE_FIELD(quals);
|
||||
WRITE_NODE_FIELD(alias);
|
||||
WRITE_INT_FIELD(rtindex);
|
||||
@@ -3193,6 +3194,7 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
|
||||
WRITE_NODE_FIELD(joinaliasvars);
|
||||
WRITE_NODE_FIELD(joinleftcols);
|
||||
WRITE_NODE_FIELD(joinrightcols);
|
||||
WRITE_NODE_FIELD(join_using_alias);
|
||||
break;
|
||||
case RTE_FUNCTION:
|
||||
WRITE_NODE_FIELD(functions);
|
||||
|
||||
@@ -1346,6 +1346,7 @@ _readJoinExpr(void)
|
||||
READ_NODE_FIELD(larg);
|
||||
READ_NODE_FIELD(rarg);
|
||||
READ_NODE_FIELD(usingClause);
|
||||
READ_NODE_FIELD(join_using_alias);
|
||||
READ_NODE_FIELD(quals);
|
||||
READ_NODE_FIELD(alias);
|
||||
READ_INT_FIELD(rtindex);
|
||||
@@ -1449,6 +1450,7 @@ _readRangeTblEntry(void)
|
||||
READ_NODE_FIELD(joinaliasvars);
|
||||
READ_NODE_FIELD(joinleftcols);
|
||||
READ_NODE_FIELD(joinrightcols);
|
||||
READ_NODE_FIELD(join_using_alias);
|
||||
break;
|
||||
case RTE_FUNCTION:
|
||||
READ_NODE_FIELD(functions);
|
||||
|
||||
Reference in New Issue
Block a user