diff options
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 604cb0625b8..74ef35cd250 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -851,7 +851,8 @@ InitPlan(QueryDesc *queryDesc, int eflags) /* * initialize the node's execution state */ - ExecInitRangeTable(estate, rangeTable, plannedstmt->permInfos); + ExecInitRangeTable(estate, rangeTable, plannedstmt->permInfos, + bms_copy(plannedstmt->unprunableRelids)); estate->es_plannedstmt = plannedstmt; estate->es_part_prune_infos = plannedstmt->partPruneInfos; @@ -881,8 +882,13 @@ InitPlan(QueryDesc *queryDesc, int eflags) Relation relation; ExecRowMark *erm; - /* ignore "parent" rowmarks; they are irrelevant at runtime */ - if (rc->isParent) + /* + * Ignore "parent" rowmarks, because they are irrelevant at + * runtime. Also ignore the rowmarks belonging to child tables + * that have been pruned in ExecDoInitialPruning(). + */ + if (rc->isParent || + !bms_is_member(rc->rti, estate->es_unpruned_relids)) continue; /* get relation's OID (will produce InvalidOid if subquery) */ @@ -2934,6 +2940,13 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree) } /* + * Copy es_unpruned_relids so that pruned relations are ignored by + * ExecInitLockRows() and ExecInitModifyTable() when initializing the plan + * trees below. + */ + rcestate->es_unpruned_relids = parentestate->es_unpruned_relids; + + /* * Initialize private state information for each SubPlan. We must do this * before running ExecInitNode on the main query tree, since * ExecInitSubPlan expects to be able to find these entries. Some of the |