diff --git a/src/core.c b/src/core.c index a837a6a4..b218a38a 100644 --- a/src/core.c +++ b/src/core.c @@ -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; diff --git a/test/test.cc b/test/test.cc index d9cfec13..d2c11d9e 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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;