v1-0001-Use-foreach_int-foreach_node-for-resultRelationRe.patch
text/x-patch
Filename: v1-0001-Use-foreach_int-foreach_node-for-resultRelationRe.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0001
Subject: Use foreach_int/foreach_node for resultRelationRelids and rowMarkRelids
| File | + | − |
|---|---|---|
| src/backend/optimizer/plan/planner.c | 5 | 6 |
From cd9ba7cce756ad870a00ce82faae41b5564980b7 Mon Sep 17 00:00:00 2001 From: Melanie Plageman <melanieplageman@gmail.com> Date: Tue, 31 Mar 2026 12:06:39 -0400 Subject: [PATCH v1] Use foreach_int/foreach_node for resultRelationRelids and rowMarkRelids 0f4c170cf3b85e iterated through PlannerGlobal->resultRelations and PlannerGlobal->finalrowmarks adding their RTIs to bitmapsets in the PlannedStmt. It used the generic foreach() instead of the more recently introduced, preferred, type-safe specialized variants: foreach_int() and foreach_node(). Do that now. Reported-by: David Rowley <dgrowleyml@gmail.com> Discussion: https://postgr.es/m/CAApHDvq_R-gNXu%2B06GQW6w_HaEMh1pezsyiCh7GNhgh%2Bh0UqMw%40mail.gmail.com --- src/backend/optimizer/plan/planner.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 07944612668..2b8243635a9 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -341,8 +341,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions, Path *best_path; Plan *top_plan; ListCell *lp, - *lr, - *lc; + *lr; /* * Set up global state for this planner invocation. This data is needed @@ -666,12 +665,12 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions, * Compute resultRelationRelids and rowMarkRelids from resultRelations and * rowMarks. These can be used for cheap membership checks. */ - foreach(lc, glob->resultRelations) + foreach_int(rti, glob->resultRelations) result->resultRelationRelids = bms_add_member(result->resultRelationRelids, - lfirst_int(lc)); - foreach(lc, glob->finalrowmarks) + rti); + foreach_node(PlanRowMark, rowmark, glob->finalrowmarks) result->rowMarkRelids = bms_add_member(result->rowMarkRelids, - ((PlanRowMark *) lfirst(lc))->rti); + rowmark->rti); result->relationOids = glob->relationOids; result->invalItems = glob->invalItems; -- 2.43.0