mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Correct current history item in InfoPg to always be in position 0.
The InfoPg object was partially modified in 960ad732
to place the current history item in position 0, but infoPgDataCurrent() didn't get updated correctly.
Remove this->indexCurrent and make the current position always equal 0. Use the new lstInsert() function when adding new history items via infoPgAdd(), but continue to use lstAdd() when loading from a file for efficiency.
This does not appear to be a live bug because infoPgDataCurrent() and infoPgAdd() are not yet used in any production code. The archive-get command is the only C code using InfoPG and it always looks at the entire list of items rather than just the current item.
Suggested by Cynthia Shang.
This commit is contained in:
parent
f345db3f7c
commit
070455ce44
@ -15,6 +15,14 @@
|
||||
<release date="XXXX-XX-XX" version="2.07dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-development-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Correct current history item in <code>InfoPg</code> to always be in position 0.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Add <code>lstInsert()</code> to <code>List</code> object.</p>
|
||||
</release-item>
|
||||
|
@ -40,7 +40,6 @@ struct InfoPg
|
||||
{
|
||||
MemContext *memContext; // Context that contains the infoPg
|
||||
List *history; // A list of InfoPgData
|
||||
unsigned int indexCurrent; // Index to the history list for the db Section
|
||||
Info *info; // Info contents
|
||||
};
|
||||
|
||||
@ -118,7 +117,7 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type)
|
||||
else if (type != infoPgArchive)
|
||||
THROW_FMT(AssertError, "invalid InfoPg type %u", type);
|
||||
|
||||
infoPgAdd(this, &infoPgData);
|
||||
lstAdd(this->history, &infoPgData);
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
@ -132,7 +131,7 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type)
|
||||
/***********************************************************************************************************************************
|
||||
Add Postgres data to the history list and return the new currentIndex
|
||||
***********************************************************************************************************************************/
|
||||
unsigned int
|
||||
void
|
||||
infoPgAdd(InfoPg *this, const InfoPgData *infoPgData)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelDebug);
|
||||
@ -143,10 +142,9 @@ infoPgAdd(InfoPg *this, const InfoPgData *infoPgData)
|
||||
FUNCTION_DEBUG_ASSERT(infoPgData != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
lstAdd(this->history, infoPgData);
|
||||
this->indexCurrent = lstSize(this->history) - 1;
|
||||
lstInsert(this->history, 0, infoPgData);
|
||||
|
||||
FUNCTION_DEBUG_RESULT(UINT, this->indexCurrent);
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -195,7 +193,7 @@ infoPgDataCurrent(const InfoPg *this)
|
||||
FUNCTION_DEBUG_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(INFO_PG_DATA, infoPgData(this, this->indexCurrent));
|
||||
FUNCTION_DEBUG_RESULT(INFO_PG_DATA, infoPgData(this, 0));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -43,7 +43,7 @@ InfoPg *infoPgNew(const Storage *storage, const String *fileName, InfoPgType typ
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
unsigned int infoPgAdd(InfoPg *this, const InfoPgData *infoPgData);
|
||||
void infoPgAdd(InfoPg *this, const InfoPgData *infoPgData);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
|
@ -137,8 +137,6 @@ P00 DEBUG: info/info::infoNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
P00 DEBUG: info/info::infoNew: => {Info}
|
||||
P00 DEBUG: info/info::infoIni: (this: {Info})
|
||||
P00 DEBUG: info/info::infoIni: => {Ini}
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 1, version: 90400, systemId: 1000000000000000094, catalogVersion: 0, controlVersion: 0})
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 0
|
||||
P00 DEBUG: info/infoPg::infoPgNew: => {InfoPg}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: => {InfoArchive}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, archiveId: {"9.4-1"}, walSegment: {"700000007000000070000000"})
|
||||
@ -181,8 +179,6 @@ P00 DEBUG: info/info::infoNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
P00 DEBUG: info/info::infoNew: => {Info}
|
||||
P00 DEBUG: info/info::infoIni: (this: {Info})
|
||||
P00 DEBUG: info/info::infoIni: => {Ini}
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 1, version: 90400, systemId: 1000000000000000094, catalogVersion: 0, controlVersion: 0})
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 0
|
||||
P00 DEBUG: info/infoPg::infoPgNew: => {InfoPg}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: => {InfoArchive}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, archiveId: {"9.4-1"}, walSegment: {"000000010000000100000001"})
|
||||
|
@ -554,10 +554,6 @@ P00 DEBUG: info/info::infoNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
P00 DEBUG: info/info::infoNew: => {Info}
|
||||
P00 DEBUG: info/info::infoIni: (this: {Info})
|
||||
P00 DEBUG: info/info::infoIni: => {Ini}
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 2, version: 90400, systemId: 1000000000000000094, catalogVersion: 0, controlVersion: 0})
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 0
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 1, version: 90300, systemId: 1000000000000000093, catalogVersion: 0, controlVersion: 0})
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 1
|
||||
P00 DEBUG: info/infoPg::infoPgNew: => {InfoPg}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: => {InfoArchive}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, archiveId: {"9.3-1"}, walSegment: {"000000010000000100000002"})
|
||||
|
@ -39,7 +39,6 @@ testRun(void)
|
||||
TEST_ASSIGN(infoPg, infoPgNew(storageLocal(), fileName, infoPgArchive), "new infoPg archive - load file");
|
||||
|
||||
TEST_RESULT_INT(lstSize(infoPg->history), 1, " history record added");
|
||||
TEST_RESULT_INT(infoPg->indexCurrent, 0, " current index set");
|
||||
|
||||
InfoPgData infoPgData = infoPgDataCurrent(infoPg);
|
||||
TEST_RESULT_INT(infoPgData.id, 1, " id set");
|
||||
@ -76,7 +75,6 @@ testRun(void)
|
||||
TEST_ASSIGN(infoPg, infoPgNew(storageLocal(), fileName, infoPgBackup), "new infoPg backup - load file");
|
||||
|
||||
TEST_RESULT_INT(lstSize(infoPg->history), 1, " history record added");
|
||||
TEST_RESULT_INT(infoPg->indexCurrent, 0, " current index set");
|
||||
|
||||
infoPgData = infoPgDataCurrent(infoPg);
|
||||
TEST_RESULT_INT(infoPgData.id, 1, " id set");
|
||||
@ -90,7 +88,6 @@ testRun(void)
|
||||
TEST_ASSIGN(infoPg, infoPgNew(storageLocal(), fileName, infoPgManifest), "new infoPg manifest - load file");
|
||||
|
||||
TEST_RESULT_INT(lstSize(infoPg->history), 1, "history record added");
|
||||
TEST_RESULT_INT(infoPg->indexCurrent, 0, "current index set");
|
||||
|
||||
infoPgData = infoPgDataCurrent(infoPg);
|
||||
TEST_RESULT_INT(infoPgData.id, 1, " id set");
|
||||
@ -106,7 +103,7 @@ testRun(void)
|
||||
infoPgData.systemId = 6365925855999999999;
|
||||
infoPgData.catalogVersion = 201510051;
|
||||
infoPgData.controlVersion = 942;
|
||||
TEST_RESULT_INT(infoPgAdd(infoPg, &infoPgData), 1, "infoPgAdd - currentIndex incremented");
|
||||
TEST_RESULT_VOID(infoPgAdd(infoPg, &infoPgData), "infoPgAdd");
|
||||
|
||||
InfoPgData infoPgDataTest = infoPgDataCurrent(infoPg);
|
||||
TEST_RESULT_INT(infoPgDataTest.id, 2, " id set");
|
||||
|
Loading…
Reference in New Issue
Block a user