mdbx-tools: avoid output NaN from mdbx_chk for empty tables.

Change-Id: Ie1ff87da3a5e5e124eac1dafd7d5b456f8bde6e3
This commit is contained in:
Leonid Yuriev 2019-06-10 13:28:31 +03:00
parent 48655b41fb
commit ce0e5d67f5

View File

@ -1177,20 +1177,22 @@ int main(int argc, char *argv[]) {
total_page_bytes); total_page_bytes);
if (verbose > 2) { if (verbose > 2) {
for (walk_dbi_t *dbi = walk.dbi; dbi < walk.dbi + MAX_DBI && dbi->name; for (walk_dbi_t *dbi = walk.dbi; dbi < walk.dbi + MAX_DBI && dbi->name;
++dbi) { ++dbi)
uint64_t dbi_bytes = dbi->pages.total * envstat.ms_psize; if (dbi->pages.total) {
print(" %s: subtotal %" PRIu64 " bytes (%.1f%%)," uint64_t dbi_bytes = dbi->pages.total * envstat.ms_psize;
" payload %" PRIu64 " (%.1f%%), unused %" PRIu64 " (%.1f%%)", print(" %s: subtotal %" PRIu64 " bytes (%.1f%%),"
dbi->name, dbi_bytes, dbi_bytes * 100.0 / total_page_bytes, " payload %" PRIu64 " (%.1f%%), unused %" PRIu64 " (%.1f%%)",
dbi->payload_bytes, dbi->payload_bytes * 100.0 / dbi_bytes, dbi->name, dbi_bytes, dbi_bytes * 100.0 / total_page_bytes,
dbi_bytes - dbi->payload_bytes, dbi->payload_bytes, dbi->payload_bytes * 100.0 / dbi_bytes,
(dbi_bytes - dbi->payload_bytes) * 100.0 / dbi_bytes); dbi_bytes - dbi->payload_bytes,
if (dbi->pages.empty) (dbi_bytes - dbi->payload_bytes) * 100.0 / dbi_bytes);
print(", %" PRIu64 " empty pages", dbi->pages.empty); if (dbi->pages.empty)
if (dbi->lost_bytes) print(", %" PRIu64 " empty pages", dbi->pages.empty);
print(", %" PRIu64 " bytes lost", dbi->lost_bytes); if (dbi->lost_bytes)
print("\n"); print(", %" PRIu64 " bytes lost", dbi->lost_bytes);
} print("\n");
} else
print(" %s: empty\n", dbi->name);
} }
print(" - summary: average fill %.1f%%", print(" - summary: average fill %.1f%%",
walk.total_payload_bytes * 100.0 / total_page_bytes); walk.total_payload_bytes * 100.0 / total_page_bytes);