Ensure that all TransactionId comparisons are encapsulated in macros

(TransactionIdPrecedes, TransactionIdFollows, etc).  First step on the
way to transaction ID wrap solution ...
This commit is contained in:
Tom Lane 2001-08-23 23:06:38 +00:00
parent 29ec29ffac
commit 7326e78c42
17 changed files with 139 additions and 100 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.72 2001/06/12 05:55:49 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.73 2001/08/23 23:06:37 tgl Exp $
*
* NOTES
* The old interface functions have been converted to macros
@ -441,20 +441,16 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
result = ObjectIdGetDatum(tup->t_data->t_oid);
break;
case MinTransactionIdAttributeNumber:
/* XXX should have a TransactionIdGetDatum macro */
result = (Datum) (tup->t_data->t_xmin);
result = TransactionIdGetDatum(tup->t_data->t_xmin);
break;
case MinCommandIdAttributeNumber:
/* XXX should have a CommandIdGetDatum macro */
result = (Datum) (tup->t_data->t_cmin);
result = CommandIdGetDatum(tup->t_data->t_cmin);
break;
case MaxTransactionIdAttributeNumber:
/* XXX should have a TransactionIdGetDatum macro */
result = (Datum) (tup->t_data->t_xmax);
result = TransactionIdGetDatum(tup->t_data->t_xmax);
break;
case MaxCommandIdAttributeNumber:
/* XXX should have a CommandIdGetDatum macro */
result = (Datum) (tup->t_data->t_cmax);
result = CommandIdGetDatum(tup->t_data->t_cmax);
break;
case TableOidAttributeNumber:
result = ObjectIdGetDatum(tup->t_tableOid);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.124 2001/08/10 18:57:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.125 2001/08/23 23:06:37 tgl Exp $
*
*
* INTERFACE ROUTINES
@ -1206,7 +1206,7 @@ l1:
* update then some other xaction could update this tuple before
* we got to this point.
*/
if (tp.t_data->t_xmax != xwait)
if (!TransactionIdEquals(tp.t_data->t_xmax, xwait))
goto l1;
if (!(tp.t_data->t_infomask & HEAP_XMAX_COMMITTED))
{
@ -1398,7 +1398,7 @@ l2:
* update then some other xaction could update this tuple before
* we got to this point.
*/
if (oldtup.t_data->t_xmax != xwait)
if (!TransactionIdEquals(oldtup.t_data->t_xmax, xwait))
goto l2;
if (!(oldtup.t_data->t_infomask & HEAP_XMAX_COMMITTED))
{
@ -1694,7 +1694,7 @@ l3:
* update then some other xaction could update this tuple before
* we got to this point.
*/
if (tuple->t_data->t_xmax != xwait)
if (!TransactionIdEquals(tuple->t_data->t_xmax, xwait))
goto l3;
if (!(tuple->t_data->t_infomask & HEAP_XMAX_COMMITTED))
{
@ -2123,7 +2123,8 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
htup->t_hoff = xlhdr.t_hoff;
htup->t_xmin = record->xl_xid;
htup->t_cmin = FirstCommandId;
htup->t_xmax = htup->t_cmax = 0;
htup->t_xmax = InvalidTransactionId;
htup->t_cmax = FirstCommandId;
htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask;
offnum = PageAddItem(page, (Item) htup, newlen, offnum,
@ -2310,7 +2311,8 @@ newsame:;
{
htup->t_xmin = record->xl_xid;
htup->t_cmin = FirstCommandId;
htup->t_xmax = htup->t_cmax = 0;
htup->t_xmax = InvalidTransactionId;
htup->t_cmax = FirstCommandId;
htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask;
}
@ -2366,7 +2368,7 @@ _heap_unlock_tuple(void *data)
htup = (HeapTupleHeader) PageGetItem(page, lp);
if (htup->t_xmax != GetCurrentTransactionId() ||
if (!TransactionIdEquals(htup->t_xmax, GetCurrentTransactionId()) ||
htup->t_cmax != GetCurrentCommandId())
elog(STOP, "_heap_unlock_tuple: invalid xmax/cmax in rollback");
htup->t_infomask &= ~HEAP_XMAX_UNLOGGED;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.84 2001/07/15 22:48:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.85 2001/08/23 23:06:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -149,8 +149,8 @@ top:
/*
* _bt_check_unique() -- Check for violation of unique index constraint
*
* Returns NullTransactionId if there is no conflict, else an xact ID we
* must wait for to see if it commits a conflicting tuple. If an actual
* Returns InvalidTransactionId if there is no conflict, else an xact ID
* we must wait for to see if it commits a conflicting tuple. If an actual
* conflict is detected, no return --- just elog().
*/
static TransactionId
@ -275,7 +275,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
if (nbuf != InvalidBuffer)
_bt_relbuf(rel, nbuf);
return NullTransactionId;
return InvalidTransactionId;
}
/*----------

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.45 2001/07/12 04:11:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.46 2001/08/23 23:06:37 tgl Exp $
*
* NOTES
* This file contains the high level access-method interface to the
@ -44,7 +44,7 @@ Relation LogRelation = (Relation) NULL;
* Single-item cache for results of TransactionLogTest.
* ----------------
*/
static TransactionId cachedTestXid = NullTransactionId;
static TransactionId cachedTestXid = InvalidTransactionId;
static XidStatus cachedTestXidStatus;
/* ----------------
@ -333,18 +333,19 @@ InitializeTransactionLog(void)
/*
* if we have a virgin database, we initialize the log relation by
* committing the AmiTransactionId and we initialize the
* committing the BootstrapTransactionId and we initialize the
* variable relation by setting the next available transaction id to
* FirstTransactionId. OID initialization happens as a side
* FirstNormalTransactionId. OID initialization happens as a side
* effect of bootstrapping in varsup.c.
*/
SpinAcquire(OidGenLockId);
if (!TransactionIdDidCommit(AmiTransactionId))
if (!TransactionIdDidCommit(BootstrapTransactionId))
{
TransactionLogUpdate(AmiTransactionId, XID_COMMIT);
TransactionLogUpdate(BootstrapTransactionId, XID_COMMIT);
Assert(!IsUnderPostmaster &&
ShmemVariableCache->nextXid <= FirstTransactionId);
ShmemVariableCache->nextXid = FirstTransactionId;
TransactionIdEquals(ShmemVariableCache->nextXid,
FirstNormalTransactionId));
ShmemVariableCache->nextXid = FirstNormalTransactionId;
}
else if (RecoveryCheckingEnabled())
{

View File

@ -6,7 +6,7 @@
* Copyright (c) 2000, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.43 2001/08/10 18:57:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.44 2001/08/23 23:06:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -41,7 +41,7 @@ GetNewTransactionId(TransactionId *xid)
*/
if (AMI_OVERRIDE)
{
*xid = AmiTransactionId;
*xid = BootstrapTransactionId;
return;
}
@ -49,7 +49,7 @@ GetNewTransactionId(TransactionId *xid)
*xid = ShmemVariableCache->nextXid;
(ShmemVariableCache->nextXid)++;
TransactionIdAdvance(ShmemVariableCache->nextXid);
/*
* Must set MyProc->xid before releasing XidGenLock. This ensures that
@ -89,7 +89,7 @@ ReadNewTransactionId(TransactionId *xid)
*/
if (AMI_OVERRIDE)
{
*xid = AmiTransactionId;
*xid = BootstrapTransactionId;
return;
}

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: xid.c,v 1.31 2001/07/12 04:11:13 tgl Exp $
* $Id: xid.c,v 1.32 2001/08/23 23:06:37 tgl Exp $
*
* OLD COMMENTS
* XXX WARNING
@ -23,11 +23,8 @@
#include "access/xact.h"
/*
* TransactionId is typedef'd as uint32, so...
*/
#define PG_GETARG_TRANSACTIONID(n) PG_GETARG_UINT32(n)
#define PG_RETURN_TRANSACTIONID(x) PG_RETURN_UINT32(x)
#define PG_GETARG_TRANSACTIONID(n) DatumGetTransactionId(PG_GETARG_DATUM(n))
#define PG_RETURN_TRANSACTIONID(x) return TransactionIdGetDatum(x)
Datum
@ -42,7 +39,6 @@ Datum
xidout(PG_FUNCTION_ARGS)
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
/* maximum 32 bit unsigned integer representation takes 10 chars */
char *representation = palloc(11);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.73 2001/08/10 18:57:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.74 2001/08/23 23:06:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -2349,7 +2349,7 @@ BootStrapXLOG(void)
checkPoint.redo.xrecoff = SizeOfXLogPHD;
checkPoint.undo = checkPoint.redo;
checkPoint.ThisStartUpID = 0;
checkPoint.nextXid = FirstTransactionId;
checkPoint.nextXid = FirstNormalTransactionId;
checkPoint.nextOid = BootstrapObjectIdData;
checkPoint.time = time(NULL);
@ -2508,7 +2508,7 @@ StartupXLOG(void)
wasShutdown ? "TRUE" : "FALSE");
elog(LOG, "next transaction id: %u; next oid: %u",
checkPoint.nextXid, checkPoint.nextOid);
if (checkPoint.nextXid < FirstTransactionId)
if (!TransactionIdIsNormal(checkPoint.nextXid))
elog(STOP, "invalid next transaction id");
ShmemVariableCache->nextXid = checkPoint.nextXid;
@ -2550,8 +2550,10 @@ StartupXLOG(void)
if (XLByteLT(checkPoint.redo, RecPtr))
record = ReadRecord(&(checkPoint.redo), STOP, buffer);
else
/* read past CheckPoint record */
{
/* read past CheckPoint record */
record = ReadRecord(NULL, LOG, buffer);
}
if (record != NULL)
{
@ -2560,8 +2562,13 @@ StartupXLOG(void)
ReadRecPtr.xlogid, ReadRecPtr.xrecoff);
do
{
if (record->xl_xid >= ShmemVariableCache->nextXid)
ShmemVariableCache->nextXid = record->xl_xid + 1;
/* nextXid must be beyond record's xid */
if (TransactionIdFollowsOrEquals(record->xl_xid,
ShmemVariableCache->nextXid))
{
ShmemVariableCache->nextXid = record->xl_xid;
TransactionIdAdvance(ShmemVariableCache->nextXid);
}
if (XLOG_DEBUG)
{
char buf[8192];
@ -3101,7 +3108,8 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
/* In an ONLINE checkpoint, treat the counters like NEXTOID */
if (ShmemVariableCache->nextXid < checkPoint.nextXid)
if (TransactionIdPrecedes(ShmemVariableCache->nextXid,
checkPoint.nextXid))
ShmemVariableCache->nextXid = checkPoint.nextXid;
if (ShmemVariableCache->nextOid < checkPoint.nextOid)
{

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.16 2001/06/29 21:08:24 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.17 2001/08/23 23:06:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -76,7 +76,7 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
htup = (HeapTupleHeader) PageGetItem(page, lp);
Assert(PageGetSUI(page) == ThisStartUpID);
if (htup->t_xmin != xid || htup->t_cmin != cid)
if (!TransactionIdEquals(htup->t_xmin, xid) || htup->t_cmin != cid)
{
UnlockAndReleaseBuffer(buffer);
return (-1);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.95 2001/08/10 18:57:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.96 2001/08/23 23:06:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -2078,7 +2078,8 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event,
* foreign referenced key value that's changing now has been
* updated once before in this transaction.
*/
if (oldtup->t_data->t_xmin != GetCurrentTransactionId())
if (!TransactionIdEquals(oldtup->t_data->t_xmin,
GetCurrentTransactionId()))
prev_event = NULL;
else
prev_event =
@ -2212,7 +2213,8 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event,
* possibly referenced key value has changed in this
* transaction.
*/
if (oldtup->t_data->t_xmin != GetCurrentTransactionId())
if (!TransactionIdEquals(oldtup->t_data->t_xmin,
GetCurrentTransactionId()))
break;
/*

View File

@ -16,7 +16,7 @@
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.6 2001/08/05 02:06:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.7 2001/08/23 23:06:37 tgl Exp $
* ----------
*/
#include "postgres.h"
@ -500,10 +500,10 @@ pgstat_vacuum_tabstat(void)
* If not done for this transaction, read the statistics collector
* stats file into some hash tables.
*/
if (pgStatDBHashXact != GetCurrentTransactionId())
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
@ -916,10 +916,10 @@ pgstat_fetch_stat_dbentry(Oid dbid)
* stats file into some hash tables. Be careful with the read_statsfile()
* call below!
*/
if (pgStatDBHashXact != GetCurrentTransactionId())
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
@ -956,10 +956,10 @@ pgstat_fetch_stat_tabentry(Oid relid)
* stats file into some hash tables. Be careful with the read_statsfile()
* call below!
*/
if (pgStatDBHashXact != GetCurrentTransactionId())
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
@ -997,10 +997,10 @@ pgstat_fetch_stat_tabentry(Oid relid)
PgStat_StatBeEntry *
pgstat_fetch_stat_beentry(int beid)
{
if (pgStatDBHashXact != GetCurrentTransactionId())
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}
@ -1021,10 +1021,10 @@ pgstat_fetch_stat_beentry(int beid)
int
pgstat_fetch_stat_numbackends(void)
{
if (pgStatDBHashXact != GetCurrentTransactionId())
if (!TransactionIdEquals(pgStatDBHashXact, GetCurrentTransactionId()))
{
pgstat_read_statsfile(&pgStatDBHash, MyDatabaseId,
&pgStatBeTable, &pgStatNumBackends);
&pgStatBeTable, &pgStatNumBackends);
pgStatDBHashXact = GetCurrentTransactionId();
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.37 2001/07/16 22:43:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.38 2001/08/23 23:06:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -241,12 +241,12 @@ GetXmaxRecent(TransactionId *XmaxRecent)
/* Fetch xid just once - see GetNewTransactionId */
TransactionId xid = proc->xid;
if (! TransactionIdIsSpecial(xid))
if (TransactionIdIsNormal(xid))
{
if (TransactionIdPrecedes(xid, result))
result = xid;
xid = proc->xmin;
if (! TransactionIdIsSpecial(xid))
if (TransactionIdIsNormal(xid))
if (TransactionIdPrecedes(xid, result))
result = xid;
}
@ -347,8 +347,8 @@ GetSnapshotData(bool serializable)
* treat them as running anyway.
*/
if (proc == MyProc ||
TransactionIdIsSpecial(xid) ||
! TransactionIdPrecedes(xid, snapshot->xmax))
! TransactionIdIsNormal(xid) ||
TransactionIdFollowsOrEquals(xid, snapshot->xmax))
continue;
if (TransactionIdPrecedes(xid, snapshot->xmin))
@ -364,7 +364,7 @@ GetSnapshotData(bool serializable)
SpinRelease(SInvalLock);
/* Serializable snapshot must be computed before any other... */
Assert(MyProc->xmin != InvalidTransactionId);
Assert(TransactionIdIsValid(MyProc->xmin));
snapshot->xcnt = count;
return snapshot;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.91 2001/07/09 22:18:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.92 2001/08/23 23:06:38 tgl Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@ -1277,7 +1277,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
goto next_item;
/* If not allxids, ignore items that are of the wrong xid */
if (!allxids && xid != holder->tag.xid)
if (!allxids && !TransactionIdEquals(xid, holder->tag.xid))
goto next_item;
HOLDER_PRINT("LockReleaseAll", holder);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.39 2001/07/16 22:43:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.40 2001/08/23 23:06:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -531,15 +531,15 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
* when...
*/
if (tuple->t_xmin >= snapshot->xmax)
if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmax))
return false;
if (tuple->t_xmin >= snapshot->xmin)
if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmin))
{
uint32 i;
for (i = 0; i < snapshot->xcnt; i++)
{
if (tuple->t_xmin == snapshot->xip[i])
if (TransactionIdEquals(tuple->t_xmin, snapshot->xip[i]))
return false;
}
}
@ -571,15 +571,15 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
tuple->t_infomask |= HEAP_XMAX_COMMITTED;
}
if (tuple->t_xmax >= snapshot->xmax)
if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmax))
return true;
if (tuple->t_xmax >= snapshot->xmin)
if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmin))
{
uint32 i;
for (i = 0; i < snapshot->xcnt; i++)
{
if (tuple->t_xmax == snapshot->xip[i])
if (TransactionIdEquals(tuple->t_xmax, snapshot->xip[i]))
return true;
}
}

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: transam.h,v 1.37 2001/08/10 18:57:39 tgl Exp $
* $Id: transam.h,v 1.38 2001/08/23 23:06:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -24,29 +24,37 @@
* 128 bytes of pg_log available for special purposes such as version number
* storage. (Currently, we do not actually use them for anything.)
*
* AmiTransactionId is the XID for "bootstrap" operations. It should always
* be considered valid.
* BootstrapTransactionId is the XID for "bootstrap" operations. It should
* always be considered valid.
*
* FirstTransactionId is the first "normal" transaction id.
* FirstNormalTransactionId is the first "normal" transaction id.
* ----------------
*/
#define NullTransactionId ((TransactionId) 0)
#define DisabledTransactionId ((TransactionId) 1)
#define AmiTransactionId ((TransactionId) 512)
#define FirstTransactionId ((TransactionId) 514)
#define InvalidTransactionId ((TransactionId) 0)
#define DisabledTransactionId ((TransactionId) 1)
#define BootstrapTransactionId ((TransactionId) 512)
#define FirstNormalTransactionId ((TransactionId) 514)
/* ----------------
* transaction ID manipulation macros
* ----------------
*/
#define TransactionIdIsValid(xid) ((bool) ((xid) != NullTransactionId))
#define TransactionIdIsSpecial(xid) ((bool) ((xid) < FirstTransactionId))
#define TransactionIdEquals(id1, id2) ((bool) ((id1) == (id2)))
#define TransactionIdPrecedes(id1, id2) ((bool) ((id1) < (id2)))
#define TransactionIdStore(xid, dest) \
(*((TransactionId*) (dest)) = (TransactionId) (xid))
#define StoreInvalidTransactionId(dest) \
(*((TransactionId*) (dest)) = NullTransactionId)
#define TransactionIdIsValid(xid) ((xid) != InvalidTransactionId)
#define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId)
#define TransactionIdEquals(id1, id2) ((id1) == (id2))
#define TransactionIdPrecedes(id1, id2) ((id1) < (id2))
#define TransactionIdPrecedesOrEquals(id1, id2) ((id1) <= (id2))
#define TransactionIdFollows(id1, id2) ((id1) > (id2))
#define TransactionIdFollowsOrEquals(id1, id2) ((id1) >= (id2))
#define TransactionIdStore(xid, dest) (*(dest) = (xid))
#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
/* advance a transaction ID variable, handling wraparound correctly */
#define TransactionIdAdvance(dest) \
do { \
(dest)++; \
if ((dest) < FirstNormalTransactionId) \
(dest) = FirstNormalTransactionId; \
} while(0)
/* ----------------
* transaction status values

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.97 2001/07/11 22:12:43 momjian Exp $
* $Id: c.h,v 1.98 2001/08/23 23:06:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -330,11 +330,9 @@ typedef Oid RegProcedure;
typedef uint32 TransactionId;
#define InvalidTransactionId 0
typedef uint32 CommandId;
#define FirstCommandId 0
#define FirstCommandId ((CommandId) 0)
/*
* Array indexing support

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
* $Id: postgres.h,v 1.50 2001/08/10 18:57:41 tgl Exp $
* $Id: postgres.h,v 1.51 2001/08/23 23:06:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -261,6 +261,34 @@ typedef Datum *DatumPtr;
#define ObjectIdGetDatum(X) ((Datum) SET_4_BYTES(X))
/*
* DatumGetTransactionId
* Returns transaction identifier value of a datum.
*/
#define DatumGetTransactionId(X) ((TransactionId) GET_4_BYTES(X))
/*
* TransactionIdGetDatum
* Returns datum representation for a transaction identifier.
*/
#define TransactionIdGetDatum(X) ((Datum) SET_4_BYTES((X)))
/*
* DatumGetCommandId
* Returns command identifier value of a datum.
*/
#define DatumGetCommandId(X) ((CommandId) GET_4_BYTES(X))
/*
* CommandIdGetDatum
* Returns datum representation for a command identifier.
*/
#define CommandIdGetDatum(X) ((Datum) SET_4_BYTES(X))
/*
* DatumGetPointer
* Returns pointer value of a datum.

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: tqual.h,v 1.32 2001/07/12 04:11:13 tgl Exp $
* $Id: tqual.h,v 1.33 2001/08/23 23:06:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -57,7 +57,7 @@ extern bool ReferentialIntegritySnapshotOverride;
*/
#define HeapTupleSatisfiesVisibility(tuple, snapshot) \
( \
TransactionIdEquals((tuple)->t_data->t_xmax, AmiTransactionId) ? \
TransactionIdEquals((tuple)->t_data->t_xmax, BootstrapTransactionId) ? \
false \
: \
( \