1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Rename PG_VERSION_*_STR constants to PG_VERSION_*_Z.

This is more consistent with other zero-terminated string constants and also has the benefit of being shorter.
This commit is contained in:
David Steele
2023-04-16 17:32:24 +03:00
parent 75254c9285
commit a05bf6bb15
11 changed files with 39 additions and 40 deletions

View File

@ -1581,7 +1581,7 @@ restoreRecoveryOption(unsigned int pgVersion)
{
THROW_FMT(
OptionInvalidError,
"option '" CFGOPT_ARCHIVE_MODE "' is not supported on " PG_NAME " < " PG_VERSION_12_STR "\n"
"option '" CFGOPT_ARCHIVE_MODE "' is not supported on " PG_NAME " < " PG_VERSION_12_Z "\n"
"HINT: 'archive_mode' should be manually set to 'off' in postgresql.conf.");
}

View File

@ -284,7 +284,7 @@ dbOpen(Db *this)
DbQueryError,
"unable to select some rows from pg_settings\n"
"HINT: is the backup running as the postgres user?\n"
"HINT: is the pg_read_all_settings role assigned for " PG_NAME " >= " PG_VERSION_10_STR "?");
"HINT: is the pg_read_all_settings role assigned for " PG_NAME " >= " PG_VERSION_10_Z "?");
}
}

View File

@ -169,7 +169,7 @@ pgWalSegmentSizeCheck(unsigned int pgVersion, unsigned int walSegmentSize)
if (pgVersion < PG_VERSION_11 && walSegmentSize != PG_WAL_SEGMENT_SIZE_DEFAULT)
{
THROW_FMT(
FormatError, "wal segment size is %u but must be %u for " PG_NAME " <= " PG_VERSION_10_STR, walSegmentSize,
FormatError, "wal segment size is %u but must be %u for " PG_NAME " <= " PG_VERSION_10_Z, walSegmentSize,
PG_WAL_SEGMENT_SIZE_DEFAULT);
}

View File

@ -46,15 +46,15 @@ Version where various PostgreSQL capabilities were introduced
/***********************************************************************************************************************************
PostgreSQL version string constants for use in error messages
***********************************************************************************************************************************/
#define PG_VERSION_93_STR "9.3"
#define PG_VERSION_94_STR "9.4"
#define PG_VERSION_95_STR "9.5"
#define PG_VERSION_96_STR "9.6"
#define PG_VERSION_10_STR "10"
#define PG_VERSION_11_STR "11"
#define PG_VERSION_12_STR "12"
#define PG_VERSION_13_STR "13"
#define PG_VERSION_14_STR "14"
#define PG_VERSION_15_STR "15"
#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

View File

@ -2421,7 +2421,7 @@ testRun(void)
// Add files
HRN_STORAGE_PUT_Z(storagePgWrite(), "postgresql.conf", "CONFIGSTUFF", .timeModified = backupTimeStart);
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_95_STR, .timeModified = backupTimeStart);
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_95_Z, .timeModified = backupTimeStart);
HRN_STORAGE_PATH_CREATE(storagePgWrite(), strZ(pgWalPath(PG_VERSION_95)), .noParentCreate = true);
// Create a backup manifest that looks like a halted backup manifest
@ -2871,7 +2871,7 @@ testRun(void)
HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_96);
// Update version
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_96_STR, .timeModified = backupTimeStart);
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_96_Z, .timeModified = backupTimeStart);
// Upgrade stanza
StringList *argList = strLstNew();
@ -3029,7 +3029,7 @@ testRun(void)
HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_11, .pageChecksum = true, .walSegmentSize = 1024 * 1024);
// Update version
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_STR, .timeModified = backupTimeStart);
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_Z, .timeModified = backupTimeStart);
// Update wal path
HRN_STORAGE_PATH_REMOVE(storagePgWrite(), strZ(pgWalPath(PG_VERSION_95)));
@ -3551,7 +3551,7 @@ testRun(void)
HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_11, .pageChecksum = false, .walSegmentSize = 2 * 1024 * 1024);
// Update version
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_STR, .timeModified = backupTimeStart);
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_Z, .timeModified = backupTimeStart);
// Load options
StringList *argList = strLstNew();
@ -3638,7 +3638,7 @@ testRun(void)
HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_11, .pageChecksum = false, .walSegmentSize = 2 * 1024 * 1024);
// Update version
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_STR, .timeModified = backupTimeStart);
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_Z, .timeModified = backupTimeStart);
// Load options
StringList *argList = strLstNew();

