pgsql: Keep the planner from failing on "WHERE false AND something IN - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Keep the planner from failing on "WHERE false AND something IN
Date
Msg-id 20071004204447.98177753E4C@cvs.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/src/backend/optimizer/plan:
        initsplan.c (r1.133 -> r1.134)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/initsplan.c?r1=1.133&r2=1.134)
        planmain.c (r1.102 -> r1.103)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/planmain.c?r1=1.102&r2=1.103)
    pgsql/src/include/optimizer:
        planmain.h (r1.101 -> r1.102)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/planmain.h?r1=1.101&r2=1.102)

pgsql-committers by date:

Previous
From: kostas@pgfoundry.org (User Kostas)
Date:
Subject: pgtreelib - pgtreelib:
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Keep the planner from failing on "WHERE false AND something IN