pgsql: Fix handling of init_plans list in inheritance_planner(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix handling of init_plans list in inheritance_planner().
Date
Msg-id E1RrJVu-00084w-NS@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix handling of init_plans list in inheritance_planner().

Formerly we passed an empty list to each per-child-table invocation of
grouping_planner, and then merged the results into the global list.
However, that fails if there's a CTE attached to the statement, because
create_ctescan_plan uses the list to find the plan referenced by a CTE
reference; so it was unable to find any CTEs attached to the outer UPDATE
or DELETE.  But there's no real reason not to use the same list throughout
the process, and doing so is simpler and faster anyway.

Per report from Josh Berkus of "could not find plan for CTE" failures.
Back-patch to 9.1 where we added support for WITH attached to UPDATE or
DELETE.  Add some regression test cases, too.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1a096957d747a3bc93abe65722c919c8a40a1049

Modified Files
--------------
src/backend/optimizer/plan/planner.c |    3 +-
src/test/regress/expected/with.out   |   56 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/with.sql        |   30 ++++++++++++++++++
3 files changed, 87 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Add simple tests of EvalPlanQual using the isolationtester infra
Next
From: Tom Lane
Date:
Subject: pgsql: Fix handling of init_plans list in inheritance_planner().