Sqlite: Use FULL synchronous mode with non-WAL journal

According to the documentation DELETE+NORMAL isn't safe from corruption
on older file systems.
This commit is contained in:
Christian Kamm 2019-01-23 09:50:21 +01:00 committed by Kevin Ottens
parent 076e24f465
commit a4f357ee4b
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View file

@ -333,10 +333,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);