1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

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
This commit is contained in:
Dean Rasheed
2023-09-30 10:54:29 +01:00
parent 5948664214
commit 6d2de076cb
10 changed files with 237 additions and 38 deletions

View File

@@ -2242,11 +2242,12 @@ preprocess_rowmarks(PlannerInfo *root)
else
{
/*
* We only need rowmarks for UPDATE, DELETE, or FOR [KEY]
* We only need rowmarks for UPDATE, DELETE, MERGE, or FOR [KEY]
* UPDATE/SHARE.
*/
if (parse->commandType != CMD_UPDATE &&
parse->commandType != CMD_DELETE)
parse->commandType != CMD_DELETE &&
parse->commandType != CMD_MERGE)
return;
}