From 77b6d72a3e8d841977a3e30ea435cd9e9289fc96 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Thu, 16 Mar 2017 14:54:55 +0300 Subject: [PATCH] core/database: configure fts3 tokenizer support Original patch by Arfrever This fixes https://github.com/clementine-player/Clementine/issues/5297 --- src/core/database.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/database.cpp b/src/core/database.cpp index 86e8a1052..36113d8c1 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -265,6 +265,20 @@ QSqlDatabase Database::Connect() { StaticInit(); { + +#ifdef SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER + // 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 + QVariant v = db.driver()->handle(); + if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) { + sqlite3* handle = *static_cast(v.data()); + if (handle) { + sqlite3_db_config(handle, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, NULL); + } + } +#endif + QSqlQuery set_fts_tokenizer(db); set_fts_tokenizer.prepare("SELECT fts3_tokenizer(:name, :pointer)"); set_fts_tokenizer.bindValue(":name", "unicode");