mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:24:13 +08:00
mdbx-chk: avoid continuing to check bad records.
Change-Id: I03b9d425c8413d6cacc1b67ed4a8253a10a9d603
This commit is contained in:
parent
2bea60a1a4
commit
cd75c4f081
@ -642,48 +642,56 @@ static int process_db(MDBX_dbi dbi_handle, char *dbi_name, visitor *handler,
|
|||||||
goto bailout;
|
goto bailout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bad_key = false;
|
||||||
if (key.iov_len > maxkeysize) {
|
if (key.iov_len > maxkeysize) {
|
||||||
problem_add("entry", record_count, "key length exceeds max-key-size",
|
problem_add("entry", record_count, "key length exceeds max-key-size",
|
||||||
"%" PRIuPTR " > %" PRIuPTR, key.iov_len, maxkeysize);
|
"%" PRIuPTR " > %" PRIuPTR, key.iov_len, maxkeysize);
|
||||||
|
bad_key = true;
|
||||||
} else if ((flags & MDBX_INTEGERKEY) && key.iov_len != sizeof(uint64_t) &&
|
} else if ((flags & MDBX_INTEGERKEY) && key.iov_len != sizeof(uint64_t) &&
|
||||||
key.iov_len != sizeof(uint32_t)) {
|
key.iov_len != sizeof(uint32_t)) {
|
||||||
problem_add("entry", record_count, "wrong key length",
|
problem_add("entry", record_count, "wrong key length",
|
||||||
"%" PRIuPTR " != 4or8", key.iov_len);
|
"%" PRIuPTR " != 4or8", key.iov_len);
|
||||||
|
bad_key = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bad_data = false;
|
||||||
if ((flags & MDBX_INTEGERDUP) && data.iov_len != sizeof(uint64_t) &&
|
if ((flags & MDBX_INTEGERDUP) && data.iov_len != sizeof(uint64_t) &&
|
||||||
data.iov_len != sizeof(uint32_t)) {
|
data.iov_len != sizeof(uint32_t)) {
|
||||||
problem_add("entry", record_count, "wrong data length",
|
problem_add("entry", record_count, "wrong data length",
|
||||||
"%" PRIuPTR " != 4or8", data.iov_len);
|
"%" PRIuPTR " != 4or8", data.iov_len);
|
||||||
|
bad_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_key.iov_base) {
|
if (prev_key.iov_base && !bad_data) {
|
||||||
if ((flags & MDBX_DUPFIXED) && prev_data.iov_len != data.iov_len) {
|
if ((flags & MDBX_DUPFIXED) && prev_data.iov_len != data.iov_len) {
|
||||||
problem_add("entry", record_count, "different data length",
|
problem_add("entry", record_count, "different data length",
|
||||||
"%" PRIuPTR " != %" PRIuPTR, prev_data.iov_len,
|
"%" PRIuPTR " != %" PRIuPTR, prev_data.iov_len,
|
||||||
data.iov_len);
|
data.iov_len);
|
||||||
|
bad_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmp = mdbx_cmp(txn, dbi_handle, &prev_key, &key);
|
if (!bad_key) {
|
||||||
if (cmp == 0) {
|
int cmp = mdbx_cmp(txn, dbi_handle, &prev_key, &key);
|
||||||
++dups;
|
if (cmp == 0) {
|
||||||
if ((flags & MDBX_DUPSORT) == 0) {
|
++dups;
|
||||||
problem_add("entry", record_count, "duplicated entries", NULL);
|
if ((flags & MDBX_DUPSORT) == 0) {
|
||||||
if (data.iov_len == prev_data.iov_len &&
|
problem_add("entry", record_count, "duplicated entries", NULL);
|
||||||
memcmp(data.iov_base, prev_data.iov_base, data.iov_len) == 0) {
|
if (data.iov_len == prev_data.iov_len &&
|
||||||
problem_add("entry", record_count, "complete duplicate", NULL);
|
memcmp(data.iov_base, prev_data.iov_base, data.iov_len) == 0) {
|
||||||
}
|
problem_add("entry", record_count, "complete duplicate", NULL);
|
||||||
} else {
|
}
|
||||||
cmp = mdbx_dcmp(txn, dbi_handle, &prev_data, &data);
|
} else if (!bad_data) {
|
||||||
if (cmp == 0) {
|
cmp = mdbx_dcmp(txn, dbi_handle, &prev_data, &data);
|
||||||
problem_add("entry", record_count, "complete duplicate", NULL);
|
if (cmp == 0) {
|
||||||
} else if (cmp > 0 && !ignore_wrong_order) {
|
problem_add("entry", record_count, "complete duplicate", NULL);
|
||||||
problem_add("entry", record_count, "wrong order of multi-values",
|
} else if (cmp > 0 && !ignore_wrong_order) {
|
||||||
NULL);
|
problem_add("entry", record_count, "wrong order of multi-values",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (cmp > 0 && !ignore_wrong_order) {
|
||||||
|
problem_add("entry", record_count, "wrong order of entries", NULL);
|
||||||
}
|
}
|
||||||
} else if (cmp > 0 && !ignore_wrong_order) {
|
|
||||||
problem_add("entry", record_count, "wrong order of entries", NULL);
|
|
||||||
}
|
}
|
||||||
} else if (verbose) {
|
} else if (verbose) {
|
||||||
if (flags & MDBX_INTEGERKEY)
|
if (flags & MDBX_INTEGERKEY)
|
||||||
@ -702,8 +710,10 @@ static int process_db(MDBX_dbi dbi_handle, char *dbi_name, visitor *handler,
|
|||||||
key_bytes += key.iov_len;
|
key_bytes += key.iov_len;
|
||||||
data_bytes += data.iov_len;
|
data_bytes += data.iov_len;
|
||||||
|
|
||||||
prev_key = key;
|
if (!bad_key)
|
||||||
prev_data = data;
|
prev_key = key;
|
||||||
|
if (!bad_data)
|
||||||
|
prev_data = data;
|
||||||
rc = mdbx_cursor_get(mc, &key, &data, MDBX_NEXT);
|
rc = mdbx_cursor_get(mc, &key, &data, MDBX_NEXT);
|
||||||
}
|
}
|
||||||
if (rc != MDBX_NOTFOUND)
|
if (rc != MDBX_NOTFOUND)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user