mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:24:12 +08:00
mdbx: fix LEAF2-pages handling in mdb_cursor_count().
This commit is contained in:
parent
7bf9d381ee
commit
d3518bf75b
13
mdb.c
13
mdb.c
@ -7914,16 +7914,13 @@ mdb_cursor_count(MDB_cursor *mc, size_t *countp)
|
|||||||
return MDB_NOTFOUND;
|
return MDB_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->mc_xcursor == NULL || IS_LEAF2(mp)) {
|
*countp = 1;
|
||||||
*countp = 1;
|
if (mc->mc_xcursor != NULL) {
|
||||||
} else {
|
|
||||||
MDB_node *leaf = NODEPTR(mp, mc->mc_ki[mc->mc_top]);
|
MDB_node *leaf = NODEPTR(mp, mc->mc_ki[mc->mc_top]);
|
||||||
if (!F_ISSET(leaf->mn_flags, F_DUPDATA))
|
if (F_ISSET(leaf->mn_flags, F_DUPDATA)) {
|
||||||
*countp = 1;
|
mdb_cassert(mc, mc->mc_xcursor && (mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED));
|
||||||
else if (unlikely(!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED)))
|
|
||||||
return EINVAL;
|
|
||||||
else
|
|
||||||
*countp = mc->mc_xcursor->mx_db.md_entries;
|
*countp = mc->mc_xcursor->mx_db.md_entries;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (unlikely(mc->mc_xcursor == NULL))
|
if (unlikely(mc->mc_xcursor == NULL))
|
||||||
|
22
mdbx.c
22
mdbx.c
@ -547,21 +547,13 @@ mdbx_get_ex(MDB_txn *txn, MDB_dbi dbi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (values_count) {
|
if (values_count) {
|
||||||
if (mc.mc_xcursor == NULL)
|
*values_count = 1;
|
||||||
*values_count = 1;
|
if (mc.mc_xcursor != NULL) {
|
||||||
else {
|
MDB_node *leaf = NODEPTR(mc.mc_pg[mc.mc_top], mc.mc_ki[mc.mc_top]);
|
||||||
MDB_page *mp = mc.mc_pg[mc.mc_top];
|
if (F_ISSET(leaf->mn_flags, F_DUPDATA)) {
|
||||||
if (IS_LEAF2(mp))
|
mdb_tassert(txn, mc.mc_xcursor == &mx
|
||||||
*values_count = 1;
|
&& (mx.mx_cursor.mc_flags & C_INITIALIZED));
|
||||||
else {
|
*values_count = mx.mx_db.md_entries;
|
||||||
MDB_node *leaf = NODEPTR(mp, mc.mc_ki[mc.mc_top]);
|
|
||||||
if (!F_ISSET(leaf->mn_flags, F_DUPDATA))
|
|
||||||
*values_count = 1;
|
|
||||||
else {
|
|
||||||
mdb_tassert(txn, mc.mc_xcursor == &mx);
|
|
||||||
mdb_tassert(txn, mx.mx_cursor.mc_flags & C_INITIALIZED);
|
|
||||||
*values_count = mx.mx_db.md_entries;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user