]> granicus.if.org Git - postgresql/blobdiff - src/include/access/xlog.h
Invent WAL timelines, as per recent discussion, to make point-in-time
[postgresql] / src / include / access / xlog.h
index 71a2fe72fd29589e94e6d82342819ec3b6e749c6..f2542d6fc7143f59357716cec87a605f9fd0bc57 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: xlog.h,v 1.44 2003/08/04 02:40:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.54 2004/07/21 22:31:25 tgl Exp $
  */
 #ifndef XLOG_H
 #define XLOG_H
@@ -14,7 +14,7 @@
 #include "access/rmgr.h"
 #include "access/transam.h"
 #include "access/xlogdefs.h"
-#include "storage/bufmgr.h"
+#include "storage/buf.h"
 #include "utils/pg_crc.h"
 
 
@@ -76,87 +76,6 @@ typedef struct XLogRecord
 #define XLOG_NO_TRAN                   XLR_INFO_MASK
 
 /*
- * Header info for a backup block appended to an XLOG record.
- *
- * Note that the backup block has its own CRC, and is not covered by
- * the CRC of the XLOG record proper.  Also note that we don't attempt
- * to align either the BkpBlock struct or the block's data.
- */
-typedef struct BkpBlock
-{
-       crc64           crc;
-       RelFileNode node;
-       BlockNumber block;
-} BkpBlock;
-
-/*
- * When there is not enough space on current page for whole record, we
- * continue on the next page with continuation record. (However, the
- * XLogRecord header will never be split across pages; if there's less than
- * SizeOfXLogRecord space left at the end of a page, we just waste it.)
- *
- * Note that xl_rem_len includes backup-block data, unlike xl_len in the
- * initial header.
- */
-typedef struct XLogContRecord
-{
-       uint32          xl_rem_len;             /* total len of remaining data for record */
-
-       /* ACTUAL LOG DATA FOLLOWS AT END OF STRUCT */
-
-} XLogContRecord;
-
-#define SizeOfXLogContRecord   MAXALIGN(sizeof(XLogContRecord))
-
-/*
- * Each page of XLOG file has a header like this:
- */
-#define XLOG_PAGE_MAGIC 0xD05A /* can be used as WAL version indicator */
-
-typedef struct XLogPageHeaderData
-{
-       uint16          xlp_magic;              /* magic value for correctness checks */
-       uint16          xlp_info;               /* flag bits, see below */
-       StartUpID       xlp_sui;                /* StartUpID of first record on page */
-       XLogRecPtr      xlp_pageaddr;   /* XLOG address of this page */
-} XLogPageHeaderData;
-
-#define SizeOfXLogPHD  MAXALIGN(sizeof(XLogPageHeaderData))
-
-typedef XLogPageHeaderData *XLogPageHeader;
-
-/* When record crosses page boundary, set this flag in new page's header */
-#define XLP_FIRST_IS_CONTRECORD                0x0001
-/* All defined flag bits in xlp_info (used for validity checking of header) */
-#define XLP_ALL_FLAGS                          0x0001
-
-/*
- * We break each logical log file (xlogid value) into 16Mb segments.
- * One possible segment at the end of each log file is wasted, to ensure
- * that we don't have problems representing last-byte-position-plus-1.
- */
-#define XLogSegSize            ((uint32) (16*1024*1024))
-#define XLogSegsPerFile (((uint32) 0xffffffff) / XLogSegSize)
-#define XLogFileSize   (XLogSegsPerFile * XLogSegSize)
-
-/*
- * Method table for resource managers.
- *
- * RmgrTable[] is indexed by RmgrId values (see rmgr.h).
- */
-typedef struct RmgrData
-{
-       const char *rm_name;
-       void            (*rm_redo) (XLogRecPtr lsn, XLogRecord *rptr);
-       void            (*rm_undo) (XLogRecPtr lsn, XLogRecord *rptr);
-       void            (*rm_desc) (char *buf, uint8 xl_info, char *rec);
-       void            (*rm_startup) (void);
-       void            (*rm_cleanup) (void);
-} RmgrData;
-
-extern RmgrData RmgrTable[];
-
-/*--------------------
  * List of these structs is used to pass data to XLogInsert().
  *
  * If buffer is valid then XLOG will check if buffer must be backed up
@@ -168,7 +87,6 @@ extern RmgrData RmgrTable[];
  * the XLOG record, since we assume it's present in the buffer.  Therefore,
  * rmgr redo routines MUST pay attention to XLR_BKP_BLOCK_X to know what
  * is actually stored in the XLOG record.
- *--------------------
  */
 typedef struct XLogRecData
 {
@@ -178,7 +96,7 @@ typedef struct XLogRecData
        struct XLogRecData *next;
 } XLogRecData;
 
-extern StartUpID ThisStartUpID; /* current SUI */
+extern TimeLineID ThisTimeLineID; /* current TLI */
 extern bool InRecovery;
 extern XLogRecPtr MyLastRecPtr;
 extern bool MyXactMadeXLogEntry;
@@ -187,12 +105,16 @@ extern XLogRecPtr ProcLastRecEnd;
 
 /* these variables are GUC parameters related to XLOG */
 extern int     CheckPointSegments;
-extern int     CheckPointWarning;
 extern int     XLOGbuffers;
-extern int     XLOG_DEBUG;
+extern char *XLogArchiveCommand;
 extern char *XLOG_sync_method;
 extern const char XLOG_sync_method_default[];
 
+#define XLogArchivingActive()  (XLogArchiveCommand[0] != '\0')
+
+#ifdef WAL_DEBUG
+extern bool    XLOG_DEBUG;
+#endif
 
 extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata);
 extern void XLogFlush(XLogRecPtr RecPtr);
@@ -207,12 +129,10 @@ extern void XLOGShmemInit(void);
 extern void XLOGPathInit(void);
 extern void BootStrapXLOG(void);
 extern void StartupXLOG(void);
-extern void ShutdownXLOG(void);
+extern void ShutdownXLOG(int code, Datum arg);
+extern void InitXLOGAccess(void);
 extern void CreateCheckPoint(bool shutdown, bool force);
-extern void SetThisStartUpID(void);
 extern void XLogPutNextOid(Oid nextOid);
-extern void SetSavedRedoRecPtr(void);
-extern void GetSavedRedoRecPtr(void);
 extern XLogRecPtr GetRedoRecPtr(void);
 
 /* in storage/ipc/sinval.c, but don't want to declare in sinval.h because
@@ -220,7 +140,4 @@ extern XLogRecPtr GetRedoRecPtr(void);
  */
 extern XLogRecPtr GetUndoRecPtr(void);
 
-extern const char *assign_xlog_sync_method(const char *method,
-                                               bool doit, bool interactive);
-
 #endif   /* XLOG_H */