summaryrefslogtreecommitdiff
blob: 41a5cd76c992f6127f50657ccc4dad281cc0cae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From 77b6d72a3e8d841977a3e30ea435cd9e9289fc96 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
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<sqlite3**>(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");