From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Keep track of what RTIs a Result node is scanning.
Date: Tue, 23 Sep 2025 13:21:41 +0000
Message-ID: <E1v12xh-0026S5-0Y@gemulon.postgresql.org> (raw)
Keep track of what RTIs a Result node is scanning.
Result nodes now include an RTI set, which is only non-NULL when they
have no subplan, and is taken from the relid set of the RelOptInfo that
the Result is generating. ExplainPreScanNode now takes notice of these
RTIs, which means that a few things get schema-qualified in the
regression tests that previously did not. This makes the output more
consistent between cases where some part of the plan tree is replaced by
a Result node and those where this does not happen.
Likewise, pg_overexplain's EXPLAIN (RANGE_TABLE) now displays the RTIs
stored in a Result node just as it already does for other RTI-bearing
node types.
Result nodes also now include a result_reason, which tells us something
about why the Result node was inserted. Using that information, EXPLAIN
now emits, where relevant, a "Replaces" line describing the origin of
a Result node.
The purpose of these changes is to allow code that inspects a Plan
tree to understand the origin of Result nodes that appear therein.
Discussion: http://postgr.es/m/CA+TgmoYeUZePZWLsSO+1FAN7UPePT_RMEZBKkqYBJVCF1s60=w@mail.gmail.com
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f2bae51dfd5b2edc460c86071c577a45a1acbfd7
Modified Files
--------------
contrib/file_fdw/expected/file_fdw.out | 1 +
contrib/pg_overexplain/expected/pg_overexplain.out | 6 +-
contrib/pg_overexplain/pg_overexplain.c | 12 ++
contrib/postgres_fdw/expected/postgres_fdw.out | 9 +-
src/backend/commands/explain.c | 102 +++++++++++++++
src/backend/optimizer/plan/createplan.c | 117 +++++++++++------
src/backend/optimizer/plan/setrefs.c | 2 +
src/include/nodes/plannodes.h | 22 ++++
src/test/regress/expected/aggregates.out | 51 +++++---
src/test/regress/expected/case.out | 21 +--
src/test/regress/expected/explain.out | 8 ++
src/test/regress/expected/generated_virtual.out | 25 ++--
src/test/regress/expected/groupingsets.out | 3 +-
src/test/regress/expected/inherit.out | 28 ++--
src/test/regress/expected/join.out | 143 ++++++++++++---------
src/test/regress/expected/merge.out | 3 +-
src/test/regress/expected/partition_aggregate.out | 21 +--
src/test/regress/expected/partition_join.out | 35 ++---
src/test/regress/expected/partition_prune.out | 141 +++++++++++---------
src/test/regress/expected/predicate.out | 33 +++--
src/test/regress/expected/rowsecurity.out | 13 +-
src/test/regress/expected/rowtypes.out | 6 +-
src/test/regress/expected/select.out | 7 +-
src/test/regress/expected/subselect.out | 17 ++-
src/test/regress/expected/tsrf.out | 6 +-
src/test/regress/sql/explain.sql | 1 +
src/tools/pgindent/typedefs.list | 1 +
27 files changed, 567 insertions(+), 267 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Keep track of what RTIs a Result node is scanning.
In-Reply-To: <E1v12xh-0026S5-0Y@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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