This commit is contained in:
Hongze Cheng 2022-03-22 11:47:25 +00:00
parent 3b49a863ea
commit 3a173f4660
1 changed files with 16 additions and 6 deletions

View File

@ -204,7 +204,19 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
} }
static int tdbBtCursorMoveToChild(SBtCursor *pCur, SPgno pgno) { static int tdbBtCursorMoveToChild(SBtCursor *pCur, SPgno pgno) {
// TODO int ret;
pCur->pgStack[pCur->iPage] = pCur->pPage;
pCur->idxStack[pCur->iPage] = pCur->idx;
pCur->iPage++;
pCur->pPage = NULL;
pCur->idx = -1;
ret = tdbPagerFetchPage(pCur->pBt->pPager, pgno, &pCur->pPage, tdbBtreeInitPage, pCur->pBt);
if (ret < 0) {
ASSERT(0);
}
return 0; return 0;
} }
@ -287,14 +299,12 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *p
pCur->idx = midx; pCur->idx = midx;
tdbBtCursorMoveToChild(pCur, cd.pgno); tdbBtCursorMoveToChild(pCur, cd.pgno);
} else { } else {
pCur->idx = midx + 1;
if (midx == nCells - 1) { if (midx == nCells - 1) {
/* Move to right-most child */ /* Move to right-most child */
pCur->idx = midx + 1; tdbBtCursorMoveToChild(pCur, ((SIntHdr *)pCur->pPage->pData)->pgno);
// tdbBtCursorMoveToChild(pCur, ((SBtPageHdr *)(pPage->pAmHdr))->rChild);
} else { } else {
// TODO: reset cd as uninitialized pCell = tdbPageGetCell(pPage, pCur->idx);
pCur->idx = midx + 1;
pCell = tdbPageGetCell(pPage, midx + 1);
tdbBtreeDecodeCell(pPage, pCell, &cd); tdbBtreeDecodeCell(pPage, pCell, &cd);
tdbBtCursorMoveToChild(pCur, cd.pgno); tdbBtCursorMoveToChild(pCur, cd.pgno);
} }