From e17149317a8786c0516bb3cd2f30b2fd0841016d Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sat, 26 Nov 2016 10:07:24 +0900 Subject: [PATCH] re-enable perl tokenizer by calling sqlite3_db_config if SQLite >= 3.12 --- SQLite.xs | 4 ---- dbdimp.c | 7 +------ dbdimp_tokenizer.inc | 7 +++++++ t/43_fts3.t | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/SQLite.xs b/SQLite.xs index f20e511..5b51aef 100644 --- a/SQLite.xs +++ b/SQLite.xs @@ -288,11 +288,7 @@ register_fts3_perl_tokenizer(dbh) ALIAS: DBD::SQLite::db::sqlite_register_fts3_perl_tokenizer = 1 CODE: -#if SQLITE_ENABLE_FTS3_TOKENIZER RETVAL = sqlite_db_register_fts3_perl_tokenizer(aTHX_ dbh); -#else - RETVAL = 0; -#endif OUTPUT: RETVAL diff --git a/dbdimp.c b/dbdimp.c index a4ee8fe..e287d73 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -2632,12 +2632,7 @@ sqlite_db_backup_to_file(pTHX_ SV *dbh, char *filename) #endif } -#if SQLITE_VERSION_NUMBER < 3011000 - #include "dbdimp_tokenizer.inc" -#elif SQLITE_ENABLE_FTS3_TOKENIZER - #include "dbdimp_tokenizer.inc" -#endif - +#include "dbdimp_tokenizer.inc" #include "dbdimp_virtual_table.inc" /* end */ diff --git a/dbdimp_tokenizer.inc b/dbdimp_tokenizer.inc index ad507fe..d48409a 100644 --- a/dbdimp_tokenizer.inc +++ b/dbdimp_tokenizer.inc @@ -276,6 +276,13 @@ int sqlite_db_register_fts3_perl_tokenizer(pTHX_ SV *dbh) return FALSE; } +#if SQLITE_VERSION_NUMBER >= 3012000 + rc = sqlite3_db_config(imp_dbh->db, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, 0); + if( rc!=SQLITE_OK ){ + return rc; + } +#endif + rc = sqlite3_prepare_v2(imp_dbh->db, zSql, -1, &pStmt, 0); if( rc!=SQLITE_OK ){ return rc; diff --git a/t/43_fts3.t b/t/43_fts3.t index 64910ee..37052f1 100644 --- a/t/43_fts3.t +++ b/t/43_fts3.t @@ -33,7 +33,7 @@ BEGIN { if (!grep /ENABLE_FTS3/, DBD::SQLite::compile_options()) { plan skip_all => 'FTS3 is disabled for this DBD::SQLite'; } - if ($DBD::SQLite::sqlite_version_number >= 3011000 and !grep /ENABLE_FTS3_TOKENIZER/, DBD::SQLite::compile_options()) { + if ($DBD::SQLite::sqlite_version_number >= 3011000 and $DBD::SQLite::sqlite_version_number < 3012000 and !grep /ENABLE_FTS3_TOKENIZER/, DBD::SQLite::compile_options()) { plan skip_all => 'FTS3 tokenizer is disabled for this DBD::SQLite'; } }