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