mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 20:14:14 +08:00
mdbx: fix returning MDBX_NOTFOUND
for non-exact seek case of MDBX_GET_BOTH
.
Fixed https://github.com/erthink/libmdbx/issues/243
This commit is contained in:
parent
4f2aba2d22
commit
76399bd643
12
src/core.c
12
src/core.c
@ -14139,6 +14139,10 @@ got_node:
|
|||||||
MDBX_SET_RANGE);
|
MDBX_SET_RANGE);
|
||||||
if (unlikely(ret.err != MDBX_SUCCESS))
|
if (unlikely(ret.err != MDBX_SUCCESS))
|
||||||
return ret;
|
return ret;
|
||||||
|
if (op == MDBX_GET_BOTH && !ret.exact) {
|
||||||
|
ret.err = MDBX_NOTFOUND;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (likely(data)) {
|
} else if (likely(data)) {
|
||||||
if (op == MDBX_GET_BOTH || op == MDBX_GET_BOTH_RANGE) {
|
if (op == MDBX_GET_BOTH || op == MDBX_GET_BOTH_RANGE) {
|
||||||
@ -14170,12 +14174,12 @@ got_node:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MDBX_val olddata;
|
MDBX_val actual_data;
|
||||||
ret.err = mdbx_node_read(mc, node, &olddata,
|
ret.err = mdbx_node_read(mc, node, &actual_data,
|
||||||
pp_txnid4chk(mc->mc_pg[mc->mc_top], mc->mc_txn));
|
pp_txnid4chk(mc->mc_pg[mc->mc_top], mc->mc_txn));
|
||||||
if (unlikely(ret.err != MDBX_SUCCESS))
|
if (unlikely(ret.err != MDBX_SUCCESS))
|
||||||
return ret;
|
return ret;
|
||||||
const int cmp = mc->mc_dbx->md_dcmp(&aligned_data, &olddata);
|
const int cmp = mc->mc_dbx->md_dcmp(&aligned_data, &actual_data);
|
||||||
if (cmp) {
|
if (cmp) {
|
||||||
mdbx_cassert(mc, mc->mc_ki[mc->mc_top] <
|
mdbx_cassert(mc, mc->mc_ki[mc->mc_top] <
|
||||||
page_numkeys(mc->mc_pg[mc->mc_top]) ||
|
page_numkeys(mc->mc_pg[mc->mc_top]) ||
|
||||||
@ -14185,7 +14189,7 @@ got_node:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*data = olddata;
|
*data = actual_data;
|
||||||
} else {
|
} else {
|
||||||
ret.err = mdbx_node_read(mc, node, data,
|
ret.err = mdbx_node_read(mc, node, data,
|
||||||
pp_txnid4chk(mc->mc_pg[mc->mc_top], mc->mc_txn));
|
pp_txnid4chk(mc->mc_pg[mc->mc_top], mc->mc_txn));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user