mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 10:01:02 +00:00
Merge pull request #3782
18cd6837
Fix mdb_load append option (hyc)97050326
ITS#8831 move flag init into readhdr (hyc)
This commit is contained in:
commit
e6d45d2db6
2 changed files with 10 additions and 6 deletions
4
external/db_drivers/liblmdb/mdb.c
vendored
4
external/db_drivers/liblmdb/mdb.c
vendored
|
@ -7231,7 +7231,7 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
|
||||||
|
|
||||||
dkey.mv_size = 0;
|
dkey.mv_size = 0;
|
||||||
|
|
||||||
if (flags == MDB_CURRENT) {
|
if (flags & MDB_CURRENT) {
|
||||||
if (!(mc->mc_flags & C_INITIALIZED))
|
if (!(mc->mc_flags & C_INITIALIZED))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
rc = MDB_SUCCESS;
|
rc = MDB_SUCCESS;
|
||||||
|
@ -7624,7 +7624,7 @@ put_sub:
|
||||||
xdata.mv_size = 0;
|
xdata.mv_size = 0;
|
||||||
xdata.mv_data = "";
|
xdata.mv_data = "";
|
||||||
leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
|
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;
|
xflags = MDB_CURRENT|MDB_NOSPILL;
|
||||||
} else {
|
} else {
|
||||||
mdb_xcursor_init1(mc, leaf);
|
mdb_xcursor_init1(mc, leaf);
|
||||||
|
|
12
external/db_drivers/liblmdb/mdb_load.c
vendored
12
external/db_drivers/liblmdb/mdb_load.c
vendored
|
@ -78,6 +78,7 @@ static void readhdr(void)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
|
flags = 0;
|
||||||
while (fgets(dbuf.mv_data, dbuf.mv_size, stdin) != NULL) {
|
while (fgets(dbuf.mv_data, dbuf.mv_size, stdin) != NULL) {
|
||||||
lineno++;
|
lineno++;
|
||||||
if (!strncmp(dbuf.mv_data, "VERSION=", STRLENOF("VERSION="))) {
|
if (!strncmp(dbuf.mv_data, "VERSION=", STRLENOF("VERSION="))) {
|
||||||
|
@ -303,7 +304,7 @@ int main(int argc, char *argv[])
|
||||||
MDB_cursor *mc;
|
MDB_cursor *mc;
|
||||||
MDB_dbi dbi;
|
MDB_dbi dbi;
|
||||||
char *envname;
|
char *envname;
|
||||||
int envflags = 0, putflags = 0;
|
int envflags = MDB_NOSYNC, putflags = 0;
|
||||||
int dohdr = 0, append = 0;
|
int dohdr = 0, append = 0;
|
||||||
MDB_val prevk;
|
MDB_val prevk;
|
||||||
|
|
||||||
|
@ -391,13 +392,11 @@ int main(int argc, char *argv[])
|
||||||
kbuf.mv_data = malloc(kbuf.mv_size * 2);
|
kbuf.mv_data = malloc(kbuf.mv_size * 2);
|
||||||
k0buf.mv_size = kbuf.mv_size;
|
k0buf.mv_size = kbuf.mv_size;
|
||||||
k0buf.mv_data = (char *)kbuf.mv_data + kbuf.mv_size;
|
k0buf.mv_data = (char *)kbuf.mv_data + kbuf.mv_size;
|
||||||
prevk.mv_size = 0;
|
|
||||||
prevk.mv_data = k0buf.mv_data;
|
prevk.mv_data = k0buf.mv_data;
|
||||||
|
|
||||||
while(!Eof) {
|
while(!Eof) {
|
||||||
MDB_val key, data;
|
MDB_val key, data;
|
||||||
int batch = 0;
|
int batch = 0;
|
||||||
flags = 0;
|
|
||||||
int appflag;
|
int appflag;
|
||||||
|
|
||||||
if (!dohdr) {
|
if (!dohdr) {
|
||||||
|
@ -416,6 +415,7 @@ int main(int argc, char *argv[])
|
||||||
fprintf(stderr, "mdb_open failed, error %d %s\n", rc, mdb_strerror(rc));
|
fprintf(stderr, "mdb_open failed, error %d %s\n", rc, mdb_strerror(rc));
|
||||||
goto txn_abort;
|
goto txn_abort;
|
||||||
}
|
}
|
||||||
|
prevk.mv_size = 0;
|
||||||
if (append) {
|
if (append) {
|
||||||
mdb_set_compare(txn, dbi, greater);
|
mdb_set_compare(txn, dbi, greater);
|
||||||
if (flags & MDB_DUPSORT)
|
if (flags & MDB_DUPSORT)
|
||||||
|
@ -443,7 +443,7 @@ int main(int argc, char *argv[])
|
||||||
appflag = MDB_APPEND;
|
appflag = MDB_APPEND;
|
||||||
if (flags & MDB_DUPSORT) {
|
if (flags & MDB_DUPSORT) {
|
||||||
if (prevk.mv_size == key.mv_size && !memcmp(prevk.mv_data, key.mv_data, key.mv_size))
|
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 {
|
else {
|
||||||
memcpy(prevk.mv_data, key.mv_data, key.mv_size);
|
memcpy(prevk.mv_data, key.mv_data, key.mv_size);
|
||||||
prevk.mv_size = 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));
|
fprintf(stderr, "mdb_cursor_open failed, error %d %s\n", rc, mdb_strerror(rc));
|
||||||
goto txn_abort;
|
goto txn_abort;
|
||||||
}
|
}
|
||||||
|
if (appflag & MDB_APPENDDUP) {
|
||||||
|
MDB_val k, d;
|
||||||
|
mdb_cursor_get(mc, &k, &d, MDB_LAST);
|
||||||
|
}
|
||||||
batch = 0;
|
batch = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue