-BtPageSet right[1], temp[1];
-unsigned char value[BtId];
-uid right_page_no;
-BtKey *ptr;
-
- bt_lockpage(BtLockWrite, prev->latch, thread_no);
-
- // grab the right sibling
-
- if( right->latch = bt_pinlatch(mgr, bt_getid (prev->page->right), NULL, thread_no) )
- right->page = bt_mappage (mgr, right->latch);
- else
- return mgr->err;
-
- bt_lockpage(BtLockAtomic, right->latch, thread_no);
- bt_lockpage(BtLockWrite, right->latch, thread_no);
-
- // and pull contents over empty page
- // while preserving master's left link
-
- memcpy (right->page->left, prev->page->left, BtId);
- memcpy (prev->page, right->page, mgr->page_size);
-
- // forward seekers to old right sibling
- // to new page location in set
-
- bt_putid (right->page->right, prev->latch->page_no);
- right->latch->dirty = 1;
- right->page->kill = 1;
-
- // remove pointer to right page for searchers by
- // changing right fence key to point to the master page
-
- ptr = keyptr(right->page,right->page->cnt);
- bt_putid (value, prev->latch->page_no);
-
- if( bt_insertkey (mgr, ptr->key, ptr->len, 1, value, BtId, Unique, thread_no) )
- return mgr->err;
-
- // now that master page is in good shape we can
- // remove its locks.
-
- bt_unlockpage (BtLockAtomic, prev->latch);
- bt_unlockpage (BtLockWrite, prev->latch);
-
- // fix master's right sibling's left pointer
- // to remove scanner's poiner to the right page
-
- if( right_page_no = bt_getid (prev->page->right) ) {
- if( temp->latch = bt_pinlatch (mgr, right_page_no, NULL, thread_no) )
- temp->page = bt_mappage (mgr, temp->latch);
- else
- return mgr->err;
-
- bt_lockpage (BtLockWrite, temp->latch, thread_no);
- bt_putid (temp->page->left, prev->latch->page_no);
- temp->latch->dirty = 1;
-
- bt_unlockpage (BtLockWrite, temp->latch);
- bt_unpinlatch (mgr, temp->latch);
- } else { // master is now the far right page
- bt_mutexlock (mgr->lock);
- bt_putid (mgr->pagezero->alloc->left, prev->latch->page_no);
- bt_releasemutex(mgr->lock);
- }
-
- // now that there are no pointers to the right page
- // we can delete it after the last read access occurs