From 25303678a1d334200c0f1446eef2ebe1aaf2709b Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Sat, 29 Mar 2025 09:50:14 +0000 Subject: 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 Author: Tender Wang Reviewed-by: Gurjeet Singh Discussion: https://postgr.es/m/18871-b44e3c96de3bd2e8%40postgresql.org Backpatch-through: 15 --- src/backend/executor/execPartition.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/backend/executor/execPartition.c') diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 76518862291..a3602b81687 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -872,7 +872,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, * reference and make copy for this relation, converting stuff that * references attribute numbers to match this relation's. * - * This duplicates much of the logic in ExecInitMerge(), so something + * This duplicates much of the logic in ExecInitMerge(), so if something * changes there, look here too. */ if (node && node->operation == CMD_MERGE) @@ -952,6 +952,8 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, NULL); break; case CMD_DELETE: + case CMD_NOTHING: + /* Nothing to do */ break; default: -- cgit v1.2.3