pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix planner error with multiple copies of an AlternativeSubPlan.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix planner error with multiple copies of an AlternativeSubPlan.
@ 2021-09-14 19:11  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2021-09-14 19:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e8638d78a2cb94efba11a5dfbf3e7cd746d0af3e

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c    | 71 ++++++++++++++++++++++-----------
src/include/nodes/pathnodes.h           |  4 ++
src/test/regress/expected/subselect.out | 40 +++++++++++++++++++
src/test/regress/sql/subselect.sql      | 12 ++++++
4 files changed, 103 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix planner error with multiple copies of an AlternativeSubPlan.
@ 2021-09-14 19:11  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2021-09-14 19:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/29aa0ce361d16a79e4ebf7561cbb16ed1d0e2211

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c    | 71 ++++++++++++++++++++++-----------
src/include/nodes/pathnodes.h           |  4 ++
src/test/regress/expected/subselect.out | 40 +++++++++++++++++++
src/test/regress/sql/subselect.sql      | 12 ++++++
4 files changed, 103 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-09-14 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 19:11 pgsql: Fix planner error with multiple copies of an AlternativeSubPlan. Tom Lane <tgl@sss.pgh.pa.us>
2021-09-14 19:11 pgsql: Fix planner error with multiple copies of an AlternativeSubPlan. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox