xlog.diff
text/x-patch
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index 4eaa243..28848f4 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -112,57 +112,6 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
#define XLogPageHeaderSize(hdr) \
(((hdr)->xlp_info & XLP_LONG_HEADER) ? SizeOfXLogLongPHD : SizeOfXLogShortPHD)
-/*
- * We break each logical log file (xlogid value) into segment files of the
- * size indicated by XLOG_SEG_SIZE. 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) XLOG_SEG_SIZE)
-#define XLogSegsPerFile (((uint32) 0xffffffff) / XLogSegSize)
-#define XLogFileSize (XLogSegsPerFile * XLogSegSize)
-
-
-/*
- * Macros for manipulating XLOG pointers
- */
-
-/* Increment an xlogid/segment pair */
-#define NextLogSeg(logId, logSeg) \
- do { \
- if ((logSeg) >= XLogSegsPerFile-1) \
- { \
- (logId)++; \
- (logSeg) = 0; \
- } \
- else \
- (logSeg)++; \
- } while (0)
-
-/* Decrement an xlogid/segment pair (assume it's not 0,0) */
-#define PrevLogSeg(logId, logSeg) \
- do { \
- if (logSeg) \
- (logSeg)--; \
- else \
- { \
- (logId)--; \
- (logSeg) = XLogSegsPerFile-1; \
- } \
- } while (0)
-
-/* Align a record pointer to next page */
-#define NextLogPage(recptr) \
- do { \
- if ((recptr).xrecoff % XLOG_BLCKSZ != 0) \
- (recptr).xrecoff += \
- (XLOG_BLCKSZ - (recptr).xrecoff % XLOG_BLCKSZ); \
- if ((recptr).xrecoff >= XLogFileSize) \
- { \
- ((recptr).xlogid)++; \
- (recptr).xrecoff = 0; \
- } \
- } while (0)
/*
* Compute ID and segment from an XLogRecPtr.
@@ -207,36 +156,6 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
#define XLOGDIR "pg_xlog"
#define XLOG_CONTROL_FILE "global/pg_control"
-/*
- * These macros encapsulate knowledge about the exact layout of XLog file
- * names, timeline history file names, and archive-status file names.
- */
-#define MAXFNAMELEN 64
-
-#define XLogFileName(fname, tli, log, seg) \
- snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, log, seg)
-
-#define XLogFromFileName(fname, tli, log, seg) \
- sscanf(fname, "%08X%08X%08X", tli, log, seg)
-
-#define XLogFilePath(path, tli, log, seg) \
- snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X", tli, log, seg)
-
-#define TLHistoryFileName(fname, tli) \
- snprintf(fname, MAXFNAMELEN, "%08X.history", tli)
-
-#define TLHistoryFilePath(path, tli) \
- snprintf(path, MAXPGPATH, XLOGDIR "/%08X.history", tli)
-
-#define StatusFilePath(path, xlog, suffix) \
- snprintf(path, MAXPGPATH, XLOGDIR "/archive_status/%s%s", xlog, suffix)
-
-#define BackupHistoryFileName(fname, tli, log, seg, offset) \
- snprintf(fname, MAXFNAMELEN, "%08X%08X%08X.%08X.backup", tli, log, seg, offset)
-
-#define BackupHistoryFilePath(path, tli, log, seg, offset) \
- snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X.%08X.backup", tli, log, seg, offset)
-
/*
* Method table for resource managers.
diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h
index 6530df0..6c0394d 100644
--- a/src/include/access/xlogdefs.h
+++ b/src/include/access/xlogdefs.h
@@ -71,6 +71,90 @@ typedef struct XLogRecPtr
recptr.xrecoff += nbytes; \
} while (0)
+/*
+ * We break each logical log file (xlogid value) into segment files of the
+ * size indicated by XLOG_SEG_SIZE. 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) XLOG_SEG_SIZE)
+#define XLogSegsPerFile (((uint32) 0xffffffff) / XLogSegSize)
+#define XLogFileSize (XLogSegsPerFile * XLogSegSize)
+
+/*
+ * Macros for manipulating XLOG pointers
+ */
+
+/* Increment an xlogid/segment pair */
+#define NextLogSeg(logId, logSeg) \
+ do { \
+ if ((logSeg) >= XLogSegsPerFile-1) \
+ { \
+ (logId)++; \
+ (logSeg) = 0; \
+ } \
+ else \
+ (logSeg)++; \
+ } while (0)
+
+/* Decrement an xlogid/segment pair (assume it's not 0,0) */
+#define PrevLogSeg(logId, logSeg) \
+ do { \
+ if (logSeg) \
+ (logSeg)--; \
+ else \
+ { \
+ (logId)--; \
+ (logSeg) = XLogSegsPerFile-1; \
+ } \
+ } while (0)
+
+/* Align a record pointer to next page */
+#define NextLogPage(recptr) \
+ do { \
+ if ((recptr).xrecoff % XLOG_BLCKSZ != 0) \
+ (recptr).xrecoff += \
+ (XLOG_BLCKSZ - (recptr).xrecoff % XLOG_BLCKSZ); \
+ if ((recptr).xrecoff >= XLogFileSize) \
+ { \
+ ((recptr).xlogid)++; \
+ (recptr).xrecoff = 0; \
+ } \
+ } while (0)
+
+
+
+/*
+ * These macros encapsulate knowledge about the exact layout of XLog file
+ * names, timeline history file names, and archive-status file names.
+ */
+#define MAXFNAMELEN 64
+
+#define XLogFileName(fname, tli, log, seg) \
+ snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, log, seg)
+
+#define XLogFromFileName(fname, tli, log, seg) \
+ sscanf(fname, "%08X%08X%08X", tli, log, seg)
+
+#define XLogFilePath(path, tli, log, seg) \
+ snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X", tli, log, seg)
+
+#define TLHistoryFileName(fname, tli) \
+ snprintf(fname, MAXFNAMELEN, "%08X.history", tli)
+
+#define TLHistoryFilePath(path, tli) \
+ snprintf(path, MAXPGPATH, XLOGDIR "/%08X.history", tli)
+
+#define StatusFilePath(path, xlog, suffix) \
+ snprintf(path, MAXPGPATH, XLOGDIR "/archive_status/%s%s", xlog, suffix)
+
+#define BackupHistoryFileName(fname, tli, log, seg, offset) \
+ snprintf(fname, MAXFNAMELEN, "%08X%08X%08X.%08X.backup", tli, log, seg, offset)
+
+#define BackupHistoryFilePath(path, tli, log, seg, offset) \
+ snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X.%08X.backup", tli, log, seg, offset)
+
+
/*
* TimeLineID (TLI) - identifies different database histories to prevent