1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* xact.h
|
2000-07-28 03:04:40 +02:00
|
|
|
* postgres transaction system definitions
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2000-11-21 22:16:06 +01:00
|
|
|
* $Id: xact.h,v 1.30 2000/11/21 21:16:05 petere Exp $
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef XACT_H
|
|
|
|
#define XACT_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/transam.h"
|
2000-11-21 22:16:06 +01:00
|
|
|
#include "access/xlog.h"
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "utils/nabstime.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2000-07-28 03:04:40 +02:00
|
|
|
/*
|
|
|
|
* Xact isolation levels
|
|
|
|
*/
|
|
|
|
#define XACT_DIRTY_READ 0 /* not implemented */
|
|
|
|
#define XACT_READ_COMMITTED 1
|
|
|
|
#define XACT_REPEATABLE_READ 2 /* not implemented */
|
|
|
|
#define XACT_SERIALIZABLE 3
|
|
|
|
|
|
|
|
extern int DefaultXactIsoLevel;
|
|
|
|
extern int XactIsoLevel;
|
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* transaction state structure
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct TransactionStateData
|
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
TransactionId transactionIdData;
|
|
|
|
CommandId commandId;
|
|
|
|
CommandId scanCommandId;
|
|
|
|
AbsoluteTime startTime;
|
|
|
|
int state;
|
|
|
|
int blockState;
|
1997-09-08 23:56:23 +02:00
|
|
|
} TransactionStateData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2000-07-28 03:04:40 +02:00
|
|
|
typedef TransactionStateData *TransactionState;
|
1998-12-15 13:47:01 +01:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* transaction states
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define TRANS_DEFAULT 0
|
|
|
|
#define TRANS_START 1
|
|
|
|
#define TRANS_INPROGRESS 2
|
|
|
|
#define TRANS_COMMIT 3
|
|
|
|
#define TRANS_ABORT 4
|
|
|
|
#define TRANS_DISABLED 5
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* transaction block states
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define TBLOCK_DEFAULT 0
|
|
|
|
#define TBLOCK_BEGIN 1
|
|
|
|
#define TBLOCK_INPROGRESS 2
|
|
|
|
#define TBLOCK_END 3
|
|
|
|
#define TBLOCK_ABORT 4
|
|
|
|
#define TBLOCK_ENDABORT 5
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2000-07-28 03:04:40 +02:00
|
|
|
/* ----------------
|
|
|
|
* transaction ID manipulation macros
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
#define TransactionIdIsValid(xid) ((bool) ((xid) != NullTransactionId))
|
|
|
|
#define TransactionIdEquals(id1, id2) ((bool) ((id1) == (id2)))
|
1997-11-02 16:27:14 +01:00
|
|
|
#define TransactionIdStore(xid, dest) \
|
2000-07-28 03:04:40 +02:00
|
|
|
(*((TransactionId*) (dest)) = (TransactionId) (xid))
|
1998-02-26 05:46:47 +01:00
|
|
|
#define StoreInvalidTransactionId(dest) \
|
2000-07-28 03:04:40 +02:00
|
|
|
(*((TransactionId*) (dest)) = NullTransactionId)
|
1998-04-24 16:43:33 +02:00
|
|
|
|
|
|
|
|
2000-10-20 13:01:21 +02:00
|
|
|
#ifdef XLOG
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XLOG allows to store some information in high 4 bits of log
|
|
|
|
* record xl_info field
|
|
|
|
*/
|
|
|
|
#define XLOG_XACT_COMMIT 0x00
|
|
|
|
#define XLOG_XACT_ABORT 0x20
|
|
|
|
|
|
|
|
typedef struct xl_xact_commit
|
|
|
|
{
|
|
|
|
time_t xtime;
|
|
|
|
/*
|
|
|
|
* Array of RelFileNode-s to drop may follow
|
|
|
|
* at the end of struct
|
|
|
|
*/
|
|
|
|
} xl_xact_commit;
|
|
|
|
|
|
|
|
#define SizeOfXactCommit ((offsetof(xl_xact_commit, xtime) + sizeof(time_t)))
|
|
|
|
|
|
|
|
typedef struct xl_xact_abort
|
|
|
|
{
|
|
|
|
time_t xtime;
|
|
|
|
} xl_xact_abort;
|
|
|
|
|
|
|
|
#define SizeOfXactAbort ((offsetof(xl_xact_abort, xtime) + sizeof(time_t)))
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* extern definitions
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int TransactionFlushEnabled(void);
|
|
|
|
extern void SetTransactionFlushEnabled(bool state);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool IsAbortedTransactionBlockState(void);
|
|
|
|
extern void OverrideTransactionSystem(bool flag);
|
1996-08-27 23:50:29 +02:00
|
|
|
extern TransactionId GetCurrentTransactionId(void);
|
|
|
|
extern CommandId GetCurrentCommandId(void);
|
1997-08-29 11:05:25 +02:00
|
|
|
extern CommandId GetScanCommandId(void);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void SetScanCommandId(CommandId);
|
1996-08-27 23:50:29 +02:00
|
|
|
extern AbsoluteTime GetCurrentTransactionStartTime(void);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool TransactionIdIsCurrentTransactionId(TransactionId xid);
|
|
|
|
extern bool CommandIdIsCurrentCommandId(CommandId cid);
|
|
|
|
extern bool CommandIdGEScanCommandId(CommandId cid);
|
|
|
|
extern void CommandCounterIncrement(void);
|
|
|
|
extern void InitializeTransactionSystem(void);
|
|
|
|
extern void StartTransactionCommand(void);
|
|
|
|
extern void CommitTransactionCommand(void);
|
|
|
|
extern void AbortCurrentTransaction(void);
|
|
|
|
extern void BeginTransactionBlock(void);
|
|
|
|
extern void EndTransactionBlock(void);
|
|
|
|
extern bool IsTransactionBlock(void);
|
|
|
|
extern void UserAbortTransactionBlock(void);
|
1998-10-06 04:40:09 +02:00
|
|
|
extern void AbortOutOfAnyTransaction(void);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2000-10-28 18:21:00 +02:00
|
|
|
extern void RecordTransactionCommit(void);
|
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
extern TransactionId DisabledTransactionId;
|
|
|
|
|
2000-10-20 13:01:21 +02:00
|
|
|
extern void XactPushRollback(void (*func) (void *), void* data);
|
|
|
|
extern void XactPopRollback(void);
|
|
|
|
|
2000-11-21 22:16:06 +01:00
|
|
|
extern void xact_redo(XLogRecPtr lsn, XLogRecord *record);
|
|
|
|
extern void xact_undo(XLogRecPtr lsn, XLogRecord *record);
|
|
|
|
extern void xact_desc(char *buf, uint8 xl_info, char* rec);
|
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* defined in xid.c */
|
2000-06-05 09:29:25 +02:00
|
|
|
extern Datum xidin(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum xidout(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum xideq(PG_FUNCTION_ARGS);
|
1997-09-08 23:56:23 +02:00
|
|
|
extern void TransactionIdAdd(TransactionId *xid, int value);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* XACT_H */
|