diff --git a/src/Database.cpp b/src/Database.cpp index f6e2f07b..3ba77ab1 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -92,7 +92,7 @@ void Database::Deleter::operator()(sqlite3* apSQLite) SQLITECPP_ASSERT(SQLITE_OK == ret, "database is locked"); // See SQLITECPP_ENABLE_ASSERT_HANDLER } -//Set a busy handler that sleeps for a specified amount of time when a table is locked. +// Set a busy handler that sleeps for a specified amount of time when a table is locked. void Database::setBusyTimeout(const int aBusyTimeoutMs) { const int ret = sqlite3_busy_timeout(getHandle(), aBusyTimeoutMs); diff --git a/src/Savepoint.cpp b/src/Savepoint.cpp index 421a0d90..7a801729 100644 --- a/src/Savepoint.cpp +++ b/src/Savepoint.cpp @@ -36,6 +36,7 @@ Savepoint::~Savepoint() { if (!mbReleased) { try { rollback(); + release(); } catch (SQLite::Exception&) { // Never throw an exception in a destructor: error if already rolled // back or released, but no harm is caused by this. @@ -49,7 +50,7 @@ void Savepoint::release() { mDatabase.exec(std::string("RELEASE SAVEPOINT ") + msName); mbReleased = true; } else { - throw SQLite::Exception("Savepoint already released or rolled back."); + throw SQLite::Exception("Savepoint already released."); } } @@ -57,9 +58,8 @@ void Savepoint::release() { void Savepoint::rollback() { if (!mbReleased) { mDatabase.exec(std::string("ROLLBACK TO SAVEPOINT ") + msName); - mbReleased = true; } else { - throw SQLite::Exception("Savepoint already released or rolled back."); + throw SQLite::Exception("Savepoint already released."); } } diff --git a/tests/Savepoint_test.cpp b/tests/Savepoint_test.cpp index b1e1e447..bafe62c7 100644 --- a/tests/Savepoint_test.cpp +++ b/tests/Savepoint_test.cpp @@ -33,7 +33,7 @@ TEST(Savepoint, commitRollback) { db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)")); EXPECT_EQ(SQLite::OK, db.getErrorCode()); - // Insert a first valu + // Insert a first value EXPECT_EQ(1, db.exec("INSERT INTO test VALUES (NULL, 'first')")); EXPECT_EQ(1, db.getLastInsertRowid());