Add error handling for FTS3 tokenizer

This commit is contained in:
John Maguire 2018-09-29 23:30:37 +01:00
parent 5e8dcd668c
commit 97eadbd441

View File

@ -270,11 +270,13 @@ QSqlDatabase Database::Connect() {
// In case sqlite>=3.12 is compiled without -DSQLITE_ENABLE_FTS3_TOKENIZER (generally a good idea
// due to security reasons) the fts3 support should be enabled explicitly.
// see https://github.com/clementine-player/Clementine/issues/5297
//
// See https://www.sqlite.org/fts3.html#custom_application_defined_tokenizers
QVariant v = db.driver()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) {
sqlite3* handle = *static_cast<sqlite3**>(v.data());
if (handle) {
sqlite3_db_config(handle, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, NULL);
if (!handle || sqlite3_db_config(handle, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, nullptr) != SQLITE_OK) {
qLog(Fatal) << "Failed to enable FTS3 tokenizer";
}
}
#endif