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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix handling of init_plans list in inheritance_planner().
Date: 2012-01-29 01:25:02
Message-ID: E1RrJVu-00084w-NS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-01-29 01:55:52 pgsql: Update statement about sorting of character-string data.
Previous Message Tom Lane 2012-01-28 22:55:30 pgsql: Add simple tests of EvalPlanQual using the isolationtester infra