]> granicus.if.org Git - postgresql/commit
Keep the planner from failing on "WHERE false AND something IN (SELECT ...)".
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 4 Oct 2007 20:45:09 +0000 (20:45 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 4 Oct 2007 20:45:09 +0000 (20:45 +0000)
commit4ef9e9f8776e9e8935464ef4ca011070d93677be
treeceac3779c9680597e9c3224e7f22948ff6c17ac6
parent79f1d7f5a35c588959eceaab016d9a9ae4ec0c52
Keep the planner from failing on "WHERE false AND something IN (SELECT ...)".
eval_const_expressions simplifies this to just "WHERE false", but we have
already done pull_up_IN_clauses so the IN join will be done, or at least
planned, anyway.  The trouble case comes when the sub-SELECT is itself a join
and we decide to implement the IN by unique-ifying the sub-SELECT outputs:
with no remaining reference to the output Vars in WHERE, we won't have
propagated the Vars up to the upper join point, leading to "variable not found
in subplan target lists" error.  Fix by adding an extra scan of in_info_list
and forcing all Vars mentioned therein to be propagated up to the IN join
point.  Per bug report from Miroslav Sulc.
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planmain.c
src/include/optimizer/planmain.h