| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix MERGE into inheritance parent with extra child columns. |
| Date: | 2026-11-12 21:22:16 |
| Message-ID: | E1xRcFM-00000000Tzi-15gl@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Author: Tender Wang <tndrwang(at)gmail(dot)com>
Reviewed-by: Keyerror Smart <smartkeyerror(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHewXNm-SQqJ6UeT2sTb4q-CUVyA3NN7tKgcSmPRjYFoZQvdGA%40mail.gmail.com
Backpatch-through: 15
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/a2adfc411be39b917f46c4a546d8d701108890d7
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-11-12 22:55:42 | pgsql: Fix some edge cases with characteristics after COMMIT/ROLLBACK A |
| Previous Message | Melanie Plageman | 2026-11-12 21:14:07 | pgsql: Scale VACUUM reltuples estimates after relation growth |