diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-07-23 16:23:01 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-07-23 16:23:45 -0400 |
| commit | a7cd853b75d01666135ca87353cee83b99d06b9b (patch) | |
| tree | 04e1610ac70c4d368982694b733073f7e46a2340 /src/test | |
| parent | c359a1b0823f798fc419adea5da7991845c915aa (diff) | |
Change post-rewriter representation of dropped columns in joinaliasvars.
It's possible to drop a column from an input table of a JOIN clause in a
view, if that column is nowhere actually referenced in the view. But it
will still be there in the JOIN clause's joinaliasvars list. We used to
replace such entries with NULL Const nodes, which is handy for generation
of RowExpr expansion of a whole-row reference to the view. The trouble
with that is that it can't be distinguished from the situation after
subquery pull-up of a constant subquery output expression below the JOIN.
Instead, replace such joinaliasvars with null pointers (empty expression
trees), which can't be confused with pulled-up expressions. expandRTE()
still emits the old convention, though, for convenience of RowExpr
generation and to reduce the risk of breaking extension code.
In HEAD and 9.3, this patch also fixes a problem with some new code in
ruleutils.c that was failing to cope with implicitly-casted joinaliasvars
entries, as per recent report from Feike Steenbergen. That oversight was
because of an inadequate description of the data structure in parsenodes.h,
which I've now corrected. There were some pre-existing oversights of the
same ilk elsewhere, which I believe are now all fixed.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/create_view.out | 27 | ||||
| -rw-r--r-- | src/test/regress/sql/create_view.sql | 15 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out index 4fa77495034..8b451429674 100644 --- a/src/test/regress/expected/create_view.out +++ b/src/test/regress/expected/create_view.out @@ -1243,6 +1243,33 @@ select pg_get_viewdef('vv4', true); FULL JOIN tt8 tt8y(x_1, z, z2) USING (x_1); (1 row) +-- +-- Also check dropping a column that existed when the view was made +-- +create table tt9 (x int, xx int, y int); +create table tt10 (x int, z int); +create view vv5 as select x,y,z from tt9 join tt10 using(x); +select pg_get_viewdef('vv5', true); + pg_get_viewdef +------------------------- + SELECT tt9.x, + + tt9.y, + + tt10.z + + FROM tt9 + + JOIN tt10 USING (x); +(1 row) + +alter table tt9 drop column xx; +select pg_get_viewdef('vv5', true); + pg_get_viewdef +------------------------- + SELECT tt9.x, + + tt9.y, + + tt10.z + + FROM tt9 + + JOIN tt10 USING (x); +(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 3d85d9cfdc5..4fbd5a5e6f8 100644 --- a/src/test/regress/sql/create_view.sql +++ b/src/test/regress/sql/create_view.sql @@ -389,6 +389,21 @@ select pg_get_viewdef('vv2', true); select pg_get_viewdef('vv3', true); select pg_get_viewdef('vv4', true); +-- +-- Also check dropping a column that existed when the view was made +-- + +create table tt9 (x int, xx int, y int); +create table tt10 (x int, z int); + +create view vv5 as select x,y,z from tt9 join tt10 using(x); + +select pg_get_viewdef('vv5', true); + +alter table tt9 drop column xx; + +select pg_get_viewdef('vv5', true); + -- clean up all the random objects we made above set client_min_messages = warning; DROP SCHEMA temp_view_test CASCADE; |
