Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd923b5

Browse filesBrowse files
committed
Don't rely on uninitialized value in MERGE / DELETE
On MERGE / WHEN MATCHED DELETE it's not possible to get cross-partition updates, so we don't initialize cpUpdateRetrySlot; however, the code was not careful to ignore the value in that case. Make it do so. Backpatch to 15. Reported-by: Alexander Lakhin <exclusion@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/17792-0f89452029662c36@postgresql.org
1 parent 5352ca2 commit fd923b5
Copy full SHA for fd923b5

File tree

1 file changed

+7
-8
lines changed
Filter options

1 file changed

+7
-8
lines changed

‎src/backend/executor/nodeModifyTable.c

Copy file name to clipboardExpand all lines: src/backend/executor/nodeModifyTable.c
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,21 +2967,20 @@ ExecMergeMatched(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
29672967
*/
29682968

29692969
/*
2970-
* If cpUpdateRetrySlot is set, ExecCrossPartitionUpdate()
2971-
* must have detected that the tuple was concurrently
2972-
* updated, so we restart the search for an appropriate
2973-
* WHEN MATCHED clause to process the updated tuple.
2970+
* During an UPDATE, if cpUpdateRetrySlot is set, then
2971+
* ExecCrossPartitionUpdate() must have detected that the
2972+
* tuple was concurrently updated, so we restart the
2973+
* search for an appropriate WHEN MATCHED clause to
2974+
* process the updated tuple.
29742975
*
29752976
* In this case, ExecDelete() would already have performed
29762977
* EvalPlanQual() on the latest version of the tuple,
29772978
* which in turn would already have been loaded into
29782979
* ri_oldTupleSlot, so no need to do either of those
29792980
* things.
2980-
*
2981-
* XXX why do we not check the WHEN NOT MATCHED list in
2982-
* this case?
29832981
*/
2984-
if (!TupIsNull(context->cpUpdateRetrySlot))
2982+
if (commandType == CMD_UPDATE &&
2983+
!TupIsNull(context->cpUpdateRetrySlot))
29852984
goto lmerge_matched;
29862985

29872986
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.