You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-05 04:30:41 +03: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);
|
||||
|
||||
Reference in New Issue
Block a user