]> granicus.if.org Git - postgresql/blob - src/include/access/transam.h
pgindent run on all C files. Java run to follow. initdb/regression
[postgresql] / src / include / access / transam.h
1 /*-------------------------------------------------------------------------
2  *
3  * transam.h
4  *        postgres transaction access method support code
5  *
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: transam.h,v 1.42 2001/10/25 05:49:55 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef TRANSAM_H
15 #define TRANSAM_H
16
17
18 /* ----------------
19  *              Special transaction ID values
20  *
21  * BootstrapTransactionId is the XID for "bootstrap" operations, and
22  * FrozenTransactionId is used for very old tuples.  Both should
23  * always be considered valid.
24  *
25  * FirstNormalTransactionId is the first "normal" transaction id.
26  * ----------------
27  */
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)
33
34 /* ----------------
35  *              transaction ID manipulation macros
36  * ----------------
37  */
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)      \
45         do { \
46                 (dest)++; \
47                 if ((dest) < FirstNormalTransactionId) \
48                         (dest) = FirstNormalTransactionId; \
49         } while(0)
50
51
52 /* ----------
53  *              Object ID (OID) zero is InvalidOid.
54  *
55  *              OIDs 1-9999 are reserved for manual assignment (see the files
56  *              in src/include/catalog/).
57  *
58  *              OIDS 10000-16383 are reserved for assignment by genbki.sh.
59  *
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.)
63  *
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.
67  *
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.
71  * ----------
72  */
73 #define FirstGenBKIObjectId   10000
74 #define BootstrapObjectIdData 16384
75
76 /*
77  * VariableCache is placed in shmem and used by
78  * backends to get next available XID & OID.
79  */
80 typedef struct VariableCacheData
81 {
82         TransactionId nextXid;          /* next XID to assign */
83         Oid                     nextOid;                /* next OID to assign */
84         uint32          oidCount;               /* OIDs available before must do XLOG work */
85 } VariableCacheData;
86
87 typedef VariableCacheData *VariableCache;
88
89
90 /* ----------------
91  *              extern declarations
92  * ----------------
93  */
94
95 /*
96  * prototypes for functions in transam/transam.c
97  */
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);
107
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);
113
114 /* ----------------
115  *              global variable extern declarations
116  * ----------------
117  */
118
119 /* in xact.c */
120 extern bool AMI_OVERRIDE;
121
122 /* in varsup.c */
123 extern VariableCache ShmemVariableCache;
124 #endif   /* TRAMSAM_H */