aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeModifyTable.c
diff options
context:
space:
mode:
authorDean Rasheed <dean.a.rasheed@gmail.com>2023-03-13 11:11:10 +0000
committerDean Rasheed <dean.a.rasheed@gmail.com>2023-03-13 11:11:10 +0000
commitda6257eee35db5d281a115838abaf285b46b52f3 (patch)
tree1979b2df1a221327a17dd7dadc9d773663f96543 /src/backend/executor/nodeModifyTable.c
parent7d9a75713ab91071a2110e25e7c86cbf2a6fdc4b (diff)
downloadpostgresql-da6257eee35db5d281a115838abaf285b46b52f3.tar.gz
postgresql-da6257eee35db5d281a115838abaf285b46b52f3.zip
Fix MERGE command tag for actions blocked by BEFORE ROW triggers.
This ensures that the row count in the command tag for a MERGE is correctly computed in the case where UPDATEs or DELETEs are skipped due to a BEFORE ROW trigger returning NULL (the INSERT case was already handled correctly by ExecMergeNotMatched() calling ExecInsert()). Back-patch to v15, where MERGE was introduced. Discussion: https://postgr.es/m/CAEZATCU8XEmR0JWKDtyb7iZ%3DqCffxS9uyJt0iOZ4TV4RT%2Bow1w%40mail.gmail.com
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r--src/backend/executor/nodeModifyTable.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index e1fc8ff501b..2f6e66b6413 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2867,8 +2867,9 @@ lmerge_matched:;
if (!ExecUpdatePrologue(context, resultRelInfo,
tupleid, NULL, newslot, &result))
{
- /* Blocked by trigger, or concurrent update/delete */
- break;
+ if (result == TM_Ok)
+ return true; /* "do nothing" */
+ break; /* concurrent update/delete */
}
result = ExecUpdateAct(context, resultRelInfo, tupleid, NULL,
newslot, false, &updateCxt);
@@ -2885,8 +2886,9 @@ lmerge_matched:;
if (!ExecDeletePrologue(context, resultRelInfo, tupleid,
NULL, NULL, &result))
{
- /* Blocked by trigger, or concurrent update/delete */
- break;
+ if (result == TM_Ok)
+ return true; /* "do nothing" */
+ break; /* concurrent update/delete */
}
result = ExecDeleteAct(context, resultRelInfo, tupleid, false);
if (result == TM_Ok)