Skip to content
Permalink
Browse files

Use MDB_CURRENT to avoid seeking new key

  • Loading branch information...
miltonf committed Apr 7, 2019
1 parent b63192a commit 7999dda64e695335f22d2bf4600d3cf49f9fe133
Showing with 9 additions and 5 deletions.
  1. +2 −2 external/db_drivers/liblmdb/mdb.c
  2. +7 −3 external/db_drivers/liblmdb/mdb_load.c
@@ -7231,7 +7231,7 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,

dkey.mv_size = 0;

if (flags == MDB_CURRENT) {
if (flags & MDB_CURRENT) {
if (!(mc->mc_flags & C_INITIALIZED))
return EINVAL;
rc = MDB_SUCCESS;
@@ -7624,7 +7624,7 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
xdata.mv_size = 0;
xdata.mv_data = "";
leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
if (flags & MDB_CURRENT) {
if (flags == MDB_CURRENT) {
xflags = MDB_CURRENT|MDB_NOSPILL;
} else {
mdb_xcursor_init1(mc, leaf);
@@ -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;
}
}

0 comments on commit 7999dda

Please sign in to comment.
You can’t perform that action at this time.