pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.
5+ messages / 1 participants
[nested] [flat]

* pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.
@ 2021-10-11 15:57  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-10-11 15:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.

Commit 3f50b8263 had an oversight: formerly, to deparse expressions
attached to a plan node, it was only necessary to update the
deparse_namespace ancestors list alongside calling set_deparse_plan.
Now it's necessary to update the ancestors list *first*, because
set_deparse_plan consults it, and one call site got that wrong.

This error was masked in most cases because explain.c uses just one
List object for the ancestors list, updating it in-place as the plan
is scanned, so that we accidentally had the right List assigned to
dpns->ancestors before it was needed.  It would fail only if a
WorkTableScan node were the first one that we tried to deparse a
subexpression of.

Per report from Markus Winand.  Like the previous patch,
back-patch to v14.

Discussion: https://postgr.es/m/648B0505-AA57-42C2-A2DA-E551DE46FA15@winand.at

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/39ae0ef8561362304ee512963aa51d5a705e5616

Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



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

* pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.
@ 2021-10-11 15:57  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-10-11 15:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.

Commit 3f50b8263 had an oversight: formerly, to deparse expressions
attached to a plan node, it was only necessary to update the
deparse_namespace ancestors list alongside calling set_deparse_plan.
Now it's necessary to update the ancestors list *first*, because
set_deparse_plan consults it, and one call site got that wrong.

This error was masked in most cases because explain.c uses just one
List object for the ancestors list, updating it in-place as the plan
is scanned, so that we accidentally had the right List assigned to
dpns->ancestors before it was needed.  It would fail only if a
WorkTableScan node were the first one that we tried to deparse a
subexpression of.

Per report from Markus Winand.  Like the previous patch,
back-patch to v14.

Discussion: https://postgr.es/m/648B0505-AA57-42C2-A2DA-E551DE46FA15@winand.at

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2c25db32eedb9696c4b900c70ebef03683babf24

Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



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

* pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial valu
@ 2022-10-16 23:18  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value.

If the non-recursive term of a SEARCH BREADTH FIRST recursive
query has only constants in its target list, the planner will
fold the starting RowExpr added by rewrite into a simple Const
of type RECORD.  The executor doesn't have any problem with
that --- but EXPLAIN VERBOSE will encounter the Const as the
ultimate source of truth about what the field names of the
SET column are, and it didn't know what to do with that.
Fortunately, we can pull the identifying typmod out of the
Const, in much the same way that record_out would.

For reasons that remain a bit obscure to me, this only fails
with SEARCH BREADTH FIRST, not SEARCH DEPTH FIRST or CYCLE.
But I added regression test cases for both of those options
too, just to make sure we don't break it in future.

Per bug #17644 from Matthijs van der Vleuten.  Back-patch
to v14 where these constructs were added.

Discussion: https://postgr.es/m/17644-3bd1f3036d6d7a16@postgresql.org

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/ruleutils.c  |   3 +-
src/backend/utils/fmgr/funcapi.c   |  34 +++++++++++
src/test/regress/expected/with.out | 120 +++++++++++++++++++++++++++++++++++++
src/test/regress/sql/with.sql      |  52 ++++++++++++++++
4 files changed, 208 insertions(+), 1 deletion(-)



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

* pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial valu
@ 2022-10-16 23:18  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value.

If the non-recursive term of a SEARCH BREADTH FIRST recursive
query has only constants in its target list, the planner will
fold the starting RowExpr added by rewrite into a simple Const
of type RECORD.  The executor doesn't have any problem with
that --- but EXPLAIN VERBOSE will encounter the Const as the
ultimate source of truth about what the field names of the
SET column are, and it didn't know what to do with that.
Fortunately, we can pull the identifying typmod out of the
Const, in much the same way that record_out would.

For reasons that remain a bit obscure to me, this only fails
with SEARCH BREADTH FIRST, not SEARCH DEPTH FIRST or CYCLE.
But I added regression test cases for both of those options
too, just to make sure we don't break it in future.

Per bug #17644 from Matthijs van der Vleuten.  Back-patch
to v14 where these constructs were added.

Discussion: https://postgr.es/m/17644-3bd1f3036d6d7a16@postgresql.org

Branch
------
REL_15_STABLE

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

Modified Files
--------------
src/backend/utils/adt/ruleutils.c  |   3 +-
src/backend/utils/fmgr/funcapi.c   |  34 +++++++++++
src/test/regress/expected/with.out | 120 +++++++++++++++++++++++++++++++++++++
src/test/regress/sql/with.sql      |  52 ++++++++++++++++
4 files changed, 208 insertions(+), 1 deletion(-)



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

* pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial valu
@ 2022-10-16 23:18  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value.

If the non-recursive term of a SEARCH BREADTH FIRST recursive
query has only constants in its target list, the planner will
fold the starting RowExpr added by rewrite into a simple Const
of type RECORD.  The executor doesn't have any problem with
that --- but EXPLAIN VERBOSE will encounter the Const as the
ultimate source of truth about what the field names of the
SET column are, and it didn't know what to do with that.
Fortunately, we can pull the identifying typmod out of the
Const, in much the same way that record_out would.

For reasons that remain a bit obscure to me, this only fails
with SEARCH BREADTH FIRST, not SEARCH DEPTH FIRST or CYCLE.
But I added regression test cases for both of those options
too, just to make sure we don't break it in future.

Per bug #17644 from Matthijs van der Vleuten.  Back-patch
to v14 where these constructs were added.

Discussion: https://postgr.es/m/17644-3bd1f3036d6d7a16@postgresql.org

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8122160ffb68acb0db740f4f6456fdaaaa577d90

Modified Files
--------------
src/backend/utils/adt/ruleutils.c  |   3 +-
src/backend/utils/fmgr/funcapi.c   |  34 +++++++++++
src/test/regress/expected/with.out | 120 +++++++++++++++++++++++++++++++++++++
src/test/regress/sql/with.sql      |  52 ++++++++++++++++
4 files changed, 208 insertions(+), 1 deletion(-)



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


end of thread, other threads:[~2022-10-16 23:18 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 15:57 pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST queries some more. Tom Lane <tgl@sss.pgh.pa.us>
2021-10-11 15:57 pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST queries some more. Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 23:18 pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial valu Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 23:18 pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial valu Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 23:18 pgsql: Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial valu 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