aboutsummaryrefslogtreecommitdiff
path: root/src/include/access/xlogdefs.h
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-06-24 18:06:38 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-06-24 18:35:29 +0300
commitdfda6ebaec6763090fb78b458a979b558c50b39b (patch)
tree15720cd5663330a8c0bc1875d1041fbecd413130 /src/include/access/xlogdefs.h
parent47c7365e794a0a57382efefbf1f2b062c7a3e3d3 (diff)
downloadpostgresql-dfda6ebaec6763090fb78b458a979b558c50b39b.tar.gz
postgresql-dfda6ebaec6763090fb78b458a979b558c50b39b.zip
Don't waste the last segment of each 4GB logical log file.
The comments claimed that wasting the last segment made it easier to do calculations with XLogRecPtrs, because you don't have problems representing last-byte-position-plus-1 that way. In my experience, however, it only made things more complicated, because the there was two ways to represent the boundary at the beginning of a logical log file: logid = n+1 and xrecoff = 0, or as xlogid = n and xrecoff = 4GB - XLOG_SEG_SIZE. Some functions were picky about which representation was used. Also, use a 64-bit segment number instead of the log/seg combination, to point to a certain WAL segment. We assume that all platforms have a working 64-bit integer type nowadays. This is an incompatible change in WAL format, so bumping WAL version number.
Diffstat (limited to 'src/include/access/xlogdefs.h')
-rw-r--r--src/include/access/xlogdefs.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h
index 5e6d7e600bd..603854884f0 100644
--- a/src/include/access/xlogdefs.h
+++ b/src/include/access/xlogdefs.h
@@ -61,16 +61,16 @@ typedef struct XLogRecPtr
*/
#define XLByteAdvance(recptr, nbytes) \
do { \
- if (recptr.xrecoff + nbytes >= XLogFileSize) \
- { \
- recptr.xlogid += 1; \
- recptr.xrecoff \
- = recptr.xrecoff + nbytes - XLogFileSize; \
- } \
- else \
- recptr.xrecoff += nbytes; \
+ uint32 oldxrecoff = (recptr).xrecoff; \
+ (recptr).xrecoff += nbytes; \
+ if ((recptr).xrecoff < oldxrecoff) \
+ (recptr).xlogid += 1; /* xrecoff wrapped around */ \
} while (0)
+/*
+ * XLogSegNo - physical log file sequence number.
+ */
+typedef uint64 XLogSegNo;
/*
* TimeLineID (TLI) - identifies different database histories to prevent