]> granicus.if.org Git - postgresql/commit
Fix whole-row Var evaluation to cope with resjunk columns (again).
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Jul 2012 17:09:10 +0000 (13:09 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Jul 2012 17:09:10 +0000 (13:09 -0400)
commitd7991a13d86e2b94b0ca3d087fdad8a840ebf025
tree0d80fa47c61e3d0d8da93f79bac38751d86c0105
parente3981da37a2f071951e54d74d45ad47733cc74a6
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.
src/backend/executor/execQual.c
src/backend/executor/execUtils.c
src/include/nodes/execnodes.h
src/include/nodes/nodes.h
src/test/regress/expected/subselect.out
src/test/regress/sql/subselect.sql