mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-04 09:02:07 +08:00
mdbx: refine mdbx_update_key() and mdbx_cursor_put().
Change-Id: I26b97f1eecff1f03e578193aebb5592ab48dd38e
This commit is contained in:
parent
8cd0107e6a
commit
36fe81edad
@ -8341,10 +8341,7 @@ new_sub:
|
|||||||
MDBX_page *mp = mc->mc_pg[i];
|
MDBX_page *mp = mc->mc_pg[i];
|
||||||
|
|
||||||
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) {
|
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) {
|
||||||
if (mc->mc_flags & C_SUB)
|
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
|
||||||
m3 = &m2->mc_xcursor->mx_cursor;
|
|
||||||
else
|
|
||||||
m3 = m2;
|
|
||||||
if (m3 == mc || m3->mc_snum < mc->mc_snum || m3->mc_pg[i] != mp)
|
if (m3 == mc || m3->mc_snum < mc->mc_snum || m3->mc_pg[i] != mp)
|
||||||
continue;
|
continue;
|
||||||
if (m3->mc_ki[i] >= mc->mc_ki[i] && insert_key) {
|
if (m3->mc_ki[i] >= mc->mc_ki[i] && insert_key) {
|
||||||
@ -9470,10 +9467,9 @@ static int mdbx_update_key(MDBX_cursor *mc, const MDBX_val *key) {
|
|||||||
/* Shift node contents if EVEN(key length) changed. */
|
/* Shift node contents if EVEN(key length) changed. */
|
||||||
if (delta) {
|
if (delta) {
|
||||||
if (SIZELEFT(mp) < delta) {
|
if (SIZELEFT(mp) < delta) {
|
||||||
pgno_t pgno;
|
|
||||||
/* not enough space left, do a delete and split */
|
/* not enough space left, do a delete and split */
|
||||||
mdbx_debug("Not enough room, delta = %d, splitting...", delta);
|
mdbx_debug("Not enough room, delta = %d, splitting...", delta);
|
||||||
pgno = NODEPGNO(node);
|
pgno_t pgno = NODEPGNO(node);
|
||||||
mdbx_node_del(mc, 0);
|
mdbx_node_del(mc, 0);
|
||||||
return mdbx_page_split(mc, key, NULL, pgno, MDBX_SPLIT_REPLACE);
|
return mdbx_page_split(mc, key, NULL, pgno, MDBX_SPLIT_REPLACE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user