Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3246401
D5291.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5291.diff
View Options
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,20 @@
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 && shouldBeInTransaction) {
+ sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+ }
+ if (error) {
+ 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
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 11:31 PM (21 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2495775
Default Alt Text
D5291.diff (1 KB)
Attached To
Mode
D5291: [native/sqlite] check for error while updating db version
Attached
Detach File
Event Timeline
Log In to Comment