diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-01-28 20:24:42 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-01-28 20:24:42 -0500 |
commit | 4ec6581c0cdddfda767641f535116ee9a0412149 (patch) | |
tree | 8ad9f64f2f8f918d746717b517810023224cd800 /src/backend/optimizer/plan/planner.c | |
parent | 759d9d67695783f6d04a85aba383a41c5382548c (diff) | |
download | postgresql-4ec6581c0cdddfda767641f535116ee9a0412149.tar.gz |
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.
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 921262948b..2e8ea5afad 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -835,8 +835,6 @@ inheritance_planner(PlannerInfo *root) Assert(subroot.join_info_list == NIL); /* and we haven't created PlaceHolderInfos, either */ Assert(subroot.placeholder_list == NIL); - /* build a separate list of initplans for each child */ - subroot.init_plans = NIL; /* hack to mark target relation as an inheritance partition */ subroot.hasInheritedTarget = true; @@ -883,7 +881,7 @@ inheritance_planner(PlannerInfo *root) save_rel_array = subroot.simple_rel_array; /* Make sure any initplans from this rel get into the outer list */ - root->init_plans = list_concat(root->init_plans, subroot.init_plans); + root->init_plans = subroot.init_plans; /* Build list of target-relation RT indexes */ resultRelations = lappend_int(resultRelations, appinfo->child_relid); |