1 /*-------------------------------------------------------------------------
4 * postgres transaction access method support code
7 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: transam.h,v 1.39 2001/08/25 18:52:42 tgl Exp $
12 *-------------------------------------------------------------------------
17 #include "storage/spin.h"
21 * Special transaction ID values
23 * BootstrapTransactionId is the XID for "bootstrap" operations, and
24 * FrozenTransactionId is used for very old tuples. Both should
25 * always be considered valid.
27 * FirstNormalTransactionId is the first "normal" transaction id.
30 #define InvalidTransactionId ((TransactionId) 0)
31 #define BootstrapTransactionId ((TransactionId) 1)
32 #define FrozenTransactionId ((TransactionId) 2)
33 #define FirstNormalTransactionId ((TransactionId) 3)
36 * transaction ID manipulation macros
39 #define TransactionIdIsValid(xid) ((xid) != InvalidTransactionId)
40 #define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId)
41 #define TransactionIdEquals(id1, id2) ((id1) == (id2))
42 #define TransactionIdPrecedes(id1, id2) ((id1) < (id2))
43 #define TransactionIdPrecedesOrEquals(id1, id2) ((id1) <= (id2))
44 #define TransactionIdFollows(id1, id2) ((id1) > (id2))
45 #define TransactionIdFollowsOrEquals(id1, id2) ((id1) >= (id2))
46 #define TransactionIdStore(xid, dest) (*(dest) = (xid))
47 #define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
48 /* advance a transaction ID variable, handling wraparound correctly */
49 #define TransactionIdAdvance(dest) \
52 if ((dest) < FirstNormalTransactionId) \
53 (dest) = FirstNormalTransactionId; \
58 * Object ID (OID) zero is InvalidOid.
60 * OIDs 1-9999 are reserved for manual assignment (see the files
61 * in src/include/catalog/).
63 * OIDS 10000-16383 are reserved for assignment by genbki.sh.
65 * OIDs beginning at 16384 are assigned at runtime from the OID
66 * generator. (The first few of these will be assigned during initdb,
67 * to objects created after the initial BKI script processing.)
69 * The choices of 10000 and 16384 are completely arbitrary, and can be moved
70 * if we run low on OIDs in either category. Changing the macros below
71 * should be sufficient to do this.
73 * NOTE: if the OID generator wraps around, we should skip over OIDs 0-16383
74 * and resume with 16384. This minimizes the odds of OID conflict, by not
75 * reassigning OIDs that might have been assigned during initdb.
78 #define FirstGenBKIObjectId 10000
79 #define BootstrapObjectIdData 16384
82 * VariableCache is placed in shmem and used by
83 * backends to get next available XID & OID.
85 typedef struct VariableCacheData
87 TransactionId nextXid; /* next XID to assign */
88 Oid nextOid; /* next OID to assign */
89 uint32 oidCount; /* OIDs available before must do XLOG work */
92 typedef VariableCacheData *VariableCache;
101 * prototypes for functions in transam/transam.c
103 extern void AmiTransactionOverride(bool flag);
104 extern bool TransactionIdDidCommit(TransactionId transactionId);
105 extern bool TransactionIdDidAbort(TransactionId transactionId);
106 extern void TransactionIdCommit(TransactionId transactionId);
107 extern void TransactionIdAbort(TransactionId transactionId);
109 /* in transam/varsup.c */
110 extern TransactionId GetNewTransactionId(void);
111 extern TransactionId ReadNewTransactionId(void);
112 extern Oid GetNewObjectId(void);
113 extern void CheckMaxObjectId(Oid assigned_oid);
116 * global variable extern declarations
121 extern bool AMI_OVERRIDE;
124 extern SPINLOCK OidGenLockId;
125 extern SPINLOCK XidGenLockId;
126 extern VariableCache ShmemVariableCache;
128 #endif /* TRAMSAM_H */