summaryrefslogtreecommitdiffstats
path: root/lib/libc/db/btree
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-03-28 07:31:02 +0000
committerdelphij <delphij@FreeBSD.org>2009-03-28 07:31:02 +0000
commit1db7e98746958564da51eee2a32c7c3f1b56e03d (patch)
treeed6c7564fb2f2d25581d74c48ca0074066b16e39 /lib/libc/db/btree
parent2ca1d8e1e96f9ca5abe40be147c7076163b69c68 (diff)
downloadFreeBSD-src-1db7e98746958564da51eee2a32c7c3f1b56e03d.zip
FreeBSD-src-1db7e98746958564da51eee2a32c7c3f1b56e03d.tar.gz
Minor changes from Berkeley DB 1.86 and further improvements from OpenBSD.
This does not include the new hash routines since they will cause problems when reading old hash files. Since mpool(3) has been changed, provide a compatibility shim for older binaries. Obtained from: OpenBSD
Diffstat (limited to 'lib/libc/db/btree')
-rw-r--r--lib/libc/db/btree/bt_debug.c18
-rw-r--r--lib/libc/db/btree/bt_open.c17
-rw-r--r--lib/libc/db/btree/bt_page.c2
3 files changed, 19 insertions, 18 deletions
diff --git a/lib/libc/db/btree/bt_debug.c b/lib/libc/db/btree/bt_debug.c
index ff5357a..dc8b83d 100644
--- a/lib/libc/db/btree/bt_debug.c
+++ b/lib/libc/db/btree/bt_debug.c
@@ -83,10 +83,9 @@ __bt_dump(DB *dbp)
}
#undef X
- for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
+ for (i = P_ROOT;
+ (h = mpool_get(t->bt_mp, i, MPOOL_IGNOREPIN)) != NULL; ++i)
__bt_dpage(h);
- (void)mpool_put(t->bt_mp, h, 0);
- }
}
/*
@@ -135,10 +134,8 @@ __bt_dnpage(DB *dbp, pgno_t pgno)
PAGE *h;
t = dbp->internal;
- if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) {
+ if ((h = mpool_get(t->bt_mp, pgno, MPOOL_IGNOREPIN)) != NULL)
__bt_dpage(h);
- (void)mpool_put(t->bt_mp, h, 0);
- }
}
/*
@@ -257,7 +254,8 @@ __bt_stat(DB *dbp)
t = dbp->internal;
pcont = pinternal = pleaf = 0;
nkeys = ifree = lfree = 0;
- for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
+ for (i = P_ROOT;
+ (h = mpool_get(t->bt_mp, i, MPOOL_IGNOREPIN)) != NULL; ++i)
switch (h->flags & P_TYPE) {
case P_BINTERNAL:
case P_RINTERNAL:
@@ -274,22 +272,18 @@ __bt_stat(DB *dbp)
++pcont;
break;
}
- (void)mpool_put(t->bt_mp, h, 0);
- }
/* Count the levels of the tree. */
for (i = P_ROOT, levels = 0 ;; ++levels) {
- h = mpool_get(t->bt_mp, i, 0);
+ h = mpool_get(t->bt_mp, i, MPOOL_IGNOREPIN);
if (h->flags & (P_BLEAF|P_RLEAF)) {
if (levels == 0)
levels = 1;
- (void)mpool_put(t->bt_mp, h, 0);
break;
}
i = F_ISSET(t, R_RECNO) ?
GETRINTERNAL(h, 0)->pgno :
GETBINTERNAL(h, 0)->pgno;
- (void)mpool_put(t->bt_mp, h, 0);
}
(void)fprintf(stderr, "%d level%s with %lu keys",
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index 7422ca4..47f3646 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -352,18 +352,25 @@ nroot(BTREE *t)
PAGE *meta, *root;
pgno_t npg;
- if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) {
- mpool_put(t->bt_mp, meta, 0);
- return (RET_SUCCESS);
+ if ((root = mpool_get(t->bt_mp, 1, 0)) != NULL) {
+ if (root->lower == 0 &&
+ root->pgno == 0 &&
+ root->linp[0] == 0) {
+ mpool_delete(t->bt_mp, root);
+ errno = EINVAL;
+ } else {
+ mpool_put(t->bt_mp, root, 0);
+ return (RET_SUCCESS);
+ }
}
if (errno != EINVAL) /* It's OK to not exist. */
return (RET_ERROR);
errno = 0;
- if ((meta = mpool_new(t->bt_mp, &npg)) == NULL)
+ if ((meta = mpool_new(t->bt_mp, &npg, MPOOL_PAGE_NEXT)) == NULL)
return (RET_ERROR);
- if ((root = mpool_new(t->bt_mp, &npg)) == NULL)
+ if ((root = mpool_new(t->bt_mp, &npg, MPOOL_PAGE_NEXT)) == NULL)
return (RET_ERROR);
if (npg != P_ROOT)
diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c
index face4b1..ab5e359 100644
--- a/lib/libc/db/btree/bt_page.c
+++ b/lib/libc/db/btree/bt_page.c
@@ -90,5 +90,5 @@ __bt_new(BTREE *t, pgno_t *npg)
F_SET(t, B_METADIRTY);
return (h);
}
- return (mpool_new(t->bt_mp, npg));
+ return (mpool_new(t->bt_mp, npg, MPOOL_PAGE_NEXT));
}
OpenPOWER on IntegriCloud