From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix MERGE into inheritance parent with extra child columns.
Date: Thu, 12 Nov 2026 21:22:16 +0000
Message-ID: <E1xRcFM-00000000Tzg-0woH@gemulon.postgresql.org> (raw)
Fix MERGE into inheritance parent with extra child columns.
When a MERGE with INSERT actions targets the parent of an inheritance
tree, and the parent itself is excluded by constraint exclusion, and
the first child table has extra columns, the command would fail during
initialization, while attempting to convert the child row type to the
parent.
Fix in ExecInitMerge() by calling build_attrmap_by_name() with
missing_ok = true to build the child-to-parent attribute map --- that
code (added by commit b006bcd5310) deals exclusively with plain
inheritance, not partitioning, so the child table may have extra
columns, which can be safely ignored, since they cannot be referenced
in the main query.
Backpatch to v15, where MERGE was introduced.
Reported-by: Tender Wang <tndrwang@gmail.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Keyerror Smart <smartkeyerror@gmail.com>
Discussion: https://postgr.es/m/CAHewXNm-SQqJ6UeT2sTb4q-CUVyA3NN7tKgcSmPRjYFoZQvdGA%40mail.gmail.com
Backpatch-through: 15
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/7fffb114377507fca5e8c2b4db1820a4ec11615b
Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 12 +++++++++---
src/test/regress/expected/merge.out | 34 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/merge.sql | 32 ++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 3 deletions(-)
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 inheritance parent with extra child columns.
In-Reply-To: <E1xRcFM-00000000Tzg-0woH@gemulon.postgresql.org>
References: <E1xRcFM-00000000Tzg-0woH@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