pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix MERGE into inheritance parent with extra child columns.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix MERGE into inheritance parent with extra child columns.
@ 2026-11-12 21:22  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2026-11-12 21:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix MERGE into inheritance parent with extra child columns.
@ 2026-11-12 21:22  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2026-11-12 21:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix MERGE into inheritance parent with extra child columns.
@ 2026-11-12 21:22  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2026-11-12 21:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/45d4395b7d67f64328974e9fcd061fc4b324512a

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix MERGE into inheritance parent with extra child columns.
@ 2026-11-12 21:22  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2026-11-12 21:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d8d46d17ca00f1d92b87f6d54b7f3f7374ca0cdf

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix MERGE into inheritance parent with extra child columns.
@ 2026-11-12 21:22  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2026-11-12 21:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2d9278ae1302ffe3a997b03070d80f3557af88df

Modified Files
--------------
src/backend/executor/nodeModifyTable.c |  9 +++++++--
src/test/regress/expected/merge.out    | 18 ++++++++++++++++++
src/test/regress/sql/merge.sql         | 20 ++++++++++++++++++++
3 files changed, 45 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix MERGE into inheritance parent with extra child columns.
@ 2026-11-12 21:22  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2026-11-12 21:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5ea558ef761f882cae7087e60d4422cce7eeae48

Modified Files
--------------
src/backend/access/common/attmap.c     | 18 +++++++++++++++++-
src/backend/executor/nodeModifyTable.c | 12 +++++++++---
src/include/access/attmap.h            |  3 +++
src/test/regress/expected/merge.out    | 18 ++++++++++++++++++
src/test/regress/sql/merge.sql         | 20 ++++++++++++++++++++
5 files changed, 67 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-11-12 21:22 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 21:22 pgsql: Fix MERGE into inheritance parent with extra child columns. Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 21:22 pgsql: Fix MERGE into inheritance parent with extra child columns. Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 21:22 pgsql: Fix MERGE into inheritance parent with extra child columns. Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 21:22 pgsql: Fix MERGE into inheritance parent with extra child columns. Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 21:22 pgsql: Fix MERGE into inheritance parent with extra child columns. Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 21:22 pgsql: Fix MERGE into inheritance parent with extra child columns. Dean Rasheed <dean.a.rasheed@gmail.com>

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