aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-09-29 22:14:09 +0200
committerRiccardo Spagni <ric@spagni.net>2018-09-29 22:14:09 +0200
commit05c942aba8d09f50306b86213079934dceb768cc (patch)
tree9b0a548d29dfb3e870875b4a38e5668901963d9f /src
parentMerge pull request #4443 (diff)
parentFixup RENAME_DB() macro (diff)
downloadmonero-05c942aba8d09f50306b86213079934dceb768cc.tar.xz
Merge pull request #4445
fe125647 Fixup RENAME_DB() macro (Howard Chu)
Diffstat (limited to 'src')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index b0f3ca5f0..d8f7df5f7 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -3490,7 +3490,17 @@ void BlockchainLMDB::fixup()
BlockchainDB::fixup();
}
-#define RENAME_DB(name) \
+#define RENAME_DB(name) do { \
+ char n2[] = name; \
+ MDB_dbi tdbi; \
+ n2[sizeof(n2)-2]--; \
+ /* play some games to put (name) on a writable page */ \
+ result = mdb_dbi_open(txn, n2, MDB_CREATE, &tdbi); \
+ if (result) \
+ throw0(DB_ERROR(lmdb_error("Failed to create " + std::string(n2) + ": ", result).c_str())); \
+ result = mdb_drop(txn, tdbi, 1); \
+ if (result) \
+ throw0(DB_ERROR(lmdb_error("Failed to delete " + std::string(n2) + ": ", result).c_str())); \
k.mv_data = (void *)name; \
k.mv_size = sizeof(name)-1; \
result = mdb_cursor_open(txn, 1, &c_cur); \
@@ -3500,7 +3510,7 @@ void BlockchainLMDB::fixup()
if (result) \
throw0(DB_ERROR(lmdb_error("Failed to get DB record for " name ": ", result).c_str())); \
ptr = (char *)k.mv_data; \
- ptr[sizeof(name)-2]++
+ ptr[sizeof(name)-2]++; } while(0)
#define LOGIF(y) if (ELPP->vRegistry()->allowed(y, "global"))