pgsql: Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.
Date: 2026-10-20 21:32:46
Message-ID: E1xJHRu-000000003qG-2uOO@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.

set_deparse_context_plan() set the aliases for OLD and NEW in
RETURNING when EXPLAIN printed a ModifyTable, but that's the
wrong place: they should be set in set_deparse_plan() like other
plan-node-specific fields. So they were not changed when
push_ancestor_plan() moved to the ancestor ModifyTable to print a
Param of a SubPlan in its RETURNING list, and the aliases of some
previously-printed ModifyTable could be used instead. It seems
possible that we'd also fail to print an alias at all, since
get_variable() is unfazed by obtaining a NULL refname. That
shouldn't happen for RETURNING variables, so complain.

Author: Henson Choi <assam258(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAAAe_zAUb_XydapJqUk7O8o2crJa7xbxX=KvSi3nY9h98OcN7g@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4ee8af2e86388dedb02f27a4384c9f46e9c7050a

Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 30 ++++++++++------
src/test/regress/expected/returning.out | 64 +++++++++++++++++++++++++++++++++
src/test/regress/sql/returning.sql | 24 +++++++++++++
3 files changed, 107 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-20 22:49:53 pgsql: Fix cross-version upgrade tests for commits 0497318e4 et al.
Previous Message Tom Lane 2026-10-20 19:13:40 pgsql: contrib/intarray: always parse query_int integers as decimal.