~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/include/access/transam.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * transam.h
 
4
 *        postgres transaction access method support code
 
5
 *
 
6
 *
 
7
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
8
 * Portions Copyright (c) 1994, Regents of the University of California
 
9
 *
 
10
 * $PostgreSQL: pgsql/src/include/access/transam.h,v 1.51 2004-12-31 22:03:21 pgsql 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
/* in transam/transam.c */
 
96
extern bool AMI_OVERRIDE;
 
97
 
 
98
/* in transam/varsup.c */
 
99
extern VariableCache ShmemVariableCache;
 
100
 
 
101
 
 
102
/*
 
103
 * prototypes for functions in transam/transam.c
 
104
 */
 
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);
 
117
 
 
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);
 
123
 
 
124
#endif   /* TRAMSAM_H */