From 6fdcd0e7c02e4454375735091a7774c3c05d7279 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 18 Dec 2022 18:41:11 +0100 Subject: [PATCH] Set sqlite to serialized mode. --- modules/database_sqlite/config.py | 9 +++------ modules/database_sqlite/sqlite3_connection.cpp | 12 ++++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/database_sqlite/config.py b/modules/database_sqlite/config.py index f54ede989..02f9fda7a 100644 --- a/modules/database_sqlite/config.py +++ b/modules/database_sqlite/config.py @@ -37,13 +37,10 @@ def configure(env): def _configure(env): #env.ParseConfig("pkg-config sqlite3 --cflags --libs") - env.Append(CPPDEFINES=["SQLITE_PRESENT"]) + #env.Append(CPPDEFINES=[("SQLITE_THREADSAFE", 1)]) - # Link those statically for portability - #if env["use_static_cpp"]: - #env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) - - env.Append(LINKFLAGS=["-ldl"]) + #env.Append(LINKFLAGS=["-ldl"]) + pass def get_doc_classes(): diff --git a/modules/database_sqlite/sqlite3_connection.cpp b/modules/database_sqlite/sqlite3_connection.cpp index d1063ebc7..80530e7bf 100644 --- a/modules/database_sqlite/sqlite3_connection.cpp +++ b/modules/database_sqlite/sqlite3_connection.cpp @@ -27,15 +27,19 @@ Ref SQLite3DatabaseConnection::get_table_builder() { } void SQLite3DatabaseConnection::database_connect(const String &connection_str) { - int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); - if (ret != SQLITE_OK) { - ERR_PRINT("SQLITE3 multithreading is not supported!\n"); - } + int ret = sqlite3_config(SQLITE_CONFIG_SERIALIZED); + //if (ret != SQLITE_OK) { + //ERR_PRINT("SQLITE3 multithreading is not supported!\n"); + //} //CharString cstr = connection_str.ascii(); CharString cstr = connection_str.utf8(); ret = sqlite3_open(cstr.get_data(), &conn); + + if (ret != SQLITE_OK) { + ERR_PRINT(vformat("SQLITE3 database_connect failed! code: %d !", ret)); + } } Ref SQLite3DatabaseConnection::query(const String &query) {