From: Howard Chu Date: Sun, 18 Sep 2011 21:18:27 +0000 (-0700) Subject: Fix mdb_drop() if not deleting the DB record X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~25 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2c70d0430adc24b1afb59a265ffcc43a124e64ad;p=openldap Fix mdb_drop() if not deleting the DB record --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index aa5f2cd3c6..6e829c864b 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -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;