mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user