pgsql: Fix MERGE into inheritance parent with extra child columns.
pgsql: Fix MERGE into inheritance parent with extra child columns.
От:
Dean Rasheed <dean.a.rasheed@gmail.com>
Дата:
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 Author: Tender Wang Reviewed-by: Keyerror Smart 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(-)