From 055fee7eb4dcc78e58672aef146334275e1cc40d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 31 Mar 2021 17:09:24 +0200 Subject: 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 Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/flat/454638cf-d563-ab76-a585-2564428062af@2ndquadrant.com --- src/backend/utils/adt/ruleutils.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/backend/utils/adt/ruleutils.c') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 3de98d2333e..82b73726f13 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -10813,6 +10813,10 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) appendStringInfoString(buf, quote_identifier(colname)); } appendStringInfoChar(buf, ')'); + + if (j->join_using_alias) + appendStringInfo(buf, " AS %s", + quote_identifier(j->join_using_alias->aliasname)); } else if (j->quals) { -- cgit v1.2.3