1
/*-------------------------------------------------------------------------
4
* postgres transaction access method support code
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
* Portions Copyright (c) 1994, Regents of the University of California
10
* $PostgreSQL: pgsql/src/include/access/transam.h,v 1.51 2004-12-31 22:03:21 pgsql 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;
95
/* in transam/transam.c */
96
extern bool AMI_OVERRIDE;
98
/* in transam/varsup.c */
99
extern VariableCache ShmemVariableCache;
103
* prototypes for functions in transam/transam.c
105
extern void AmiTransactionOverride(bool flag);
106
extern bool TransactionIdDidCommit(TransactionId transactionId);
107
extern bool TransactionIdDidAbort(TransactionId transactionId);
108
extern void TransactionIdCommit(TransactionId transactionId);
109
extern void TransactionIdAbort(TransactionId transactionId);
110
extern void TransactionIdSubCommit(TransactionId transactionId);
111
extern void TransactionIdCommitTree(int nxids, TransactionId *xids);
112
extern void TransactionIdAbortTree(int nxids, TransactionId *xids);
113
extern bool TransactionIdPrecedes(TransactionId id1, TransactionId id2);
114
extern bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2);
115
extern bool TransactionIdFollows(TransactionId id1, TransactionId id2);
116
extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2);
118
/* in transam/varsup.c */
119
extern TransactionId GetNewTransactionId(bool isSubXact);
120
extern TransactionId ReadNewTransactionId(void);
121
extern Oid GetNewObjectId(void);
122
extern void CheckMaxObjectId(Oid assigned_oid);
124
#endif /* TRAMSAM_H */