View File

@ -183,8 +183,8 @@ testRun(void)
TEST_ERROR(
cmdCheck(), DbMismatchError,
"version '" PG_VERSION_15_STR "' and path '" TEST_PATH "' queried from cluster do not match version"
" '" PG_VERSION_15_STR "' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/global/pg_control'\n"
"version '" PG_VERSION_15_Z "' and path '" TEST_PATH "' queried from cluster do not match version '" PG_VERSION_15_Z
"' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/global/pg_control'\n"
"HINT: the pg1-path and pg1-port settings likely reference different clusters.");
// -------------------------------------------------------------------------------------------------------------------------
@ -421,8 +421,8 @@ testRun(void)
TEST_ERROR(
checkDbConfig(PG_VERSION_94, db.primaryIdx, db.primary, false), DbMismatchError,
"version '" PG_VERSION_11_STR "' and path '" TEST_PATH "/pg' queried from cluster do not match version '"
PG_VERSION_94_STR "' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/global/pg_control'\n"
"version '" PG_VERSION_11_Z "' and path '" TEST_PATH "/pg' queried from cluster do not match version '"
PG_VERSION_94_Z "' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/global/pg_control'\n"
"HINT: the pg1-path and pg1-port settings likely reference different clusters.");
// -------------------------------------------------------------------------------------------------------------------------
@ -430,7 +430,7 @@ testRun(void)
TEST_ERROR_FMT(
checkDbConfig(PG_VERSION_11, db.standbyIdx, db.standby, true), DbMismatchError,
"version '" PG_VERSION_11_STR "' and path '%s' queried from cluster do not match version '" PG_VERSION_11_STR "' and"
"version '" PG_VERSION_11_Z "' and path '%s' queried from cluster do not match version '" PG_VERSION_11_Z "' and"
" '" TEST_PATH "/pg8' read from '" TEST_PATH "/pg8/global/pg_control'\n"
"HINT: the pg8-path and pg8-port settings likely reference different clusters.",
strZ(dbPgDataPath(db.standby)));

View File

@ -81,7 +81,7 @@ testRun(void)
// Version file that will not be updated after the full backup
HRN_STORAGE_PUT_Z(
storagePgWrite(), PG_PATH_BASE "/" PG_FILE_PGVERSION, PG_VERSION_95_STR, .timeModified = backupTimeStart);
storagePgWrite(), PG_PATH_BASE "/" PG_FILE_PGVERSION, PG_VERSION_95_Z, .timeModified = backupTimeStart);
// Zeroed file large enough to use block incr
Buffer *relation = bufNew(8 * 8192);

View File

