mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-05 15:05:48 +02:00
Remove pgPath parameter from pgControlFromFile().
In practice this function is always used with storagePg*() so pgPath is known.
This commit is contained in:
parent
887ec97e07
commit
5394893e33
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user