pgsql: Improve EXPLAIN's display of SubPlan nodes and output parameters - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Improve EXPLAIN's display of SubPlan nodes and output parameters
Date
Msg-id E1rmho7-004evd-6q@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve EXPLAIN's display of SubPlan nodes and output parameters.

Historically we've printed SubPlan expression nodes as "(SubPlan N)",
which is pretty uninformative.  Trying to reproduce the original SQL
for the subquery is still as impractical as before, and would be
mighty verbose as well.  However, we can still do better than that.
Displaying the "testexpr" when present, and adding a keyword to
indicate the SubLinkType, goes a long way toward showing what's
really going on.

In addition, this patch gets rid of EXPLAIN's use of "$n" to represent
subplan and initplan output Params.  Instead we now print "(SubPlan
N).colX" or "(InitPlan N).colX" to represent the X'th output column
of that subplan.  This eliminates confusion with the use of "$n" to
represent PARAM_EXTERN Params, and it's useful for the first part of
this change because it eliminates needing some other indication of
which subplan is referenced by a SubPlan that has a testexpr.

In passing, this adds simple regression test coverage of the
ROWCOMPARE_SUBLINK code paths, which were entirely unburdened
by testing before.

Tom Lane and Dean Rasheed, reviewed by Aleksander Alekseev.
Thanks to Chantal Keller for raising the question of whether
this area couldn't be improved.

Discussion: https://postgr.es/m/2838538.1705692747@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out |  34 +--
doc/src/sgml/perform.sgml                      | 102 ++++++++-
src/backend/commands/explain.c                 |  32 ---
src/backend/optimizer/plan/subselect.c         |  22 +-
src/backend/utils/adt/ruleutils.c              | 231 ++++++++++++++++++-
src/test/regress/expected/aggregates.out       |  48 ++--
src/test/regress/expected/groupingsets.out     |  20 +-
src/test/regress/expected/inherit.out          |  30 +--
src/test/regress/expected/insert_conflict.out  |   2 +-
src/test/regress/expected/join.out             |  26 +--
src/test/regress/expected/memoize.out          |   2 +-
src/test/regress/expected/merge.out            |   6 +-
src/test/regress/expected/partition_prune.out  | 292 ++++++++++++-------------
src/test/regress/expected/portals.out          |  12 +-
src/test/regress/expected/rowsecurity.out      | 122 +++++------
src/test/regress/expected/rowtypes.out         |   8 +-
src/test/regress/expected/select_parallel.out  |  37 ++--
src/test/regress/expected/sqljson.out          |   4 +-
src/test/regress/expected/subselect.out        | 157 ++++++++-----
src/test/regress/expected/updatable_views.out  |  40 ++--
src/test/regress/expected/update.out           |   8 +-
src/test/regress/expected/window.out           |   2 +-
src/test/regress/expected/with.out             |   6 +-
src/test/regress/sql/subselect.sql             |  14 ++
24 files changed, 793 insertions(+), 464 deletions(-)


pgsql-committers by date:

Previous
From: Nathan Bossart
Date:
Subject: pgsql: Inline pg_popcount{32,64} into pg_popcount().
Next
From: Jeff Davis
Date:
Subject: pgsql: Support C.UTF-8 locale in the new builtin collation provider.