diff options
Diffstat (limited to 'src/test/regress')
| -rw-r--r-- | src/test/regress/expected/aggregates.out | 22 | ||||
| -rw-r--r-- | src/test/regress/expected/alter_table.out | 18 | ||||
| -rw-r--r-- | src/test/regress/expected/create_view.out | 371 | ||||
| -rw-r--r-- | src/test/regress/expected/inherit.out | 94 | ||||
| -rw-r--r-- | src/test/regress/expected/select_views.out | 10 | ||||
| -rw-r--r-- | src/test/regress/expected/select_views_1.out | 10 | ||||
| -rw-r--r-- | src/test/regress/expected/with.out | 34 | ||||
| -rw-r--r-- | src/test/regress/sql/create_view.sql | 62 |
8 files changed, 525 insertions, 96 deletions
diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out index 6ca73a0ed73..7286f1aa446 100644 --- a/src/test/regress/expected/aggregates.out +++ b/src/test/regress/expected/aggregates.out @@ -705,32 +705,32 @@ insert into minmaxtest2 values(15), (16); insert into minmaxtest3 values(17), (18); explain (costs off) select min(f1), max(f1) from minmaxtest; - QUERY PLAN -------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------- Result InitPlan 1 (returns $0) -> Limit -> Merge Append - Sort Key: public.minmaxtest.f1 + Sort Key: minmaxtest.f1 -> Index Only Scan using minmaxtesti on minmaxtest Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest1i on minmaxtest1 minmaxtest + -> Index Only Scan using minmaxtest1i on minmaxtest1 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 minmaxtest + -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest3i on minmaxtest3 minmaxtest + -> Index Only Scan using minmaxtest3i on minmaxtest3 Index Cond: (f1 IS NOT NULL) InitPlan 2 (returns $1) -> Limit -> Merge Append - Sort Key: public.minmaxtest.f1 - -> Index Only Scan Backward using minmaxtesti on minmaxtest + Sort Key: minmaxtest_1.f1 + -> Index Only Scan Backward using minmaxtesti on minmaxtest minmaxtest_1 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest + -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest1_1 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest + -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest2_1 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest + -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest3_1 Index Cond: (f1 IS NOT NULL) (25 rows) diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 453a3894b20..c22d74c7b56 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -391,9 +391,9 @@ explain (costs off) select * from nv_parent where d between '2011-08-01' and '20 -> Append -> Seq Scan on nv_parent Filter: ((d >= '08-01-2011'::date) AND (d <= '08-31-2011'::date)) - -> Seq Scan on nv_child_2010 nv_parent + -> Seq Scan on nv_child_2010 Filter: ((d >= '08-01-2011'::date) AND (d <= '08-31-2011'::date)) - -> Seq Scan on nv_child_2011 nv_parent + -> Seq Scan on nv_child_2011 Filter: ((d >= '08-01-2011'::date) AND (d <= '08-31-2011'::date)) (8 rows) @@ -405,9 +405,9 @@ explain (costs off) select * from nv_parent where d between '2011-08-01'::date a -> Append -> Seq Scan on nv_parent Filter: ((d >= '08-01-2011'::date) AND (d <= '08-31-2011'::date)) - -> Seq Scan on nv_child_2010 nv_parent + -> Seq Scan on nv_child_2010 Filter: ((d >= '08-01-2011'::date) AND (d <= '08-31-2011'::date)) - -> Seq Scan on nv_child_2011 nv_parent + -> Seq Scan on nv_child_2011 Filter: ((d >= '08-01-2011'::date) AND (d <= '08-31-2011'::date)) (8 rows) @@ -418,11 +418,11 @@ explain (costs off) select * from nv_parent where d between '2009-08-01'::date a -> Append -> Seq Scan on nv_parent Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) - -> Seq Scan on nv_child_2010 nv_parent + -> Seq Scan on nv_child_2010 Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) - -> Seq Scan on nv_child_2011 nv_parent + -> Seq Scan on nv_child_2011 Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) - -> Seq Scan on nv_child_2009 nv_parent + -> Seq Scan on nv_child_2009 Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) (10 rows) @@ -435,9 +435,9 @@ explain (costs off) select * from nv_parent where d between '2009-08-01'::date a -> Append -> Seq Scan on nv_parent Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) - -> Seq Scan on nv_child_2010 nv_parent + -> Seq Scan on nv_child_2010 Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) - -> Seq Scan on nv_child_2009 nv_parent + -> Seq Scan on nv_child_2009 Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date)) (8 rows) diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out index cc93854c423..d37c88234a2 100644 --- a/src/test/regress/expected/create_view.out +++ b/src/test/regress/expected/create_view.out @@ -288,8 +288,368 @@ SELECT relname, relkind, reloptions FROM pg_class mysecview4 | v | {security_barrier=false} (4 rows) +-- Test view decompilation in the face of renaming conflicts +CREATE TABLE tt1 (f1 int, f2 int, f3 text); +CREATE TABLE tx1 (x1 int, x2 int, x3 text); +CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 text); +CREATE VIEW aliased_view_1 AS + select * from tt1 + where exists (select 1 from tx1 where tt1.f1 = tx1.x1); +CREATE VIEW aliased_view_2 AS + select * from tt1 a1 + where exists (select 1 from tx1 where a1.f1 = tx1.x1); +CREATE VIEW aliased_view_3 AS + select * from tt1 + where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1); +CREATE VIEW aliased_view_4 AS + select * from temp_view_test.tt1 + where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1); +\d+ aliased_view_1 + View "testviewschm2.aliased_view_1" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.f1, tt1.f2, tt1.f3 + FROM tt1 + WHERE (EXISTS ( SELECT 1 + FROM tx1 + WHERE tt1.f1 = tx1.x1)); + +\d+ aliased_view_2 + View "testviewschm2.aliased_view_2" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a1.f1, a1.f2, a1.f3 + FROM tt1 a1 + WHERE (EXISTS ( SELECT 1 + FROM tx1 + WHERE a1.f1 = tx1.x1)); + +\d+ aliased_view_3 + View "testviewschm2.aliased_view_3" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.f1, tt1.f2, tt1.f3 + FROM tt1 + WHERE (EXISTS ( SELECT 1 + FROM tx1 a2 + WHERE tt1.f1 = a2.x1)); + +\d+ aliased_view_4 + View "testviewschm2.aliased_view_4" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + y1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.y1, tt1.f2, tt1.f3 + FROM temp_view_test.tt1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 tt1_1 + WHERE tt1.y1 = tt1_1.f1)); + +ALTER TABLE tx1 RENAME TO a1; +\d+ aliased_view_1 + View "testviewschm2.aliased_view_1" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.f1, tt1.f2, tt1.f3 + FROM tt1 + WHERE (EXISTS ( SELECT 1 + FROM a1 + WHERE tt1.f1 = a1.x1)); + +\d+ aliased_view_2 + View "testviewschm2.aliased_view_2" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a1.f1, a1.f2, a1.f3 + FROM tt1 a1 + WHERE (EXISTS ( SELECT 1 + FROM a1 a1_1 + WHERE a1.f1 = a1_1.x1)); + +\d+ aliased_view_3 + View "testviewschm2.aliased_view_3" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.f1, tt1.f2, tt1.f3 + FROM tt1 + WHERE (EXISTS ( SELECT 1 + FROM a1 a2 + WHERE tt1.f1 = a2.x1)); + +\d+ aliased_view_4 + View "testviewschm2.aliased_view_4" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + y1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.y1, tt1.f2, tt1.f3 + FROM temp_view_test.tt1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 tt1_1 + WHERE tt1.y1 = tt1_1.f1)); + +ALTER TABLE tt1 RENAME TO a2; +\d+ aliased_view_1 + View "testviewschm2.aliased_view_1" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a2.f1, a2.f2, a2.f3 + FROM a2 + WHERE (EXISTS ( SELECT 1 + FROM a1 + WHERE a2.f1 = a1.x1)); + +\d+ aliased_view_2 + View "testviewschm2.aliased_view_2" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a1.f1, a1.f2, a1.f3 + FROM a2 a1 + WHERE (EXISTS ( SELECT 1 + FROM a1 a1_1 + WHERE a1.f1 = a1_1.x1)); + +\d+ aliased_view_3 + View "testviewschm2.aliased_view_3" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a2.f1, a2.f2, a2.f3 + FROM a2 + WHERE (EXISTS ( SELECT 1 + FROM a1 a2_1 + WHERE a2.f1 = a2_1.x1)); + +\d+ aliased_view_4 + View "testviewschm2.aliased_view_4" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + y1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.y1, tt1.f2, tt1.f3 + FROM temp_view_test.tt1 + WHERE (EXISTS ( SELECT 1 + FROM a2 + WHERE tt1.y1 = a2.f1)); + +ALTER TABLE a1 RENAME TO tt1; +\d+ aliased_view_1 + View "testviewschm2.aliased_view_1" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a2.f1, a2.f2, a2.f3 + FROM a2 + WHERE (EXISTS ( SELECT 1 + FROM tt1 + WHERE a2.f1 = tt1.x1)); + +\d+ aliased_view_2 + View "testviewschm2.aliased_view_2" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a1.f1, a1.f2, a1.f3 + FROM a2 a1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 + WHERE a1.f1 = tt1.x1)); + +\d+ aliased_view_3 + View "testviewschm2.aliased_view_3" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a2.f1, a2.f2, a2.f3 + FROM a2 + WHERE (EXISTS ( SELECT 1 + FROM tt1 a2_1 + WHERE a2.f1 = a2_1.x1)); + +\d+ aliased_view_4 + View "testviewschm2.aliased_view_4" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + y1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.y1, tt1.f2, tt1.f3 + FROM temp_view_test.tt1 + WHERE (EXISTS ( SELECT 1 + FROM a2 + WHERE tt1.y1 = a2.f1)); + +ALTER TABLE a2 RENAME TO tx1; +ALTER TABLE tx1 SET SCHEMA temp_view_test; +\d+ aliased_view_1 + View "testviewschm2.aliased_view_1" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tx1.f1, tx1.f2, tx1.f3 + FROM temp_view_test.tx1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 + WHERE tx1.f1 = tt1.x1)); + +\d+ aliased_view_2 + View "testviewschm2.aliased_view_2" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a1.f1, a1.f2, a1.f3 + FROM temp_view_test.tx1 a1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 + WHERE a1.f1 = tt1.x1)); + +\d+ aliased_view_3 + View "testviewschm2.aliased_view_3" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tx1.f1, tx1.f2, tx1.f3 + FROM temp_view_test.tx1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 a2 + WHERE tx1.f1 = a2.x1)); + +\d+ aliased_view_4 + View "testviewschm2.aliased_view_4" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + y1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tt1.y1, tt1.f2, tt1.f3 + FROM temp_view_test.tt1 + WHERE (EXISTS ( SELECT 1 + FROM temp_view_test.tx1 + WHERE tt1.y1 = tx1.f1)); + +ALTER TABLE temp_view_test.tt1 RENAME TO tmp1; +ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2; +ALTER TABLE tmp1 RENAME TO tx1; +\d+ aliased_view_1 + View "testviewschm2.aliased_view_1" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tx1.f1, tx1.f2, tx1.f3 + FROM temp_view_test.tx1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 + WHERE tx1.f1 = tt1.x1)); + +\d+ aliased_view_2 + View "testviewschm2.aliased_view_2" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT a1.f1, a1.f2, a1.f3 + FROM temp_view_test.tx1 a1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 + WHERE a1.f1 = tt1.x1)); + +\d+ aliased_view_3 + View "testviewschm2.aliased_view_3" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + f1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tx1.f1, tx1.f2, tx1.f3 + FROM temp_view_test.tx1 + WHERE (EXISTS ( SELECT 1 + FROM tt1 a2 + WHERE tx1.f1 = a2.x1)); + +\d+ aliased_view_4 + View "testviewschm2.aliased_view_4" + Column | Type | Modifiers | Storage | Description +--------+---------+-----------+----------+------------- + y1 | integer | | plain | + f2 | integer | | plain | + f3 | text | | extended | +View definition: + SELECT tx1.y1, tx1.f2, tx1.f3 + FROM tx1 + WHERE (EXISTS ( SELECT 1 + FROM temp_view_test.tx1 tx1_1 + WHERE tx1.y1 = tx1_1.f1)); + DROP SCHEMA temp_view_test CASCADE; -NOTICE: drop cascades to 22 other objects +NOTICE: drop cascades to 27 other objects DETAIL: drop cascades to table temp_view_test.base_table drop cascades to view v7_temp drop cascades to view v10_temp @@ -312,8 +672,13 @@ drop cascades to view temp_view_test.v7 drop cascades to view temp_view_test.v8 drop cascades to sequence temp_view_test.seq1 drop cascades to view temp_view_test.v9 +drop cascades to table temp_view_test.tx1 +drop cascades to view aliased_view_1 +drop cascades to view aliased_view_2 +drop cascades to view aliased_view_3 +drop cascades to view aliased_view_4 DROP SCHEMA testviewschm2 CASCADE; -NOTICE: drop cascades to 20 other objects +NOTICE: drop cascades to 22 other objects DETAIL: drop cascades to table t1 drop cascades to view temporal1 drop cascades to view temporal2 @@ -334,4 +699,6 @@ drop cascades to view mysecview1 drop cascades to view mysecview2 drop cascades to view mysecview3 drop cascades to view mysecview4 +drop cascades to table tt1 +drop cascades to table tx1 SET search_path to public; diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index 25adcd23461..906a928b0c0 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -1105,17 +1105,17 @@ analyze patest1; analyze patest2; explain (costs off) select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; - QUERY PLAN ----------------------------------------------------------- + QUERY PLAN +-------------------------------------------------- Nested Loop -> Limit -> Seq Scan on int4_tbl -> Append -> Index Scan using patest0i on patest0 Index Cond: (id = int4_tbl.f1) - -> Index Scan using patest1i on patest1 patest0 + -> Index Scan using patest1i on patest1 Index Cond: (id = int4_tbl.f1) - -> Index Scan using patest2i on patest2 patest0 + -> Index Scan using patest2i on patest2 Index Cond: (id = int4_tbl.f1) (10 rows) @@ -1130,17 +1130,17 @@ select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; drop index patest2i; explain (costs off) select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; - QUERY PLAN ----------------------------------------------------------- + QUERY PLAN +-------------------------------------------------- Nested Loop -> Limit -> Seq Scan on int4_tbl -> Append -> Index Scan using patest0i on patest0 Index Cond: (id = int4_tbl.f1) - -> Index Scan using patest1i on patest1 patest0 + -> Index Scan using patest1i on patest1 Index Cond: (id = int4_tbl.f1) - -> Seq Scan on patest2 patest0 + -> Seq Scan on patest2 Filter: (int4_tbl.f1 = id) (10 rows) @@ -1178,22 +1178,22 @@ insert into matest3 (name) values ('Test 5'); insert into matest3 (name) values ('Test 6'); set enable_indexscan = off; -- force use of seqscan/sort, so no merge explain (verbose, costs off) select * from matest0 order by 1-id; - QUERY PLAN ---------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------ Sort - Output: public.matest0.id, public.matest0.name, ((1 - public.matest0.id)) - Sort Key: ((1 - public.matest0.id)) + Output: matest0.id, matest0.name, ((1 - matest0.id)) + Sort Key: ((1 - matest0.id)) -> Result - Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id) + Output: matest0.id, matest0.name, (1 - matest0.id) -> Append -> Seq Scan on public.matest0 - Output: public.matest0.id, public.matest0.name - -> Seq Scan on public.matest1 matest0 - Output: public.matest0.id, public.matest0.name - -> Seq Scan on public.matest2 matest0 - Output: public.matest0.id, public.matest0.name - -> Seq Scan on public.matest3 matest0 - Output: public.matest0.id, public.matest0.name + Output: matest0.id, matest0.name + -> Seq Scan on public.matest1 + Output: matest1.id, matest1.name + -> Seq Scan on public.matest2 + Output: matest2.id, matest2.name + -> Seq Scan on public.matest3 + Output: matest3.id, matest3.name (14 rows) select * from matest0 order by 1-id; @@ -1210,23 +1210,23 @@ select * from matest0 order by 1-id; reset enable_indexscan; set enable_seqscan = off; -- plan with fewest seqscans should be merge explain (verbose, costs off) select * from matest0 order by 1-id; - QUERY PLAN ---------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------ Result - Output: public.matest0.id, public.matest0.name, ((1 - public.matest0.id)) + Output: matest0.id, matest0.name, ((1 - matest0.id)) -> Merge Append - Sort Key: ((1 - public.matest0.id)) + Sort Key: ((1 - matest0.id)) -> Index Scan using matest0i on public.matest0 - Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id) - -> Index Scan using matest1i on public.matest1 matest0 - Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id) + Output: matest0.id, matest0.name, (1 - matest0.id) + -> Index Scan using matest1i on public.matest1 + Output: matest1.id, matest1.name, (1 - matest1.id) -> Sort - Output: public.matest0.id, public.matest0.name, ((1 - public.matest0.id)) - Sort Key: ((1 - public.matest0.id)) - -> Seq Scan on public.matest2 matest0 - Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id) - -> Index Scan using matest3i on public.matest3 matest0 - Output: public.matest0.id, public.matest0.name, (1 - public.matest0.id) + Output: matest2.id, matest2.name, ((1 - matest2.id)) + Sort Key: ((1 - matest2.id)) + -> Seq Scan on public.matest2 + Output: matest2.id, matest2.name, (1 - matest2.id) + -> Index Scan using matest3i on public.matest3 + Output: matest3.id, matest3.name, (1 - matest3.id) (15 rows) select * from matest0 order by 1-id; @@ -1258,15 +1258,15 @@ SELECT thousand, tenthous FROM tenk1 UNION ALL SELECT thousand, thousand FROM tenk1 ORDER BY thousand, tenthous; - QUERY PLAN ------------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------------- Result -> Merge Append - Sort Key: public.tenk1.thousand, public.tenk1.tenthous + Sort Key: tenk1.thousand, tenk1.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 -> Sort - Sort Key: public.tenk1.thousand, public.tenk1.thousand - -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Sort Key: tenk1_1.thousand, tenk1_1.thousand + -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1 (7 rows) explain (costs off) @@ -1274,15 +1274,15 @@ SELECT thousand, tenthous, thousand+tenthous AS x FROM tenk1 UNION ALL SELECT 42, 42, hundred FROM tenk1 ORDER BY thousand, tenthous; - QUERY PLAN ------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------ Result -> Merge Append - Sort Key: public.tenk1.thousand, public.tenk1.tenthous + Sort Key: tenk1.thousand, tenk1.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 -> Sort Sort Key: (42), (42) - -> Index Only Scan using tenk1_hundred on tenk1 + -> Index Only Scan using tenk1_hundred on tenk1 tenk1_1 (7 rows) explain (costs off) @@ -1290,15 +1290,15 @@ SELECT thousand, tenthous FROM tenk1 UNION ALL SELECT thousand, random()::integer FROM tenk1 ORDER BY thousand, tenthous; - QUERY PLAN ------------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------------- Result -> Merge Append - Sort Key: public.tenk1.thousand, public.tenk1.tenthous + Sort Key: tenk1.thousand, tenk1.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 -> Sort - Sort Key: public.tenk1.thousand, ((random())::integer) - -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Sort Key: tenk1_1.thousand, ((random())::integer) + -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1 (7 rows) -- Check min/max aggregate optimization diff --git a/src/test/regress/expected/select_views.out b/src/test/regress/expected/select_views.out index e4eba1ae36c..24bbff9d2e4 100644 --- a/src/test/regress/expected/select_views.out +++ b/src/test/regress/expected/select_views.out @@ -1421,10 +1421,10 @@ EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_normal -> Subquery Scan on l Filter: f_leak(l.cnum) -> Hash Join - Hash Cond: (r.cid = l.cid) - -> Seq Scan on credit_card r + Hash Cond: (r_1.cid = l_1.cid) + -> Seq Scan on credit_card r_1 -> Hash - -> Seq Scan on customer l + -> Seq Scan on customer l_1 Filter: (name = ("current_user"())::text) (13 rows) @@ -1452,8 +1452,8 @@ EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_secure Filter: ((ymd >= '10-01-2011'::date) AND (ymd < '11-01-2011'::date)) -> Materialize -> Hash Join - Hash Cond: (r.cid = l.cid) - -> Seq Scan on credit_card r + Hash Cond: (r_1.cid = l.cid) + -> Seq Scan on credit_card r_1 -> Hash -> Seq Scan on customer l Filter: (name = ("current_user"())::text) diff --git a/src/test/regress/expected/select_views_1.out b/src/test/regress/expected/select_views_1.out index 94b439825c4..ec6e938cb1d 100644 --- a/src/test/regress/expected/select_views_1.out +++ b/src/test/regress/expected/select_views_1.out @@ -1421,10 +1421,10 @@ EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_normal -> Subquery Scan on l Filter: f_leak(l.cnum) -> Hash Join - Hash Cond: (r.cid = l.cid) - -> Seq Scan on credit_card r + Hash Cond: (r_1.cid = l_1.cid) + -> Seq Scan on credit_card r_1 -> Hash - -> Seq Scan on customer l + -> Seq Scan on customer l_1 Filter: (name = ("current_user"())::text) (13 rows) @@ -1452,8 +1452,8 @@ EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_secure Filter: ((ymd >= '10-01-2011'::date) AND (ymd < '11-01-2011'::date)) -> Materialize -> Hash Join - Hash Cond: (r.cid = l.cid) - -> Seq Scan on credit_card r + Hash Cond: (r_1.cid = l.cid) + -> Seq Scan on credit_card r_1 -> Hash -> Seq Scan on customer l Filter: (name = ("current_user"())::text) diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out index 38cfb8c7276..671f293b68d 100644 --- a/src/test/regress/expected/with.out +++ b/src/test/regress/expected/with.out @@ -2006,8 +2006,8 @@ SELECT * FROM parent; EXPLAIN (VERBOSE, COSTS OFF) WITH wcte AS ( INSERT INTO int8_tbl VALUES ( 42, 47 ) RETURNING q2 ) DELETE FROM a USING wcte WHERE aa = q2; - QUERY PLAN --------------------------------------------------- + QUERY PLAN +------------------------------------------------ Delete on public.a CTE wcte -> Insert on public.int8_tbl @@ -2015,31 +2015,31 @@ DELETE FROM a USING wcte WHERE aa = q2; -> Result Output: 42::bigint, 47::bigint -> Nested Loop - Output: public.a.ctid, wcte.* - Join Filter: (public.a.aa = wcte.q2) + Output: a.ctid, wcte.* + Join Filter: (a.aa = wcte.q2) -> Seq Scan on public.a - Output: public.a.ctid, public.a.aa + Output: a.ctid, a.aa -> CTE Scan on wcte Output: wcte.*, wcte.q2 -> Nested Loop - Output: public.a.ctid, wcte.* - Join Filter: (public.a.aa = wcte.q2) - -> Seq Scan on public.b a - Output: public.a.ctid, public.a.aa + Output: b.ctid, wcte.* + Join Filter: (b.aa = wcte.q2) + -> Seq Scan on public.b + Output: b.ctid, b.aa -> CTE Scan on wcte Output: wcte.*, wcte.q2 -> Nested Loop - Output: public.a.ctid, wcte.* - Join Filter: (public.a.aa = wcte.q2) - -> Seq Scan on public.c a - Output: public.a.ctid, public.a.aa + Output: c.ctid, wcte.* + Join Filter: (c.aa = wcte.q2) + -> Seq Scan on public.c + Output: c.ctid, c.aa -> CTE Scan on wcte Output: wcte.*, wcte.q2 -> Nested Loop - Output: public.a.ctid, wcte.* - Join Filter: (public.a.aa = wcte.q2) - -> Seq Scan on public.d a - Output: public.a.ctid, public.a.aa + Output: d.ctid, wcte.* + Join Filter: (d.aa = wcte.q2) + -> Seq Scan on public.d + Output: d.ctid, d.aa -> CTE Scan on wcte Output: wcte.*, wcte.q2 (34 rows) diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql index 48d8d22d1b8..07145911e6b 100644 --- a/src/test/regress/sql/create_view.sql +++ b/src/test/regress/sql/create_view.sql @@ -224,6 +224,68 @@ SELECT relname, relkind, reloptions FROM pg_class 'mysecview3'::regclass, 'mysecview4'::regclass) ORDER BY relname; +-- Test view decompilation in the face of renaming conflicts + +CREATE TABLE tt1 (f1 int, f2 int, f3 text); +CREATE TABLE tx1 (x1 int, x2 int, x3 text); +CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 text); + +CREATE VIEW aliased_view_1 AS + select * from tt1 + where exists (select 1 from tx1 where tt1.f1 = tx1.x1); +CREATE VIEW aliased_view_2 AS + select * from tt1 a1 + where exists (select 1 from tx1 where a1.f1 = tx1.x1); +CREATE VIEW aliased_view_3 AS + select * from tt1 + where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1); +CREATE VIEW aliased_view_4 AS + select * from temp_view_test.tt1 + where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1); + +\d+ aliased_view_1 +\d+ aliased_view_2 +\d+ aliased_view_3 +\d+ aliased_view_4 + +ALTER TABLE tx1 RENAME TO a1; + +\d+ aliased_view_1 +\d+ aliased_view_2 +\d+ aliased_view_3 +\d+ aliased_view_4 + +ALTER TABLE tt1 RENAME TO a2; + +\d+ aliased_view_1 +\d+ aliased_view_2 +\d+ aliased_view_3 +\d+ aliased_view_4 + +ALTER TABLE a1 RENAME TO tt1; + +\d+ aliased_view_1 +\d+ aliased_view_2 +\d+ aliased_view_3 +\d+ aliased_view_4 + +ALTER TABLE a2 RENAME TO tx1; +ALTER TABLE tx1 SET SCHEMA temp_view_test; + +\d+ aliased_view_1 +\d+ aliased_view_2 +\d+ aliased_view_3 +\d+ aliased_view_4 + +ALTER TABLE temp_view_test.tt1 RENAME TO tmp1; +ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2; +ALTER TABLE tmp1 RENAME TO tx1; + +\d+ aliased_view_1 +\d+ aliased_view_2 +\d+ aliased_view_3 +\d+ aliased_view_4 + DROP SCHEMA temp_view_test CASCADE; DROP SCHEMA testviewschm2 CASCADE; |
