mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-23 06:47:14 +08: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:
@ -328,6 +328,17 @@ select * from
|
||||
|
||||
\d+ view_of_joins
|
||||
|
||||
create table tbl1a (a int, c int);
|
||||
create view view_of_joins_2a as select * from tbl1 join tbl1a using (a);
|
||||
create view view_of_joins_2b as select * from tbl1 join tbl1a using (a) as x;
|
||||
create view view_of_joins_2c as select * from (tbl1 join tbl1a using (a)) as y;
|
||||
create view view_of_joins_2d as select * from (tbl1 join tbl1a using (a) as x) as y;
|
||||
|
||||
select pg_get_viewdef('view_of_joins_2a', true);
|
||||
select pg_get_viewdef('view_of_joins_2b', true);
|
||||
select pg_get_viewdef('view_of_joins_2c', true);
|
||||
select pg_get_viewdef('view_of_joins_2d', true);
|
||||
|
||||
-- Test view decompilation in the face of column addition/deletion/renaming
|
||||
|
||||
create table tt2 (a int, b int, c int);
|
||||
|
||||
Reference in New Issue
Block a user