mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 23:04:13 +08:00
mdbx: fix tracking inside mdbx_cursor_del0().
Change-Id: If65804a610730cf80d73fc31c1e62fb9bf3b6c82
This commit is contained in:
parent
94aa20febc
commit
01e016e6aa
17
src/mdbx.c
17
src/mdbx.c
@ -10222,6 +10222,7 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
|
|||||||
MDBX_cursor *m2, *m3;
|
MDBX_cursor *m2, *m3;
|
||||||
MDBX_dbi dbi = mc->mc_dbi;
|
MDBX_dbi dbi = mc->mc_dbi;
|
||||||
|
|
||||||
|
mdbx_cassert(mc, IS_LEAF(mc->mc_pg[mc->mc_top]));
|
||||||
ki = mc->mc_ki[mc->mc_top];
|
ki = mc->mc_ki[mc->mc_top];
|
||||||
mp = mc->mc_pg[mc->mc_top];
|
mp = mc->mc_pg[mc->mc_top];
|
||||||
mdbx_node_del(mc, mc->mc_db->md_xsize);
|
mdbx_node_del(mc, mc->mc_db->md_xsize);
|
||||||
@ -10230,9 +10231,9 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
|
|||||||
/* Adjust other cursors pointing to mp */
|
/* Adjust other cursors pointing to mp */
|
||||||
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) {
|
||||||
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
|
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
|
||||||
if (!(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
|
if (m3 == mc || !(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
|
||||||
continue;
|
continue;
|
||||||
if (m3 == mc || m3->mc_snum < mc->mc_snum)
|
if (m3->mc_snum < mc->mc_snum)
|
||||||
continue;
|
continue;
|
||||||
if (m3->mc_pg[mc->mc_top] == mp) {
|
if (m3->mc_pg[mc->mc_top] == mp) {
|
||||||
if (m3->mc_ki[mc->mc_top] == ki) {
|
if (m3->mc_ki[mc->mc_top] == ki) {
|
||||||
@ -10264,13 +10265,14 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp = mc->mc_pg[mc->mc_top];
|
mp = mc->mc_pg[mc->mc_top];
|
||||||
|
mdbx_cassert(mc, IS_LEAF(mc->mc_pg[mc->mc_top]));
|
||||||
nkeys = NUMKEYS(mp);
|
nkeys = NUMKEYS(mp);
|
||||||
mdbx_cassert(mc, (mc->mc_db->md_entries > 0 && nkeys > 0) ||
|
mdbx_cassert(mc, (mc->mc_db->md_entries > 0 && nkeys > 0) ||
|
||||||
((mc->mc_flags & C_SUB) &&
|
((mc->mc_flags & C_SUB) &&
|
||||||
mc->mc_db->md_entries == 0 && nkeys == 0));
|
mc->mc_db->md_entries == 0 && nkeys == 0));
|
||||||
|
|
||||||
/* Adjust other cursors pointing to mp */
|
/* Adjust THIS and other cursors pointing to mp */
|
||||||
for (m2 = mc->mc_txn->mt_cursors[dbi]; !rc && m2; m2 = m2->mc_next) {
|
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) {
|
||||||
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
|
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
|
||||||
if (!(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
|
if (!(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
|
||||||
continue;
|
continue;
|
||||||
@ -10280,7 +10282,7 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
|
|||||||
/* if m3 points past last node in page, find next sibling */
|
/* if m3 points past last node in page, find next sibling */
|
||||||
if (m3->mc_ki[mc->mc_top] >= mc->mc_ki[mc->mc_top]) {
|
if (m3->mc_ki[mc->mc_top] >= mc->mc_ki[mc->mc_top]) {
|
||||||
if (m3->mc_ki[mc->mc_top] >= nkeys) {
|
if (m3->mc_ki[mc->mc_top] >= nkeys) {
|
||||||
rc = mdbx_cursor_sibling(m3, 1);
|
rc = mdbx_cursor_sibling(m3, true);
|
||||||
if (rc == MDBX_NOTFOUND) {
|
if (rc == MDBX_NOTFOUND) {
|
||||||
m3->mc_flags |= C_EOF;
|
m3->mc_flags |= C_EOF;
|
||||||
rc = MDBX_SUCCESS;
|
rc = MDBX_SUCCESS;
|
||||||
@ -10301,8 +10303,9 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
|
|||||||
m3->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(node);
|
m3->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(node);
|
||||||
} else {
|
} else {
|
||||||
rc = mdbx_xcursor_init1(m3, node);
|
rc = mdbx_xcursor_init1(m3, node);
|
||||||
if (likely(rc == MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
m3->mc_xcursor->mx_cursor.mc_flags |= C_DEL;
|
break;
|
||||||
|
m3->mc_xcursor->mx_cursor.mc_flags |= C_DEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user