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);
}
}
}
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);
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
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);