You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Automatically create PostgreSQL version interfaces.
Maintaining the version interfaces was complicated by the fact that each interface needed to be in separate compilation unit to avoid type conflicts. This also meant that various build/test files needed to be updated to add the new interfaces. Solve these problems by auto-generating all the interfaces into a single file. This is made possible by parsing defines and types out of the header files and creating macros to rename the types. At the end of the version interface everything is undef'd. Another benefit is that the auto-generated interfaces can be static and included directly into postgres/interface.c. Since some code generation is now always required for tests, change --no-gen to --min-gen in test.pl. It would also make sense to auto-generate the version defines in postgres/version.h, but that will be left for a future commit.
This commit is contained in:
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.0 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_90
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(090);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.1 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_91
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(091);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.2 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_92
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(092);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.3 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_93
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(093);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.4 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_94
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(094);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.5 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_95
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(095);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.6 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_96
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(096);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 10 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_10
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(100);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 11 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_11
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(110);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 12 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_12
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(120);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 13 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_13
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(130);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 14 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_14
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(140);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 15 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_15
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(150);
|
@ -1,90 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Version Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef POSTGRES_INTERFACE_VERSION_H
|
||||
#define POSTGRES_INTERFACE_VERSION_H
|
||||
|
||||
#include "postgres/interface.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
bool pgInterfaceControlIs130(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl130(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion130(void);
|
||||
bool pgInterfaceWalIs130(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal130(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs140(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl140(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion140(void);
|
||||
bool pgInterfaceWalIs140(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal140(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs150(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl150(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion150(void);
|
||||
bool pgInterfaceWalIs150(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal150(const unsigned char *controlFile);
|
||||
|
||||
#endif
|
@ -1,24 +1,18 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Version Interface
|
||||
|
||||
Macros for building version-specific functions that interface with the types in version.vendor.h. Due to the way PostgreSQL types
|
||||
Macros for building version-specific functions that interface with the types in version.vendor.h. Due to the way PostgreSQL types
|
||||
evolve over time, this seems to be the easiest way to extract information from them.
|
||||
|
||||
These macros should be kept as simple as possible, with most of the logic contained in postgres/interface.c.
|
||||
|
||||
Each version of PostgreSQL will need a vXXX.c file to contain the version-specific functions created by these macros.
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef POSTGRES_INTERFACE_VERSIONINTERN_H
|
||||
#define POSTGRES_INTERFACE_VERSIONINTERN_H
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "postgres/interface/version.h"
|
||||
#include "postgres/interface/version.vendor.h"
|
||||
#include "postgres/version.h"
|
||||
|
||||
#include "postgres/interface/version.vendor.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
Determine if the supplied pg_control is for this version of PostgreSQL. When CATALOG_VERSION_NO_MAX is defined then the catalog will
|
||||
be accepted as a range that lasts until the end of the encoded year. This allows pgBackRest to work with PostgreSQL during the
|
||||
alpha/beta/rc period without needing to be updated, unless of course the actual interface changes.
|
||||
***********************************************************************************************************************************/
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
@ -27,7 +21,7 @@ Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
#ifdef CATALOG_VERSION_NO_MAX
|
||||
|
||||
#define PG_INTERFACE_CONTROL_IS(version) \
|
||||
bool \
|
||||
static bool \
|
||||
pgInterfaceControlIs##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -41,7 +35,7 @@ Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
#else
|
||||
|
||||
#define PG_INTERFACE_CONTROL_IS(version) \
|
||||
bool \
|
||||
static bool \
|
||||
pgInterfaceControlIs##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -63,7 +57,7 @@ Read the version specific pg_control into a general data structure
|
||||
#elif PG_VERSION >= PG_VERSION_93
|
||||
|
||||
#define PG_INTERFACE_CONTROL(version) \
|
||||
PgControl \
|
||||
static PgControl \
|
||||
pgInterfaceControl##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -84,7 +78,7 @@ Read the version specific pg_control into a general data structure
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_CONTROL(version) \
|
||||
PgControl \
|
||||
static PgControl \
|
||||
pgInterfaceControl##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -113,7 +107,7 @@ Get the control version
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_CONTROL_VERSION(version) \
|
||||
uint32_t \
|
||||
static uint32_t \
|
||||
pgInterfaceControlVersion##version(void) \
|
||||
{ \
|
||||
return PG_CONTROL_VERSION; \
|
||||
@ -129,7 +123,7 @@ Determine if the supplied WAL is for this version of PostgreSQL
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_WAL_IS(version) \
|
||||
bool \
|
||||
static bool \
|
||||
pgInterfaceWalIs##version(const unsigned char *walFile) \
|
||||
{ \
|
||||
ASSERT(walFile != NULL); \
|
||||
@ -147,7 +141,7 @@ Read the version specific WAL header into a general data structure
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_WAL(version) \
|
||||
PgWal \
|
||||
static PgWal \
|
||||
pgInterfaceWal##version(const unsigned char *walFile) \
|
||||
{ \
|
||||
ASSERT(walFile != NULL); \
|
||||
@ -161,15 +155,3 @@ Read the version specific WAL header into a general data structure
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Call all macros with a single macro to make the vXXX.c files as simple as possible
|
||||
***********************************************************************************************************************************/
|
||||
#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)
|
||||
|
||||
#endif
|
||||
|
@ -177,12 +177,6 @@ Types from src/include/catalog/catversion.h
|
||||
***********************************************************************************************************************************/
|
||||
|
||||
// CATALOG_VERSION_NO define
|
||||
//
|
||||
// When PostgreSQL is in alpha/beta/rc the catalog version may change with each release. To prevent breakage during this period
|
||||
// define CATATLOG_VERSION_NO_MAX. This will allow the catalog version to "float" through the end of the year. After the PostgreSQL
|
||||
// release, remove CATALOG_VERSION_NO_MAX in the next pgBackRest release to lock down the catalog version. A side effect of this is
|
||||
// that during the period when the catalog number is allowed to float pgBackRest may misidentify development versions of PostgreSQL
|
||||
// for the next release as being an alpha/beta/rc for the current release. This seems a minor issue to prevent breakage.
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
@ -199,9 +193,6 @@ Types from src/include/catalog/catversion.h
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202204076
|
||||
|
||||
// Allow the catalog version to float during the PostgreSQL 15 beta/rc period
|
||||
#define CATALOG_VERSION_NO_MAX
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_14
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user