From 255bbf74b8293ecca9bfe3cf29b08f930bd9ca49 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 27 Nov 2026 00:04:40 -0800 Subject: [PATCH] Fixed insert page logic for IVFFlat vacuuming - resolves #1078 Co-authored-by: Song Bian <29000790+Waterpine@users.noreply.github.com> --- src/ivfutils.c | 2 +- src/ivfvacuum.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ivfutils.c b/src/ivfutils.c index 18914612..e1f710cc 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -260,7 +260,7 @@ IvfflatUpdateList(Relation index, ListInfo listInfo, { /* Skip update if insert page is lower than original insert page */ /* This is needed to prevent insert from overwriting vacuum */ - if (!BlockNumberIsValid(originalInsertPage) || insertPage >= originalInsertPage) + if (!BlockNumberIsValid(originalInsertPage) || list->insertPage >= originalInsertPage) { list->insertPage = insertPage; changed = true; diff --git a/src/ivfvacuum.c b/src/ivfvacuum.c index 7d9b0d95..b715bbb0 100644 --- a/src/ivfvacuum.c +++ b/src/ivfvacuum.c @@ -143,7 +143,7 @@ ivfflatbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, /* Set to first free page */ /* Must be set before searchPage is updated */ - if (!BlockNumberIsValid(insertPage) && ndeletable > 0) + if (!BlockNumberIsValid(insertPage) && (ndeletable > 0 || maxoffno < FirstOffsetNumber || PageGetFreeSpace(page) >= ItemIdGetLength(PageGetItemId(page, FirstOffsetNumber)))) insertPage = searchPage; searchPage = IvfflatPageGetOpaque(page)->nextblkno;