@ -2121,11 +2121,11 @@ testRun(void)
HRN_MANIFEST_FILE_ADD(
manifest, .name = TEST_PGDATA PG_FILE_PGVERSION, .size = 4, .timestamp = 1482182860,
.checksumSha1 = "8dbabb96e032b8d9f1993c0e4b9141e71ade01a1");
HRN_STORAGE_PUT_Z(storageRepoIdxWrite(0), TEST_REPO_PATH PG_FILE_PGVERSION, PG_VERSION_94_STR "\n");
HRN_STORAGE_PUT_Z(storageRepoIdxWrite(0), TEST_REPO_PATH PG_FILE_PGVERSION, PG_VERSION_94_Z "\n");
// Store the file also to the encrypted repo
HRN_STORAGE_PUT_Z(
storageRepoIdxWrite(1), TEST_REPO_PATH PG_FILE_PGVERSION, PG_VERSION_94_STR "\n",
storageRepoIdxWrite(1), TEST_REPO_PATH PG_FILE_PGVERSION, PG_VERSION_94_Z "\n",
.cipherType = cipherTypeAes256Cbc, .cipherPass = TEST_CIPHER_PASS_ARCHIVE);
// pg_tblspc
@ -2292,7 +2292,7 @@ testRun(void)
HRN_STORAGE_PUT_Z(
storageRepoWrite(), STORAGE_REPO_BACKUP "/" TEST_LABEL "/" MANIFEST_TARGET_PGTBLSPC "/1/16384/" PG_FILE_PGVERSION,
PG_VERSION_94_STR "\n");
PG_VERSION_94_Z "\n");
// Always sort
lstSort(manifest->pub.targetList, sortOrderAsc);
@ -2439,7 +2439,7 @@ testRun(void)
.level = storageInfoLevelBasic, .includeDot = true);
// PG_VERSION was restored by the force option
TEST_STORAGE_GET(storagePg(), PG_FILE_PGVERSION, PG_VERSION_94_STR "\n", .comment = "check PG_VERSION was restored");
TEST_STORAGE_GET(storagePg(), PG_FILE_PGVERSION, PG_VERSION_94_Z "\n", .comment = "check PG_VERSION was restored");
// Remove tablespace
HRN_STORAGE_PATH_REMOVE(storagePgWrite(), MANIFEST_TARGET_PGTBLSPC "/1/PG_9.4_201409291", .recurse = true);
@ -2538,7 +2538,7 @@ testRun(void)
.bundleId = 1, .bundleOffset = 17, .checksumSha1 = "d7dacae2c968388960bf8970080a980ed5c5dcb7");
HRN_STORAGE_PUT_Z(
storageRepoWrite(), STORAGE_REPO_BACKUP "/" TEST_LABEL "/bundle/1",
PG_VERSION_96_STR "\n" PG_VERSION_96_STR "\nyyyxxxxxAzzA");
PG_VERSION_96_Z "\n" PG_VERSION_96_Z "\nyyyxxxxxAzzA");
// base directory
HRN_MANIFEST_PATH_ADD(manifest, .name = TEST_PGDATA PG_PATH_BASE);
@ -2603,7 +2603,7 @@ testRun(void)
HRN_MANIFEST_FILE_ADD(
manifest, .name = TEST_PGDATA "base/16384/" PG_FILE_PGVERSION, .size = 4, .timestamp = 1482182860,
.checksumSha1 = "8dbabb96e032b8d9f1993c0e4b9141e71ade01a1");
HRN_STORAGE_PUT_Z(storageRepoWrite(), TEST_REPO_PATH "base/16384/" PG_FILE_PGVERSION, PG_VERSION_94_STR "\n");
HRN_STORAGE_PUT_Z(storageRepoWrite(), TEST_REPO_PATH "base/16384/" PG_FILE_PGVERSION, PG_VERSION_94_Z "\n");
// base/16384/16385
fileBuffer = bufNew(16384);
@ -2623,7 +2623,7 @@ testRun(void)
HRN_MANIFEST_FILE_ADD(
manifest, .name = TEST_PGDATA "base/32768/" PG_FILE_PGVERSION, .size = 4, .timestamp = 1482182860,
.checksumSha1 = "8dbabb96e032b8d9f1993c0e4b9141e71ade01a1");
HRN_STORAGE_PUT_Z(storageRepoWrite(), TEST_REPO_PATH "base/32768/" PG_FILE_PGVERSION, PG_VERSION_94_STR "\n");
HRN_STORAGE_PUT_Z(storageRepoWrite(), TEST_REPO_PATH "base/32768/" PG_FILE_PGVERSION, PG_VERSION_94_Z "\n");
// base/32768/32769
fileBuffer = bufNew(32768);
@ -2946,7 +2946,7 @@ testRun(void)
// Enlarge a file so it gets truncated. Keep timestamp the same to prove that it gets updated after the truncate.
HRN_STORAGE_PUT_Z(
storagePgWrite(), "base/16384/" PG_FILE_PGVERSION, PG_VERSION_94_STR "\n\n", .modeFile = 0600,
storagePgWrite(), "base/16384/" PG_FILE_PGVERSION, PG_VERSION_94_Z "\n\n", .modeFile = 0600,
.timeModified = 1482182860);
// Enlarge a zero-length file so it gets truncated

