Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7884d54

Browse files
committed
Fix buffer access bug in OnConflict
1 parente780704 commit7884d54

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎src/backend/executor/nodeModifyTable.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,13 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
10871087
test=heap_lock_tuple(relation,&tuple,estate->es_output_cid,
10881088
lockmode,LockWaitBlock, false,&buffer,
10891089
&hufd);
1090+
/*
1091+
* We must hold share lock on the buffer content while examining tuple
1092+
* visibility. Afterwards, however, the tuples we have found to be
1093+
* visible are guaranteed good as long as we hold the buffer pin.
1094+
*/
1095+
LockBuffer(buffer,BUFFER_LOCK_SHARE);
1096+
10901097
switch (test)
10911098
{
10921099
caseHeapTupleMayBeUpdated:
@@ -1142,6 +1149,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
11421149
* loop here, as the new version of the row might not conflict
11431150
* anymore, or the conflicting tuple has actually been deleted.
11441151
*/
1152+
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
11451153
ReleaseBuffer(buffer);
11461154
return false;
11471155

@@ -1175,6 +1183,8 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
11751183
/* Store target's existing tuple in the state's dedicated slot */
11761184
ExecStoreTuple(&tuple,mtstate->mt_existing,buffer, false);
11771185

1186+
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
1187+
11781188
/*
11791189
* Make tuple and any needed join variables available to ExecQual and
11801190
* ExecProject. The EXCLUDED tuple is installed in ecxt_innertuple, while

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp