You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Improve PostgreSQL version identification.
Previously, catalog versions were fixed for all versions which made maintaining the catalog versions during PostgreSQL beta and release candidate cycles very painful. A version of pgBackRest which was functionally compatible was rendered useless by a catalog version bump in PostgreSQL. Instead use only the control version to identify a PostgreSQL version when possible. Some older versions require a catalog version to positively identify a PostgreSQL version, so include them when required. Since the catalog number is required to work with tablespaces it will need to be stored. There's already a copy of it in backup.info so use that (even though we have been ignoring it in the C versions).
This commit is contained in:
@ -66,9 +66,6 @@ typedef struct PgInterface
|
||||
// Version of PostgreSQL supported by this interface
|
||||
unsigned int version;
|
||||
|
||||
// Get the catalog version for this version of PostgreSQL
|
||||
uint32_t (*catalogVersion)(void);
|
||||
|
||||
// Does pg_control match this version of PostgreSQL?
|
||||
bool (*controlIs)(const unsigned char *);
|
||||
|
||||
@ -85,6 +82,8 @@ typedef struct PgInterface
|
||||
PgWal (*wal)(const unsigned char *);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Catalog version for testing
|
||||
unsigned int catalogVersion;
|
||||
|
||||
// Create pg_control for testing
|
||||
void (*controlTest)(PgControl, unsigned char *);
|
||||
@ -99,8 +98,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_13,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion130,
|
||||
|
||||
.controlIs = pgInterfaceControlIs130,
|
||||
.control = pgInterfaceControl130,
|
||||
.controlVersion = pgInterfaceControlVersion130,
|
||||
@ -109,6 +106,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal130,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 202007201,
|
||||
|
||||
.controlTest = pgInterfaceControlTest130,
|
||||
.walTest = pgInterfaceWalTest130,
|
||||
#endif
|
||||
@ -116,8 +115,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_12,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion120,
|
||||
|
||||
.controlIs = pgInterfaceControlIs120,
|
||||
.control = pgInterfaceControl120,
|
||||
.controlVersion = pgInterfaceControlVersion120,
|
||||
@ -126,6 +123,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal120,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201909212,
|
||||
|
||||
.controlTest = pgInterfaceControlTest120,
|
||||
.walTest = pgInterfaceWalTest120,
|
||||
#endif
|
||||
@ -133,8 +132,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_11,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion110,
|
||||
|
||||
.controlIs = pgInterfaceControlIs110,
|
||||
.control = pgInterfaceControl110,
|
||||
.controlVersion = pgInterfaceControlVersion110,
|
||||
@ -143,6 +140,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal110,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201809051,
|
||||
|
||||
.controlTest = pgInterfaceControlTest110,
|
||||
.walTest = pgInterfaceWalTest110,
|
||||
#endif
|
||||
@ -150,8 +149,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_10,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion100,
|
||||
|
||||
.controlIs = pgInterfaceControlIs100,
|
||||
.control = pgInterfaceControl100,
|
||||
.controlVersion = pgInterfaceControlVersion100,
|
||||
@ -160,6 +157,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal100,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201707211,
|
||||
|
||||
.controlTest = pgInterfaceControlTest100,
|
||||
.walTest = pgInterfaceWalTest100,
|
||||
#endif
|
||||
@ -167,8 +166,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_96,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion096,
|
||||
|
||||
.controlIs = pgInterfaceControlIs096,
|
||||
.control = pgInterfaceControl096,
|
||||
.controlVersion = pgInterfaceControlVersion096,
|
||||
@ -177,6 +174,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal096,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201608131,
|
||||
|
||||
.controlTest = pgInterfaceControlTest096,
|
||||
.walTest = pgInterfaceWalTest096,
|
||||
#endif
|
||||
@ -184,8 +183,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_95,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion095,
|
||||
|
||||
.controlIs = pgInterfaceControlIs095,
|
||||
.control = pgInterfaceControl095,
|
||||
.controlVersion = pgInterfaceControlVersion095,
|
||||
@ -194,6 +191,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal095,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201510051,
|
||||
|
||||
.controlTest = pgInterfaceControlTest095,
|
||||
.walTest = pgInterfaceWalTest095,
|
||||
#endif
|
||||
@ -201,8 +200,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_94,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion094,
|
||||
|
||||
.controlIs = pgInterfaceControlIs094,
|
||||
.control = pgInterfaceControl094,
|
||||
.controlVersion = pgInterfaceControlVersion094,
|
||||
@ -211,6 +208,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal094,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201409291,
|
||||
|
||||
.controlTest = pgInterfaceControlTest094,
|
||||
.walTest = pgInterfaceWalTest094,
|
||||
#endif
|
||||
@ -218,8 +217,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_93,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion093,
|
||||
|
||||
.controlIs = pgInterfaceControlIs093,
|
||||
.control = pgInterfaceControl093,
|
||||
.controlVersion = pgInterfaceControlVersion093,
|
||||
@ -228,6 +225,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal093,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201306121,
|
||||
|
||||
.controlTest = pgInterfaceControlTest093,
|
||||
.walTest = pgInterfaceWalTest093,
|
||||
#endif
|
||||
@ -235,8 +234,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_92,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion092,
|
||||
|
||||
.controlIs = pgInterfaceControlIs092,
|
||||
.control = pgInterfaceControl092,
|
||||
.controlVersion = pgInterfaceControlVersion092,
|
||||
@ -245,6 +242,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal092,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201204301,
|
||||
|
||||
.controlTest = pgInterfaceControlTest092,
|
||||
.walTest = pgInterfaceWalTest092,
|
||||
#endif
|
||||
@ -252,8 +251,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_91,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion091,
|
||||
|
||||
.controlIs = pgInterfaceControlIs091,
|
||||
.control = pgInterfaceControl091,
|
||||
.controlVersion = pgInterfaceControlVersion091,
|
||||
@ -262,6 +259,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal091,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201105231,
|
||||
|
||||
.controlTest = pgInterfaceControlTest091,
|
||||
.walTest = pgInterfaceWalTest091,
|
||||
#endif
|
||||
@ -269,8 +268,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_90,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion090,
|
||||
|
||||
.controlIs = pgInterfaceControlIs090,
|
||||
.control = pgInterfaceControl090,
|
||||
.controlVersion = pgInterfaceControlVersion090,
|
||||
@ -279,6 +276,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal090,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 201008051,
|
||||
|
||||
.controlTest = pgInterfaceControlTest090,
|
||||
.walTest = pgInterfaceWalTest090,
|
||||
#endif
|
||||
@ -286,8 +285,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_84,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion084,
|
||||
|
||||
.controlIs = pgInterfaceControlIs084,
|
||||
.control = pgInterfaceControl084,
|
||||
.controlVersion = pgInterfaceControlVersion084,
|
||||
@ -296,6 +293,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal084,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 200904091,
|
||||
|
||||
.controlTest = pgInterfaceControlTest084,
|
||||
.walTest = pgInterfaceWalTest084,
|
||||
#endif
|
||||
@ -303,8 +302,6 @@ static const PgInterface pgInterface[] =
|
||||
{
|
||||
.version = PG_VERSION_83,
|
||||
|
||||
.catalogVersion = pgInterfaceCatalogVersion083,
|
||||
|
||||
.controlIs = pgInterfaceControlIs083,
|
||||
.control = pgInterfaceControl083,
|
||||
.controlVersion = pgInterfaceControlVersion083,
|
||||
@ -313,6 +310,8 @@ static const PgInterface pgInterface[] =
|
||||
.wal = pgInterfaceWal083,
|
||||
|
||||
#ifdef DEBUG
|
||||
.catalogVersion = 200711281,
|
||||
|
||||
.controlTest = pgInterfaceControlTest083,
|
||||
.walTest = pgInterfaceWalTest083,
|
||||
#endif
|
||||
@ -361,17 +360,6 @@ pgInterfaceVersion(unsigned int pgVersion)
|
||||
FUNCTION_TEST_RETURN(result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
uint32_t
|
||||
pgCatalogVersion(unsigned int pgVersion)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(pgInterfaceVersion(pgVersion)->catalogVersion());
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Check expected WAL segment size for older PostgreSQL versions
|
||||
***********************************************************************************************************************************/
|
||||
@ -559,10 +547,11 @@ pgWalFromFile(const String *walFile, const Storage *storage)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
String *
|
||||
pgTablespaceId(unsigned int pgVersion)
|
||||
pgTablespaceId(unsigned int pgVersion, unsigned int pgCatalogVersion)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_PARAM(UINT, pgCatalogVersion);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
String *result = NULL;
|
||||
@ -575,7 +564,7 @@ pgTablespaceId(unsigned int pgVersion)
|
||||
|
||||
MEM_CONTEXT_PRIOR_BEGIN()
|
||||
{
|
||||
result = strNewFmt("PG_%s_%u", strZ(pgVersionStr), pgCatalogVersion(pgVersion));
|
||||
result = strNewFmt("PG_%s_%u", strZ(pgVersionStr), pgCatalogVersion);
|
||||
}
|
||||
MEM_CONTEXT_PRIOR_END();
|
||||
}
|
||||
@ -758,6 +747,21 @@ pgXactPath(unsigned int pgVersion)
|
||||
/**********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
|
||||
unsigned int
|
||||
pgCatalogTestVersion(unsigned int pgVersion)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(pgInterfaceVersion(pgVersion)->catalogVersion);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
|
||||
Buffer *
|
||||
pgControlTestToBuffer(PgControl pgControl)
|
||||
{
|
||||
@ -768,6 +772,8 @@ pgControlTestToBuffer(PgControl pgControl)
|
||||
// Set defaults if values are not passed
|
||||
pgControl.pageSize = pgControl.pageSize == 0 ? PG_PAGE_SIZE_DEFAULT : pgControl.pageSize;
|
||||
pgControl.walSegmentSize = pgControl.walSegmentSize == 0 ? PG_WAL_SEGMENT_SIZE_DEFAULT : pgControl.walSegmentSize;
|
||||
pgControl.catalogVersion = pgControl.catalogVersion == 0 ?
|
||||
pgInterfaceVersion(pgControl.version)->catalogVersion : pgControl.catalogVersion;
|
||||
|
||||
// Create the buffer and clear it
|
||||
Buffer *result = bufNew(PG_CONTROL_SIZE);
|
||||
|
@ -109,6 +109,7 @@ typedef struct PgControl
|
||||
{
|
||||
unsigned int version;
|
||||
uint64_t systemId;
|
||||
unsigned int catalogVersion;
|
||||
|
||||
unsigned int pageSize;
|
||||
unsigned int walSegmentSize;
|
||||
@ -129,9 +130,6 @@ typedef struct PgWal
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Get the catalog version for a PostgreSQL version
|
||||
uint32_t pgCatalogVersion(unsigned int pgVersion);
|
||||
|
||||
// Get info from pg_control
|
||||
PgControl pgControlFromFile(const Storage *storage);
|
||||
PgControl pgControlFromBuffer(const Buffer *controlFile);
|
||||
@ -148,7 +146,7 @@ PgWal pgWalFromFile(const String *walFile, const Storage *storage);
|
||||
PgWal pgWalFromBuffer(const Buffer *walBuffer);
|
||||
|
||||
// Get the tablespace identifier used to distinguish versions in a tablespace directory, e.g. PG_9.0_201008051
|
||||
String *pgTablespaceId(unsigned int pgVersion);
|
||||
String *pgTablespaceId(unsigned int pgVersion, unsigned int pgCatalogVersion);
|
||||
|
||||
// Convert a string to an lsn and vice versa
|
||||
uint64_t pgLsnFromStr(const String *lsn);
|
||||
@ -180,6 +178,9 @@ const String *pgXactPath(unsigned int pgVersion);
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
// Get the catalog version for a PostgreSQL version for testing
|
||||
unsigned int pgCatalogTestVersion(unsigned int pgVersion);
|
||||
|
||||
// Create pg_control for testing
|
||||
Buffer *pgControlTestToBuffer(PgControl pgControl);
|
||||
|
||||
|
@ -9,91 +9,78 @@ PostgreSQL Version Interface
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
uint32_t pgInterfaceCatalogVersion083(void);
|
||||
bool pgInterfaceControlIs083(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl083(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion083(void);
|
||||
bool pgInterfaceWalIs083(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal083(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion084(void);
|
||||
bool pgInterfaceControlIs084(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl084(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion084(void);
|
||||
bool pgInterfaceWalIs084(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal084(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion090(void);
|
||||
bool pgInterfaceControlIs090(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl090(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion090(void);
|
||||
bool pgInterfaceWalIs090(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal090(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion091(void);
|
||||
bool pgInterfaceControlIs091(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl091(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion091(void);
|
||||
bool pgInterfaceWalIs091(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal091(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion092(void);
|
||||
bool pgInterfaceControlIs092(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl092(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion092(void);
|
||||
bool pgInterfaceWalIs092(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal092(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion093(void);
|
||||
bool pgInterfaceControlIs093(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl093(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion093(void);
|
||||
bool pgInterfaceWalIs093(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal093(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion094(void);
|
||||
bool pgInterfaceControlIs094(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl094(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion094(void);
|
||||
bool pgInterfaceWalIs094(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal094(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion095(void);
|
||||
bool pgInterfaceControlIs095(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl095(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion095(void);
|
||||
bool pgInterfaceWalIs095(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal095(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion096(void);
|
||||
bool pgInterfaceControlIs096(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl096(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion096(void);
|
||||
bool pgInterfaceWalIs096(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal096(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion100(void);
|
||||
bool pgInterfaceControlIs100(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl100(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion100(void);
|
||||
bool pgInterfaceWalIs100(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal100(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion110(void);
|
||||
bool pgInterfaceControlIs110(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl110(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion110(void);
|
||||
bool pgInterfaceWalIs110(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal110(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion120(void);
|
||||
bool pgInterfaceControlIs120(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl120(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion120(void);
|
||||
bool pgInterfaceWalIs120(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal120(const unsigned char *controlFile);
|
||||
|
||||
uint32_t pgInterfaceCatalogVersion130(void);
|
||||
bool pgInterfaceControlIs130(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl130(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion130(void);
|
||||
|
@ -17,22 +17,6 @@ Each version of PostgreSQL will need a vXXX.c file to contain the version-specif
|
||||
|
||||
#include "postgres/interface/version.vendor.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get the catalog version
|
||||
***********************************************************************************************************************************/
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_83
|
||||
|
||||
#define PG_INTERFACE_CATALOG_VERSION(version) \
|
||||
uint32_t \
|
||||
pgInterfaceCatalogVersion##version(void) \
|
||||
{ \
|
||||
return CATALOG_VERSION_NO; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
***********************************************************************************************************************************/
|
||||
@ -40,6 +24,8 @@ Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_83
|
||||
|
||||
#ifdef CATALOG_VERSION_NO
|
||||
|
||||
#define PG_INTERFACE_CONTROL_IS(version) \
|
||||
bool \
|
||||
pgInterfaceControlIs##version(const unsigned char *controlFile) \
|
||||
@ -51,6 +37,19 @@ Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
((ControlFileData *)controlFile)->catalog_version_no == CATALOG_VERSION_NO; \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define PG_INTERFACE_CONTROL_IS(version) \
|
||||
bool \
|
||||
pgInterfaceControlIs##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
\
|
||||
return ((ControlFileData *)controlFile)->pg_control_version == PG_CONTROL_VERSION; \
|
||||
}
|
||||
|
||||
#endif // CATALOG_VERSION_NO
|
||||
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -70,6 +69,7 @@ Read the version specific pg_control into a general data structure
|
||||
return (PgControl) \
|
||||
{ \
|
||||
.systemId = ((ControlFileData *)controlFile)->system_identifier, \
|
||||
.catalogVersion = ((ControlFileData *)controlFile)->catalog_version_no, \
|
||||
.pageSize = ((ControlFileData *)controlFile)->blcksz, \
|
||||
.walSegmentSize = ((ControlFileData *)controlFile)->xlog_seg_size, \
|
||||
.pageChecksum = ((ControlFileData *)controlFile)->data_checksum_version != 0, \
|
||||
@ -88,6 +88,7 @@ Read the version specific pg_control into a general data structure
|
||||
return (PgControl) \
|
||||
{ \
|
||||
.systemId = ((ControlFileData *)controlFile)->system_identifier, \
|
||||
.catalogVersion = ((ControlFileData *)controlFile)->catalog_version_no, \
|
||||
.pageSize = ((ControlFileData *)controlFile)->blcksz, \
|
||||
.walSegmentSize = ((ControlFileData *)controlFile)->xlog_seg_size, \
|
||||
}; \
|
||||
@ -128,7 +129,7 @@ Create a pg_control file for testing
|
||||
{ \
|
||||
.system_identifier = pgControl.systemId, \
|
||||
.pg_control_version = PG_CONTROL_VERSION, \
|
||||
.catalog_version_no = CATALOG_VERSION_NO, \
|
||||
.catalog_version_no = pgControl.catalogVersion, \
|
||||
.blcksz = pgControl.pageSize, \
|
||||
.xlog_seg_size = pgControl.walSegmentSize, \
|
||||
.data_checksum_version = pgControl.pageChecksum, \
|
||||
@ -148,7 +149,7 @@ Create a pg_control file for testing
|
||||
{ \
|
||||
.system_identifier = pgControl.systemId, \
|
||||
.pg_control_version = PG_CONTROL_VERSION, \
|
||||
.catalog_version_no = CATALOG_VERSION_NO, \
|
||||
.catalog_version_no = pgControl.catalogVersion, \
|
||||
.blcksz = pgControl.pageSize, \
|
||||
.xlog_seg_size = pgControl.walSegmentSize, \
|
||||
}; \
|
||||
@ -220,7 +221,6 @@ Create a WAL file file for testing
|
||||
Call all macros with a single macro to make the vXXX.c files as simple as possible
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_INTERFACE_BASE(version) \
|
||||
PG_INTERFACE_CATALOG_VERSION(version) \
|
||||
PG_INTERFACE_CONTROL_IS(version) \
|
||||
PG_INTERFACE_CONTROL(version) \
|
||||
PG_INTERFACE_CONTROL_VERSION(version) \
|
||||
|
@ -177,71 +177,17 @@ Types from src/include/catalog/catversion.h
|
||||
***********************************************************************************************************************************/
|
||||
|
||||
// CATALOG_VERSION_NO define
|
||||
//
|
||||
// Add CATALOG_VERSION_NO when more than one PostgreSQL version shares a control version so the PostgreSQL version can be reliably
|
||||
// identified. Newer versions of PostgreSQL have bumped the control version but that has not always been the case.
|
||||
//
|
||||
// Undef CATALOG_VERSION_NO in PostgreSQL versions where it is not required to improve readability.
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_13
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202007201
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_12
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201909212
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_11
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201809051
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_10
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201707211
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_96
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201608131
|
||||
#undef CATALOG_VERSION_NO
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_95
|
||||
|
||||
@ -269,31 +215,9 @@ Types from src/include/catalog/catversion.h
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201409291
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_93
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201306121
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_92
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201204301
|
||||
#undef CATALOG_VERSION_NO
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_91
|
||||
|
||||
@ -321,31 +245,9 @@ Types from src/include/catalog/catversion.h
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201008051
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_84
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 200904091
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_83
|
||||
|
||||
/*
|
||||
* We could use anything we wanted for version numbers, but I recommend
|
||||
* following the "YYYYMMDDN" style often used for DNS zone serial numbers.
|
||||
* YYYYMMDD are the date of the change, and N is the number of the change
|
||||
* on that day. (Hopefully we'll never commit ten independent sets of
|
||||
* catalog changes on the same day...)
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 200711281
|
||||
#undef CATALOG_VERSION_NO
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user