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-00000000JMu-0ku7@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_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/220b5263dbb71bbe2966c6d47c0c456c14ed4e48
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(-)
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-00000000JMu-0ku7@gemulon.postgresql.org>
References: <E1xR7Pz-00000000JMu-0ku7@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