Thread: pgsql: Fix MERGE with DO NOTHING actions into a partitioned table.

pgsql: Fix MERGE with DO NOTHING actions into a partitioned table.

From
Dean Rasheed
Date:
Fix MERGE with DO NOTHING actions into a partitioned table.

ExecInitPartitionInfo() duplicates much of the logic in
ExecInitMerge(), except that it failed to handle DO NOTHING
actions. This would cause an "unknown action in MERGE WHEN clause"
error if a MERGE with any DO NOTHING actions attempted to insert into
a partition not already initialised by ExecInitModifyTable().

Bug: #18871
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Gurjeet Singh <gurjeet@singh.im>
Discussion: https://postgr.es/m/18871-b44e3c96de3bd2e8%40postgresql.org
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/25303678a1d334200c0f1446eef2ebe1aaf2709b

Modified Files
--------------
src/backend/executor/execPartition.c   |  4 +++-
src/backend/executor/nodeModifyTable.c |  2 +-
src/test/regress/expected/merge.out    | 17 +++++++++++++++++
src/test/regress/sql/merge.sql         | 13 +++++++++++++
4 files changed, 34 insertions(+), 2 deletions(-)