mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:14:14 +08:00
mdbx: minor refine/fix MDBX_ENODATA
for compatibility.
Related to https://github.com/erthink/libmdbx/issues/243
This commit is contained in:
parent
c2cab7a6a8
commit
d96bc98244
@ -13750,7 +13750,7 @@ static int mdbx_cursor_next(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
|
||||
mp = mc->mc_pg[mc->mc_top];
|
||||
if (mc->mc_flags & C_EOF) {
|
||||
if (mc->mc_ki[mc->mc_top] + 1u >= page_numkeys(mp))
|
||||
return MDBX_ENODATA;
|
||||
return (mc->mc_flags & C_SUB) ? MDBX_NOTFOUND : MDBX_ENODATA;
|
||||
mc->mc_flags ^= C_EOF;
|
||||
}
|
||||
|
||||
@ -14337,12 +14337,14 @@ int mdbx_cursor_get(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
|
||||
int (*mfunc)(MDBX_cursor * mc, MDBX_val * key, MDBX_val * data);
|
||||
switch (op) {
|
||||
case MDBX_GET_CURRENT: {
|
||||
if (unlikely((mc->mc_flags & (C_INITIALIZED | C_EOF)) != C_INITIALIZED))
|
||||
if (unlikely(!(mc->mc_flags & C_INITIALIZED)))
|
||||
return MDBX_ENODATA;
|
||||
MDBX_page *mp = mc->mc_pg[mc->mc_top];
|
||||
const unsigned nkeys = page_numkeys(mp);
|
||||
if (mc->mc_ki[mc->mc_top] >= nkeys) {
|
||||
mdbx_cassert(mc, nkeys <= UINT16_MAX);
|
||||
if (mc->mc_flags & C_EOF)
|
||||
return MDBX_ENODATA;
|
||||
mc->mc_ki[mc->mc_top] = (uint16_t)nkeys;
|
||||
mc->mc_flags |= C_EOF;
|
||||
return MDBX_NOTFOUND;
|
||||
|
@ -1174,6 +1174,8 @@ bool testcase::speculum_verify() {
|
||||
rc = false;
|
||||
}
|
||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_GET_CURRENT);
|
||||
if (err == MDBX_SUCCESS)
|
||||
err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_NEXT);
|
||||
if (err != MDBX_ENODATA) {
|
||||
log_error("unexpected %d for MDBX_GET_CURRENT at EOF", err);
|
||||
rc = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user