A constant embedded in a WAL file defining its version

XLOG_PAGE_MAGIC is a preprocessor constant embedded in the header of a WAL file defining its version.

XLOG_PAGE_MAGIC has been present since PostgreSQL 7.0 (although it has only been of practical use since the full introduction of WAL in PostgreSQL 7.1).

Source code

XLOG_PAGE_MAGIC is defined in src/include/access/xlog_internal.h (prior to PostgreSQL 8.0 in src/include/access/xlog.h.

Usage and values

XLOG_PAGE_MAGIC is a two-byte constant, which is incremented each time a change is made to the format of WAL files. There is no direct correlation to the PostgreSQL version number, but the value at the point of each stable PostgreSQL release since PostgreSQL 8.0 has been higher than the value at the point of the previous stable release, so it's theoretically possible to determine which PostgreSQL version a WAL file is associated with based on the value of XLOG_PAGE_MAGIC. Note that there was no increment between PostgreSQL 7.3 and PostgreSQL 7.4 (see table below).

PostgreSQL version XLOG_PAGE_MAGIC Notes
PostgreSQL 14 0xD108 not final
PostgreSQL 13 0xD106  
PostgreSQL 12 0xD101  
PostgreSQL 11 0xD098  
PostgreSQL 10 0xD097  
PostgreSQL 9.6 0xD093  
PostgreSQL 9.5 0xD087  
PostgreSQL 9.4 0xD07E  
PostgreSQL 9.3 0xD075  
PostgreSQL 9.2 0xD071  
PostgreSQL 9.1 0xD066  
PostgreSQL 9.0 0xD064  
PostgreSQL 8.4 0xD063  
PostgreSQL 8.3 0xD062  
PostgreSQL 8.2 0xD05E  
PostgreSQL 8.1 0xD05D  
PostgreSQL 8.0 0xD05C moved to src/include/access/xlog_internal.h
PostgreSQL 7.4 0xD05A same as PostgreSQL 7.3
PostgreSQL 7.3 0xD05A  
PostgreSQL 7.2 0xD059  
PostgreSQL 7.1 0xD058  
PostgreSQL 7.0 0x17345168 experimental


PostgreSQL internals, WAL