mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:24:12 +08:00
mdbx-chk: add '-i' option for custom comparators.
Change-Id: Ie3d7fdb3c3a881a484d351ca9a3160eb467b43b9
This commit is contained in:
parent
309955be75
commit
460751bc01
@ -92,7 +92,8 @@ MDBX_envinfo envinfo;
|
|||||||
MDBX_stat envstat;
|
MDBX_stat envstat;
|
||||||
size_t maxkeysize, userdb_count, skipped_subdb;
|
size_t maxkeysize, userdb_count, skipped_subdb;
|
||||||
uint64_t reclaimable_pages, gc_pages, lastpgno, unused_pages;
|
uint64_t reclaimable_pages, gc_pages, lastpgno, unused_pages;
|
||||||
unsigned verbose, quiet;
|
unsigned verbose;
|
||||||
|
char ignore_wrong_order, quiet;
|
||||||
const char *only_subdb;
|
const char *only_subdb;
|
||||||
|
|
||||||
struct problem {
|
struct problem {
|
||||||
@ -615,6 +616,8 @@ static int process_db(MDBX_dbi dbi_handle, char *dbi_name, visitor *handler,
|
|||||||
|
|
||||||
saved_list = problems_push();
|
saved_list = problems_push();
|
||||||
prev_key.iov_base = NULL;
|
prev_key.iov_base = NULL;
|
||||||
|
prev_key.iov_len = 0;
|
||||||
|
prev_data.iov_base = NULL;
|
||||||
prev_data.iov_len = 0;
|
prev_data.iov_len = 0;
|
||||||
rc = mdbx_cursor_get(mc, &key, &data, MDBX_FIRST);
|
rc = mdbx_cursor_get(mc, &key, &data, MDBX_FIRST);
|
||||||
while (rc == MDBX_SUCCESS) {
|
while (rc == MDBX_SUCCESS) {
|
||||||
@ -649,17 +652,16 @@ static int process_db(MDBX_dbi dbi_handle, char *dbi_name, visitor *handler,
|
|||||||
|
|
||||||
int cmp = mdbx_cmp(txn, dbi_handle, &prev_key, &key);
|
int cmp = mdbx_cmp(txn, dbi_handle, &prev_key, &key);
|
||||||
if (cmp > 0) {
|
if (cmp > 0) {
|
||||||
problem_add("entry", record_count, "broken ordering of entries", NULL);
|
if (!ignore_wrong_order)
|
||||||
|
problem_add("entry", record_count, "wrong order of entries", NULL);
|
||||||
} else if (cmp == 0) {
|
} else if (cmp == 0) {
|
||||||
++dups;
|
++dups;
|
||||||
if (!(flags & MDBX_DUPSORT))
|
if (!(flags & MDBX_DUPSORT))
|
||||||
problem_add("entry", record_count, "duplicated entries", NULL);
|
problem_add("entry", record_count, "duplicated entries", NULL);
|
||||||
else if (flags & MDBX_INTEGERDUP) {
|
else if (!ignore_wrong_order &&
|
||||||
cmp = mdbx_dcmp(txn, dbi_handle, &prev_data, &data);
|
mdbx_dcmp(txn, dbi_handle, &prev_data, &data) > 0)
|
||||||
if (cmp > 0)
|
problem_add("entry", record_count, "wrong order of multi-values",
|
||||||
problem_add("entry", record_count,
|
NULL);
|
||||||
"broken ordering of multi-values", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (verbose) {
|
} else if (verbose) {
|
||||||
if (flags & MDBX_INTEGERKEY)
|
if (flags & MDBX_INTEGERKEY)
|
||||||
@ -714,7 +716,8 @@ static void usage(char *prog) {
|
|||||||
" -w\t\tlock DB for writing while checking\n"
|
" -w\t\tlock DB for writing while checking\n"
|
||||||
" -d\t\tdisable page-by-page traversal of b-tree\n"
|
" -d\t\tdisable page-by-page traversal of b-tree\n"
|
||||||
" -s subdb\tprocess a specific subdatabase only\n"
|
" -s subdb\tprocess a specific subdatabase only\n"
|
||||||
" -c\t\tforce cooperative mode (don't try exclusive)\n",
|
" -c\t\tforce cooperative mode (don't try exclusive)\n"
|
||||||
|
" -i\t\tignore wrong order errors (for custom comparators case)\n",
|
||||||
prog);
|
prog);
|
||||||
exit(EXIT_INTERRUPTED);
|
exit(EXIT_INTERRUPTED);
|
||||||
}
|
}
|
||||||
@ -898,7 +901,7 @@ int main(int argc, char *argv[]) {
|
|||||||
usage(prog);
|
usage(prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i; (i = getopt(argc, argv, "Vvqnwcds:")) != EOF;) {
|
for (int i; (i = getopt(argc, argv, "Vvqnwcdsi:")) != EOF;) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
||||||
@ -928,6 +931,9 @@ int main(int argc, char *argv[]) {
|
|||||||
usage(prog);
|
usage(prog);
|
||||||
only_subdb = optarg;
|
only_subdb = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
ignore_wrong_order = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(prog);
|
usage(prog);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user