Improved UpdateMetaPage logic [skip ci]

This commit is contained in:
Andrew Kane
2023-07-30 17:23:24 -07:00
parent d902e1daff
commit 9e115c629f
2 changed files with 11 additions and 6 deletions

View File

@@ -151,9 +151,6 @@ CreateElementPages(HnswBuildState * buildstate)
e->offno = PageAddItem(page, (Item) element, elementsz, InvalidOffsetNumber, false, false);
if (e->offno == InvalidOffsetNumber)
elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(index));
if (e == buildstate->entryPoint)
UpdateMetaPage(index, true, e, InvalidBlockNumber, forkNum);
}
insertPage = BufferGetBlockNumber(buf);
@@ -163,7 +160,7 @@ CreateElementPages(HnswBuildState * buildstate)
GenericXLogFinish(state);
UnlockReleaseBuffer(buf);
UpdateMetaPage(index, false, NULL, insertPage, forkNum);
UpdateMetaPage(index, true, buildstate->entryPoint, insertPage, forkNum);
}
/*

View File

@@ -876,8 +876,16 @@ UpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNu
if (updateEntry)
{
metap->entryBlkno = entryPoint->blkno;
metap->entryOffno = entryPoint->offno;
if (entryPoint == NULL)
{
metap->entryBlkno = InvalidBlockNumber;
metap->entryOffno = InvalidOffsetNumber;
}
else
{
metap->entryBlkno = entryPoint->blkno;
metap->entryOffno = entryPoint->offno;
}
}
if (BlockNumberIsValid(insertPage))