mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 10:16:01 -04:00
Merge pull request #390 fix incorrect work of savepoint from spoyler/save_point
Fix #381
This commit is contained in:
commit
343299a31d
@ -93,7 +93,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);
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user