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.41 2001/09/29 04:02:26 tgl Exp $
12 *-------------------------------------------------------------------------
19 * Special transaction ID values
21 * BootstrapTransactionId is the XID for "bootstrap" operations, and
22 * FrozenTransactionId is used for very old tuples. Both should
23 * always be considered valid.
25 * FirstNormalTransactionId is the first "normal" transaction id.
28 #define InvalidTransactionId ((TransactionId) 0)
29 #define BootstrapTransactionId ((TransactionId) 1)
30 #define FrozenTransactionId ((TransactionId) 2)
31 #define FirstNormalTransactionId ((TransactionId) 3)
32 #define MaxTransactionId ((TransactionId) 0xFFFFFFFF)
35 * transaction ID manipulation macros
38 #define TransactionIdIsValid(xid) ((xid) != InvalidTransactionId)
39 #define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId)
40 #define TransactionIdEquals(id1, id2) ((id1) == (id2))
41 #define TransactionIdStore(xid, dest) (*(dest) = (xid))
42 #define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
43 /* advance a transaction ID variable, handling wraparound correctly */
44 #define TransactionIdAdvance(dest) \
47 if ((dest) < FirstNormalTransactionId) \
48 (dest) = FirstNormalTransactionId; \
53 * Object ID (OID) zero is InvalidOid.
55 * OIDs 1-9999 are reserved for manual assignment (see the files
56 * in src/include/catalog/).
58 * OIDS 10000-16383 are reserved for assignment by genbki.sh.
60 * OIDs beginning at 16384 are assigned at runtime from the OID
61 * generator. (The first few of these will be assigned during initdb,
62 * to objects created after the initial BKI script processing.)
64 * The choices of 10000 and 16384 are completely arbitrary, and can be moved
65 * if we run low on OIDs in either category. Changing the macros below
66 * should be sufficient to do this.
68 * NOTE: if the OID generator wraps around, we should skip over OIDs 0-16383
69 * and resume with 16384. This minimizes the odds of OID conflict, by not
70 * reassigning OIDs that might have been assigned during initdb.
73 #define FirstGenBKIObjectId 10000
74 #define BootstrapObjectIdData 16384
77 * VariableCache is placed in shmem and used by
78 * backends to get next available XID & OID.
80 typedef struct VariableCacheData
82 TransactionId nextXid; /* next XID to assign */
83 Oid nextOid; /* next OID to assign */
84 uint32 oidCount; /* OIDs available before must do XLOG work */
87 typedef VariableCacheData *VariableCache;
96 * prototypes for functions in transam/transam.c
98 extern void AmiTransactionOverride(bool flag);
99 extern bool TransactionIdDidCommit(TransactionId transactionId);
100 extern bool TransactionIdDidAbort(TransactionId transactionId);
101 extern void TransactionIdCommit(TransactionId transactionId);
102 extern void TransactionIdAbort(TransactionId transactionId);
103 extern bool TransactionIdPrecedes(TransactionId id1, TransactionId id2);
104 extern bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2);
105 extern bool TransactionIdFollows(TransactionId id1, TransactionId id2);
106 extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2);
108 /* in transam/varsup.c */
109 extern TransactionId GetNewTransactionId(void);
110 extern TransactionId ReadNewTransactionId(void);
111 extern Oid GetNewObjectId(void);
112 extern void CheckMaxObjectId(Oid assigned_oid);
115 * global variable extern declarations
120 extern bool AMI_OVERRIDE;
123 extern VariableCache ShmemVariableCache;
125 #endif /* TRAMSAM_H */