1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Replace XLogRecPtr struct with a 64-bit integer.

This simplifies code that needs to do arithmetic on XLogRecPtrs.

To avoid changing on-disk format of data pages, the LSN on data pages is
still stored in the old format. That should keep pg_upgrade happy. However,
we have XLogRecPtrs embedded in the control file, and in the structs that
are sent over the replication protocol, so this changes breaks compatibility
of pg_basebackup and server. I didn't do anything about this in this patch,
per discussion on -hackers, the right thing to do would to be to change the
replication protocol to be architecture-independent, so that you could use
a newer version of pg_receivexlog, for example, against an older server
version.
This commit is contained in:
Heikki Linnakangas
2012-06-24 18:51:37 +03:00
parent 061e7efb1b
commit 0ab9d1c4b3
28 changed files with 279 additions and 357 deletions

View File

@@ -119,10 +119,18 @@ typedef uint16 LocationIndex;
* On the high end, we can only support pages up to 32KB because lp_off/lp_len
* are 15 bits.
*/
/* for historical reasons, the LSN is stored as two 32-bit values. */
typedef struct
{
uint32 xlogid; /* high bits */
uint32 xrecoff; /* low bits */
} PageXLogRecPtr;
typedef struct PageHeaderData
{
/* XXX LSN is member of *any* block, not only page-organized ones */
XLogRecPtr pd_lsn; /* LSN: next byte after last byte of xlog
PageXLogRecPtr pd_lsn; /* LSN: next byte after last byte of xlog
* record for last change to this page */
uint16 pd_tli; /* least significant bits of the TimeLineID
* containing the LSN */
@@ -314,9 +322,10 @@ typedef PageHeaderData *PageHeader;
* Additional macros for access to page headers
*/
#define PageGetLSN(page) \
(((PageHeader) (page))->pd_lsn)
((uint64) ((PageHeader) (page))->pd_lsn.xlogid << 32 | ((PageHeader) (page))->pd_lsn.xrecoff)
#define PageSetLSN(page, lsn) \
(((PageHeader) (page))->pd_lsn = (lsn))
(((PageHeader) (page))->pd_lsn.xlogid = (uint32) ((lsn) >> 32), \
((PageHeader) (page))->pd_lsn.xrecoff = (uint32) (lsn))
/* NOTE: only the 16 least significant bits are stored */
#define PageGetTLI(page) \