diff --git a/src/command/archive/get/file.c b/src/command/archive/get/file.c index eb3cdfa94..c80f65d2a 100644 --- a/src/command/archive/get/file.c +++ b/src/command/archive/get/file.c @@ -47,7 +47,7 @@ archiveGetCheck(const String *archiveFile, CipherType cipherType, const String * MEM_CONTEXT_TEMP_BEGIN() { // Get pg control info - PgControl controlInfo = pgControlFromFile(storagePg(), cfgOptionStr(cfgOptPgPath)); + PgControl controlInfo = pgControlFromFile(storagePg()); // Attempt to load the archive info file InfoArchive *info = infoArchiveLoadFile(storageRepo(), INFO_ARCHIVE_PATH_FILE_STR, cipherType, cipherPass); diff --git a/src/command/archive/get/get.c b/src/command/archive/get/get.c index 3370ae0bd..e34bf606d 100644 --- a/src/command/archive/get/get.c +++ b/src/command/archive/get/get.c @@ -206,7 +206,7 @@ cmdArchiveGet(void) lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockType(), 0, false)) { // Get control info - PgControl pgControl = pgControlFromFile(storagePg(), cfgOptionStr(cfgOptPgPath)); + PgControl pgControl = pgControlFromFile(storagePg()); // Create the queue storagePathCreateNP(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_IN_STR); diff --git a/src/command/archive/push/push.c b/src/command/archive/push/push.c index 277c779c9..190318ae5 100644 --- a/src/command/archive/push/push.c +++ b/src/command/archive/push/push.c @@ -213,7 +213,7 @@ archivePushCheck(CipherType cipherType, const String *cipherPass) MEM_CONTEXT_TEMP_BEGIN() { // Get info from pg_control - PgControl controlInfo = pgControlFromFile(storagePg(), cfgOptionStr(cfgOptPgPath)); + PgControl controlInfo = pgControlFromFile(storagePg()); // Attempt to load the archive info file InfoArchive *info = infoArchiveLoadFile(storageRepo(), INFO_ARCHIVE_PATH_FILE_STR, cipherType, cipherPass); diff --git a/src/command/stanza/common.c b/src/command/stanza/common.c index 7aa730459..4cbb2a8bd 100644 --- a/src/command/stanza/common.c +++ b/src/command/stanza/common.c @@ -86,14 +86,14 @@ pgValidate(void) DbGetResult dbObject = dbGet(false, true); // Get the pgControl information from the pg*-path deemed to be the master - result = pgControlFromFile(storagePgId(dbObject.primaryId), cfgOptionStr(cfgOptPgPath + dbObject.primaryId - 1)); + result = pgControlFromFile(storagePgId(dbObject.primaryId)); // Check the user configured path and version against the database checkDbConfig(result.version, dbObject.primaryId, dbPgVersion(dbObject.primary), dbPgDataPath(dbObject.primary)); } // If the database is not online, assume that pg1 is the master else - result = pgControlFromFile(storagePg(), cfgOptionStr(cfgOptPgPath)); + result = pgControlFromFile(storagePg()); } MEM_CONTEXT_TEMP_END(); diff --git a/src/main.c b/src/main.c index 7bc3f90cc..af2632186 100644 --- a/src/main.c +++ b/src/main.c @@ -111,7 +111,7 @@ main(int argListSize, const char *argList[]) // archive-get/archive-push and end up in the PostgreSQL log which is not output in CI. This can be removed // once backup is written in C. if (cfgOptionBool(cfgOptOnline) && !cfgOptionBool(cfgOptBackupStandby) && !cfgOptionTest(cfgOptPgHost)) - pgControlFromFile(storagePg(), cfgOptionStr(cfgOptPgPath)); + pgControlFromFile(storagePg()); #endif // Run backup diff --git a/src/postgres/interface.c b/src/postgres/interface.c index 85514d8c0..842444b0b 100644 --- a/src/postgres/interface.c +++ b/src/postgres/interface.c @@ -417,15 +417,13 @@ pgControlFromBuffer(const Buffer *controlFile) Get info from pg_control ***********************************************************************************************************************************/ PgControl -pgControlFromFile(const Storage *storage, const String *pgPath) +pgControlFromFile(const Storage *storage) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STORAGE, storage); - FUNCTION_LOG_PARAM(STRING, pgPath); FUNCTION_LOG_END(); ASSERT(storage != NULL); - ASSERT(pgPath != NULL); PgControl result = {0}; @@ -433,8 +431,7 @@ pgControlFromFile(const Storage *storage, const String *pgPath) { // Read control file Buffer *controlFile = storageGetP( - storageNewReadNP(storage, strNewFmt("%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, strPtr(pgPath))), - .exactSize = PG_CONTROL_DATA_SIZE); + storageNewReadNP(storage, STRDEF(PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL)), .exactSize = PG_CONTROL_DATA_SIZE); result = pgControlFromBuffer(controlFile); } diff --git a/src/postgres/interface.h b/src/postgres/interface.h index 816e72466..276aa3283 100644 --- a/src/postgres/interface.h +++ b/src/postgres/interface.h @@ -93,7 +93,7 @@ typedef struct PgWal Functions ***********************************************************************************************************************************/ uint32_t pgCatalogVersion(unsigned int pgVersion); -PgControl pgControlFromFile(const Storage *storage, const String *pgPath); +PgControl pgControlFromFile(const Storage *storage); PgControl pgControlFromBuffer(const Buffer *controlFile); uint32_t pgControlVersion(unsigned int pgVersion); unsigned int pgVersionFromStr(const String *version); diff --git a/test/src/module/postgres/interfaceTest.c b/test/src/module/postgres/interfaceTest.c index 475aa0875..ebeaea712 100644 --- a/test/src/module/postgres/interfaceTest.c +++ b/test/src/module/postgres/interfaceTest.c @@ -72,7 +72,7 @@ testRun(void) pgControlTestToBuffer((PgControl){.version = PG_VERSION_11, .systemId = 0xFACEFACE, .walSegmentSize = 1024 * 1024})); PgControl info = {0}; - TEST_ASSIGN(info, pgControlFromFile(storageTest, strNew(testPath())), "get control info v11"); + TEST_ASSIGN(info, pgControlFromFile(storageTest), "get control info v11"); TEST_RESULT_INT(info.systemId, 0xFACEFACE, " check system id"); TEST_RESULT_INT(info.version, PG_VERSION_11, " check version"); @@ -82,22 +82,21 @@ testRun(void) pgControlTestToBuffer((PgControl){.version = PG_VERSION_93, .walSegmentSize = 1024 * 1024})); TEST_ERROR( - pgControlFromFile(storageTest, strNew(testPath())), FormatError, - "wal segment size is 1048576 but must be 16777216 for PostgreSQL <= 10"); + pgControlFromFile(storageTest), FormatError, "wal segment size is 1048576 but must be 16777216 for PostgreSQL <= 10"); //-------------------------------------------------------------------------------------------------------------------------- storagePutNP( storageNewWriteNP(storageTest, controlFile), pgControlTestToBuffer((PgControl){.version = PG_VERSION_95, .pageSize = 32 * 1024})); - TEST_ERROR(pgControlFromFile(storageTest, strNew(testPath())), FormatError, "page size is 32768 but must be 8192"); + TEST_ERROR(pgControlFromFile(storageTest), FormatError, "page size is 32768 but must be 8192"); //-------------------------------------------------------------------------------------------------------------------------- storagePutNP( storageNewWriteNP(storageTest, controlFile), pgControlTestToBuffer((PgControl){.version = PG_VERSION_83, .systemId = 0xEFEFEFEFEF})); - TEST_ASSIGN(info, pgControlFromFile(storageTest, strNew(testPath())), "get control info v83"); + TEST_ASSIGN(info, pgControlFromFile(storageTest), "get control info v83"); TEST_RESULT_INT(info.systemId, 0xEFEFEFEFEF, " check system id"); TEST_RESULT_INT(info.version, PG_VERSION_83, " check version"); }