]> granicus.if.org Git - postgresql/commit
Fix set_subquery_pathlist() to copy the RTE's subquery before it gets mangled
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Mar 2009 20:58:41 +0000 (20:58 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Mar 2009 20:58:41 +0000 (20:58 +0000)
commit6f7e1d1db8897fd3de2f5262b3d226a84407306f
tree6c0d92fb36ecb82867da0fb4d5297697daad27a4
parent359771007e24804a9fd3912d8c8e023442ddde0d
Fix set_subquery_pathlist() to copy the RTE's subquery before it gets mangled
by the planning process.  This prevents the "failed to locate grouping columns"
error recently reported by Dickson Guedes.  That happens because planning
replaces SubLinks by SubPlans in the subquery's targetlist, and exprTypmod()
is smarter about the former than the latter, causing the apparent type of
the subquery's output columns to change.  This seems to be a deficiency we
should fix in exprTypmod(), but that will be a much more invasive patch
with possible side-effects elsewhere, so I'll do that only in HEAD.

Back-patch to 8.3.  Arguably the lack of a copying step is broken/dangerous
all the way back, but in the absence of known problems I'll refrain from
making the older branches pay the extra cost.  (The reason this particular
symptom didn't appear before is that exprTypmod() wasn't smart about SubLinks
either, until 8.3.)
src/backend/optimizer/path/allpaths.c
src/test/regress/expected/subselect.out
src/test/regress/sql/subselect.sql