]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Keep track of what RTIs a Result node is scanning.
authorRobert Haas <rhaas@postgresql.org>
Tue, 23 Sep 2025 13:07:55 +0000 (09:07 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 23 Sep 2025 13:07:55 +0000 (09:07 -0400)
commitf2bae51dfd5b2edc460c86071c577a45a1acbfd7
tree5ec981ac88314052d5fdf1485b0ba33f18971013
parenta48d1ef58652229521ba4b5070e19f857608b22e
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>
27 files changed:
contrib/file_fdw/expected/file_fdw.out
contrib/pg_overexplain/expected/pg_overexplain.out
contrib/pg_overexplain/pg_overexplain.c
contrib/postgres_fdw/expected/postgres_fdw.out
src/backend/commands/explain.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/setrefs.c
src/include/nodes/plannodes.h
src/test/regress/expected/aggregates.out
src/test/regress/expected/case.out
src/test/regress/expected/explain.out
src/test/regress/expected/generated_virtual.out
src/test/regress/expected/groupingsets.out
src/test/regress/expected/inherit.out
src/test/regress/expected/join.out
src/test/regress/expected/merge.out
src/test/regress/expected/partition_aggregate.out
src/test/regress/expected/partition_join.out
src/test/regress/expected/partition_prune.out
src/test/regress/expected/predicate.out
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/rowtypes.out
src/test/regress/expected/select.out
src/test/regress/expected/subselect.out
src/test/regress/expected/tsrf.out
src/test/regress/sql/explain.sql
src/tools/pgindent/typedefs.list