| 656 | } |
| 657 | |
| 658 | bool SQLiteBatch::TxnBegin() |
| 659 | { |
| 660 | if (!m_database.m_db || m_txn) return false; |
| 661 | m_database.m_write_semaphore.acquire(); |
| 662 | Assert(!m_database.HasActiveTxn()); |
| 663 | int res = Assert(m_exec_handler)->Exec(m_database, "BEGIN TRANSACTION"); |
| 664 | if (res != SQLITE_OK) { |
| 665 | LogWarning("SQLiteBatch: Failed to begin the transaction"); |
| 666 | m_database.m_write_semaphore.release(); |
| 667 | } else { |
| 668 | m_txn = true; |
| 669 | } |
| 670 | return res == SQLITE_OK; |
| 671 | } |
| 672 | |
| 673 | bool SQLiteBatch::TxnCommit() |
| 674 | { |