1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +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:
David Steele
2020-09-18 16:55:26 -04:00
committed by GitHub
parent 94475bfbe6
commit 927d9adbee
26 changed files with 259 additions and 270 deletions

View File

@ -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);

View File

@ -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) \

View File

@ -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