mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +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:
@@ -721,8 +721,8 @@ typedef struct EState
|
||||
* ExecRowMark -
|
||||
* runtime representation of FOR [KEY] UPDATE/SHARE clauses
|
||||
*
|
||||
* When doing UPDATE, DELETE, or SELECT FOR [KEY] UPDATE/SHARE, we will have an
|
||||
* ExecRowMark for each non-target relation in the query (except inheritance
|
||||
* When doing UPDATE/DELETE/MERGE/SELECT FOR [KEY] UPDATE/SHARE, we will have
|
||||
* an ExecRowMark for each non-target relation in the query (except inheritance
|
||||
* parent RTEs, which can be ignored at runtime). Virtual relations such as
|
||||
* subqueries-in-FROM will have an ExecRowMark with relation == NULL. See
|
||||
* PlanRowMark for details about most of the fields. In addition to fields
|
||||
|
@@ -1309,7 +1309,7 @@ typedef struct Limit
|
||||
* doing a separate remote query to lock each selected row is usually pretty
|
||||
* unappealing, so early locking remains a credible design choice for FDWs.
|
||||
*
|
||||
* When doing UPDATE, DELETE, or SELECT FOR UPDATE/SHARE, we have to uniquely
|
||||
* When doing UPDATE/DELETE/MERGE/SELECT FOR UPDATE/SHARE, we have to uniquely
|
||||
* identify all the source rows, not only those from the target relations, so
|
||||
* that we can perform EvalPlanQual rechecking at need. For plain tables we
|
||||
* can just fetch the TID, much as for a target relation; this case is
|
||||
@@ -1338,7 +1338,7 @@ typedef enum RowMarkType
|
||||
* PlanRowMark -
|
||||
* plan-time representation of FOR [KEY] UPDATE/SHARE clauses
|
||||
*
|
||||
* When doing UPDATE, DELETE, or SELECT FOR UPDATE/SHARE, we create a separate
|
||||
* When doing UPDATE/DELETE/MERGE/SELECT FOR UPDATE/SHARE, we create a separate
|
||||
* PlanRowMark node for each non-target relation in the query. Relations that
|
||||
* are not specified as FOR UPDATE/SHARE are marked ROW_MARK_REFERENCE (if
|
||||
* regular tables or supported foreign tables) or ROW_MARK_COPY (if not).
|
||||
|
Reference in New Issue
Block a user