summaryrefslogtreecommitdiffstats
path: root/lib/libc/db/btree/bt_split.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/db/btree/bt_split.c')
-rw-r--r--lib/libc/db/btree/bt_split.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index 22334c1e430..110e3f9dd1d 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bt_split.c,v 1.5 1995/02/27 13:20:55 cgd Exp $ */
+/* $NetBSD: bt_split.c,v 1.6 1996/05/03 21:50:56 cgd Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -38,9 +38,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
-static char sccsid[] = "@(#)bt_split.c 8.6 (Berkeley) 6/16/94";
+static char sccsid[] = "@(#)bt_split.c 8.9 (Berkeley) 7/26/94";
#else
-static char rcsid[] = "$NetBSD: bt_split.c,v 1.5 1995/02/27 13:20:55 cgd Exp $";
+static char rcsid[] = "$NetBSD: bt_split.c,v 1.6 1996/05/03 21:50:56 cgd Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -123,14 +123,14 @@ __bt_split(t, sp, key, data, flags, ilen, argskip)
*/
h->linp[skip] = h->upper -= ilen;
dest = (char *)h + h->upper;
- if (ISSET(t, R_RECNO))
+ if (F_ISSET(t, R_RECNO))
WR_RLEAF(dest, data, flags)
else
WR_BLEAF(dest, key, data, flags)
/* If the root page was split, make it look right. */
if (sp->pgno == P_ROOT &&
- (ISSET(t, R_RECNO) ?
+ (F_ISSET(t, R_RECNO) ?
bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR)
goto err2;
@@ -238,7 +238,7 @@ __bt_split(t, sp, key, data, flags, ilen, argskip)
}
/* Insert the key into the parent page. */
- switch(rchild->flags & P_TYPE) {
+ switch (rchild->flags & P_TYPE) {
case P_BINTERNAL:
h->linp[skip] = h->upper -= nbytes;
dest = (char *)h + h->linp[skip];
@@ -303,7 +303,7 @@ __bt_split(t, sp, key, data, flags, ilen, argskip)
/* If the root page was split, make it look right. */
if (sp->pgno == P_ROOT &&
- (ISSET(t, R_RECNO) ?
+ (F_ISSET(t, R_RECNO) ?
bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR)
goto err1;
@@ -396,6 +396,9 @@ bt_page(t, h, lp, rp, skip, ilen)
mpool_put(t->bt_mp, r, 0);
return (NULL);
}
+#ifdef PURIFY
+ memset(l, 0xff, t->bt_psize);
+#endif
l->pgno = h->pgno;
l->nextpg = r->pgno;
l->prevpg = h->prevpg;
@@ -411,7 +414,7 @@ bt_page(t, h, lp, rp, skip, ilen)
return (NULL);
}
tp->prevpg = r->pgno;
- mpool_put(t->bt_mp, tp, 0);
+ mpool_put(t->bt_mp, tp, MPOOL_DIRTY);
}
/*
@@ -558,7 +561,7 @@ bt_broot(t, h, l, r)
dest = (char *)h + h->upper;
WR_BINTERNAL(dest, 0, l->pgno, 0);
- switch(h->flags & P_TYPE) {
+ switch (h->flags & P_TYPE) {
case P_BLEAF:
bl = GETBLEAF(r, 0);
nbytes = NBINTERNAL(bl->ksize);
@@ -621,8 +624,8 @@ bt_psplit(t, h, l, r, pskip, ilen)
{
BINTERNAL *bi;
BLEAF *bl;
+ CURSOR *c;
RLEAF *rl;
- EPGNO *c;
PAGE *rval;
void *src;
indx_t full, half, nxt, off, skip, top, used;
@@ -710,19 +713,16 @@ bt_psplit(t, h, l, r, pskip, ilen)
* cursor is at or past the skipped slot, the cursor is incremented by
* one. If the cursor is on the right page, it is decremented by the
* number of records split to the left page.
- *
- * Don't bother checking for the B_SEQINIT flag, the page number will
- * be P_INVALID.
*/
- c = &t->bt_bcursor;
- if (c->pgno == h->pgno) {
- if (c->index >= skip)
- ++c->index;
- if (c->index < nxt) /* Left page. */
- c->pgno = l->pgno;
+ c = &t->bt_cursor;
+ if (F_ISSET(c, CURS_INIT) && c->pg.pgno == h->pgno) {
+ if (c->pg.index >= skip)
+ ++c->pg.index;
+ if (c->pg.index < nxt) /* Left page. */
+ c->pg.pgno = l->pgno;
else { /* Right page. */
- c->pgno = r->pgno;
- c->index -= nxt;
+ c->pg.pgno = r->pgno;
+ c->pg.index -= nxt;
}
}