UI: SqliteDb: Set default busy handler timeout

This commit is contained in:
Nodir Temirkhodjaev 2024-01-31 19:52:16 +03:00
parent 9369484f00
commit f5550751ad
2 changed files with 4 additions and 6 deletions

View File

@ -14,6 +14,8 @@ namespace {
const QLoggingCategory LC("db");
constexpr int DATABASE_BUSY_TIMEOUT = 2000; // 2 seconds
const char *const defaultSqlPragmas = "PRAGMA journal_mode = WAL;"
"PRAGMA locking_mode = NORMAL;"
"PRAGMA synchronous = NORMAL;"
@ -333,6 +335,8 @@ QStringList SqliteDb::columnNames(const QString &tableName, const QString &schem
bool SqliteDb::migrate(MigrateOptions &opt)
{
setBusyTimeoutMs(DATABASE_BUSY_TIMEOUT);
if (!opt.sqlPragmas) {
opt.sqlPragmas = defaultSqlPragmas;
}

View File

@ -20,8 +20,6 @@ const QLoggingCategory LC("statBlock");
constexpr int DATABASE_USER_VERSION = 7;
constexpr int DATABASE_BUSY_TIMEOUT = 3000; // 3 seconds
bool migrateFunc(SqliteDb *db, int version, bool isNewDb, void *ctx)
{
Q_UNUSED(ctx);
@ -191,12 +189,8 @@ bool StatBlockManager::setupDb()
<< roSqliteDb()->errorMessage();
return false;
}
roSqliteDb()->setBusyTimeoutMs(DATABASE_BUSY_TIMEOUT);
}
sqliteDb()->setBusyTimeoutMs(DATABASE_BUSY_TIMEOUT);
return true;
}