transam.h 4.0 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * transam.h
4
 *	  postgres transaction access method support code
5 6
 *
 *
7
 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
B
Add:  
Bruce Momjian 已提交
8
 * Portions Copyright (c) 1994, Regents of the University of California
9
 *
10
 * $Id: transam.h,v 1.44 2001/11/05 17:46:31 momjian Exp $
11 12 13 14 15 16
 *
 *-------------------------------------------------------------------------
 */
#ifndef TRANSAM_H
#define TRANSAM_H

17

18
/* ----------------
19
 *		Special transaction ID values
20
 *
21 22
 * BootstrapTransactionId is the XID for "bootstrap" operations, and
 * 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 30 31
#define BootstrapTransactionId		((TransactionId) 1)
#define FrozenTransactionId			((TransactionId) 2)
#define FirstNormalTransactionId	((TransactionId) 3)
32
#define MaxTransactionId			((TransactionId) 0xFFFFFFFF)
33 34 35

/* ----------------
 *		transaction ID manipulation macros
36 37
 * ----------------
 */
38 39
#define TransactionIdIsValid(xid)		((xid) != InvalidTransactionId)
#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 44 45 46 47 48 49
/* advance a transaction ID variable, handling wraparound correctly */
#define TransactionIdAdvance(dest)	\
	do { \
		(dest)++; \
		if ((dest) < FirstNormalTransactionId) \
			(dest) = FirstNormalTransactionId; \
	} while(0)
50 51 52


/* ----------
53 54 55 56 57 58 59 60
 *		Object ID (OID) zero is InvalidOid.
 *
 *		OIDs 1-9999 are reserved for manual assignment (see the files
 *		in src/include/catalog/).
 *
 *		OIDS 10000-16383 are reserved for assignment by genbki.sh.
 *
 *		OIDs beginning at 16384 are assigned at runtime from the OID
61
 *		generator.	(The first few of these will be assigned during initdb,
62 63 64 65 66 67 68 69 70
 *		to objects created after the initial BKI script processing.)
 *
 * The choices of 10000 and 16384 are completely arbitrary, and can be moved
 * if we run low on OIDs in either category.  Changing the macros below
 * should be sufficient to do this.
 *
 * NOTE: if the OID generator wraps around, we should skip over OIDs 0-16383
 * and resume with 16384.  This minimizes the odds of OID conflict, by not
 * reassigning OIDs that might have been assigned during initdb.
71 72
 * ----------
 */
73
#define FirstGenBKIObjectId   10000
74 75
#define BootstrapObjectIdData 16384

76
/*
V
Vadim B. Mikheev 已提交
77 78
 * VariableCache is placed in shmem and used by
 * backends to get next available XID & OID.
79 80 81
 */
typedef struct VariableCacheData
{
B
Bruce Momjian 已提交
82 83 84
	TransactionId nextXid;		/* next XID to assign */
	Oid			nextOid;		/* next OID to assign */
	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 97
 * ----------------
 */

/*
 * prototypes for functions in transam/transam.c
 */
98
extern void AmiTransactionOverride(bool flag);
99 100 101 102
extern bool TransactionIdDidCommit(TransactionId transactionId);
extern bool TransactionIdDidAbort(TransactionId transactionId);
extern void TransactionIdCommit(TransactionId transactionId);
extern void TransactionIdAbort(TransactionId transactionId);
103 104 105 106
extern bool TransactionIdPrecedes(TransactionId id1, TransactionId id2);
extern bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2);
extern bool TransactionIdFollows(TransactionId id1, TransactionId id2);
extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2);
107 108

/* in transam/varsup.c */
109 110
extern TransactionId GetNewTransactionId(void);
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

125
#endif   /* TRAMSAM_H */