aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/sqlite.cpp
diff options
context:
space:
mode:
authorAndrew Chow <[email protected]>2020-06-16 14:57:30 -0400
committerAndrew Chow <[email protected]>2020-10-14 11:28:18 -0400
commit6636a2608a4e5906ee8092d5731595542261e0ad (patch)
treec68cd3445b812937eac78554f13c810b8b20b1b9 /src/wallet/sqlite.cpp
parentImplement SQLiteDatabase::Close (diff)
downloaddiscoin-6636a2608a4e5906ee8092d5731595542261e0ad.tar.xz
discoin-6636a2608a4e5906ee8092d5731595542261e0ad.zip
Implement SQLiteBatch::Close
Diffstat (limited to 'src/wallet/sqlite.cpp')
-rw-r--r--src/wallet/sqlite.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp
index 7d96575a6..d89508c9d 100644
--- a/src/wallet/sqlite.cpp
+++ b/src/wallet/sqlite.cpp
@@ -182,6 +182,14 @@ SQLiteBatch::SQLiteBatch(SQLiteDatabase& database)
void SQLiteBatch::Close()
{
+ // If m_db is in a transaction (i.e. not in autocommit mode), then abort the transaction in progress
+ if (m_database.m_db && sqlite3_get_autocommit(m_database.m_db) == 0) {
+ if (TxnAbort()) {
+ LogPrintf("SQLiteBatch: Batch closed unexpectedly without the transaction being explicitly committed or aborted\n");
+ } else {
+ LogPrintf("SQLiteBatch: Batch closed and failed to abort transaction\n");
+ }
+ }
}
bool SQLiteBatch::ReadKey(CDataStream&& key, CDataStream& value)