[geary] Enable use of custom FTS3 tokeniser in SQLite 3.12 and later.
- From: Adam Dingle <adamd src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Enable use of custom FTS3 tokeniser in SQLite 3.12 and later.
- Date: Fri, 29 Apr 2016 11:54:36 +0000 (UTC)
commit f5448f8290e9d36325c2edbad01b9374a4a4510f
Author: Michael James Gratton <mike vee net>
Date: Fri Apr 29 12:59:14 2016 +1000
Enable use of custom FTS3 tokeniser in SQLite 3.12 and later.
Bug 763203.
This enables the two-arg form of fts3_tokenizer in SQLite for the Geary
databases, used set the custom unicodesn tokeniser for full-text message
search. The two-arg form was disabled by default in 3.11 for secuity
reasons, but can be programmatically enabled in 3.12.
Note that this does not fix SQLite 3.11, to do that it must be recompiled
with -DSQLITE_ENABLE_FTS3_TOKENIZER.
* src/sqlite3-unicodesn/static.c (registerTokenizer): Enable two-arg form
of fts3_tokenizer if SQLite >= 3.12 is detected.
* src/sqlite3-unicodesn/CMakeLists.txt: Set SQLITE_3_12 define as needed.
* CMakeLists.txt: Check for both SQLite 3.12 and 3.11, print a warning if
the latter is found.
CMakeLists.txt | 6 ++++++
src/sqlite3-unicodesn/CMakeLists.txt | 5 +++++
src/sqlite3-unicodesn/static.c | 8 ++++++++
3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 245141f..d7e0032 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,12 @@ pkg_check_modules(WEBKITGTK110X QUIET webkitgtk-3.0>=1.10.0 webkitgtk-3.0<=1.10.
pkg_check_modules(GTK312X QUIET gtk+-3.0>=3.12.0)
+pkg_check_modules(SQLITE311 QUIET sqlite3>=3.11.0)
+pkg_check_modules(SQLITE312 QUIET sqlite3>=3.12.0)
+if (SQLITE311_FOUND AND NOT SQLITE312_FOUND)
+ message(WARNING "SQLite 3.11.x found. Ensure it has been compiled with -DSQLITE_ENABLE_FTS3_TOKENIZER or
upgrade to SQLite 3.12.x. See https://bugzilla.gnome.org/show_bug.cgi?id=763203 for details.")
+endif ()
+
# intl
include(Gettext)
if (XGETTEXT_FOUND)
diff --git a/src/sqlite3-unicodesn/CMakeLists.txt b/src/sqlite3-unicodesn/CMakeLists.txt
index 2cabbfe..e531fa2 100644
--- a/src/sqlite3-unicodesn/CMakeLists.txt
+++ b/src/sqlite3-unicodesn/CMakeLists.txt
@@ -23,6 +23,11 @@ add_definitions(
-DSQLITE_ENABLE_FTS4_UNICODE61
)
+if (SQLITE312_FOUND)
+ message(STATUS "SQLite 3.12 support: ON")
+ add_definitions(-DSQLITE_3_12)
+endif ()
+
include_directories(
libstemmer_c/runtime
libstemmer_c/src_c
diff --git a/src/sqlite3-unicodesn/static.c b/src/sqlite3-unicodesn/static.c
index 4ddbede..df1115f 100644
--- a/src/sqlite3-unicodesn/static.c
+++ b/src/sqlite3-unicodesn/static.c
@@ -28,6 +28,14 @@ static int registerTokenizer(
sqlite3_stmt *pStmt;
const char *zSql = "SELECT fts3_tokenizer(?, ?)";
+#ifdef SQLITE_3_12
+ /* Enable the 2-argument form of fts3_tokenizer in SQLite >= 3.12 */
+ rc = sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,1,0);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
+#endif
+
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( rc!=SQLITE_OK ){
return rc;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]