ITS#8321 deinit empty cursors

Always unset C_INIT flag if the cursor's target DB has been deleted
mdb.RE/0.9
Howard Chu 9 years ago
parent 75bca7f311
commit 00515babcc
  1. 9
      libraries/liblmdb/mdb.c

@ -5163,8 +5163,11 @@ mdb_cursor_pop(MDB_cursor *mc)
mc->mc_pg[mc->mc_top]->mp_pgno, DDBI(mc), (void *) mc)); mc->mc_pg[mc->mc_top]->mp_pgno, DDBI(mc), (void *) mc));
mc->mc_snum--; mc->mc_snum--;
if (mc->mc_snum) if (mc->mc_snum) {
mc->mc_top--; mc->mc_top--;
} else {
mc->mc_flags &= ~C_INITIALIZED;
}
} }
} }
@ -6820,6 +6823,7 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags)
if (flags & MDB_NODUPDATA) { if (flags & MDB_NODUPDATA) {
/* mdb_cursor_del0() will subtract the final entry */ /* mdb_cursor_del0() will subtract the final entry */
mc->mc_db->md_entries -= mc->mc_xcursor->mx_db.md_entries - 1; mc->mc_db->md_entries -= mc->mc_xcursor->mx_db.md_entries - 1;
mc->mc_xcursor->mx_cursor.mc_flags &= ~C_INITIALIZED;
} else { } else {
if (!F_ISSET(leaf->mn_flags, F_SUBDATA)) { if (!F_ISSET(leaf->mn_flags, F_SUBDATA)) {
mc->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(leaf); mc->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(leaf);
@ -6857,6 +6861,8 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags)
mc->mc_db->md_entries--; mc->mc_db->md_entries--;
mc->mc_flags |= C_DEL; mc->mc_flags |= C_DEL;
return rc; return rc;
} else {
mc->mc_xcursor->mx_cursor.mc_flags &= ~C_INITIALIZED;
} }
/* otherwise fall thru and delete the sub-DB */ /* otherwise fall thru and delete the sub-DB */
} }
@ -9646,6 +9652,7 @@ done:
} else if (rc == MDB_NOTFOUND) { } else if (rc == MDB_NOTFOUND) {
rc = MDB_SUCCESS; rc = MDB_SUCCESS;
} }
mc->mc_flags &= ~C_INITIALIZED;
return rc; return rc;
} }

Loading…
Cancel
Save