diff options
Diffstat (limited to 'src/include/access')
| -rw-r--r-- | src/include/access/rmgr.h | 34 | ||||
| -rw-r--r-- | src/include/access/xlog.h | 70 |
2 files changed, 104 insertions, 0 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 */ |
