提交 72aed899 编写于 作者: H Hongze Cheng

more TDB

上级 d5a1c7a3
...@@ -493,6 +493,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { ...@@ -493,6 +493,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
int szDivCell[2]; int szDivCell[2];
int sIdx; int sIdx;
u8 childNotLeaf; u8 childNotLeaf;
SPgno rPgno;
{ // Find 3 child pages at most to do balance { // Find 3 child pages at most to do balance
int nCells = TDB_PAGE_TOTAL_CELLS(pParent); int nCells = TDB_PAGE_TOTAL_CELLS(pParent);
...@@ -547,6 +548,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { ...@@ -547,6 +548,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
// the slow defragment process // the slow defragment process
tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1);
} }
rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno;
} }
// drop the cells on parent page // drop the cells on parent page
for (int i = 0; i < nOlds; i++) { for (int i = 0; i < nOlds; i++) {
...@@ -741,14 +743,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { ...@@ -741,14 +743,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
((SIntHdr *)pNews[iNew]->pData)->pgno = ((SPgno *)pCell)[0]; ((SIntHdr *)pNews[iNew]->pData)->pgno = ((SPgno *)pCell)[0];
// insert to parent as divider cell // insert to parent as divider cell
SIntHdr *pIntHdr = (SIntHdr *)pParent->pData; ASSERT(iNew < nNews - 1);
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
if (iNew == nNews - 1 && pIntHdr->pgno == 0) { tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[iNew]);
} else {
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
}
// move to next new page // move to next new page
iNew++; iNew++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册