]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove PlannedStmt->resultRelations in favor of resultRelationRelids
authorMelanie Plageman <melanieplageman@gmail.com>
Mon, 30 Mar 2026 13:51:28 +0000 (09:51 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Mon, 30 Mar 2026 13:51:28 +0000 (09:51 -0400)
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

contrib/pg_overexplain/pg_overexplain.c
src/backend/executor/execParallel.c
src/backend/executor/execUtils.c
src/backend/optimizer/plan/planner.c
src/include/nodes/plannodes.h

index c2b90493cc6a4780216a97ade1076e2fdef32f20..b4e9090928905685c21322fed40e8614080b1b36 100644 (file)
@@ -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);
index f203ed85f50d529c1f9144d9eff017d02e8cfc6c..755191b51ef66541c42d1dde64f48a920d1dc10a 100644 (file)
@@ -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;
 
index 9886ab06b6955e52c2633faeb74747dc4f645edf..36c5285d252a6f08c5935eed3c18d87a22d01121 100644 (file)
@@ -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);
 }
 
 /* ----------------------------------------------------------------
index c81eb76ad7517b2ec2b27d179ee320e962927261..07944612668b095841f8f70789583f0e1d654eb8 100644 (file)
@@ -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;
index ca61ecfc1328b253fa8ced03835cb8150a727433..e2c00576d41c7bec4ef129e168c041022d29bebe 100644 (file)
@@ -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;