From 6eb2e1b288d1363abf998b1604978a64340ad20a Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sun, 20 Mar 2022 13:13:08 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/page/tdbPage.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/libs/tdb/src/page/tdbPage.c b/source/libs/tdb/src/page/tdbPage.c index 9d679118e7..d91a32cb7c 100644 --- a/source/libs/tdb/src/page/tdbPage.c +++ b/source/libs/tdb/src/page/tdbPage.c @@ -136,19 +136,26 @@ int tdbPageDropCell(SPage *pPage, int idx) { SCell *pCell; int szCell; int nCells; + int iOvfl; nCells = TDB_PAGE_NCELLS(pPage); - if (pPage->nOverflow == 0) { - lidx = idx; - } else { - // TODO + ASSERT(idx >= 0 && idx < nCells + pPage->nOverflow); + + iOvfl = 0; + for (; iOvfl < pPage->nOverflow; iOvfl++) { + if (pPage->aiOvfl[iOvfl] == idx) { + // TODO: remove the over flow cell + return 0; + } else if (pPage->aiOvfl[iOvfl] > idx) { + break; + } } + lidx = idx - iOvfl; pCell = TDB_PAGE_CELL_AT(pPage, lidx); szCell = (*pPage->xCellSize)(pCell); tdbPageFree(pPage, lidx, pCell, szCell); - TDB_PAGE_NCELLS_SET(pPage, nCells - 1); return 0;