Commit 66f2b7b2 authored by Howard Chu's avatar Howard Chu
Browse files

Make sure mdb_open flags are committed on main DB

If no data was modified in the txn, mdb_open flag changes were dropped.
parent 5f2ddb55
...@@ -826,6 +826,7 @@ struct MDB_txn { ...@@ -826,6 +826,7 @@ struct MDB_txn {
*/ */
#define MDB_TXN_RDONLY 0x01 /**< read-only transaction */ #define MDB_TXN_RDONLY 0x01 /**< read-only transaction */
#define MDB_TXN_ERROR 0x02 /**< an error has occurred */ #define MDB_TXN_ERROR 0x02 /**< an error has occurred */
#define MDB_TXN_DIRTY 0x04 /**< must write, even if dirty list is empty */
/** @} */ /** @} */
unsigned int mt_flags; /**< @ref mdb_txn */ unsigned int mt_flags; /**< @ref mdb_txn */
/** Tracks which of the two meta pages was used at the start /** Tracks which of the two meta pages was used at the start
...@@ -2005,7 +2006,7 @@ mdb_txn_commit(MDB_txn *txn) ...@@ -2005,7 +2006,7 @@ mdb_txn_commit(MDB_txn *txn)
return EINVAL; return EINVAL;
} }
if (!txn->mt_u.dirty_list[0].mid) if (!txn->mt_u.dirty_list[0].mid && !(txn->mt_flags & MDB_TXN_DIRTY))
goto done; goto done;
DPRINTF("committing txn %zu %p on mdbenv %p, root page %zu", DPRINTF("committing txn %zu %p on mdbenv %p, root page %zu",
...@@ -6715,8 +6716,13 @@ int mdb_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi) ...@@ -6715,8 +6716,13 @@ int mdb_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
/* main DB? */ /* main DB? */
if (!name) { if (!name) {
*dbi = MAIN_DBI; *dbi = MAIN_DBI;
if (flags & (MDB_DUPSORT|MDB_REVERSEKEY|MDB_INTEGERKEY)) if (flags & (MDB_DUPSORT|MDB_REVERSEKEY|MDB_INTEGERKEY)) {
/* make sure flag changes get committed */
if ((txn->mt_dbs[MAIN_DBI].md_flags | flags) != txn->mt_dbs[MAIN_DBI].md_flags) {
txn->mt_dbs[MAIN_DBI].md_flags |= (flags & (MDB_DUPSORT|MDB_REVERSEKEY|MDB_INTEGERKEY)); txn->mt_dbs[MAIN_DBI].md_flags |= (flags & (MDB_DUPSORT|MDB_REVERSEKEY|MDB_INTEGERKEY));
txn->mt_flags |= MDB_TXN_DIRTY;
}
}
mdb_default_cmp(txn, MAIN_DBI); mdb_default_cmp(txn, MAIN_DBI);
return MDB_SUCCESS; return MDB_SUCCESS;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment