From 9849b00a06ae25bbc72d345dcb7ee78426b4eaf3 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 21 Aug 2024 13:26:37 +0900 Subject: [PATCH] Improve style around manipulation of AppendPath node As coded, the logic in charge of computing parallel_workers based on the lookup of the paths would assign AppendPath before making sure that it is a node of the expected type. The code was not wrong, but that would encourage incorrect logic, like looking at the values inside the AppendPath before checking that it is of the correct type. Backpatch-through: 17 --- pg_hint_plan.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pg_hint_plan.c b/pg_hint_plan.c index ff8aef2..9b7a025 100644 --- a/pg_hint_plan.c +++ b/pg_hint_plan.c @@ -4768,13 +4768,16 @@ pg_hint_plan_set_rel_pathlist(PlannerInfo * root, RelOptInfo *rel, foreach(lc, rel->partial_pathlist) { - ListCell *lcp; - AppendPath *apath = (AppendPath *) lfirst(lc); - int parallel_workers = 0; + ListCell *lcp; + Node *path = (Node *) lfirst(lc); + AppendPath *apath; + int parallel_workers = 0; - if (!IsA(apath, AppendPath)) + if (!IsA(path, AppendPath)) continue; + apath = (AppendPath *) path; + foreach (lcp, apath->subpaths) { Path *spath = (Path *) lfirst(lcp);