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
|
|
|
*
|
2002-11-18 02:17:39 +01:00
|
|
|
* $Id: xact.h,v 1.48 2002/11/18 01:17:39 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;
|
|
|
|
|
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;
|
1998-09-01 06:40:42 +02:00
|
|
|
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
|
|
|
|
2002-11-13 04:12:05 +01:00
|
|
|
/*
|
|
|
|
* transaction states - transaction state from server perspective
|
|
|
|
*
|
|
|
|
* Syntax error could cause transaction to abort, but client code thinks
|
|
|
|
* it is still in a transaction, so we have to wait for COMMIT/ROLLBACK.
|
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
|
|
|
|
2002-11-13 04:12:05 +01:00
|
|
|
/*
|
|
|
|
* transaction block states - transaction state of client queries
|
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
|
|
|
* ----------------
|
|
|
|
*/
|
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);
|
|
|
|
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
|
|
|
|
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);
|
2001-08-26 18:56:03 +02:00
|
|
|
extern Datum xid_age(PG_FUNCTION_ARGS);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* XACT_H */
|