lmdb: Simpler flag/DBI checks and MDB_DEBUG.

Change-Id: I37a00fcc23f2060538ab4378f204ae0efcdb59ea
This commit is contained in:
Hallvard Furuseth 2015-07-04 13:48:07 +02:00 committed by Leo Yuriev
parent 9e52d29fd8
commit 4cb5d637d4

13
mdb.c
View File

@ -5012,13 +5012,12 @@ static void
mdb_cursor_pop(MDB_cursor *mc) mdb_cursor_pop(MDB_cursor *mc)
{ {
if (mc->mc_snum) { if (mc->mc_snum) {
MDB_page *top = mc->mc_pg[mc->mc_top]; mdb_debug("popped page %zu off db %d cursor %p",
mc->mc_pg[mc->mc_top]->mp_pgno, DDBI(mc), (void *) mc);
mc->mc_snum--; mc->mc_snum--;
if (mc->mc_snum) if (mc->mc_snum)
mc->mc_top--; mc->mc_top--;
mdb_debug("popped page %zu off db %d cursor %p", top->mp_pgno,
DDBI(mc), (void *) mc);
} }
} }
@ -8404,7 +8403,7 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi,
if (!key || !data || dbi == FREE_DBI || !TXN_DBI_EXIST(txn, dbi)) if (!key || !data || dbi == FREE_DBI || !TXN_DBI_EXIST(txn, dbi))
return EINVAL; return EINVAL;
if ((flags & (MDB_NOOVERWRITE|MDB_NODUPDATA|MDB_RESERVE|MDB_APPEND|MDB_APPENDDUP)) != flags) if (flags & ~(MDB_NOOVERWRITE|MDB_NODUPDATA|MDB_RESERVE|MDB_APPEND|MDB_APPENDDUP))
return EINVAL; return EINVAL;
mdb_cursor_init(&mc, txn, dbi, &mx); mdb_cursor_init(&mc, txn, dbi, &mx);
@ -8936,7 +8935,7 @@ mdb_env_copy(MDB_env *env, const char *path)
int ESECT int ESECT
mdb_env_set_flags(MDB_env *env, unsigned flag, int onoff) mdb_env_set_flags(MDB_env *env, unsigned flag, int onoff)
{ {
if ((flag & CHANGEABLE) != flag) if (flag & ~CHANGEABLE)
return EINVAL; return EINVAL;
if (onoff) if (onoff)
env->me_flags |= flag; env->me_flags |= flag;
@ -9108,7 +9107,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned flags, MDB_dbi *dbi)
unsigned unused = 0, seq; unsigned unused = 0, seq;
size_t len; size_t len;
if ((flags & VALID_FLAGS) != flags) if (flags & ~VALID_FLAGS)
return EINVAL; return EINVAL;
if (txn->mt_flags & MDB_TXN_ERROR) if (txn->mt_flags & MDB_TXN_ERROR)
return MDB_BAD_TXN; return MDB_BAD_TXN;