tdb/btree: recyle pNews 0
This commit is contained in:
parent
40b741dfee
commit
4e3df6606b
|
@ -860,10 +860,10 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
|
||||
if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
|
||||
((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno;
|
||||
} else {
|
||||
// printf("tdb/balance: btree balance delete pgno: %d.\n", TDB_PAGE_PGNO(pNews[0]));
|
||||
tdbPagerInsertFreePage(pBt->pPager, TDB_PAGE_PGNO(pNews[0]), pTxn);
|
||||
}
|
||||
} // else {
|
||||
// printf("tdb/balance: btree balance delete pgno: %d.\n", TDB_PAGE_PGNO(pNews[0]));
|
||||
tdbPagerInsertFreePage(pBt->pPager, TDB_PAGE_PGNO(pNews[0]), pTxn);
|
||||
//}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
|
|
@ -703,8 +703,10 @@ void tdbPagerReturnPage(SPager *pPager, SPage *pPage, TXN *pTxn) {
|
|||
int tdbPagerInsertFreePage(SPager *pPager, SPgno pgno, TXN *pTxn) {
|
||||
int code = 0;
|
||||
|
||||
// tdbError("tdb/insert-free-page: tbc get page: %d.", pgno);
|
||||
code = tdbTbInsert(pPager->pEnv->pFreeDb, &pgno, sizeof(pgno), NULL, 0, pTxn);
|
||||
if (code < 0) {
|
||||
tdbError("tdb/insert-free-page: tb insert failed with ret: %d.", code);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -742,6 +744,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
|||
}
|
||||
|
||||
*pPgno = *(SPgno *)pKey;
|
||||
// tdbError("tdb/remove-free-page: tbc get page: %d.", *pPgno);
|
||||
|
||||
code = tdbTbcDelete(pCur);
|
||||
if (code < 0) {
|
||||
|
@ -760,6 +763,7 @@ static int tdbPagerAllocFreePage(SPager *pPager, SPgno *ppgno, TXN *pTxn) {
|
|||
|
||||
static int tdbPagerAllocNewPage(SPager *pPager, SPgno *ppgno) {
|
||||
*ppgno = ++pPager->dbFileSize;
|
||||
// tdbError("tdb/alloc-new-page: %d.", *ppgno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue