aboutsummaryrefslogtreecommitdiff
path: root/external/db_drivers/liblmdb/mdb_load.c
diff options
context:
space:
mode:
authorhyc <hyc@symas.com>2018-05-08 06:14:39 +0100
committerhyc <hyc@symas.com>2018-05-08 06:29:13 +0100
commit18cd6837b632dda74c7b2f8da4a5ce188a3cb235 (patch)
treeb479271b1c57a040939880ef1fd2d1be7be34207 /external/db_drivers/liblmdb/mdb_load.c
parentITS#8831 move flag init into readhdr (diff)
downloadmonero-18cd6837b632dda74c7b2f8da4a5ce188a3cb235.tar.xz
Fix mdb_load append option
Use MDB_CURRENT to avoid seeking to new key when appending DUPs. Reinit cursor on new batch, if appending DUPs.
Diffstat (limited to '')
-rw-r--r--external/db_drivers/liblmdb/mdb_load.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/external/db_drivers/liblmdb/mdb_load.c b/external/db_drivers/liblmdb/mdb_load.c
index 58a663fda..c74ce81c9 100644
--- a/external/db_drivers/liblmdb/mdb_load.c
+++ b/external/db_drivers/liblmdb/mdb_load.c
@@ -304,7 +304,7 @@ int main(int argc, char *argv[])
MDB_cursor *mc;
MDB_dbi dbi;
char *envname;
- int envflags = 0, putflags = 0;
+ int envflags = MDB_NOSYNC, putflags = 0;
int dohdr = 0, append = 0;
MDB_val prevk;
@@ -392,7 +392,6 @@ int main(int argc, char *argv[])
kbuf.mv_data = malloc(kbuf.mv_size * 2);
k0buf.mv_size = kbuf.mv_size;
k0buf.mv_data = (char *)kbuf.mv_data + kbuf.mv_size;
- prevk.mv_size = 0;
prevk.mv_data = k0buf.mv_data;
while(!Eof) {
@@ -416,6 +415,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "mdb_open failed, error %d %s\n", rc, mdb_strerror(rc));
goto txn_abort;
}
+ prevk.mv_size = 0;
if (append) {
mdb_set_compare(txn, dbi, greater);
if (flags & MDB_DUPSORT)
@@ -443,7 +443,7 @@ int main(int argc, char *argv[])
appflag = MDB_APPEND;
if (flags & MDB_DUPSORT) {
if (prevk.mv_size == key.mv_size && !memcmp(prevk.mv_data, key.mv_data, key.mv_size))
- appflag = MDB_APPENDDUP;
+ appflag = MDB_CURRENT|MDB_APPENDDUP;
else {
memcpy(prevk.mv_data, key.mv_data, key.mv_size);
prevk.mv_size = key.mv_size;
@@ -477,6 +477,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "mdb_cursor_open failed, error %d %s\n", rc, mdb_strerror(rc));
goto txn_abort;
}
+ if (appflag & MDB_APPENDDUP) {
+ MDB_val k, d;
+ mdb_cursor_get(mc, &k, &d, MDB_LAST);
+ }
batch = 0;
}
}