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 MERGE into partitioned table with subquery in UPDATE targetl
Date: Wed, 11 Nov 2026 12:27:11 +0000
Message-ID: <E1xR7Pz-00000000JMq-0ZK1@gemulon.postgresql.org> (raw)

Fix MERGE into partitioned table with subquery in UPDATE targetlist.

Under some circumstances, a MERGE into a partitioned table with an
UPDATE action with a subquery in its targetlist would fail with a
"SubPlan found with no parent plan" error.

This was due to ExecInitPartitionInfo() passing a NULL parent
PlanState to ExecBuildUpdateProjection() for the MERGE UPDATE action's
targetlist. Fix by passing &mtstate->ps, like ExecInitMerge().

Backpatch to v15, where MERGE was introduced.

Bug: #19802
Reported-by: Gowtham Reddy <gowthamdoma18@gmail.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Discussion: https://postgr.es/m/19802-ef50a8f1a4b5deee%40postgresql.org
Backpatch-through: 15

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/84b86f7a510bceecc2de86b5f4de775d5e0a4fbc

Modified Files
--------------
src/backend/executor/execPartition.c |  2 +-
src/test/regress/expected/merge.out  | 15 +++++++++++++++
src/test/regress/sql/merge.sql       | 11 +++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xR7Pz-00000000JMq-0ZK1@gemulon.postgresql.org>
Permalink:  ../E1xR7Pz-00000000JMq-0ZK1@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xR7Pz-00000000JMq-0ZK1@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: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Fix MERGE into partitioned table with subquery in UPDATE targetl
  In-Reply-To: <E1xR7Pz-00000000JMq-0ZK1@gemulon.postgresql.org>
  References: <E1xR7Pz-00000000JMq-0ZK1@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