mdbx: backport - ITS#8355 fix subcursors.

make sure C_DEL gets reset in subcursor after it moves.

Change-Id: I334cadcd981e7578d98e326e6bd785bed709a83a
This commit is contained in:
Howard Chu 2016-01-24 11:32:49 +00:00 committed by Leo Yuriev
parent 3b7a958fcd
commit e6ff451d84
2 changed files with 6 additions and 3 deletions

View File

@ -4,6 +4,7 @@ LMDB 0.9.18 Release Engineering
Add MDB_PREV_MULTIPLE
already done for mdbx - Fix robust mutex detection on glibc 2.10-11 (ITS#8330)
Fix page_search_root assert on FreeDB (ITS#8336)
Fix subcursor move after delete (ITS#8355)
n/a for mdbx - Check for utf8_to_utf16 failures (ITS#7992)
Catch strdup failure in mdb_dbi_open
Build

8
mdb.c
View File

@ -5814,8 +5814,10 @@ mdb_cursor_next(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
mdb_debug("cursor_next: top page is %zu in cursor %p",
mdb_dbg_pgno(mp), (void *) mc);
if (mc->mc_flags & C_DEL)
if (mc->mc_flags & C_DEL) {
mc->mc_flags ^= C_DEL;
goto skip;
}
if (mc->mc_ki[mc->mc_top] + 1u >= NUMKEYS(mp)) {
mdb_debug("=====> move to next sibling page");
@ -5894,6 +5896,8 @@ mdb_cursor_prev(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
mdb_debug("cursor_prev: top page is %zu in cursor %p",
mdb_dbg_pgno(mp), (void *) mc);
mc->mc_flags &= ~(C_EOF|C_DEL);
if (mc->mc_ki[mc->mc_top] == 0) {
mdb_debug("=====> move to prev sibling page");
if ((rc = mdb_cursor_sibling(mc, 0)) != MDB_SUCCESS) {
@ -5905,8 +5909,6 @@ mdb_cursor_prev(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
} else
mc->mc_ki[mc->mc_top]--;
mc->mc_flags &= ~C_EOF;
mdb_debug("==> cursor points to page %zu with %u keys, key index %u",
mdb_dbg_pgno(mp), NUMKEYS(mp), mc->mc_ki[mc->mc_top]);