diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-09-14 15:11:21 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-09-14 15:11:21 -0400 |
commit | e8638d78a2cb94efba11a5dfbf3e7cd746d0af3e (patch) | |
tree | c57aaae614316217597539a6e4c61e45218bdacb /src/include/nodes/pathnodes.h | |
parent | bdeb2c4ec2700bfa561061ccd19181326ee01c3f (diff) |
Fix planner error with multiple copies of an AlternativeSubPlan.
It's possible for us to copy an AlternativeSubPlan expression node
into multiple places, for example the scan quals of several
partition children. Then it's possible that we choose a different
one of the alternatives as optimal in each place. Commit 41efb8340
failed to consider this scenario, so its attempt to remove "unused"
subplans could remove subplans that were still used elsewhere.
Fix by delaying the removal logic until we've examined all the
AlternativeSubPlans in a given query level. (This does assume that
AlternativeSubPlans couldn't get copied to other query levels, but
for the foreseeable future that's fine; cf qual_is_pushdown_safe.)
Per report from Rajkumar Raghuwanshi. Back-patch to v14
where the faulty logic came in.
Discussion: https://postgr.es/m/CAKcux6==O3NNZC3bZ2prRYv3cjm3_Zw1GfzmOjEVqYN4jub2+Q@mail.gmail.com
Diffstat (limited to 'src/include/nodes/pathnodes.h')
-rw-r--r-- | src/include/nodes/pathnodes.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index 1abe233db2b..c8a8eec6e2f 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -368,6 +368,10 @@ struct PlannerInfo Relids curOuterRels; /* outer rels above current node */ List *curOuterParams; /* not-yet-assigned NestLoopParams */ + /* These fields are workspace for setrefs.c */ + bool *isAltSubplan; /* array corresponding to glob->subplans */ + bool *isUsedSubplan; /* array corresponding to glob->subplans */ + /* optional private data for join_search_hook, e.g., GEQO */ void *join_search_private; |