You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Centralize PostgreSQL page header data structures.
These data structures were copied a few places (but only once in the core code) so put them in a place where everyone can use them. To do this create a new file, static.auto.h, to contain data types and macros that have stayed the same through all the versions of PostgreSQL that we support. This allows us to have single, non-versioned set of headers and code for stable data structures like page headers. Migrate a few types from version.auto.h that are required for page header structures and pull the remaining types from PostgreSQL directly. We had previously renamed xlog to wal so update those where required since we won't be modifying the PostgreSQL names anymore.
This commit is contained in:
@ -5,27 +5,9 @@ Test Common Functions and Definitions for Backup and Expire Commands
|
||||
#include "common/regExp.h"
|
||||
#include "common/type/json.h"
|
||||
#include "postgres/interface.h"
|
||||
#include "postgres/interface/static.auto.h"
|
||||
#include "storage/posix/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Need these structures to mock up test data
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t walid; // high bits
|
||||
uint32_t xrecoff; // low bits
|
||||
} PageWalRecPtr;
|
||||
|
||||
typedef struct PageHeaderData
|
||||
{
|
||||
// LSN is member of *any* block, not only page-organized ones
|
||||
PageWalRecPtr pd_lsn; // Lsn for last change to this page
|
||||
uint16_t pd_checksum; // checksum
|
||||
uint16_t pd_flags; // flag bits, see below
|
||||
uint16_t pd_lower; // offset to start of free space
|
||||
uint16_t pd_upper; // offset to end of free space
|
||||
} PageHeaderData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
***********************************************************************************************************************************/
|
||||
@ -150,9 +132,9 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x00)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.walid = 0xF0F0F0F0,
|
||||
.xlogid = 0xF0F0F0F0,
|
||||
.xrecoff = 0xF0F0F0F0,
|
||||
},
|
||||
};
|
||||
@ -183,9 +165,9 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x00)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.walid = 0xF0F0F0F0,
|
||||
.xlogid = 0xF0F0F0F0,
|
||||
.xrecoff = 0xF0F0F0F0,
|
||||
},
|
||||
};
|
||||
@ -194,9 +176,9 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x01)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.walid = 0xFACEFACE,
|
||||
.xlogid = 0xFACEFACE,
|
||||
.xrecoff = 0x00000000,
|
||||
},
|
||||
};
|
||||
@ -205,7 +187,7 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x02)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.xrecoff = 0x2,
|
||||
},
|
||||
@ -215,7 +197,7 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x03)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.xrecoff = 0x3,
|
||||
},
|
||||
@ -225,7 +207,7 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x04)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.xrecoff = 0x4,
|
||||
},
|
||||
@ -238,7 +220,7 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x06)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.xrecoff = 0x6,
|
||||
},
|
||||
@ -248,7 +230,7 @@ testRun(void)
|
||||
*(PageHeaderData *)(bufPtr(buffer) + (PG_PAGE_SIZE_DEFAULT * 0x07)) = (PageHeaderData)
|
||||
{
|
||||
.pd_upper = 0x01,
|
||||
.pd_lsn = (PageWalRecPtr)
|
||||
.pd_lsn = (PageXLogRecPtr)
|
||||
{
|
||||
.xrecoff = 0x7,
|
||||
},
|
||||
|
Reference in New Issue
Block a user