Skip to content

Commit

Permalink
Implement SQLiteDatabase::Rewrite
Browse files Browse the repository at this point in the history
Summary:
Rewrite uses the VACUUM command which does exactly what we want. A
specific advertised use case is to compact a database and ensure that
any deleted data is actually deleted.

This is a backport of [[bitcoin/bitcoin#19077 | core#19077]] [15/26]
bitcoin/bitcoin@010e365

Depends on D10562

Test Plan:
With clang-tidy
`ninja`

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D10563
  • Loading branch information
achow101 authored and PiRK committed Dec 6, 2021
1 parent 27c1c3a commit b35b946
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/wallet/sqlite.cpp
Expand Up @@ -238,7 +238,10 @@ void SQLiteDatabase::Open() {
}

bool SQLiteDatabase::Rewrite(const char *skip) {
return false;
// Rewrite the database using the VACUUM command:
// https://sqlite.org/lang_vacuum.html
int ret = sqlite3_exec(m_db, "VACUUM", nullptr, nullptr, nullptr);
return ret == SQLITE_OK;
}

bool SQLiteDatabase::Backup(const std::string &dest) const {
Expand Down

0 comments on commit b35b946

Please sign in to comment.