View File

@ -611,8 +611,8 @@ testRun(void)
TEST_ERROR(
pgValidate(), DbMismatchError,
"version '" PG_VERSION_11_STR "' and path '" TEST_PATH "/pg' queried from cluster do not match version '"
PG_VERSION_10_STR "' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\n"
"version '" PG_VERSION_11_Z "' and path '" TEST_PATH "/pg' queried from cluster do not match version '" PG_VERSION_10_Z
"' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\n"
"HINT: the pg1-path and pg1-port settings likely reference different clusters.");
// -------------------------------------------------------------------------------------------------------------------------
@ -629,9 +629,8 @@ testRun(void)
TEST_ERROR(
pgValidate(), DbMismatchError,
"version '" PG_VERSION_15_STR "' and path '" TEST_PATH "/pg2' queried from cluster do not match version"
" '" PG_VERSION_15_STR "' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/" PG_PATH_GLOBAL
"/" PG_FILE_PGCONTROL "'\n"
"version '" PG_VERSION_15_Z "' and path '" TEST_PATH "/pg2' queried from cluster do not match version '" PG_VERSION_15_Z
"' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\n"
"HINT: the pg1-path and pg1-port settings likely reference different clusters.");
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -1824,7 +1824,7 @@ testRun(void)
TEST_TITLE("none output, verbose, override WAL magic, with no verify failures");
hrnCfgArgRawZ(argList, cfgOptVerbose, "y");
hrnCfgArgRawZ(argList, cfgOptPgVersionForce, PG_VERSION_11_STR);
hrnCfgArgRawZ(argList, cfgOptPgVersionForce, PG_VERSION_11_Z);
HRN_CFG_LOAD(cfgCmdVerify, argList);
TEST_RESULT_STR_Z(
verifyProcess(cfgOptionBool(cfgOptVerbose)),

View File

@ -127,7 +127,7 @@ testRun(void)
"invalid PostgreSQL version 990000\n"
"HINT: is this version of PostgreSQL supported?");
TEST_ASSIGN(info, pgControlFromFile(storageTest, STRDEF(PG_VERSION_15_STR)), "get control info v90");
TEST_ASSIGN(info, pgControlFromFile(storageTest, STRDEF(PG_VERSION_15_Z)), "get control info v90");
TEST_RESULT_UINT(info.systemId, 0xEFEFEFEFEF, "check system id");
TEST_RESULT_UINT(info.version, PG_VERSION_15, "check version");
TEST_RESULT_UINT(info.catalogVersion, 202211111, "check catalog version");
@ -265,7 +265,7 @@ testRun(void)
"unexpected WAL magic 777\n"
"HINT: is this version of PostgreSQL supported?");
TEST_ASSIGN(info, pgWalFromFile(walFile, storageTest, STRDEF(PG_VERSION_15_STR)), "force wal info v15");
TEST_ASSIGN(info, pgWalFromFile(walFile, storageTest, STRDEF(PG_VERSION_15_Z)), "force wal info v15");
TEST_RESULT_UINT(info.systemId, 0xFAFAFAFA, "check system id");
TEST_RESULT_UINT(info.version, PG_VERSION_15, " check version");
TEST_RESULT_UINT(info.size, PG_WAL_SEGMENT_SIZE_DEFAULT, " check size");