Keep the planner from failing on "WHERE false AND something IN (SELECT ...)".
authorTom Lane <[email protected]>
Thu, 4 Oct 2007 20:45:17 +0000 (20:45 +0000)
committerTom Lane <[email protected]>
Thu, 4 Oct 2007 20:45:17 +0000 (20:45 +0000)
commita2f6ecb9e958d61c990c2a3a58561e94d87b44a1
treea12b20c0efe38027db56fe3083dddc3871adf8f2
parent49fe1374187b3d1a5a8ccf38a8cad7c6a73a9be4
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