-// drill down fixing fence values for left sibling tree
-
-// call with set write locked
-// return with set unlocked & unpinned.
-
-BTERR bt_fixfences (BtDb *bt, BtPageSet *set, unsigned char *newfence)
-{
-unsigned char oldfence[256];
-BtPageSet next[1];
-int chk;
-
- memcpy (oldfence, set->page->fence, 256);
- next->page_no = bt_getid(slotptr(set->page, set->page->cnt)->id);
-
- while( !set->page->kill && set->page->lvl ) {
- next->latch = bt_pinlatch (bt, next->page_no);
- bt_lockpage (BtLockParent, next->latch);
- bt_lockpage (BtLockAccess, next->latch);
- bt_lockpage (BtLockWrite, next->latch);
- bt_unlockpage (BtLockAccess, next->latch);
-
- if( next->pool = bt_pinpool (bt, next->page_no) )
- next->page = bt_page (bt, next->pool, next->page_no);
- else
- return bt->err;
-
- chk = keycmp ((BtKey)next->page->fence, oldfence + 1, *oldfence);
-
- if( chk < 0 ) {
- next->page_no = bt_getid (next->page->right);
- bt_unlockpage (BtLockWrite, next->latch);
- bt_unlockpage (BtLockParent, next->latch);
- bt_unpinlatch (next->latch);
- bt_unpinpool (next->pool);
- continue;
- }
-
- if( chk > 0 )
- return bt->err = BTERR_struct;
-
- if( bt_fixfences (bt, next, newfence) )
- return bt->err;
-
- break;
- }
-
- memcpy (set->page->fence, newfence, 256);
-
- bt_unlockpage (BtLockWrite, set->latch);
- bt_unlockpage (BtLockParent, set->latch);
- bt_unpinlatch (set->latch);
- bt_unpinpool (set->pool);
- return 0;
-}
-