Contents

XLogRecPtr

A data type representing a pointer to a location in the current WAL file.

XLogRecPtr is a data type representing a pointer to a location in the current WAL file.

As of PostgreSQL 9.3, XLogRecPtr is an unsigned 64 bit integer, defined in include/access/xlogdefs.h:

/*
 * 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;

In PostgreSQL 9.2 and earlier, XLogRecPtr was a struct consisting of two 32 bit integers:

typedef struct XLogRecPtr
{
	uint32		xlogid;			/* log file #, 0 based */
	uint32		xrecoff;		/* byte offset of location in log file */
} XLogRecPtr;

Externally XLogRecPtr is displayed as an LSN consisting of two sets of up to 8 hexadecimal digits separated by a slash, e.g.

postgres=# SELECT pg_last_wal_receive_lsn();
 pg_last_wal_receive_lsn 
-------------------------
 0/40043D8
(1 row)

Beginning with PostgreSQL 9.4, a discrete datatype pg_lsn was introduced to represent LSNs.

An invalid XLogRecPtr is represented in 9.3 or later as zero (constant InvalidXLogRecPtr); in 9.2 and earlier the xrecoff value is set to zero. In both cases the macro XLogRecPtrIsInvalid() can be used to check the validity of an XLogRecPtr.

Categories

PostgreSQL internals