/* * Pointer to a location in the XLOG. These pointers are 64 bits wide, * because we don't want them ever to overflow. */
typedef uint64 XLogRecPtr;
/* * Store the LSN as a single 64-bit value, to allow atomic loads/stores. * * For historical reasons, the storage of 64-bit LSN values depends on CPU * endianness; PageXLogRecPtr used to be a struct consisting of two 32-bit * values. When reading (and writing) the pd_lsn field from page headers, the * caller must convert from (and convert to) the platform's native endianness. */ typedefstruct { uint64 lsn; } PageXLogRecPtr;
/* * Generate a WAL segment file name. Do not use this function in a helper * function allocating the result generated. */ staticinlinevoid XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes) { snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, (uint32) (logSegNo / XLogSegmentsPerXLogId(wal_segsz_bytes)), (uint32) (logSegNo % XLogSegmentsPerXLogId(wal_segsz_bytes))); }
An example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
gujinfei@jeff:~/codes/blink-tree-cpp/build$ pg_controldata $PGDATA | grep "Bytes per WAL segment" Bytes per WAL segment: 16777216 gujinfei@jeff:~/codes/blink-tree-cpp/build$