summaryrefslogtreecommitdiff
path: root/src/include/access/xlogdefs.h
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-06-24 18:51:37 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-06-24 19:19:45 +0300
commit0ab9d1c4b31622e9176472b4276f3e9831e3d6ba (patch)
treeb8e9e5337338ba3010e00af50e1a33adb906a212 /src/include/access/xlogdefs.h
parent061e7efb1b4c5b8a5d02122b7780531b8d5bf23d (diff)
Replace XLogRecPtr struct with a 64-bit integer.
This simplifies code that needs to do arithmetic on XLogRecPtrs. To avoid changing on-disk format of data pages, the LSN on data pages is still stored in the old format. That should keep pg_upgrade happy. However, we have XLogRecPtrs embedded in the control file, and in the structs that are sent over the replication protocol, so this changes breaks compatibility of pg_basebackup and server. I didn't do anything about this in this patch, per discussion on -hackers, the right thing to do would to be to change the replication protocol to be architecture-independent, so that you could use a newer version of pg_receivexlog, for example, against an older server version.
Diffstat (limited to 'src/include/access/xlogdefs.h')
-rw-r--r--src/include/access/xlogdefs.h49
1 files changed, 12 insertions, 37 deletions
diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h
index 603854884f0..153d0de22a9 100644
--- a/src/include/access/xlogdefs.h
+++ b/src/include/access/xlogdefs.h
@@ -17,55 +17,30 @@
/*
* Pointer to a location in the XLOG. These pointers are 64 bits wide,
* because we don't want them ever to overflow.
- *
- * NOTE: xrecoff == 0 is used to indicate an invalid pointer. This is OK
- * because we use page headers in the XLOG, so no XLOG record can start
- * right at the beginning of a file.
- *
- * NOTE: the "log file number" is somewhat misnamed, since the actual files
- * making up the XLOG are much smaller than 4Gb. Each actual file is an
- * XLogSegSize-byte "segment" of a logical log file having the indicated
- * xlogid. The log file number and segment number together identify a
- * physical XLOG file. Segment number and offset within the physical file
- * are computed from xrecoff div and mod XLogSegSize.
*/
-typedef struct XLogRecPtr
-{
- uint32 xlogid; /* log file #, 0 based */
- uint32 xrecoff; /* byte offset of location in log file */
-} XLogRecPtr;
-
-#define XLogRecPtrIsInvalid(r) ((r).xrecoff == 0)
+typedef uint64 XLogRecPtr;
+/*
+ * Zero is used indicate an invalid pointer. Bootstrap skips the first possible
+ * WAL segment, initializing the first WAL page at XLOG_SEG_SIZE, so no XLOG
+ * record can begin at zero.
+ */
+#define InvalidXLogRecPtr 0
+#define XLogRecPtrIsInvalid(r) ((r) == InvalidXLogRecPtr)
/*
* Macros for comparing XLogRecPtrs
- *
- * Beware of passing expressions with side-effects to these macros,
- * since the arguments may be evaluated multiple times.
*/
-#define XLByteLT(a, b) \
- ((a).xlogid < (b).xlogid || \
- ((a).xlogid == (b).xlogid && (a).xrecoff < (b).xrecoff))
-
-#define XLByteLE(a, b) \
- ((a).xlogid < (b).xlogid || \
- ((a).xlogid == (b).xlogid && (a).xrecoff <= (b).xrecoff))
-
-#define XLByteEQ(a, b) \
- ((a).xlogid == (b).xlogid && (a).xrecoff == (b).xrecoff)
+#define XLByteLT(a, b) ((a) < (b))
+#define XLByteLE(a, b) ((a) <= (b))
+#define XLByteEQ(a, b) ((a) == (b))
/*
* Macro for advancing a record pointer by the specified number of bytes.
*/
#define XLByteAdvance(recptr, nbytes) \
- do { \
- uint32 oldxrecoff = (recptr).xrecoff; \
- (recptr).xrecoff += nbytes; \
- if ((recptr).xrecoff < oldxrecoff) \
- (recptr).xlogid += 1; /* xrecoff wrapped around */ \
- } while (0)
+ (recptr) += nbytes \
/*
* XLogSegNo - physical log file sequence number.