Page MenuHomePhabricator

D5291.id17324.diff
No OneTemporary

D5291.id17324.diff

diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -637,6 +637,10 @@
auto rc = applyMigration(db);
if (!rc) {
+ if (shouldBeInTransaction) {
+ sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+ }
+
migration_msg << "migration " << idx << " failed." << std::endl;
Logger::log(migration_msg.str());
break;
@@ -646,7 +650,21 @@
update_version << "PRAGMA user_version=" << idx << ";";
auto update_version_str = update_version.str();
- sqlite3_exec(db, update_version_str.c_str(), nullptr, nullptr, nullptr);
+ char *error;
+ sqlite3_exec(db, update_version_str.c_str(), nullptr, nullptr, &error);
+ if (error) {
+ if (shouldBeInTransaction) {
+ sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+ }
+
+ std::ostringstream errorStream;
+ errorStream << "Error updating database version after migration " << idx
+ << ": " << error;
+ Logger::log(errorStream.str());
+ sqlite3_free(error);
+
+ break;
+ }
if (shouldBeInTransaction) {
sqlite3_exec(db, "END TRANSACTION;", nullptr, nullptr, nullptr);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 1:54 AM (20 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496068
Default Alt Text
D5291.id17324.diff (1 KB)

Event Timeline