From c76f5247cfd11190dbcd911d62641a98d1f13d80 Mon Sep 17 00:00:00 2001 From: Tyler Karaszewski Date: Fri, 8 Nov 2024 09:11:56 -0800 Subject: [PATCH] Fix log message --- sqlitecluster/SQLite.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sqlitecluster/SQLite.cpp b/sqlitecluster/SQLite.cpp index 8ca6ba37d..d13d04f90 100644 --- a/sqlitecluster/SQLite.cpp +++ b/sqlitecluster/SQLite.cpp @@ -386,16 +386,22 @@ bool SQLite::beginTransaction(TRANSACTION_TYPE type) { _mutexLocked = true; } - if (_insideTransaction || !_uncommittedHash.empty() || !_uncommittedQuery.empty()) { - // The most likely case for hitting this is that we forgot to roll back a transaction when we were finished with it - // during the last use of this DB handle. In that case, `_insideTransaction` is likely true, and possibly - // _uncommittedHash or _uncommittedQuery is set. Rollback should put this DB handle back into a usable state, - // but it breaks the current transaction on this handle. We throw and fail the one transaction and hopefully have - // fixed the handle for the next use. + // The most likely case for hitting this is that we forgot to roll back a transaction when we were finished with it + // during the last use of this DB handle. In that case, `_insideTransaction` is likely true, and possibly + // _uncommittedHash or _uncommittedQuery is set. Rollback should put this DB handle back into a usable state, + // but it breaks the current transaction on this handle. We throw and fail the one transaction and hopefully have + // fixed the handle for the next use + if (_insideTransaction) { + rollback(); + STHROW("Attempted to begin transaction while in invalid state: already inside transaction"); + } + if (!_uncommittedHash.empty()) { + rollback(); + STHROW("Attempted to begin transaction while in invalid state: _uncommittedHash not empty"); + } + if (!_uncommittedQuery.empty()) { rollback(); - STHROW("Attempted to begin transaction while in invalid state. _insideTransaction="s + - (_insideTransaction ? "true" : "false") + ", _uncommittedHash='" + _uncommittedHash + - ", _uncommittedQuery empty? " + (_uncommittedQuery.empty() ? "true" : "false")); + STHROW("Attempted to begin transaction while in invalid state: _uncommittedQuery not empty"); } // Reset before the query, as it's possible the query sets these.