mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
- Force update values from uci on firmware update - In case of reload(uci update), old sql db gets deleted and created from uci - Use In memory sql journal mode
28 lines
1.1 KiB
Diff
28 lines
1.1 KiB
Diff
diff --git a/src/core/database.c b/src/core/database.c
|
|
index 7ad9dae..edebd7c 100644
|
|
--- a/src/core/database.c
|
|
+++ b/src/core/database.c
|
|
@@ -955,6 +955,7 @@ void DATABASE_Dump(void)
|
|
int OpenUspDatabase(char *db_file)
|
|
{
|
|
int err;
|
|
+ char *err_msg = 0;
|
|
|
|
// Exit if unable to open the database
|
|
err = sqlite3_open(db_file, &db_handle);
|
|
@@ -965,6 +966,15 @@ int OpenUspDatabase(char *db_file)
|
|
return USP_ERR_INTERNAL_ERROR;
|
|
}
|
|
|
|
+ // Execute the PRAGMA statement
|
|
+ const char *sql = "PRAGMA journal_mode = MEMORY;";
|
|
+ err = sqlite3_exec(db_handle, sql, 0, 0, &err_msg);
|
|
+ if (err != SQLITE_OK) {
|
|
+ USP_LOG_Error("%s: Failed to set journal_mode: %s", __func__, err_msg);
|
|
+ sqlite3_free(err_msg);
|
|
+ return USP_ERR_INTERNAL_ERROR;
|
|
+ }
|
|
+
|
|
// Exit if unable to create the data model parameter table (if it does not already exist)
|
|
#define CREATE_TABLE_STR "create table if not exists data_model (hash integer, instances text, value text, primary key (hash, instances));"
|
|
err = sqlite3_exec(db_handle, CREATE_TABLE_STR, NULL, NULL, NULL);
|