]> git.sur5r.net Git - openldap/commitdiff
Fix mdb_drop() if not deleting the DB record
authorHoward Chu <hyc@symas.com>
Sun, 18 Sep 2011 21:18:27 +0000 (14:18 -0700)
committerHoward Chu <hyc@symas.com>
Sun, 18 Sep 2011 21:22:27 +0000 (14:22 -0700)
libraries/libmdb/mdb.c

index aa5f2cd3c656a5690dadcb1656fe8ecc41364e24..6e829c864b7d27189073593aa4bbc1c80b6a4316 100644 (file)
@@ -5342,10 +5342,19 @@ int mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del)
                mdb_cursor_close(mc);
                return rc;
 
-       if (del) {
+       /* Can't delete the main DB */
+       if (del && dbi > MAIN_DBI) {
                rc = mdb_del(txn, MAIN_DBI, &mc->mc_dbx->md_name, NULL);
                if (!rc)
                        mdb_close(txn->mt_env, dbi);
+       } else {
+               txn->mt_dbflags[dbi] |= DB_DIRTY;
+               txn->mt_dbs[dbi].md_depth = 0;
+               txn->mt_dbs[dbi].md_branch_pages = 0;
+               txn->mt_dbs[dbi].md_leaf_pages = 0;
+               txn->mt_dbs[dbi].md_overflow_pages = 0;
+               txn->mt_dbs[dbi].md_entries = 0;
+               txn->mt_dbs[dbi].md_root = P_INVALID;
        }
        mdb_cursor_close(mc);
        return rc;