From 36b1ad02fbca047c8f2b71adf0ab88418f0c9f0c Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Mon, 21 Nov 2016 18:38:26 +0300 Subject: [PATCH] mdbx: fix MDB_CORRUPTED while walk/checking empty sub-db. This fixes https://github.com/ReOpen/libmdbx/issues/4 --- mdbx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mdbx.c b/mdbx.c index bd889f9a..3121adf6 100644 --- a/mdbx.c +++ b/mdbx.c @@ -160,7 +160,7 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee const char* type; if (pg == P_INVALID) - return MDB_CORRUPTED; + return MDB_SUCCESS; /* empty db */ rc = mdb_page_get(ctx->mw_txn, pg, &mp, NULL); if (rc) @@ -292,9 +292,9 @@ mdbx_env_pgwalk(MDB_txn *txn, MDBX_pgvisitor_func* visitor, void* user) rc = visitor(0, 2, user, "lmdb", "meta", 2, sizeof(MDB_meta)*2, PAGEHDRSZ*2, (txn->mt_env->me_psize - sizeof(MDB_meta) - PAGEHDRSZ) *2); - if (! rc && txn->mt_dbs[FREE_DBI].md_root != P_INVALID) + if (! rc) rc = mdb_env_walk(&ctx, "free", txn->mt_dbs[FREE_DBI].md_root, 0, 0); - if (! rc && txn->mt_dbs[MAIN_DBI].md_root != P_INVALID) + if (! rc) rc = mdb_env_walk(&ctx, "main", txn->mt_dbs[MAIN_DBI].md_root, 0, 0); if (! rc) rc = visitor(P_INVALID, 0, user, NULL, NULL, 0, 0, 0, 0);