diff options
| author | Vadim B. Mikheev <vadim4o@yahoo.com> | 1999-09-27 15:48:12 +0000 |
|---|---|---|
| committer | Vadim B. Mikheev <vadim4o@yahoo.com> | 1999-09-27 15:48:12 +0000 |
| commit | 30659d43eb73272e20f2eb1d785a07ba3b553ed8 (patch) | |
| tree | ee2afd4d91ec8ae3038e1bf4c4cf4997d37741f8 /src/include | |
| parent | 2902c4c64070b796e51bc12ca31671c069a8345b (diff) | |
| download | postgresql-30659d43eb73272e20f2eb1d785a07ba3b553ed8.tar.gz | |
Transaction log manager core code.
It doesn't work currently but also don't break anything -:)
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/rmgr.h | 34 | ||||
| -rw-r--r-- | src/include/access/xlog.h | 70 | ||||
| -rw-r--r-- | src/include/storage/proc.h | 5 | ||||
| -rw-r--r-- | src/include/utils/elog.h | 4 |
4 files changed, 110 insertions, 3 deletions
diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h new file mode 100644 index 0000000000..d8bde166c2 --- /dev/null +++ b/src/include/access/rmgr.h @@ -0,0 +1,34 @@ +/* + * + * rmgr.h + * + * Resource managers description table + * + */ +#ifndef RMGR_H +#define RMGR_H + +typedef uint8 RmgrId; + +typedef struct RmgrData +{ + char *rm_name; + char *(*rm_redo) (); /* REDO(XLogRecPtr rptr) */ + char *(*rm_undo) (); /* UNDO(XLogRecPtr rptr) */ +} RmgrData; + +extern RmgrData *RmgrTable; + +/* + * Built-in resource managers + */ +#define RM_XLOG_ID 0 +#define RM_XACT_ID 1 +#define RM_HEAP_ID 2 +#define RM_BTREE_ID 3 +#define RM_HASH_ID 4 +#define RM_RTREE_ID 5 +#define RM_GIST_ID 6 +#define RM_MAX_ID RM_GIST_ID + +#endif /* RMGR_H */ diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h new file mode 100644 index 0000000000..5c8c075424 --- /dev/null +++ b/src/include/access/xlog.h @@ -0,0 +1,70 @@ +/* + * + * xlog.h + * + * Postgres transaction log manager + * + */ +#ifndef XLOG_H +#define XLOG_H + +#include "access/rmgr.h" +#include "access/transam.h" + +typedef struct XLogRecPtr +{ + uint32 xlogid; /* log file #, 0 based */ + uint32 xrecoff; /* offset of record in log file */ +} XLogRecPtr; + +typedef struct XLogRecord +{ + XLogRecPtr xl_prev; /* ptr to previous record in log */ + XLogRecPtr xl_xact_prev; /* ptr to previous record of this xact */ + TransactionId xl_xid; /* xact id */ + uint16 xl_len; /* len of record on this page */ + uint8 xl_info; + RmgrId xl_rmid; /* resource manager inserted this record */ + + /* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */ + +} XLogRecord; + +#define SizeOfXLogRecord DOUBLEALIGN(sizeof(XLogRecord)) +#define MAXLOGRECSZ (2 * BLCKSZ) +/* + * When there is no space on current page we continue on the next + * page with subrecord. + */ +typedef struct XLogSubRecord +{ + uint16 xl_len; + uint8 xl_info; + + /* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */ + +} XLogSubRecord; + +#define SizeOfXLogSubRecord DOUBLEALIGN(sizeof(XLogSubRecord)) + +#define XLR_TO_BE_CONTINUED 0x01 + +#define XLOG_PAGE_MAGIC 0x17345168 + +typedef struct XLogPageHeaderData +{ + uint32 xlp_magic; + uint16 xlp_info; +} XLogPageHeaderData; + +#define SizeOfXLogPHD DOUBLEALIGN(sizeof(XLogPageHeaderData)) + +typedef XLogPageHeaderData *XLogPageHeader; + +#define XLP_FIRST_IS_SUBRECORD 0x0001 + +extern XLogRecPtr XLogInsert(RmgrId rmid, char *hdr, uint32 hdrlen, + char *buf, uint32 buflen); +extern void XLogFlush(XLogRecPtr RecPtr); + +#endif /* XLOG_H */ diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index d28e936b33..44a5fbd313 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -6,13 +6,14 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: proc.h,v 1.26 1999/09/24 00:25:27 tgl Exp $ + * $Id: proc.h,v 1.27 1999/09/27 15:48:06 vadim Exp $ * *------------------------------------------------------------------------- */ #ifndef _PROC_H_ #define _PROC_H_ +#include "access/xlog.h" #include "storage/lock.h" typedef struct @@ -47,7 +48,7 @@ typedef struct proc TransactionId xmin; /* minimal running XID as it was when we * were starting our xact: vacuum must not * remove tuples deleted by xid >= xmin ! */ - + XLogRecPtr logRec; LOCK *waitLock; /* Lock we're sleeping on ... */ int token; /* type of lock we sleeping for */ int holdLock; /* while holding these locks */ diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 5f64a6b1c7..e69ef11d7a 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: elog.h,v 1.12 1999/09/11 19:06:25 tgl Exp $ + * $Id: elog.h,v 1.13 1999/09/27 15:48:12 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,9 @@ #define ERROR (-1) /* user error - return to known state */ #define FATAL 1 /* fatal error - abort process */ #define REALLYFATAL 2 /* take down the other backends with me */ +#define STOP REALLYFATAL #define DEBUG (-2) /* debug message */ +#define LOG DEBUG #define NOIND (-3) /* debug message, don't indent as far */ extern void elog(int lev, const char *fmt, ...); |
