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
|
|
|
*
|
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, 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
|
|
|
*
|
2003-05-13 01:08:52 +02:00
|
|
|
* $Id: xact.h,v 1.51 2003/05/12 23:08:50 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"
|
2001-09-28 10:09:14 +02:00
|
|
|
#include "utils/timestamp.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;
|
2003-04-26 22:23:00 +02:00
|
|
|
|
|
|
|
/* Xact read-only state */
|
2003-01-10 23:03:30 +01:00
|
|
|
extern bool DefaultXactReadOnly;
|
|
|
|
extern bool XactReadOnly;
|
|
|
|
|
2003-04-26 22:23:00 +02:00
|
|
|
/*
|
|
|
|
* transaction states - transaction state from server perspective
|
|
|
|
*/
|
|
|
|
typedef enum TransState
|
|
|
|
{
|
|
|
|
TRANS_DEFAULT,
|
|
|
|
TRANS_START,
|
|
|
|
TRANS_INPROGRESS,
|
|
|
|
TRANS_COMMIT,
|
|
|
|
TRANS_ABORT
|
|
|
|
} TransState;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* transaction block states - transaction state of client queries
|
|
|
|
*/
|
|
|
|
typedef enum TBlockState
|
|
|
|
{
|
|
|
|
TBLOCK_DEFAULT,
|
|
|
|
TBLOCK_BEGIN,
|
|
|
|
TBLOCK_INPROGRESS,
|
|
|
|
TBLOCK_END,
|
|
|
|
TBLOCK_ABORT,
|
|
|
|
TBLOCK_ENDABORT
|
|
|
|
} TBlockState;
|
2000-07-28 03:04:40 +02:00
|
|
|
|
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;
|
|
|
|
AbsoluteTime startTime;
|
2001-10-18 19:30:21 +02:00
|
|
|
int startTimeUsec;
|
2003-04-26 22:23:00 +02:00
|
|
|
TransState state;
|
|
|
|
TBlockState 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
|
|
|
|
2003-04-26 22:23:00 +02:00
|
|
|
/* ----------------
|
|
|
|
* transaction-related XLOG entries
|
|
|
|
* ----------------
|
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
|
|
|
* ----------------
|
|
|
|
*/
|
2002-04-01 05:34:27 +02:00
|
|
|
extern bool IsTransactionState(void);
|
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);
|
|
|
|
extern AbsoluteTime GetCurrentTransactionStartTime(void);
|
2001-09-28 10:09:14 +02:00
|
|
|
extern AbsoluteTime GetCurrentTransactionStartTimeUsec(int *usec);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool TransactionIdIsCurrentTransactionId(TransactionId xid);
|
|
|
|
extern bool CommandIdIsCurrentCommandId(CommandId cid);
|
|
|
|
extern void CommandCounterIncrement(void);
|
2002-08-31 00:18:07 +02:00
|
|
|
extern void StartTransactionCommand(bool preventChain);
|
|
|
|
extern void CommitTransactionCommand(bool forceCommit);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void AbortCurrentTransaction(void);
|
|
|
|
extern void BeginTransactionBlock(void);
|
|
|
|
extern void EndTransactionBlock(void);
|
|
|
|
extern bool IsTransactionBlock(void);
|
2003-04-26 22:23:00 +02:00
|
|
|
extern char TransactionBlockStatusCode(void);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void UserAbortTransactionBlock(void);
|
1998-10-06 04:40:09 +02:00
|
|
|
extern void AbortOutOfAnyTransaction(void);
|
2002-10-22 00:06:20 +02:00
|
|
|
extern void PreventTransactionChain(void *stmtNode, const char *stmtType);
|
2002-11-18 02:17:39 +01:00
|
|
|
extern void RequireTransactionChain(void *stmtNode, const char *stmtType);
|
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
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* XACT_H */
|