mdbx-test: fix keygen-related issue.

Fixes https://github.com/erthink/libmdbx/issues/127
This commit is contained in:
Leonid Yuriev 2021-07-23 01:27:02 +03:00
parent e731260056
commit c2fa453725
3 changed files with 11 additions and 9 deletions

View File

@ -14,7 +14,6 @@ ChangeLog
- [Get rid of dirty-pages list in MDBX_WRITEMAP mode](https://github.com/erthink/libmdbx/issues/193). - [Get rid of dirty-pages list in MDBX_WRITEMAP mode](https://github.com/erthink/libmdbx/issues/193).
- [Large/Overflow pages accounting for dirty-room](https://github.com/erthink/libmdbx/issues/192). - [Large/Overflow pages accounting for dirty-room](https://github.com/erthink/libmdbx/issues/192).
- [Support for RAW devices](https://github.com/erthink/libmdbx/issues/124). - [Support for RAW devices](https://github.com/erthink/libmdbx/issues/124).
- [Test framework issue](https://github.com/erthink/libmdbx/issues/127).
- [Support MessagePack for Keys & Values](https://github.com/erthink/libmdbx/issues/115). - [Support MessagePack for Keys & Values](https://github.com/erthink/libmdbx/issues/115).
- [Engage new terminology](https://github.com/erthink/libmdbx/issues/137). - [Engage new terminology](https://github.com/erthink/libmdbx/issues/137).
- Finalize C++ API (few typos and trivia bugs are still likely for now). - Finalize C++ API (few typos and trivia bugs are still likely for now).
@ -61,6 +60,7 @@ Fixes:
- Fixed [using bad meta-pages if DB was partially/recoverable corrupted](https://github.com/erthink/libmdbx/issues/217). - Fixed [using bad meta-pages if DB was partially/recoverable corrupted](https://github.com/erthink/libmdbx/issues/217).
- Fixed extra `noexcept` for `buffer::&assign_reference()`. - Fixed extra `noexcept` for `buffer::&assign_reference()`.
- Fixed `bootid` generation on Windows for case of change system' time. - Fixed `bootid` generation on Windows for case of change system' time.
- Fixed [test framework keygen-related issue](https://github.com/erthink/libmdbx/issues/127).
## v0.10.1 at 2021-06-01 ## v0.10.1 at 2021-06-01

View File

@ -243,23 +243,25 @@ void maker::seek2end(serial_t &serial) const {
serial = actor_params::serial_mask(mapping.width) - 1; serial = actor_params::serial_mask(mapping.width) - 1;
} }
bool maker::increment(serial_t &serial, int delta) const { bool maker::increment(serial_t &serial, int64_t delta) const {
if (serial > actor_params::serial_mask(mapping.width)) { if (serial > actor_params::serial_mask(mapping.width)) {
log_extra("keygen-increment: %" PRIu64 " > %" PRIu64 ", overflow", serial, log_extra("keygen-increment: %" PRIu64 " > %" PRIu64 ", overflow", serial,
actor_params::serial_mask(mapping.width)); actor_params::serial_mask(mapping.width));
return false; return false;
} }
serial_t target = serial + (int64_t)delta; serial_t target = serial + delta;
if (target > actor_params::serial_mask(mapping.width) || if (target > actor_params::serial_mask(mapping.width) ||
((delta > 0) ? target < serial : target > serial)) { ((delta > 0) ? target < serial : target > serial)) {
log_extra("keygen-increment: %" PRIu64 "%-d => %" PRIu64 ", overflow", log_extra("keygen-increment: %" PRIu64 "%-" PRId64 " => %" PRIu64
", overflow",
serial, delta, target); serial, delta, target);
return false; return false;
} }
log_extra("keygen-increment: %" PRIu64 "%-d => %" PRIu64 ", continue", serial, log_extra("keygen-increment: %" PRIu64 "%-" PRId64 " => %" PRIu64
delta, target); ", continue",
serial, delta, target);
serial = target; serial = target;
return true; return true;
} }

View File

@ -130,8 +130,8 @@ public:
bool is_unordered() const; bool is_unordered() const;
void seek2end(serial_t &serial) const; void seek2end(serial_t &serial) const;
bool increment(serial_t &serial, int delta) const; bool increment(serial_t &serial, int64_t delta) const;
bool increment_key_part(serial_t &serial, int delta, bool increment_key_part(serial_t &serial, int64_t delta,
bool reset_value_part = true) const { bool reset_value_part = true) const {
if (reset_value_part) { if (reset_value_part) {
serial_t value_part_bits = ((serial_t(1) << mapping.split) - 1); serial_t value_part_bits = ((serial_t(1) << mapping.split) - 1);
@ -139,7 +139,7 @@ public:
if (delta >= 0) if (delta >= 0)
serial &= ~value_part_bits; serial &= ~value_part_bits;
} }
return increment(serial, delta << mapping.split); return increment(serial, int64_t(uint64_t(delta) << mapping.split));
} }
}; };