lmdb: n-entries info from b-tree traversal in mdb_chk.

Change-Id: Ic9343dcdba976ac51c8f5776d2f7c9fed59da8e0
This commit is contained in:
Leo Yuriev 2015-09-02 17:53:48 +03:00
parent 9106e80fba
commit f7d8812e6c
3 changed files with 11 additions and 10 deletions

2
lmdb.h
View File

@ -1659,7 +1659,7 @@ typedef void MDB_debug_func(int type, const char *function, int line,
int mdb_setup_debug(int flags, MDB_debug_func* logger, long edge_txn);
typedef int MDB_pgvisitor_func(size_t pgno, unsigned pgnumber, void* ctx,
const char* dbi, const char *type,
const char* dbi, const char *type, int nentries,
int payload_bytes, int header_bytes, int unused_bytes);
int mdb_env_pgwalk(MDB_txn *txn, MDB_pgvisitor_func* visitor, void* ctx);

12
mdb.c
View File

@ -9895,8 +9895,8 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee
over_unused = omp->mp_pages * ctx->mw_txn->mt_env->me_psize
- over_payload - over_header;
rc = ctx->mw_visitor(*opg, omp->mp_pages, ctx->mw_user, dbi, "overflow-data",
over_payload, over_header, over_unused);
rc = ctx->mw_visitor(*opg, omp->mp_pages, ctx->mw_user, dbi,
"overflow-data", 1, over_payload, over_header, over_unused);
if (rc)
return rc;
continue;
@ -9922,8 +9922,8 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee
}
}
return ctx->mw_visitor(mp->mp_p.p_pgno, 1, ctx->mw_user, dbi,
type, payload_size, header_size, unused_size + align_bytes);
return ctx->mw_visitor(mp->mp_p.p_pgno, 1, ctx->mw_user, dbi, type,
nkeys, payload_size, header_size, unused_size + align_bytes);
}
int ESECT
@ -9936,14 +9936,14 @@ mdb_env_pgwalk(MDB_txn *txn, MDB_pgvisitor_func* visitor, void* user)
ctx.mw_user = user;
ctx.mw_visitor = visitor;
rc = visitor(0, 2, user, "lmdb", "meta", sizeof(MDB_meta)*2, PAGEHDRSZ*2,
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)
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)
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, -1, 0, 0);
rc = visitor(P_INVALID, 0, user, NULL, NULL, 0, 0, 0, 0);
return rc;
}

View File

@ -211,7 +211,7 @@ static size_t problems_pop(struct problem* list) {
}
static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi,
const char* type, int payload_bytes, int header_bytes, int unused_bytes)
const char* type, int nentries, int payload_bytes, int header_bytes, int unused_bytes)
{
if (type) {
size_t page_bytes = payload_bytes + header_bytes + unused_bytes;
@ -236,8 +236,9 @@ static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi,
if (header_bytes < sizeof(long) || header_bytes >= stat.ms_psize - sizeof(long))
problem_add(pgno, "illegal header-length", "%zu < %i < %zu",
sizeof(long), header_bytes, stat.ms_psize - sizeof(long));
else if (payload_bytes < 1) {
problem_add(pgno, "empty page", "payload %i bytes", payload_bytes);
if (payload_bytes < 1 || nentries < 1) {
problem_add(pgno, "empty page", "payload %i bytes, %i entries",
payload_bytes, nentries);
walk.dbi_empty_pages[index] += 1;
}