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
|
|
|
*
|
|
|
|
*
|
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-08-25 20:52:43 +02:00
|
|
|
* $Id: xact.h,v 1.35 2001/08/25 18:52:42 tgl 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
|
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-10-20 13:01:21 +02:00
|
|
|
/*
|
|
|
|
* XLOG allows to store some information in high 4 bits of log
|
|
|
|
* record xl_info field
|
|
|
|
*/
|
2001-03-22 05:01:46 +01:00
|
|
|
#define XLOG_XACT_COMMIT 0x00
|
|
|
|
#define XLOG_XACT_ABORT 0x20
|
2000-10-20 13:01:21 +02:00
|
|
|
|
|
|
|
typedef struct xl_xact_commit
|
|
|
|
{
|
|
|
|
time_t xtime;
|
2001-03-22 05:01:46 +01:00
|
|
|
|
2000-10-20 13:01:21 +02:00
|
|
|
/*
|
2001-03-22 05:01:46 +01:00
|
|
|
* Array of RelFileNode-s to drop may follow at the end of struct
|
2000-10-20 13:01:21 +02:00
|
|
|
*/
|
|
|
|
} xl_xact_commit;
|
|
|
|
|
|
|
|
#define SizeOfXactCommit ((offsetof(xl_xact_commit, xtime) + sizeof(time_t)))
|
|
|
|
|
|
|
|
typedef struct xl_xact_abort
|
|
|
|
{
|
|
|
|
time_t xtime;
|
|
|
|
} xl_xact_abort;
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
#define SizeOfXactAbort ((offsetof(xl_xact_abort, xtime) + sizeof(time_t)))
|
2000-10-20 13:01:21 +02:00
|
|
|
|
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);
|
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 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);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void XactPushRollback(void (*func) (void *), void *data);
|
2000-10-20 13:01:21 +02:00
|
|
|
extern void XactPopRollback(void);
|
|
|
|
|
2001-03-22 05:01:46 +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);
|
2000-11-21 22:16:06 +01:00
|
|
|
|
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);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* XACT_H */
|