This type represents a log sequence number in Postgres as defined here
/*
* For historical reasons, the 64-bit LSN value is stored as two 32-bit
* values.
*/
typedef struct
{
uint32 xlogid; /* high bits */
uint32 xrecoff; /* low bits */
} PageXLogRecPtr;
the comment above it says:
For historical reasons, the 64-bit LSN value is stored as two 32-bit values.
I am curious what the historical reasons are considering that the getter/setter methods basically treat this type as an uint64
:
/*
* 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;
static inline XLogRecPtr PageXLogRecPtrGet(PageXLogRecPtr val)
{
return (uint64) val.xlogid << 32 | val.xrecoff;
}
#define PageXLogRecPtrSet(ptr, lsn)
((ptr).xlogid = (uint32) ((lsn) >> 32), (ptr).xrecoff = (uint32) (lsn))
The only reason I can image is that there was no uint64
type back in the day…