From: Melanie Plageman Date: Mon, 30 Mar 2026 13:51:28 +0000 (-0400) Subject: Remove PlannedStmt->resultRelations in favor of resultRelationRelids X-Git-Tag: REL_19_BETA1~604 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39dcd10a2c493821cc88a9f8d17677507571e87d;p=thirdparty%2Fpostgresql.git Remove PlannedStmt->resultRelations in favor of resultRelationRelids PlannedStmt->resultRelations was an integer list of range table indexes because at the time it was added (to Query), the Bitmapset data type did not yet exist in Postgres. 0f4c170cf3b added a Bitmapset of result relations, so remove the integer list of RTIs and use the more compact resultRelationRelids. Discussion: https://postgr.es/m/CAApHDvqAOeOwCKh9g0gfxWa040%3DHyc7_oA%3DC59rjod8kXJDWyw%40mail.gmail.com --- diff --git a/contrib/pg_overexplain/pg_overexplain.c b/contrib/pg_overexplain/pg_overexplain.c index c2b90493cc6..b4e90909289 100644 --- a/contrib/pg_overexplain/pg_overexplain.c +++ b/contrib/pg_overexplain/pg_overexplain.c @@ -780,8 +780,9 @@ overexplain_range_table(PlannedStmt *plannedstmt, ExplainState *es) overexplain_bitmapset("Unprunable RTIs", plannedstmt->unprunableRelids, es); if (es->format != EXPLAIN_FORMAT_TEXT || - plannedstmt->resultRelations != NIL) - overexplain_intlist("Result RTIs", plannedstmt->resultRelations, es); + !bms_is_empty(plannedstmt->resultRelationRelids)) + overexplain_bitmapset("Result RTIs", plannedstmt->resultRelationRelids, + es); /* Close group, we're all done */ ExplainCloseGroup("Range Table", "Range Table", false, es); diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c index f203ed85f50..755191b51ef 100644 --- a/src/backend/executor/execParallel.c +++ b/src/backend/executor/execParallel.c @@ -189,7 +189,6 @@ ExecSerializePlan(Plan *plan, EState *estate) pstmt->rtable = estate->es_range_table; pstmt->unprunableRelids = estate->es_unpruned_relids; pstmt->permInfos = estate->es_rteperminfos; - pstmt->resultRelations = NIL; pstmt->appendRelations = NIL; pstmt->planOrigin = PLAN_STMT_INTERNAL; diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 9886ab06b69..36c5285d252 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -733,7 +733,7 @@ ExecCreateScanSlotFromOuterPlan(EState *estate, bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid) { - return list_member_int(estate->es_plannedstmt->resultRelations, scanrelid); + return bms_is_member(scanrelid, estate->es_plannedstmt->resultRelationRelids); } /* ---------------------------------------------------------------- diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index c81eb76ad75..07944612668 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -657,7 +657,6 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions, glob->prunableRelids); result->permInfos = glob->finalrteperminfos; result->subrtinfos = glob->subrtinfos; - result->resultRelations = glob->resultRelations; result->appendRelations = glob->appendRelations; result->subplans = glob->subplans; result->rewindPlanIDs = glob->rewindPlanIDs; diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index ca61ecfc132..e2c00576d41 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -117,10 +117,6 @@ typedef struct PlannedStmt */ List *permInfos; - /* rtable indexes of target relations for INSERT/UPDATE/DELETE/MERGE */ - /* integer list of RT indexes, or NIL */ - List *resultRelations; - /* RT indexes of relations targeted by INSERT/UPDATE/DELETE/MERGE */ Bitmapset *resultRelationRelids;