Thanks for the reply! I have committed the patches in this thread and marked the CF entry accordingly.
On Mon, Mar 30, 2026 at 10:17 PM David Rowley <[email protected]> wrote: > > I looked at v48-0001 and it looks fine to me. I've only minor quibbles > about you using foreach() instead of foreach_int() and foreach_node() > for populating the new Bitmapsets in standard_planner(). Good point. I forgot about those. Attached patch fixes that (since the code was already committed). - Melanie
From cd9ba7cce756ad870a00ce82faae41b5564980b7 Mon Sep 17 00:00:00 2001 From: Melanie Plageman <[email protected]> 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 <[email protected]> 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
