Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3246630
D5375.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
D5375.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
@@ -324,6 +324,17 @@
}
}
+int get_database_version(sqlite3 *db) {
+ sqlite3_stmt *user_version_stmt;
+ sqlite3_prepare_v2(
+ db, "PRAGMA user_version;", -1, &user_version_stmt, nullptr);
+ sqlite3_step(user_version_stmt);
+
+ int current_user_version = sqlite3_column_int(user_version_stmt, 0);
+ sqlite3_finalize(user_version_stmt);
+ return current_user_version;
+}
+
void trace_queries(sqlite3 *db) {
int error_code = sqlite3_trace_v2(
db,
@@ -516,20 +527,13 @@
<< std::endl;
Logger::log(db_path.str());
- sqlite3_stmt *user_version_stmt;
- sqlite3_prepare_v2(
- db, "PRAGMA user_version;", -1, &user_version_stmt, nullptr);
- sqlite3_step(user_version_stmt);
-
- int current_user_version = sqlite3_column_int(user_version_stmt, 0);
- sqlite3_finalize(user_version_stmt);
-
+ auto db_version = get_database_version(db);
std::stringstream version_msg;
- version_msg << "db version: " << current_user_version << std::endl;
+ version_msg << "db version: " << db_version << std::endl;
Logger::log(version_msg.str());
for (const auto &[idx, migration] : migrations) {
- if (idx <= current_user_version) {
+ if (idx <= db_version) {
continue;
}
const auto &[applyMigration, shouldBeInTransaction] = migration;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 1:03 AM (20 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2495950
Default Alt Text
D5375.diff (1 KB)
Attached To
Mode
D5375: [native/sqlite] introduce function to get database version
Attached
Detach File
Event Timeline
Log In to Comment