1 /*-------------------------------------------------------------------------
4 * postgres transaction access method support code header
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: transam.h,v 1.16 1998/09/01 04:34:31 momjian Exp $
12 * Transaction System Version 101 now support proper oid
13 * generation and recording in the variable relation.
15 *-------------------------------------------------------------------------
20 #include <storage/bufmgr.h>
23 * transaction system version id
25 * this is stored on the first page of the log, time and variable
26 * relations on the first 4 bytes. This is so that if we improve
27 * the format of the transaction log after postgres version 2, then
28 * people won't have to rebuild their databases.
30 * TRANS_SYSTEM_VERSION 100 means major version 1 minor version 0.
31 * Two databases with the same major version should be compatible,
32 * even if their minor versions differ.
35 #define TRANS_SYSTEM_VERSION 200
38 * transaction id status values
40 * someday we will use "11" = 3 = XID_COMMIT_CHILD to mean the
41 * commiting of child xactions.
44 #define XID_COMMIT 2 /* transaction commited */
45 #define XID_ABORT 1 /* transaction aborted */
46 #define XID_INPROGRESS 0 /* transaction in progress */
47 #define XID_COMMIT_CHILD 3 /* child xact commited */
49 typedef unsigned char XidStatus;/* (2 bits) */
52 * note: we reserve the first 16384 object ids for internal use.
53 * oid's less than this appear in the .bki files. the choice of
54 * 16384 is completely arbitrary.
57 #define BootstrapObjectIdData 16384
60 * BitIndexOf computes the index of the Nth xid on a given block
63 #define BitIndexOf(N) ((N) * 2)
66 * transaction page definitions
69 #define TP_DataSize BLCKSZ
70 #define TP_NumXidStatusPerBlock (TP_DataSize * 4)
73 * LogRelationContents structure
75 * This structure describes the storage of the data in the
76 * first 128 bytes of the log relation. This storage is never
77 * used for transaction status because transaction id's begin
78 * their numbering at 512.
80 * The first 4 bytes of this relation store the version
81 * number of the transction system.
84 typedef struct LogRelationContentsData
86 int TransSystemVersion;
87 } LogRelationContentsData;
89 typedef LogRelationContentsData *LogRelationContents;
92 * VariableRelationContents structure
94 * The variable relation is a special "relation" which
95 * is used to store various system "variables" persistantly.
96 * Unlike other relations in the system, this relation
97 * is updated in place whenever the variables change.
99 * The first 4 bytes of this relation store the version
100 * number of the transction system.
102 * Currently, the relation has only one page and the next
103 * available xid, the last committed xid and the next
104 * available oid are stored there.
107 typedef struct VariableRelationContentsData
109 int TransSystemVersion;
110 TransactionId nextXidData;
111 TransactionId lastXidData; /* unused */
113 } VariableRelationContentsData;
115 typedef VariableRelationContentsData *VariableRelationContents;
118 * VariableCache is placed in shmem and used by backends to
119 * get next available XID & OID without access to
120 * variable relation. Actually, I would like to have two
121 * different on-disk storages for next XID and OID...
122 * But hoping that someday we will use per database OID
123 * generator I leaved this as is. - vadim 07/21/98
125 typedef struct VariableCacheData
128 TransactionId nextXid;
129 uint32 oid_count; /* not implemented, yet */
133 typedef VariableCacheData *VariableCache;
136 * extern declarations
141 * prototypes for functions in transam/transam.c
143 extern void InitializeTransactionLog(void);
144 extern bool TransactionIdDidCommit(TransactionId transactionId);
145 extern bool TransactionIdDidAbort(TransactionId transactionId);
146 extern void TransactionIdCommit(TransactionId transactionId);
147 extern void TransactionIdAbort(TransactionId transactionId);
149 /* in transam/transsup.c */
150 extern void AmiTransactionOverride(bool flag);
151 extern void TransComputeBlockNumber(Relation relation,
152 TransactionId transactionId, BlockNumber *blockNumberOutP);
153 extern XidStatus TransBlockNumberGetXidStatus(Relation relation,
154 BlockNumber blockNumber, TransactionId xid, bool *failP);
155 extern void TransBlockNumberSetXidStatus(Relation relation,
156 BlockNumber blockNumber, TransactionId xid, XidStatus xstatus,
159 /* in transam/varsup.c */
160 extern void VariableRelationPutNextXid(TransactionId xid);
161 extern void GetNewTransactionId(TransactionId *xid);
162 extern void GetNewObjectId(Oid *oid_return);
163 extern void CheckMaxObjectId(Oid assigned_oid);
166 * global variable extern declarations
171 extern Relation LogRelation;
172 extern Relation VariableRelation;
174 extern TransactionId cachedTestXid;
175 extern XidStatus cachedTestXidStatus;
177 extern TransactionId NullTransactionId;
178 extern TransactionId AmiTransactionId;
179 extern TransactionId FirstTransactionId;
181 extern int RecoveryCheckingEnableState;
184 extern bool AMI_OVERRIDE;
187 extern int OidGenLockId;
189 #endif /* TRAMSAM_H */