mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Transaction log manager core code.
It doesn't work currently but also don't break anything -:)
This commit is contained in:
34
src/include/access/rmgr.h
Normal file
34
src/include/access/rmgr.h
Normal file
@@ -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 */
|
||||
70
src/include/access/xlog.h
Normal file
70
src/include/access/xlog.h
Normal file
@@ -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 */
|
||||
Reference in New Issue
Block a user