1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* transam.h
|
2001-07-12 06:11:13 +02:00
|
|
|
* postgres transaction access method support code
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2001-11-05 18:46:40 +01:00
|
|
|
* $Id: transam.h,v 1.44 2001/11/05 17:46:31 momjian Exp $
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TRANSAM_H
|
|
|
|
#define TRANSAM_H
|
|
|
|
|
2001-07-12 06:11:13 +02:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* ----------------
|
2001-07-12 06:11:13 +02:00
|
|
|
* Special transaction ID values
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2001-08-25 20:52:43 +02:00
|
|
|
* BootstrapTransactionId is the XID for "bootstrap" operations, and
|
|
|
|
* FrozenTransactionId is used for very old tuples. Both should
|
2001-08-24 01:06:38 +02:00
|
|
|
* always be considered valid.
|
2001-07-12 06:11:13 +02:00
|
|
|
*
|
2001-08-24 01:06:38 +02:00
|
|
|
* FirstNormalTransactionId is the first "normal" transaction id.
|
2001-07-12 06:11:13 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
2001-08-24 01:06:38 +02:00
|
|
|
#define InvalidTransactionId ((TransactionId) 0)
|
2001-08-25 20:52:43 +02:00
|
|
|
#define BootstrapTransactionId ((TransactionId) 1)
|
|
|
|
#define FrozenTransactionId ((TransactionId) 2)
|
|
|
|
#define FirstNormalTransactionId ((TransactionId) 3)
|
2001-08-26 18:56:03 +02:00
|
|
|
#define MaxTransactionId ((TransactionId) 0xFFFFFFFF)
|
2001-07-12 06:11:13 +02:00
|
|
|
|
|
|
|
/* ----------------
|
|
|
|
* transaction ID manipulation macros
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
2001-08-24 01:06:38 +02:00
|
|
|
#define TransactionIdIsValid(xid) ((xid) != InvalidTransactionId)
|
|
|
|
#define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId)
|
2001-08-26 18:56:03 +02:00
|
|
|
#define TransactionIdEquals(id1, id2) ((id1) == (id2))
|
2001-08-24 01:06:38 +02:00
|
|
|
#define TransactionIdStore(xid, dest) (*(dest) = (xid))
|
2001-10-25 07:50:21 +02:00
|
|
|
#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
|
2001-08-24 01:06:38 +02:00
|
|
|
/* advance a transaction ID variable, handling wraparound correctly */
|
|
|
|
#define TransactionIdAdvance(dest) \
|
|
|
|
do { \
|
|
|
|
(dest)++; \
|
|
|
|
if ((dest) < FirstNormalTransactionId) \
|
|
|
|
(dest) = FirstNormalTransactionId; \
|
|
|
|
} while(0)
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------
|
2001-08-10 20:57:42 +02:00
|
|
|
* 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
|
2001-10-25 07:50:21 +02:00
|
|
|
* generator. (The first few of these will be assigned during initdb,
|
2001-08-10 20:57:42 +02:00
|
|
|
* 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.
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------
|
|
|
|
*/
|
2001-08-10 20:57:42 +02:00
|
|
|
#define FirstGenBKIObjectId 10000
|
1996-08-27 23:50:29 +02:00
|
|
|
#define BootstrapObjectIdData 16384
|
|
|
|
|
1998-07-21 08:17:39 +02:00
|
|
|
/*
|
2000-11-30 09:46:26 +01:00
|
|
|
* VariableCache is placed in shmem and used by
|
|
|
|
* backends to get next available XID & OID.
|
1998-07-21 08:17:39 +02:00
|
|
|
*/
|
|
|
|
typedef struct VariableCacheData
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
TransactionId nextXid; /* next XID to assign */
|
|
|
|
Oid nextOid; /* next OID to assign */
|
|
|
|
uint32 oidCount; /* OIDs available before must do XLOG work */
|
1999-05-26 00:43:53 +02:00
|
|
|
} VariableCacheData;
|
1998-07-21 08:17:39 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
typedef VariableCacheData *VariableCache;
|
1998-07-21 08:17:39 +02:00
|
|
|
|
2001-07-12 06:11:13 +02:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* extern declarations
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes for functions in transam/transam.c
|
|
|
|
*/
|
2001-08-25 20:52:43 +02:00
|
|
|
extern void AmiTransactionOverride(bool flag);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool TransactionIdDidCommit(TransactionId transactionId);
|
|
|
|
extern bool TransactionIdDidAbort(TransactionId transactionId);
|
|
|
|
extern void TransactionIdCommit(TransactionId transactionId);
|
|
|
|
extern void TransactionIdAbort(TransactionId transactionId);
|
2001-08-26 18:56:03 +02:00
|
|
|
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);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* in transam/varsup.c */
|
2001-08-25 20:52:43 +02:00
|
|
|
extern TransactionId GetNewTransactionId(void);
|
|
|
|
extern TransactionId ReadNewTransactionId(void);
|
2001-08-10 20:57:42 +02:00
|
|
|
extern Oid GetNewObjectId(void);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void CheckMaxObjectId(Oid assigned_oid);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* global variable extern declarations
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
2001-07-12 06:11:13 +02:00
|
|
|
/* in xact.c */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool AMI_OVERRIDE;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* in varsup.c */
|
2000-11-21 22:16:06 +01:00
|
|
|
extern VariableCache ShmemVariableCache;
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* TRAMSAM_H */
|