Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3246810
D5291.id17324.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.id17324.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,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
Details
Attached
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)
Attached To
Mode
D5291: [native/sqlite] check for error while updating db version
Attached
Detach File
Event Timeline
Log In to Comment