Bug fixes from Sleepycat Software for db_btree databases; for some corner

cases in splitting pages, and for correctly updating data base metadata.
This commit is contained in:
is 1997-10-10 21:08:53 +00:00
parent e230a48b57
commit 8871c98bb7
2 changed files with 9 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bt_page.c,v 1.8 1997/07/21 14:06:34 jtc Exp $ */ /* $NetBSD: bt_page.c,v 1.9 1997/10/10 21:08:53 is Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94"; static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94";
#else #else
__RCSID("$NetBSD: bt_page.c,v 1.8 1997/07/21 14:06:34 jtc Exp $"); __RCSID("$NetBSD: bt_page.c,v 1.9 1997/10/10 21:08:53 is Exp $");
#endif #endif
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
@ -73,6 +73,7 @@ __bt_free(t, h)
h->prevpg = P_INVALID; h->prevpg = P_INVALID;
h->nextpg = t->bt_free; h->nextpg = t->bt_free;
t->bt_free = h->pgno; t->bt_free = h->pgno;
F_SET(t, B_METADIRTY);
/* Make sure the page gets written back. */ /* Make sure the page gets written back. */
return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); return (mpool_put(t->bt_mp, h, MPOOL_DIRTY));
@ -100,6 +101,7 @@ __bt_new(t, npg)
(h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
*npg = t->bt_free; *npg = t->bt_free;
t->bt_free = h->nextpg; t->bt_free = h->nextpg;
F_SET(t, B_METADIRTY);
return (h); return (h);
} }
return (mpool_new(t->bt_mp, npg)); return (mpool_new(t->bt_mp, npg));

View File

@ -1,4 +1,4 @@
/* $NetBSD: bt_split.c,v 1.8 1997/07/21 14:06:38 jtc Exp $ */ /* $NetBSD: bt_split.c,v 1.9 1997/10/10 21:08:55 is Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)bt_split.c 8.9 (Berkeley) 7/26/94"; static char sccsid[] = "@(#)bt_split.c 8.9 (Berkeley) 7/26/94";
#else #else
__RCSID("$NetBSD: bt_split.c,v 1.8 1997/07/21 14:06:38 jtc Exp $"); __RCSID("$NetBSD: bt_split.c,v 1.9 1997/10/10 21:08:55 is Exp $");
#endif #endif
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
@ -681,7 +681,8 @@ bt_psplit(t, h, l, r, pskip, ilen)
* where we decide to try and copy too much onto the left page. * where we decide to try and copy too much onto the left page.
* Make sure that doesn't happen. * Make sure that doesn't happen.
*/ */
if (skip <= off && used + nbytes >= full) { if ((skip <= off && used + nbytes + sizeof(indx_t) >= full) ||
nxt == top - 1) {
--off; --off;
break; break;
} }
@ -694,7 +695,7 @@ bt_psplit(t, h, l, r, pskip, ilen)
memmove((char *)l + l->upper, src, nbytes); memmove((char *)l + l->upper, src, nbytes);
} }
used += nbytes; used += nbytes + sizeof(indx_t);
if (used >= half) { if (used >= half) {
if (!isbigkey || bigkeycnt == 3) if (!isbigkey || bigkeycnt == 3)
break; break;