pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix EXPLAIN of dummy set operations some more. 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix EXPLAIN of dummy set operations some more. @ 2026-10-05 15:48 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2026-10-05 15:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix EXPLAIN of dummy set operations some more. EXPLAIN failed to deal with varno-0 Vars that are made by prepunion.c and can survive into a finished plan in the case where a provably empty set operation is replaced by a dummy Result (which is possible since 03d40e4b5). Commit 928df067d tried to fix this, but it was a couple bricks shy of a load. First, it only dealt with varno-0 Vars at the top level of the Result's tlist, but they could be buried under coercion expressions. Fix that by doing a recursive mutation. Second, it always replaced varno 0 with varno 1, but that's just wrong: the Result might represent a group of setop leaf queries that do not include the leftmost leaf. That led to displaying the wrong variable(s) as outputs of the Result, risking confusion. Fortunately, we can get the actual child relids from the recently-added Result.relids field, and use that to discover the leftmost child represented by the Result. This was found while discussing bug #19742, but it's really an independent issue. Author: shihao zhong <zhong950419@gmail.com> Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAGRkXqTFwygKmjLG_Y=kbXRHsePFmD6k+qrzVLP4_KrG+-=oRg@mail.gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/90893c7b7cf355b87f403a8a56293abe33ad7848 Modified Files -------------- src/backend/optimizer/plan/setrefs.c | 69 ++++++++++++++++++++++++++---------- src/test/regress/expected/union.out | 20 +++++++++++ src/test/regress/sql/union.sql | 9 +++++ 3 files changed, 79 insertions(+), 19 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix EXPLAIN of dummy set operations some more. @ 2026-10-05 15:48 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2026-10-05 15:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix EXPLAIN of dummy set operations some more. EXPLAIN failed to deal with varno-0 Vars that are made by prepunion.c and can survive into a finished plan in the case where a provably empty set operation is replaced by a dummy Result (which is possible since 03d40e4b5). Commit 928df067d tried to fix this, but it was a couple bricks shy of a load. First, it only dealt with varno-0 Vars at the top level of the Result's tlist, but they could be buried under coercion expressions. Fix that by doing a recursive mutation. Second, it always replaced varno 0 with varno 1, but that's just wrong: the Result might represent a group of setop leaf queries that do not include the leftmost leaf. That led to displaying the wrong variable(s) as outputs of the Result, risking confusion. Fortunately, we can get the actual child relids from the recently-added Result.relids field, and use that to discover the leftmost child represented by the Result. This was found while discussing bug #19742, but it's really an independent issue. Author: shihao zhong <zhong950419@gmail.com> Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAGRkXqTFwygKmjLG_Y=kbXRHsePFmD6k+qrzVLP4_KrG+-=oRg@mail.gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3e3edd1a6147a5c1b88464bc827add54d3fe50ad Modified Files -------------- src/backend/optimizer/plan/setrefs.c | 69 ++++++++++++++++++++++++++---------- src/test/regress/expected/union.out | 20 +++++++++++ src/test/regress/sql/union.sql | 9 +++++ 3 files changed, 79 insertions(+), 19 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-10-05 15:48 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-10-05 15:48 pgsql: Fix EXPLAIN of dummy set operations some more. Tom Lane <tgl@sss.pgh.pa.us> 2026-10-05 15:48 pgsql: Fix EXPLAIN of dummy set operations some more. 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