summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/create_view.out34
-rw-r--r--src/test/regress/sql/create_view.sql18
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 1b95e90e02..06b203793a 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -1298,6 +1298,40 @@ select pg_get_viewdef('vv5', true);
JOIN tt10 USING (x);
(1 row)
+--
+-- Another corner case is that we might add a column to a table below a
+-- JOIN USING, and thereby make the USING column name ambiguous
+--
+create table tt11 (x int, y int);
+create table tt12 (x int, z int);
+create table tt13 (z int, q int);
+create view vv6 as select x,y,z,q from
+ (tt11 join tt12 using(x)) join tt13 using(z);
+select pg_get_viewdef('vv6', true);
+ pg_get_viewdef
+---------------------------
+ SELECT tt11.x, +
+ tt11.y, +
+ tt12.z, +
+ tt13.q +
+ FROM tt11 +
+ JOIN tt12 USING (x) +
+ JOIN tt13 USING (z);
+(1 row)
+
+alter table tt11 add column z int;
+select pg_get_viewdef('vv6', true);
+ pg_get_viewdef
+------------------------------
+ SELECT tt11.x, +
+ tt11.y, +
+ tt12.z, +
+ tt13.q +
+ FROM tt11 tt11(x, y, z_1)+
+ JOIN tt12 USING (x) +
+ JOIN tt13 USING (z);
+(1 row)
+
-- clean up all the random objects we made above
set client_min_messages = warning;
DROP SCHEMA temp_view_test CASCADE;
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index 234a4214b2..e09bc1a279 100644
--- a/src/test/regress/sql/create_view.sql
+++ b/src/test/regress/sql/create_view.sql
@@ -417,6 +417,24 @@ alter table tt9 drop column xx;
select pg_get_viewdef('vv5', true);
+--
+-- Another corner case is that we might add a column to a table below a
+-- JOIN USING, and thereby make the USING column name ambiguous
+--
+
+create table tt11 (x int, y int);
+create table tt12 (x int, z int);
+create table tt13 (z int, q int);
+
+create view vv6 as select x,y,z,q from
+ (tt11 join tt12 using(x)) join tt13 using(z);
+
+select pg_get_viewdef('vv6', true);
+
+alter table tt11 add column z int;
+
+select pg_get_viewdef('vv6', true);
+
-- clean up all the random objects we made above
set client_min_messages = warning;
DROP SCHEMA temp_view_test CASCADE;