mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-02-19 19:44:38 +02:00
Autogenerate PostgreSQL versions.
This will make adding/removing versions of PostgreSQL more reliable.
This commit is contained in:
parent
a05bf6bb15
commit
8240eb5da5
@ -92,6 +92,9 @@ main(const int argListSize, const char *const argList[])
|
||||
// PostgreSQL
|
||||
if (strEqZ(STRDEF("postgres"), argList[1]))
|
||||
bldPgRender(storageBuild, bldPgParse(storageRepo));
|
||||
|
||||
if (strEqZ(STRDEF("postgres-version"), argList[1]))
|
||||
bldPgVersionRender(storageBuild, bldPgParse(storageRepo));
|
||||
}
|
||||
CATCH_FATAL()
|
||||
{
|
||||
|
@ -140,3 +140,90 @@ bldPgRender(const Storage *const storageRepo, const BldPg bldPg)
|
||||
{
|
||||
bldPgRenderInterfaceAutoC(storageRepo, bldPg);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Render version.auto.h
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_VERSION_MODULE "postgres-version"
|
||||
#define PG_VERSION_AUTO_COMMENT "PostgreSQL Version"
|
||||
|
||||
static void
|
||||
bldPgRenderVersionAutoH(const Storage *const storageRepo, const BldPg bldPg)
|
||||
{
|
||||
String *const pg = strCatFmt(
|
||||
strNew(),
|
||||
"%s"
|
||||
"#ifndef POSTGRES_VERSION_AUTO_H\n"
|
||||
"#define POSTGRES_VERSION_AUTO_H\n",
|
||||
strZ(bldHeader(PG_VERSION_MODULE, PG_VERSION_AUTO_COMMENT)));
|
||||
|
||||
// PostgreSQL version numbers
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
strCatFmt(
|
||||
pg,
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL version constants\n"
|
||||
COMMENT_BLOCK_END "\n");
|
||||
|
||||
for (unsigned int pgIdx = 0; pgIdx < lstSize(bldPg.pgList); pgIdx++)
|
||||
{
|
||||
const BldPgVersion *const pgVersion = lstGet(bldPg.pgList, pgIdx);
|
||||
const char *const versionNoDot = strZ(strLstJoin(strLstNewSplitZ(pgVersion->version, "."), ""));
|
||||
|
||||
// Generate version number
|
||||
unsigned int versionNum;
|
||||
const int idxStart = strChr(pgVersion->version, '.');
|
||||
|
||||
if (idxStart == -1)
|
||||
versionNum = cvtZToUInt(strZ(pgVersion->version)) * 10000;
|
||||
else
|
||||
{
|
||||
versionNum =
|
||||
cvtZSubNToUInt(strZ(pgVersion->version), 0, (size_t)idxStart) * 10000 +
|
||||
cvtZToUInt(strZ(pgVersion->version) + (size_t)idxStart + 1) * 100;
|
||||
}
|
||||
|
||||
// Output version number
|
||||
strCatFmt(pg, "%s\n", strZ(bldDefineRender(strNewFmt("PG_VERSION_%s", versionNoDot), strNewFmt("%u", versionNum))));
|
||||
|
||||
// Output max version
|
||||
if (pgIdx == lstSize(bldPg.pgList) - 1)
|
||||
strCatFmt(pg, "\n%s\n", strZ(bldDefineRender(STRDEF("PG_VERSION_MAX"), strNewFmt("PG_VERSION_%s", versionNoDot))));
|
||||
}
|
||||
|
||||
// PostgreSQL version strings
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
strCatFmt(
|
||||
pg,
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL version string constants for use in error messages\n"
|
||||
COMMENT_BLOCK_END "\n");
|
||||
|
||||
for (unsigned int pgIdx = 0; pgIdx < lstSize(bldPg.pgList); pgIdx++)
|
||||
{
|
||||
const BldPgVersion *const pgVersion = lstGet(bldPg.pgList, pgIdx);
|
||||
const char *const versionNoDot = strZ(strLstJoin(strLstNewSplitZ(pgVersion->version, "."), ""));
|
||||
|
||||
// Output version string
|
||||
strCatFmt(
|
||||
pg, "%s\n",
|
||||
strZ(bldDefineRender(strNewFmt("PG_VERSION_%s_Z", versionNoDot), strNewFmt("\"%s\"", strZ(pgVersion->version)))));
|
||||
}
|
||||
|
||||
strCatZ(
|
||||
pg,
|
||||
"\n"
|
||||
"#endif\n");
|
||||
|
||||
bldPut(storageRepo, "src/postgres/version.auto.h", BUFSTR(pg));
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
bldPgVersionRender(const Storage *const storageRepo, const BldPg bldPg)
|
||||
{
|
||||
bldPgRenderVersionAutoH(storageRepo, bldPg);
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Render auto-generated PostgreSQL files
|
||||
void bldPgRender(const Storage *const storageRepo, const BldPg bldPg);
|
||||
void bldPgVersionRender(const Storage *const storageRepo, const BldPg bldPg);
|
||||
|
||||
#endif
|
||||
|
39
src/postgres/version.auto.h
Normal file
39
src/postgres/version.auto.h
Normal file
@ -0,0 +1,39 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Version
|
||||
|
||||
Automatically generated by 'build-code postgres-version' -- do not modify directly.
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef POSTGRES_VERSION_AUTO_H
|
||||
#define POSTGRES_VERSION_AUTO_H
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL version constants
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_VERSION_93 90300
|
||||
#define PG_VERSION_94 90400
|
||||
#define PG_VERSION_95 90500
|
||||
#define PG_VERSION_96 90600
|
||||
#define PG_VERSION_10 100000
|
||||
#define PG_VERSION_11 110000
|
||||
#define PG_VERSION_12 120000
|
||||
#define PG_VERSION_13 130000
|
||||
#define PG_VERSION_14 140000
|
||||
#define PG_VERSION_15 150000
|
||||
|
||||
#define PG_VERSION_MAX PG_VERSION_15
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL version string constants for use in error messages
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_VERSION_93_Z "9.3"
|
||||
#define PG_VERSION_94_Z "9.4"
|
||||
#define PG_VERSION_95_Z "9.5"
|
||||
#define PG_VERSION_96_Z "9.6"
|
||||
#define PG_VERSION_10_Z "10"
|
||||
#define PG_VERSION_11_Z "11"
|
||||
#define PG_VERSION_12_Z "12"
|
||||
#define PG_VERSION_13_Z "13"
|
||||
#define PG_VERSION_14_Z "14"
|
||||
#define PG_VERSION_15_Z "15"
|
||||
|
||||
#endif
|
@ -4,27 +4,13 @@ PostgreSQL Version Constants
|
||||
#ifndef POSTGRES_VERSION_H
|
||||
#define POSTGRES_VERSION_H
|
||||
|
||||
#include "postgres/version.auto.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL name
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_NAME "PostgreSQL"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL version constants
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_VERSION_93 90300
|
||||
#define PG_VERSION_94 90400
|
||||
#define PG_VERSION_95 90500
|
||||
#define PG_VERSION_96 90600
|
||||
#define PG_VERSION_10 100000
|
||||
#define PG_VERSION_11 110000
|
||||
#define PG_VERSION_12 120000
|
||||
#define PG_VERSION_13 130000
|
||||
#define PG_VERSION_14 140000
|
||||
#define PG_VERSION_15 150000
|
||||
|
||||
#define PG_VERSION_MAX PG_VERSION_15
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Version where various PostgreSQL capabilities were introduced
|
||||
***********************************************************************************************************************************/
|
||||
@ -43,18 +29,4 @@ Version where various PostgreSQL capabilities were introduced
|
||||
// recovery settings are implemented as GUCs (recovery.conf is no longer valid)
|
||||
#define PG_VERSION_RECOVERY_GUC PG_VERSION_12
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL version string constants for use in error messages
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_VERSION_93_Z "9.3"
|
||||
#define PG_VERSION_94_Z "9.4"
|
||||
#define PG_VERSION_95_Z "9.5"
|
||||
#define PG_VERSION_96_Z "9.6"
|
||||
#define PG_VERSION_10_Z "10"
|
||||
#define PG_VERSION_11_Z "11"
|
||||
#define PG_VERSION_12_Z "12"
|
||||
#define PG_VERSION_13_Z "13"
|
||||
#define PG_VERSION_14_Z "14"
|
||||
#define PG_VERSION_15_Z "15"
|
||||
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@ testRun(void)
|
||||
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("bldPgParse() and bldPgRender()"))
|
||||
if (testBegin("bldPgParse() and bldPg*Render()"))
|
||||
{
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("parse errors");
|
||||
@ -81,6 +81,37 @@ testRun(void)
|
||||
" release: false\n");
|
||||
|
||||
TEST_RESULT_VOID(bldPgRender(storageTest, bldPgParse(storageTest)), "parse and render");
|
||||
TEST_RESULT_VOID(bldPgVersionRender(storageTest, bldPgParse(storageTest)), "parse and render");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("check version.auto.h");
|
||||
|
||||
TEST_STORAGE_GET(
|
||||
storageTest,
|
||||
"src/postgres/version.auto.h",
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL Version\n"
|
||||
"\n"
|
||||
"Automatically generated by 'build-code postgres-version' -- do not modify directly.\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#ifndef POSTGRES_VERSION_AUTO_H\n"
|
||||
"#define POSTGRES_VERSION_AUTO_H\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL version constants\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PG_VERSION_96 90600\n"
|
||||
"#define PG_VERSION_11 110000\n"
|
||||
"\n"
|
||||
"#define PG_VERSION_MAX PG_VERSION_11\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL version string constants for use in error messages\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PG_VERSION_96_Z \"9.6\"\n"
|
||||
"#define PG_VERSION_11_Z \"11\"\n"
|
||||
"\n"
|
||||
"#endif\n");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("check interface.auto.c.inc");
|
||||
|
@ -589,6 +589,7 @@ eval
|
||||
"ninja -C ${strBuildPath} src/build-code test/src/test-pgbackrest" .
|
||||
($bMinGen ? '' : " && \\\n${strBuildPath}/src/build-code config ${strBackRestBase}/src") .
|
||||
($bMinGen ? '' : " && \\\n${strBuildPath}/src/build-code error ${strBackRestBase}/src") .
|
||||
($bMinGen ? '' : " && \\\n${strBuildPath}/src/build-code postgres-version ${strBackRestBase}/src") .
|
||||
" && \\\n${strBuildPath}/src/build-code postgres ${strBackRestBase}/src ${strRepoCachePath}";
|
||||
|
||||
if (!-e $strBuildNinja)
|
||||
|
Loading…
x
Reference in New Issue
Block a user