From: Howard Chu Date: Thu, 11 Aug 2011 10:23:22 +0000 (-0700) Subject: More subDB fixes X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~124 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;ds=sidebyside;h=40df306d52cf0f6e2314d1da5bc35ee76369d78d;p=openldap More subDB fixes --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 3e2d70e36c..c9291291fa 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 e55e5ae51e..171928b51a 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);