From 64a02e22799da289314001e16bfc6d2e89f63601 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Fri, 30 May 2014 10:47:56 +0200 Subject: [PATCH] More for big MDB_MAXKEYSIZE with MDB_DUPSORT. With mdb_cursor_put(new key, data item big enough to need a sub-DB): - Track cursors as when adding other nodes. The "!do_sub" is now unneeded. Before ITS#7861 it distinguished inserting key from data. - Set MDB_TXN_ERROR if an empty sub-DB was created. I.e. adding key:subDB succeeded, but inserting the data item failed. --- libraries/liblmdb/mdb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 91fc570f08..94c7ffc41c 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6170,7 +6170,7 @@ new_sub: } else { /* There is room already in this leaf page. */ rc = mdb_node_add(mc, mc->mc_ki[mc->mc_top], key, rdata, 0, nflags); - if (rc == 0 && !do_sub && insert_key) { + if (rc == 0 && insert_key) { /* Adjust other cursors pointing to mp */ MDB_cursor *m2, *m3; MDB_dbi dbi = mc->mc_dbi; @@ -6245,7 +6245,10 @@ put_sub: /* Increment count unless we just replaced an existing item. */ if (insert_data) mc->mc_db->md_entries++; - if (!rc && insert_key) { + if (insert_key) { + /* Invalidate txn if we created an empty sub-DB */ + if (rc) + goto bad_sub; /* If we succeeded and the key didn't exist before, * make sure the cursor is marked valid. */ -- 2.39.5