diff --git a/sqlite/CMakeLists.txt b/sqlite/CMakeLists.txt index 091b00cde63f..b42ca7255a06 100644 --- a/sqlite/CMakeLists.txt +++ b/sqlite/CMakeLists.txt @@ -33,6 +33,9 @@ endif() target_compile_definitions(tdsqlite PRIVATE -DSQLITE_DEFAULT_MEMSTATUS=0 + -DSQLITE_DEFAULT_SYNCHRONOUS=1 + -DSQLITE_DEFAULT_RECURSIVE_TRIGGERS=1 + -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_PROGRESS_CALLBACK diff --git a/td/telegram/LanguagePackManager.cpp b/td/telegram/LanguagePackManager.cpp index e65a9ffd2991..149d8bf60a06 100644 --- a/td/telegram/LanguagePackManager.cpp +++ b/td/telegram/LanguagePackManager.cpp @@ -125,9 +125,6 @@ bool LanguagePackManager::is_custom_language_code(Slice language_code) { static Result open_database(const string &path) { TRY_RESULT(database, SqliteDb::open_with_key(path, true, DbKey::empty())); - TRY_STATUS(database.exec("PRAGMA synchronous=NORMAL")); - TRY_STATUS(database.exec("PRAGMA temp_store=MEMORY")); - TRY_STATUS(database.exec("PRAGMA encoding=\"UTF-8\"")); TRY_STATUS(database.exec("PRAGMA journal_mode=WAL")); return std::move(database); } diff --git a/td/telegram/TdDb.cpp b/td/telegram/TdDb.cpp index 53f594eae5c8..efe6b8a76291 100644 --- a/td/telegram/TdDb.cpp +++ b/td/telegram/TdDb.cpp @@ -142,17 +142,6 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue &binlog_p return Status::OK(); } -Status init_db(SqliteDb &db) { - TRY_STATUS(db.exec("PRAGMA encoding=\"UTF-8\"")); - TRY_STATUS(db.exec("PRAGMA journal_mode=WAL")); - - TRY_STATUS(db.exec("PRAGMA synchronous=NORMAL")); - TRY_STATUS(db.exec("PRAGMA temp_store=MEMORY")); - TRY_STATUS(db.exec("PRAGMA secure_delete=1")); - - return Status::OK(); -} - } // namespace std::shared_ptr TdDb::get_file_db_shared() { @@ -310,8 +299,8 @@ Status TdDb::init_sqlite(int32 scheduler_id, const TdParameters ¶meters, DbK sql_connection_ = std::make_shared(sql_database_path, key, db_instance.get_cipher_version()); sql_connection_->set(std::move(db_instance)); auto &db = sql_connection_->get(); - - TRY_STATUS(init_db(db)); + TRY_STATUS(db.exec("PRAGMA journal_mode=WAL")); + TRY_STATUS(db.exec("PRAGMA secure_delete=1")); // Init databases // Do initialization once and before everything else to avoid "database is locked" error. diff --git a/tddb/td/db/SqliteConnectionSafe.cpp b/tddb/td/db/SqliteConnectionSafe.cpp index c7b615f62ffe..de39ce95e13f 100644 --- a/tddb/td/db/SqliteConnectionSafe.cpp +++ b/tddb/td/db/SqliteConnectionSafe.cpp @@ -21,10 +21,8 @@ SqliteConnectionSafe::SqliteConnectionSafe(string path, DbKey key, optional