pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.
Date: Tue, 20 Oct 2026 21:32:46 +0000
Message-ID: <E1xJHRu-000000003qD-2h0I@gemulon.postgresql.org> (raw)

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@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAAAe_zAUb_XydapJqUk7O8o2crJa7xbxX=KvSi3nY9h98OcN7g@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/763f95c63c2daa7a0b57860d4fe1649e041845a7

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(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1xJHRu-000000003qD-2h0I@gemulon.postgresql.org>
Permalink:  ../E1xJHRu-000000003qD-2h0I@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xJHRu-000000003qD-2h0I@gemulon.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix OLD/NEW aliases that EXPLAIN prints in RETURNING SubPlans.
  In-Reply-To: <E1xJHRu-000000003qD-2h0I@gemulon.postgresql.org>
  References: <E1xJHRu-000000003qD-2h0I@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