34 #if defined(LIBC_SCCS) && !defined(lint)
35 static char sccsid[] =
"@(#)rec_search.c 8.4 (Berkeley) 7/14/94";
38 #include <sys/types.h>
43 #include "../include/db.h"
64 __rec_search(t, recno, op)
69 register indx_t index;
79 for (pg = P_ROOT, total = 0;;) {
80 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
82 if (h->flags & P_RLEAF) {
84 t->bt_cur.index = recno - total;
87 for (index = 0, top = NEXTINDEX(h);;) {
88 r = GETRINTERNAL(h, index);
89 if (++index == top || total + r->nrecs > recno)
94 BT_PUSH(t, pg, index - 1);
99 --GETRINTERNAL(h, (index - 1))->nrecs;
100 mpool_put(t->bt_mp, h, MPOOL_DIRTY);
103 ++GETRINTERNAL(h, (index - 1))->nrecs;
104 mpool_put(t->bt_mp, h, MPOOL_DIRTY);
107 mpool_put(t->bt_mp, h, 0);
113 err: sverrno = errno;
115 while ((parent = BT_POP(t)) != NULL) {
116 if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
119 --GETRINTERNAL(h, parent->index)->nrecs;
121 ++GETRINTERNAL(h, parent->index)->nrecs;
122 mpool_put(t->bt_mp, h, MPOOL_DIRTY);