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

Commitf03d228

Browse files
committed
HeapTupleSatisfiesVacuum() needs to be more careful about the
difference between INSERT_IN_PROGRESS and DELETE_IN_PROGRESS fortuples inserted and then deleted by a concurrent transaction.Example of bug:regression=# create table foo (f1 int);CREATE TABLEregression=# begin;BEGINregression=# insert into foo values(1);INSERT 195531 1regression=# delete from foo;DELETE 1regression=# insert into foo values(1);INSERT 195532 1regression=# create unique index fooi on foo(f1);ERROR: could not create unique indexDETAIL: Table contains duplicated values.
1 parent278a13f commitf03d228

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎src/backend/utils/time/tqual.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Portions Copyright (c) 1994, Regents of the University of California
1717
*
1818
* IDENTIFICATION
19-
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.67 2003/08/04 02:40:09 momjian Exp $
19+
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.68 2003/09/22 00:47:23 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -868,7 +868,16 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin)
868868
}
869869
}
870870
elseif (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple)))
871-
returnHEAPTUPLE_INSERT_IN_PROGRESS;
871+
{
872+
if (tuple->t_infomask&HEAP_XMAX_INVALID)/* xid invalid */
873+
returnHEAPTUPLE_INSERT_IN_PROGRESS;
874+
Assert(HeapTupleHeaderGetXmin(tuple)==
875+
HeapTupleHeaderGetXmax(tuple));
876+
if (tuple->t_infomask&HEAP_MARKED_FOR_UPDATE)
877+
returnHEAPTUPLE_INSERT_IN_PROGRESS;
878+
/* inserted and then deleted by same xact */
879+
returnHEAPTUPLE_DELETE_IN_PROGRESS;
880+
}
872881
elseif (TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
873882
tuple->t_infomask |=HEAP_XMIN_COMMITTED;
874883
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp