Change tqual.c tests to use !TransactionIdIsCurrentTransactionId, rather than

TransactionIdDidAbort, when handling the case that xmin is one of the current
transaction's XIDs and the tuple has been deleted.  xmax must also be one of
the current transaction's XIDs, since no one else can see it yet, and it's
cheaper to look at local state than shared state to find out if xmax aborted.
Per an idea of Heikki's.
This commit is contained in:
Tom Lane 2007-09-21 18:24:28 +00:00
parent da072ab2ab
commit 386a5d4268

View File

@ -31,7 +31,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.105 2007/09/08 20:31:15 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.106 2007/09/21 18:24:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -219,16 +219,14 @@ HeapTupleSatisfiesSelf(HeapTupleHeader tuple, Snapshot snapshot, Buffer buffer)
Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI)); Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI));
/* deleting subtransaction aborted? */ if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
{ {
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
InvalidTransactionId); InvalidTransactionId);
return true; return true;
} }
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
return false; return false;
} }
else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple))) else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple)))
@ -395,16 +393,14 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple, Snapshot snapshot, Buffer buffer)
Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI)); Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI));
/* deleting subtransaction aborted? */ if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
{ {
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
InvalidTransactionId); InvalidTransactionId);
return true; return true;
} }
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
if (HeapTupleHeaderGetCmax(tuple) >= GetCurrentCommandId()) if (HeapTupleHeaderGetCmax(tuple) >= GetCurrentCommandId())
return true; /* deleted after scan started */ return true; /* deleted after scan started */
else else
@ -640,16 +636,14 @@ HeapTupleSatisfiesUpdate(HeapTupleHeader tuple, CommandId curcid,
Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI)); Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI));
/* deleting subtransaction aborted? */ if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
{ {
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
InvalidTransactionId); InvalidTransactionId);
return HeapTupleMayBeUpdated; return HeapTupleMayBeUpdated;
} }
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
if (HeapTupleHeaderGetCmax(tuple) >= curcid) if (HeapTupleHeaderGetCmax(tuple) >= curcid)
return HeapTupleSelfUpdated; /* updated after scan started */ return HeapTupleSelfUpdated; /* updated after scan started */
else else
@ -806,16 +800,14 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple, Snapshot snapshot,
Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI)); Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI));
/* deleting subtransaction aborted? */ if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
{ {
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
InvalidTransactionId); InvalidTransactionId);
return true; return true;
} }
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
return false; return false;
} }
else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple))) else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple)))
@ -970,17 +962,14 @@ HeapTupleSatisfiesMVCC(HeapTupleHeader tuple, Snapshot snapshot,
Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI)); Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI));
/* deleting subtransaction aborted? */ if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
/* FIXME -- is this correct w.r.t. the cmax of the tuple? */
if (TransactionIdDidAbort(HeapTupleHeaderGetXmax(tuple)))
{ {
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
InvalidTransactionId); InvalidTransactionId);
return true; return true;
} }
Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)));
if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid) if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
return true; /* deleted after scan started */ return true; /* deleted after scan started */
else else