You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Add WAL info to PostgreSQL interface.
This allows the WAL header to be read for any supported version on PostgreSQL.
This commit is contained in:
@ -6,6 +6,7 @@ PostgreSQL 8.3 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -201,3 +202,35 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD062 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -49,6 +49,37 @@ pgInterfaceControl083(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs083(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal083(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs083(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -71,4 +102,20 @@ pgInterfaceControlTest083(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest083(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs083(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl083(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs083(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal083(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest083(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest083(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 8.4 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -206,3 +207,35 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD063 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -49,6 +49,37 @@ pgInterfaceControl084(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs084(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal084(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs084(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -71,4 +102,20 @@ pgInterfaceControlTest084(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest084(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs084(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl084(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs084(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal084(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest084(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest084(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.0 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -250,3 +251,35 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD064 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -49,6 +49,37 @@ pgInterfaceControl090(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs090(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal090(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs090(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -71,4 +102,20 @@ pgInterfaceControlTest090(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest090(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs090(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl090(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs090(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal090(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest090(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest090(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.1 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -250,3 +251,35 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD066 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -49,6 +49,37 @@ pgInterfaceControl091(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs091(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal091(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs091(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -71,4 +102,20 @@ pgInterfaceControlTest091(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest091(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs091(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl091(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs091(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal091(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest091(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest091(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.2 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -265,3 +266,35 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD071 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -49,6 +49,37 @@ pgInterfaceControl092(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs092(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal092(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs092(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -71,4 +102,20 @@ pgInterfaceControlTest092(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest092(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs092(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl092(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs092(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal092(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest092(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest092(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.3 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -260,3 +261,46 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD075 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
|
||||
/*
|
||||
* When there is not enough space on current page for whole record, we
|
||||
* continue on the next page. xlp_rem_len is the number of bytes
|
||||
* remaining from a previous page.
|
||||
*
|
||||
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
||||
* xl_tot_len not xl_len in the initial header. Also note that the
|
||||
* continuation data isn't necessarily aligned.
|
||||
*/
|
||||
uint32 xlp_rem_len; /* total len of remaining data for record */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -51,6 +51,37 @@ pgInterfaceControl093(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs093(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal093(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs093(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -75,4 +106,20 @@ pgInterfaceControlTest093(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest093(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs093(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl093(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs093(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal093(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest093(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest093(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.4 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -263,3 +264,46 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32 crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD07E /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
|
||||
/*
|
||||
* When there is not enough space on current page for whole record, we
|
||||
* continue on the next page. xlp_rem_len is the number of bytes
|
||||
* remaining from a previous page.
|
||||
*
|
||||
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
||||
* xl_tot_len not xl_len in the initial header. Also note that the
|
||||
* continuation data isn't necessarily aligned.
|
||||
*/
|
||||
uint32 xlp_rem_len; /* total len of remaining data for record */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -51,6 +51,37 @@ pgInterfaceControl094(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs094(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal094(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs094(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -75,4 +106,20 @@ pgInterfaceControlTest094(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest094(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs094(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl094(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs094(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal094(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest094(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest094(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.5 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -268,3 +269,46 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32c crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD087 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
|
||||
/*
|
||||
* When there is not enough space on current page for whole record, we
|
||||
* continue on the next page. xlp_rem_len is the number of bytes
|
||||
* remaining from a previous page.
|
||||
*
|
||||
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
||||
* xl_tot_len not xl_len in the initial header. Also note that the
|
||||
* continuation data isn't necessarily aligned.
|
||||
*/
|
||||
uint32 xlp_rem_len; /* total len of remaining data for record */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -51,6 +51,37 @@ pgInterfaceControl095(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs095(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal095(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs095(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -75,4 +106,20 @@ pgInterfaceControlTest095(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest095(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs095(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl095(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs095(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal095(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest095(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest095(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 9.6 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -268,3 +269,46 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32c crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD093 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
|
||||
/*
|
||||
* When there is not enough space on current page for whole record, we
|
||||
* continue on the next page. xlp_rem_len is the number of bytes
|
||||
* remaining from a previous page.
|
||||
*
|
||||
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
||||
* xl_tot_len not xl_len in the initial header. Also note that the
|
||||
* continuation data isn't necessarily aligned.
|
||||
*/
|
||||
uint32 xlp_rem_len; /* total len of remaining data for record */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -51,6 +51,37 @@ pgInterfaceControl096(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs096(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal096(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs096(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -75,4 +106,20 @@ pgInterfaceControlTest096(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest096(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs096(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl096(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs096(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal096(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest096(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest096(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 10 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -271,3 +272,46 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32c crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD097 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
|
||||
/*
|
||||
* When there is not enough space on current page for whole record, we
|
||||
* continue on the next page. xlp_rem_len is the number of bytes
|
||||
* remaining from a previous page.
|
||||
*
|
||||
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
||||
* xl_tot_len not xl_len in the initial header. Also note that the
|
||||
* continuation data isn't necessarily aligned.
|
||||
*/
|
||||
uint32 xlp_rem_len; /* total len of remaining data for record */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -51,6 +51,37 @@ pgInterfaceControl100(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs100(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal100(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs100(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -75,4 +106,20 @@ pgInterfaceControlTest100(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest100(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs100(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl100(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs100(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal100(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest100(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest100(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@ PostgreSQL 11 Types
|
||||
Types from src/include/c.h
|
||||
***********************************************************************************************************************************/
|
||||
typedef int64_t int64;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
@ -270,3 +271,46 @@ typedef struct ControlFileData
|
||||
/* CRC of all above ... MUST BE LAST! */
|
||||
pg_crc32c crc;
|
||||
} ControlFileData;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types from src/include/access/xlog_internal.h
|
||||
***********************************************************************************************************************************/
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD098 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
uint16 xlp_magic; /* magic value for correctness checks */
|
||||
uint16 xlp_info; /* flag bits, see below */
|
||||
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
||||
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
||||
|
||||
/*
|
||||
* When there is not enough space on current page for whole record, we
|
||||
* continue on the next page. xlp_rem_len is the number of bytes
|
||||
* remaining from a previous page.
|
||||
*
|
||||
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
||||
* xl_tot_len not xl_len in the initial header. Also note that the
|
||||
* continuation data isn't necessarily aligned.
|
||||
*/
|
||||
uint32 xlp_rem_len; /* total len of remaining data for record */
|
||||
} XLogPageHeaderData;
|
||||
|
||||
/*
|
||||
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
||||
* page header. (This is ordinarily done just in the first page of an
|
||||
* XLOG file.) The additional fields serve to identify the file accurately.
|
||||
*/
|
||||
typedef struct XLogLongPageHeaderData
|
||||
{
|
||||
XLogPageHeaderData std; /* standard header fields */
|
||||
uint64 xlp_sysid; /* system identifier from pg_control */
|
||||
uint32 xlp_seg_size; /* just as a cross-check */
|
||||
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
||||
} XLogLongPageHeaderData;
|
||||
|
||||
/* This flag indicates a "long" page header */
|
||||
#define XLP_LONG_HEADER 0x0002
|
||||
|
@ -51,6 +51,37 @@ pgInterfaceControl110(const Buffer *controlFile)
|
||||
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceWalIs110(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
|
||||
FUNCTION_TEST_RETURN(((XLogPageHeaderData *)bufPtr(walFile))->xlp_magic == XLOG_PAGE_MAGIC);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
PgWal
|
||||
pgInterfaceWal110(const Buffer *walFile)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BUFFER, walFile);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(walFile != NULL);
|
||||
ASSERT(pgInterfaceWalIs110(walFile));
|
||||
|
||||
PgWal result = {0};
|
||||
|
||||
result.systemId = ((XLogLongPageHeaderData *)bufPtr(walFile))->xlp_sysid;
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -75,4 +106,20 @@ pgInterfaceControlTest110(PgControl pgControl, Buffer *buffer)
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
pgInterfaceWalTest110(PgWal pgWal, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_WAL, pgWal);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
XLogLongPageHeaderData *walData = (XLogLongPageHeaderData *)bufPtr(buffer);
|
||||
|
||||
walData->std.xlp_magic = XLOG_PAGE_MAGIC;
|
||||
walData->xlp_sysid = pgWal.systemId;
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,15 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs110(const Buffer *controlFile);
|
||||
PgControl pgInterfaceControl110(const Buffer *controlFile);
|
||||
bool pgInterfaceWalIs110(const Buffer *walFile);
|
||||
PgWal pgInterfaceWal110(const Buffer *controlFile);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
void pgInterfaceControlTest110(PgControl pgControl, Buffer *buffer);
|
||||
void pgInterfaceWalTest110(PgWal pgWal, Buffer *buffer);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user