1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Move PostgreSQL version interface test functions to a test harness.

Some version interface test functions were integrated into the core code because they relied on the PostgreSQL versioned interface. Even though they were compiled out for production builds they cluttered the core code and made it harder to determine what was required by core.

Create a PostgreSQL version interface in a test harness to contain these functions. This does require some duplication but the cleaner core code seems a good tradeoff. It is possible for some of this code to be auto-generated but since it is only updated once per year the matter is not pressing.
This commit is contained in:
David Steele
2021-05-17 07:20:28 -04:00
parent 18cc02238b
commit ae7f0af202
33 changed files with 664 additions and 426 deletions

View File

@ -87,48 +87,4 @@ uint32_t pgInterfaceControlVersion130(void);
bool pgInterfaceWalIs130(const unsigned char *walFile);
PgWal pgInterfaceWal130(const unsigned char *controlFile);
/***********************************************************************************************************************************
Test Functions
***********************************************************************************************************************************/
#ifdef DEBUG
void pgInterfaceControlTest083(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest083(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest084(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest084(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest090(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest090(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest091(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest091(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest092(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest092(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest093(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest093(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest094(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest094(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest095(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest095(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest096(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest096(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest100(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest100(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest110(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest110(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest120(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest120(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest130(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest130(PgWal pgWal, unsigned char *buffer);
#endif
#endif

View File

@ -97,51 +97,6 @@ Get the control version
#endif
/***********************************************************************************************************************************
Create a pg_control file for testing
***********************************************************************************************************************************/
#if PG_VERSION > PG_VERSION_MAX
#elif PG_VERSION >= PG_VERSION_93
#define PG_INTERFACE_CONTROL_TEST(version) \
void \
pgInterfaceControlTest##version(PgControl pgControl, unsigned char *buffer) \
{ \
ASSERT(buffer != NULL); \
\
*(ControlFileData *)buffer = (ControlFileData) \
{ \
.system_identifier = pgControl.systemId, \
.pg_control_version = PG_CONTROL_VERSION, \
.catalog_version_no = pgControl.catalogVersion, \
.blcksz = pgControl.pageSize, \
.xlog_seg_size = pgControl.walSegmentSize, \
.data_checksum_version = pgControl.pageChecksum, \
}; \
}
#elif PG_VERSION >= PG_VERSION_83
#define PG_INTERFACE_CONTROL_TEST(version) \
void \
pgInterfaceControlTest##version(PgControl pgControl, unsigned char *buffer) \
{ \
ASSERT(buffer != NULL); \
ASSERT(!pgControl.pageChecksum); \
\
*(ControlFileData *)buffer = (ControlFileData) \
{ \
.system_identifier = pgControl.systemId, \
.pg_control_version = PG_CONTROL_VERSION, \
.catalog_version_no = pgControl.catalogVersion, \
.blcksz = pgControl.pageSize, \
.xlog_seg_size = pgControl.walSegmentSize, \
}; \
}
#endif
/***********************************************************************************************************************************
Determine if the supplied WAL is for this version of PostgreSQL
***********************************************************************************************************************************/
@ -183,47 +138,14 @@ Read the version specific WAL header into a general data structure
#endif
/***********************************************************************************************************************************
Create a WAL file file for testing
***********************************************************************************************************************************/
#if PG_VERSION > PG_VERSION_MAX
#elif PG_VERSION >= PG_VERSION_83
#define PG_INTERFACE_WAL_TEST(version) \
void \
pgInterfaceWalTest##version(PgWal pgWal, unsigned char *buffer) \
{ \
((XLogLongPageHeaderData *)buffer)->std.xlp_magic = XLOG_PAGE_MAGIC; \
((XLogLongPageHeaderData *)buffer)->std.xlp_info = XLP_LONG_HEADER; \
((XLogLongPageHeaderData *)buffer)->xlp_sysid = pgWal.systemId; \
((XLogLongPageHeaderData *)buffer)->xlp_seg_size = pgWal.size; \
}
#endif
/***********************************************************************************************************************************
Call all macros with a single macro to make the vXXX.c files as simple as possible
***********************************************************************************************************************************/
#define PG_INTERFACE_BASE(version) \
#define PG_INTERFACE(version) \
PG_INTERFACE_CONTROL_IS(version) \
PG_INTERFACE_CONTROL(version) \
PG_INTERFACE_CONTROL_VERSION(version) \
PG_INTERFACE_WAL_IS(version) \
PG_INTERFACE_WAL(version)
#ifdef DEBUG
#define PG_INTERFACE(version) \
PG_INTERFACE_BASE(version) \
PG_INTERFACE_CONTROL_TEST(version) \
PG_INTERFACE_WAL_TEST(version)
#else
#define PG_INTERFACE(version) \
PG_INTERFACE_BASE(version)
#endif
#endif