From f2bae51dfd5b2edc460c86071c577a45a1acbfd7 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 23 Sep 2025 09:07:55 -0400 Subject: 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 Reviewed-by: Richard Guo Reviewed-by: Tom Lane Reviewed-by: Junwang Zhao --- contrib/postgres_fdw/expected/postgres_fdw.out | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'contrib/postgres_fdw') diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index cb74c87d1aa..6dc04e916dc 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -7159,8 +7159,9 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 < 0; Aggregate Output: count(*) -> Result + Replaces: Scan on ft1 One-Time Filter: false -(4 rows) +(5 rows) SELECT count(*) FROM ft1 WHERE c2 < 0; count @@ -7203,8 +7204,9 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 >= 0; Aggregate Output: count(*) -> Result + Replaces: Scan on ft1 One-Time Filter: false -(4 rows) +(5 rows) SELECT count(*) FROM ft1 WHERE c2 >= 0; count @@ -8032,8 +8034,9 @@ DELETE FROM rem1 WHERE false; -- currently can't be pushed down Remote SQL: DELETE FROM public.loc1 WHERE ctid = $1 -> Result Output: ctid + Replaces: Scan on rem1 One-Time Filter: false -(5 rows) +(6 rows) -- Test with statement-level triggers CREATE TRIGGER trig_stmt_before -- cgit v1.2.3