Skip to content

Commit

Permalink
Improve style around manipulation of AppendPath node
Browse files Browse the repository at this point in the history
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
  • Loading branch information
michaelpq committed Aug 21, 2024
1 parent 6a1f91a commit 9849b00
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pg_hint_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9849b00

Please sign in to comment.