diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-20 13:09:00 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-20 13:10:58 -0400 |
| commit | 8e617e29aaccfdd1b85af7f50dc83aa6dd7ef550 (patch) | |
| tree | cae7a269c2f0e1d0489b02af1301ea8c4a95fb3f /src/test/regress/sql/subselect.sql | |
| parent | 3a0e4d36ebd7f477822d5bae41ba121a40d22ccc (diff) | |
| download | postgresql-8e617e29aaccfdd1b85af7f50dc83aa6dd7ef550.tar.gz | |
Fix whole-row Var evaluation to cope with resjunk columns (again).
When a whole-row Var is reading the result of a subquery, we need it to
ignore any "resjunk" columns that the subquery might have evaluated for
GROUP BY or ORDER BY purposes. We've hacked this area before, in commit
68e40998d058c1f6662800a648ff1e1ce5d99cba, but that fix only covered
whole-row Vars of named composite types, not those of RECORD type; and it
was mighty klugy anyway, since it just assumed without checking that any
extra columns in the result must be resjunk. A proper fix requires getting
hold of the subquery's targetlist so we can actually see which columns are
resjunk (whereupon we can use a JunkFilter to get rid of them). So bite
the bullet and add some infrastructure to make that possible.
Per report from Andrew Dunstan and additional testing by Merlin Moncure.
Back-patch to all supported branches. In 8.3, also back-patch commit
292176a118da6979e5d368a4baf27f26896c99a5, which for some reason I had
not done at the time, but it's a prerequisite for this change.
Diffstat (limited to 'src/test/regress/sql/subselect.sql')
| -rw-r--r-- | src/test/regress/sql/subselect.sql | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql index 3cecbc1d41..e07a30ed03 100644 --- a/src/test/regress/sql/subselect.sql +++ b/src/test/regress/sql/subselect.sql @@ -325,6 +325,15 @@ select (select (select view_a)) from view_a; select (select (a.*)::text) from view_a a; -- +-- Check that whole-row Vars reading the result of a subselect don't include +-- any junk columns therein +-- + +select q from (select max(f1) from int4_tbl group by f1 order by f1) q; +with q as (select max(f1) from int4_tbl group by f1 order by f1) + select q from q; + +-- -- Test case for sublinks pushed down into subselects via join alias expansion -- |
