aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeModifyTable.c
diff options
context:
space:
mode:
authorDean Rasheed <dean.a.rasheed@gmail.com>2023-09-30 10:54:29 +0100
committerDean Rasheed <dean.a.rasheed@gmail.com>2023-09-30 10:54:29 +0100
commit6d2de076cbf078cd1d6d0df2136fe5b1da96d1fe (patch)
tree3ec705eb01c9ab38b2af5415c2aa2a11a7fd86bb /src/backend/executor/nodeModifyTable.c
parent594866421433c5ca54e7110b149f8a13458abd59 (diff)
downloadpostgresql-6d2de076cbf078cd1d6d0df2136fe5b1da96d1fe.tar.gz
postgresql-6d2de076cbf078cd1d6d0df2136fe5b1da96d1fe.zip
Fix EvalPlanQual rechecking during MERGE.
Under some circumstances, concurrent MERGE operations could lead to inconsistent results, that varied according the plan chosen. This was caused by a lack of rowmarks on the source relation, which meant that EvalPlanQual rechecking was not guaranteed to return the same source tuples when re-running the join query. Fix by ensuring that preprocess_rowmarks() sets up PlanRowMarks for all non-target relations used in MERGE, in the same way that it does for UPDATE and DELETE. Per bug #18103. Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Richard Guo. Discussion: https://postgr.es/m/18103-c4386baab8e355e3%40postgresql.org
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r--src/backend/executor/nodeModifyTable.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 5005d8c0d12..c87bb03219c 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -4284,9 +4284,9 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
/*
* If we have any secondary relations in an UPDATE or DELETE, they need to
- * be treated like non-locked relations in SELECT FOR UPDATE, ie, the
- * EvalPlanQual mechanism needs to be told about them. Locate the
- * relevant ExecRowMarks.
+ * be treated like non-locked relations in SELECT FOR UPDATE, i.e., the
+ * EvalPlanQual mechanism needs to be told about them. This also goes for
+ * the source relations in a MERGE. Locate the relevant ExecRowMarks.
*/
arowmarks = NIL;
foreach(l, node->rowMarks)