summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-11-13 06:35:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-11-13 06:35:07 +0000
commit4f7a8c5ede325229049538ea3a14069a96b1fb1c (patch)
tree636ee6c814aeadc6fc31e7ceda1ef12c0f6c2390 /lib
parenteac3a34b109e55a627f461ed8536fb49859f9905 (diff)
Bug fixes from Sleepycat Software for db_btree databases; for some corner
cases in splitting pages, and for correctly updating data base metadata.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/db/btree/bt_page.c4
-rw-r--r--lib/libc/db/btree/bt_split.c7
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c
index db80a7ec332..2552ef2d1fe 100644
--- a/lib/libc/db/btree/bt_page.c
+++ b/lib/libc/db/btree/bt_page.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: bt_page.c,v 1.3 1996/08/19 08:20:10 tholo Exp $";
+static char rcsid[] = "$OpenBSD: bt_page.c,v 1.4 1997/11/13 06:35:06 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -65,6 +65,7 @@ __bt_free(t, h)
h->prevpg = P_INVALID;
h->nextpg = t->bt_free;
t->bt_free = h->pgno;
+ F_SET(t, B_METADIRTY);
/* Make sure the page gets written back. */
return (mpool_put(t->bt_mp, h, MPOOL_DIRTY));
@@ -92,6 +93,7 @@ __bt_new(t, npg)
(h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
*npg = t->bt_free;
t->bt_free = h->nextpg;
+ F_SET(t, B_METADIRTY);
return (h);
}
return (mpool_new(t->bt_mp, npg));
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index a2098a70b5f..06f2eac5121 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: bt_split.c,v 1.3 1996/08/19 08:20:16 tholo Exp $";
+static char rcsid[] = "$OpenBSD: bt_split.c,v 1.4 1997/11/13 06:35:06 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -673,7 +673,8 @@ bt_psplit(t, h, l, r, pskip, ilen)
* where we decide to try and copy too much onto the left page.
* 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;
break;
}
@@ -686,7 +687,7 @@ bt_psplit(t, h, l, r, pskip, ilen)
memmove((char *)l + l->upper, src, nbytes);
}
- used += nbytes;
+ used += nbytes + sizeof(indx_t);
if (used >= half) {
if (!isbigkey || bigkeycnt == 3)
break;