diff options
author | Christian Kamm <mail@ckamm.de> | 2019-01-23 11:50:21 +0300 |
---|---|---|
committer | Markus Goetz <markus@woboq.com> | 2019-04-16 10:29:18 +0300 |
commit | 35ca4f0de7d7ed565c658679c97a66bba59bbfd3 (patch) | |
tree | 640a87354b47348682ea5ed39e5fc495fcd58542 | |
parent | 4c1e9d1f9e2bab3a2a83bb9a404916d2baabd019 (diff) |
Sqlite: Use FULL synchronous mode with non-WAL journal
According to the documentation DELETE+NORMAL isn't safe from corruption
on older file systems.
-rw-r--r-- | src/common/syncjournaldb.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index 89f6706f0..09b7471a8 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -331,10 +331,18 @@ bool SyncJournalDb::checkConnect() qCInfo(lcDb) << "sqlite3 with temp_store =" << env_temp_store; } - pragma1.prepare("PRAGMA synchronous = 1;"); + // With WAL journal the NORMAL sync mode is safe from corruption, + // otherwise use the standard FULL mode. + QByteArray synchronousMode = "FULL"; + if (QString::fromUtf8(_journalMode).compare(QStringLiteral("wal"), Qt::CaseInsensitive) == 0) + synchronousMode = "NORMAL"; + pragma1.prepare("PRAGMA synchronous = " + synchronousMode + ";"); if (!pragma1.exec()) { return sqlFail("Set PRAGMA synchronous", pragma1); + } else { + qCInfo(lcDb) << "sqlite3 synchronous=" << synchronousMode; } + pragma1.prepare("PRAGMA case_sensitive_like = ON;"); if (!pragma1.exec()) { return sqlFail("Set PRAGMA case_sensitivity", pragma1); |