@@ -431,17 +431,32 @@ void SQLiteBatch::CloseCursor()
431
431
432
432
bool SQLiteBatch::TxnBegin ()
433
433
{
434
- return false ;
434
+ if (!m_database.m_db || sqlite3_get_autocommit (m_database.m_db ) == 0 ) return false ;
435
+ int res = sqlite3_exec (m_database.m_db , " BEGIN TRANSACTION" , nullptr , nullptr , nullptr );
436
+ if (res != SQLITE_OK) {
437
+ LogPrintf (" SQLiteBatch: Failed to begin the transaction\n " );
438
+ }
439
+ return res == SQLITE_OK;
435
440
}
436
441
437
442
bool SQLiteBatch::TxnCommit ()
438
443
{
439
- return false ;
444
+ if (!m_database.m_db || sqlite3_get_autocommit (m_database.m_db ) != 0 ) return false ;
445
+ int res = sqlite3_exec (m_database.m_db , " COMMIT TRANSACTION" , nullptr , nullptr , nullptr );
446
+ if (res != SQLITE_OK) {
447
+ LogPrintf (" SQLiteBatch: Failed to commit the transaction\n " );
448
+ }
449
+ return res == SQLITE_OK;
440
450
}
441
451
442
452
bool SQLiteBatch::TxnAbort ()
443
453
{
444
- return false ;
454
+ if (!m_database.m_db || sqlite3_get_autocommit (m_database.m_db ) != 0 ) return false ;
455
+ int res = sqlite3_exec (m_database.m_db , " ROLLBACK TRANSACTION" , nullptr , nullptr , nullptr );
456
+ if (res != SQLITE_OK) {
457
+ LogPrintf (" SQLiteBatch: Failed to abort the transaction\n " );
458
+ }
459
+ return res == SQLITE_OK;
445
460
}
446
461
447
462
bool ExistsSQLiteDatabase (const fs::path& path)
0 commit comments