pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix EXPLAIN output for subplans in MERGE.
Date: Sun, 17 Mar 2024 10:23:17 +0000
Message-ID: <E1rlnfg-004GWb-SO@gemulon.postgresql.org> (raw)

Fix EXPLAIN output for subplans in MERGE.

Given a subplan in a MERGE query, EXPLAIN would sometimes fail to
properly display expressions involving Params referencing variables in
other parts of the plan tree.

This would affect subplans outside the topmost join plan node, for
which expansion of Params would go via the top-level ModifyTable plan
node.  The problem was that "inner_tlist" for the ModifyTable node's
deparse_namespace was set to the join node's targetlist, but
"inner_plan" was set to the ModifyTable node itself, rather than the
join node, leading to incorrect results when descending to the
referenced variable.

Fix and backpatch to v15, where MERGE was introduced.

Discussion: https://postgr.es/m/CAEZATCWAv-sZuH%2BwG5xJ-%2BGt7qGNGX8wUQd3XYydMFDKgRB9nw%40mail.gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/89ee14a2f22b2353a6cf9d193c54504b4d3131f5

Modified Files
--------------
src/backend/utils/adt/ruleutils.c   | 21 +++++++++-------
src/test/regress/expected/merge.out | 50 +++++++++++++++++++++++++++++++++++++
src/test/regress/sql/merge.sql      | 17 +++++++++++++
3 files changed, 79 insertions(+), 9 deletions(-)



view thread (4+ messages)

Message-ID: <E1rlnfg-004GWb-SO@gemulon.postgresql.org>
Permalink:  ../E1rlnfg-004GWb-SO@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rlnfg-004GWb-SO@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix EXPLAIN output for subplans in MERGE.
  In-Reply-To: <E1rlnfg-004GWb-SO@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