XLOG_PAGE_MAGIC

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 only became practically useful with 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 Commit Notes
PostgreSQL 15 0xD10E 445e36ad not final
PostgreSQL 14 0xD10D 08aa89b3
PostgreSQL 13 0xD106 c6b92041  
PostgreSQL 12 0xD101 b5f58cf2  
PostgreSQL 11 0xD098 cf5a1890  
PostgreSQL 10 0xD097 ea42cc18
PostgreSQL 9.6 0xD093 65578341  
PostgreSQL 9.5 0xD087 6e8af376  
PostgreSQL 9.4 0xD07E 8776faa8  
PostgreSQL 9.3 0xD075 0ab9d1c4  
PostgreSQL 9.2 0xD071 3424bff9  
PostgreSQL 9.1 0xD066 d2bc1c99  
PostgreSQL 9.0 0xD064 9b8a7332  
PostgreSQL 8.4 0xD063 cd004067  
PostgreSQL 8.3 0xD062 a8d539f1  
PostgreSQL 8.2 0xD05E 09b5271e  
PostgreSQL 8.1 0xD05D 21fda22e  
PostgreSQL 8.0 0xD05C 2042b342 moved to src/include/access/xlog_internal.h (commit 2042b342)
PostgreSQL 7.4 0xD05A n/a same as PostgreSQL 7.3
PostgreSQL 7.3 0xD05A c87469e6  
PostgreSQL 7.2 0xD059 7d4d5c00  
PostgreSQL 7.1 0xD058 1b87e24c  
PostgreSQL 7.0 0x17345168 30659d43 experimental

Categories

PostgreSQL internals, WAL