From a2aab818dd94db0d78c73ecfda4134a80dbed043 Mon Sep 17 00:00:00 2001 From: amit Date: Tue, 14 Aug 2018 10:35:47 +0900 Subject: [PATCH v2 3/4] Prune PlanRowMark of relations that are pruned from a plan --- src/backend/optimizer/plan/planner.c | 47 +++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 34fbc37702..3cca02c4a2 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -1594,7 +1594,19 @@ inheritance_planner(PlannerInfo *root) if (parse->rowMarks) rowMarks = NIL; else - rowMarks = root->rowMarks; + { + rowMarks = NIL; + foreach(lc, root->rowMarks) + { + PlanRowMark *rc = lfirst(lc); + + if (root->simple_rel_array[rc->rti] != NULL && + IS_DUMMY_REL(root->simple_rel_array[rc->rti])) + continue; + + rowMarks = lappend(rowMarks, rc); + } + } /* Create Path representing a ModifyTable to do the UPDATE/DELETE work */ add_path(final_rel, (Path *) @@ -2124,8 +2136,23 @@ grouping_planner(PlannerInfo *root, bool inheritance_update, */ if (parse->rowMarks) { + ListCell *lc2; + List *rowMarks; + + rowMarks = NIL; + foreach(lc2, root->rowMarks) + { + PlanRowMark *rc = lfirst(lc2); + + if (root->simple_rel_array[rc->rti] != NULL && + IS_DUMMY_REL(root->simple_rel_array[rc->rti])) + continue; + + rowMarks = lappend(rowMarks, rc); + } + path = (Path *) create_lockrows_path(root, final_rel, path, - root->rowMarks, + rowMarks, SS_assign_special_param(root)); } @@ -2172,7 +2199,21 @@ grouping_planner(PlannerInfo *root, bool inheritance_update, if (parse->rowMarks) rowMarks = NIL; else - rowMarks = root->rowMarks; + { + ListCell *lc2; + + rowMarks = NIL; + foreach(lc2, root->rowMarks) + { + PlanRowMark *rc = lfirst(lc2); + + if (root->simple_rel_array[rc->rti] != NULL && + IS_DUMMY_REL(root->simple_rel_array[rc->rti])) + continue; + + rowMarks = lappend(rowMarks, rc); + } + } path = (Path *) create_modifytable_path(root, final_rel, -- 2.11.0