Full_Name: Hallvard B Furuseth
Version: mdb.master, 4c8f57615c5ca7b014c038e59c1045182e74f5ad
OS: Linux x86_64
Submission from: (NULL) (2001:700:100:556::233)
Submitted by: hallvard
mdb_cursor_put() doc bug in lmdb.h:
"If the function fails for any reason, the state of the
cursor will be unchanged."
That's quite untrue. To do that, the function must backup
the cursor before moving it. (What is a "failure" anyway
- are MDB_KEYEXIST and MDB_NOTFOUND failures?)
Cursor tracking issues with MDB_DUPSORT:
Cursor tracking sometimes ignores xcursors referring to
sub-pages, yet code which uses an xcursor does not always
fix that first. The enclosed program has several crashes.
I.e. lots more code needs something like
if ((leaf->mn_flags & (F_DUPDATA|F_SUBDATA)) == F_DUPDATA)
m2->mc_xcursor->mx_cursor.mc_pg = NODEDATA(leaf);
before using an xcursor. I tried that everywhere before
using xcursors: That helped, but it was not enough. E.g.
after mdb_cursor_del() calls mdb_node_shrink(), it tracks
cursors in the same sub-page but not nearby sub-pages.
Also the fix suggested above means readers do more work
that writers did not. Maybe instead all code which
modified a database, should fix or invalidate that DB's
cursors before returning (even at failure).