From 40df306d52cf0f6e2314d1da5bc35ee76369d78d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 11 Aug 2011 03:23:22 -0700 Subject: [PATCH] More subDB fixes --- libraries/libmdb/mdb.c | 7 ++++--- libraries/libmdb/mdb_stat.c | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 3e2d70e..c929129 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -821,7 +821,7 @@ mdb_txn_commit(MDB_txn *txn) for (i = 2; i < txn->mt_numdbs; i++) { if (txn->mt_dbxs[i].md_dirty) { data.mv_data = &txn->mt_dbs[i]; - mdb_put0(txn, i, &txn->mt_dbxs[i].md_name, &data, 0); + mdb_put0(txn, MAIN_DBI, &txn->mt_dbxs[i].md_name, &data, 0); } } } @@ -2987,7 +2987,6 @@ mdb_put0(MDB_txn *txn, MDB_dbi dbi, if (SIZELEFT(mpp.mp_page) < mdb_leaf_size(txn->mt_env, key, data)) { rc = mdb_split(txn, dbi, &mpp.mp_page, &ki, key, data, P_INVALID); - leaf = NODEPTR(mpp.mp_page, ki); } else { /* There is room already in this leaf page. */ rc = mdb_add_node(txn, dbi, mpp.mp_page, ki, key, data, 0, 0); @@ -2999,8 +2998,10 @@ mdb_put0(MDB_txn *txn, MDB_dbi dbi, txn->mt_dbs[dbi].md_entries++; /* Remember if we just added a subdatabase */ - if (flags & F_SUBDATA) + if (flags & F_SUBDATA) { + leaf = NODEPTR(mpp.mp_page, ki); leaf->mn_flags |= F_SUBDATA; + } /* Now store the actual data in the child DB. Note that we're * storing the user data in the keys field, so there are strict diff --git a/libraries/libmdb/mdb_stat.c b/libraries/libmdb/mdb_stat.c index e55e5ae..171928b 100644 --- a/libraries/libmdb/mdb_stat.c +++ b/libraries/libmdb/mdb_stat.c @@ -26,10 +26,13 @@ int main(int argc,char * argv[]) char *envname = argv[1]; char *subname = NULL; - if (argc > 2) - subname = argv[2]; - rc = mdbenv_create(&env); + + if (argc > 2) { + mdbenv_set_maxdbs(env, 4); + subname = argv[2]; + } + rc = mdbenv_open(env, envname, MDB_RDONLY, 0); if (rc) { printf("mdbenv_open failed, error %d\n", rc);