diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index fb6ce49..840e459 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -1673,7 +1673,12 @@ ExecCreatePartitionPruneState(PlanState *planstate, pprune->subpart_map = palloc(sizeof(int) * partdesc->nparts); for (pp_idx = 0; pp_idx < partdesc->nparts; ++pp_idx) { - if (pinfo->relid_map[pd_idx] != partdesc->oids[pp_idx]) + /* + * Beware of InvalidOids in relid_map that were put in for + * partitions pruned by the planner. + */ + if (OidIsValid(pinfo->relid_map[pd_idx]) && + pinfo->relid_map[pd_idx] != partdesc->oids[pp_idx]) { pprune->subplan_map[pp_idx] = -1; pprune->subpart_map[pp_idx] = -1;