diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 10 | ||||
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 16 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index fae1f67b9c0..997bdcff2ea 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -5704,6 +5704,16 @@ materialize_finished_plan(Plan *subplan) matplan = (Plan *) make_material(subplan); + /* + * XXX horrid kluge: if there are any initPlans attached to the subplan, + * move them up to the Material node, which is now effectively the top + * plan node in its query level. This prevents failure in + * SS_finalize_plan(), which see for comments. We don't bother adjusting + * the subplan's cost estimate for this. + */ + matplan->initPlan = subplan->initPlan; + subplan->initPlan = NIL; + /* Set cost data */ cost_material(&matpath, subplan->startup_cost, diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 4b5902fc3ec..881742f46b6 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -316,21 +316,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) if (cursorOptions & CURSOR_OPT_SCROLL) { if (!ExecSupportsBackwardScan(top_plan)) - { - Plan *sub_plan = top_plan; - - top_plan = materialize_finished_plan(sub_plan); - - /* - * XXX horrid kluge: if there are any initPlans attached to the - * formerly-top plan node, move them up to the Material node. This - * prevents failure in SS_finalize_plan, which see for comments. - * We don't bother adjusting the sub_plan's cost estimate for - * this. - */ - top_plan->initPlan = sub_plan->initPlan; - sub_plan->initPlan = NIL; - } + top_plan = materialize_finished_plan(top_plan); } /* |