]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Provide the new SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER option to
authordrh <drh@noemail.net>
Fri, 26 Feb 2016 15:38:24 +0000 (15:38 +0000)
committerdrh <drh@noemail.net>
Fri, 26 Feb 2016 15:38:24 +0000 (15:38 +0000)
sqlite3_db_config() that can be used to activate the two-argument version
of fts3_tokenizer() for a specific database connection at run-time.

FossilOrigin-Name: 374b5108087a2eae03676c0f3469b37a272145bf

ext/fts3/fts3_tokenizer.c
manifest
manifest.uuid
src/main.c
src/sqlite.h.in
src/sqliteInt.h
src/test1.c
src/test_config.c
test/fts3atoken.test
test/fts4langid.test

index fcabe5cca2078c531704b5c390fd6856db20d676..b7d9d2b3b287b52dd39094a8a8f5089ec1ec357e 100644 (file)
 #include <assert.h>
 #include <string.h>
 
+/*
+** Return true if the two-argument version of fts3_tokenizer()
+** has been activated via a prior call to sqlite3_db_config(db,
+** SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, 0);
+*/
+static int fts3TokenizerEnabled(sqlite3_context *context){
+  sqlite3 *db = sqlite3_context_db_handle(context);
+  int isEnabled = 0;
+  sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,-1,&isEnabled);
+  return isEnabled;
+}
+
 /*
 ** Implementation of the SQL scalar function for accessing the underlying 
 ** hash table. This function may be called as follows:
@@ -49,7 +61,7 @@
 ** is a blob containing the pointer stored as the hash data corresponding
 ** to string <key-name> (after the hash-table is updated, if applicable).
 */
-static void scalarFunc(
+static void fts3TokenizerFunc(
   sqlite3_context *context,
   int argc,
   sqlite3_value **argv
@@ -67,27 +79,23 @@ static void scalarFunc(
   nName = sqlite3_value_bytes(argv[0])+1;
 
   if( argc==2 ){
-#ifdef SQLITE_ENABLE_FTS3_TOKENIZER
-    void *pOld;
-    int n = sqlite3_value_bytes(argv[1]);
-    if( zName==0 || n!=sizeof(pPtr) ){
-      sqlite3_result_error(context, "argument type mismatch", -1);
-      return;
-    }
-    pPtr = *(void **)sqlite3_value_blob(argv[1]);
-    pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);
-    if( pOld==pPtr ){
-      sqlite3_result_error(context, "out of memory", -1);
+    if( fts3TokenizerEnabled(context) ){
+      void *pOld;
+      int n = sqlite3_value_bytes(argv[1]);
+      if( zName==0 || n!=sizeof(pPtr) ){
+        sqlite3_result_error(context, "argument type mismatch", -1);
+        return;
+      }
+      pPtr = *(void **)sqlite3_value_blob(argv[1]);
+      pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);
+      if( pOld==pPtr ){
+        sqlite3_result_error(context, "out of memory", -1);
+      }
+    }else{
+      sqlite3_result_error(context, "fts3tokenize disabled", -1);
       return;
     }
-#else
-    sqlite3_result_error(context, "fts3tokenize: " 
-        "disabled - rebuild with -DSQLITE_ENABLE_FTS3_TOKENIZER", -1
-    );
-    return;
-#endif /* SQLITE_ENABLE_FTS3_TOKENIZER */
-  }else
-  {
+  }else{
     if( zName ){
       pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
     }
@@ -98,7 +106,6 @@ static void scalarFunc(
       return;
     }
   }
-
   sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
 }
 
@@ -336,7 +343,6 @@ finish:
   Tcl_DecrRefCount(pRet);
 }
 
-#ifdef SQLITE_ENABLE_FTS3_TOKENIZER
 static
 int registerTokenizer(
   sqlite3 *db, 
@@ -358,7 +364,6 @@ int registerTokenizer(
 
   return sqlite3_finalize(pStmt);
 }
-#endif /* SQLITE_ENABLE_FTS3_TOKENIZER */
 
 
 static
@@ -431,13 +436,13 @@ static void intTestFunc(
   assert( 0==strcmp(sqlite3_errmsg(db), "unknown tokenizer: nosuchtokenizer") );
 
   /* Test the storage function */
-#ifdef SQLITE_ENABLE_FTS3_TOKENIZER
-  rc = registerTokenizer(db, "nosuchtokenizer", p1);
-  assert( rc==SQLITE_OK );
-  rc = queryTokenizer(db, "nosuchtokenizer", &p2);
-  assert( rc==SQLITE_OK );
-  assert( p2==p1 );
-#endif
+  if( fts3TokenizerEnabled(context) ){
+    rc = registerTokenizer(db, "nosuchtokenizer", p1);
+    assert( rc==SQLITE_OK );
+    rc = queryTokenizer(db, "nosuchtokenizer", &p2);
+    assert( rc==SQLITE_OK );
+    assert( p2==p1 );
+  }
 
   sqlite3_result_text(context, "ok", -1, SQLITE_STATIC);
 }
@@ -453,7 +458,7 @@ static void intTestFunc(
 **    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);
 **
 ** This function adds a scalar function (see header comment above
-** scalarFunc() in this file for details) and, if ENABLE_TABLE is
+** fts3TokenizerFunc() in this file for details) and, if ENABLE_TABLE is
 ** defined at compilation time, a temporary virtual table (see header 
 ** comment above struct HashTableVtab) to the database schema. Both 
 ** provide read/write access to the contents of *pHash.
@@ -482,10 +487,10 @@ int sqlite3Fts3InitHashTable(
 #endif
 
   if( SQLITE_OK==rc ){
-    rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0);
+    rc = sqlite3_create_function(db, zName, 1, any, p, fts3TokenizerFunc, 0, 0);
   }
   if( SQLITE_OK==rc ){
-    rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0);
+    rc = sqlite3_create_function(db, zName, 2, any, p, fts3TokenizerFunc, 0, 0);
   }
 #ifdef SQLITE_TEST
   if( SQLITE_OK==rc ){
index f3c7712c00d260f01a6000d36c5fb0415a98e178..b196f4d2fb1bf7ed17fa5e900ba911aa72cd5c75 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stypo\sin\sa\scomment\s(though\san\simportant\scomment\sin\sthat\sit\sis\sused\s\nto\sgenerate\sdocumentation).
-D 2016-02-26T13:22:21.836
+C Provide\sthe\snew\sSQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER\soption\sto\s\nsqlite3_db_config()\sthat\scan\sbe\sused\sto\sactivate\sthe\stwo-argument\sversion\nof\sfts3_tokenizer()\sfor\sa\sspecific\sdatabase\sconnection\sat\srun-time.
+D 2016-02-26T15:38:24.549
 F Makefile.in 4e90dc1521879022aa9479268a4cd141d1771142
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 28fc4ee02333996d31b3602b39eeb8e609a89ce4
@@ -83,7 +83,7 @@ F ext/fts3/fts3_snippet.c 68ae118b0f834ea53d2b89e4087fc0f0b8c4ee4e
 F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7
 F ext/fts3/fts3_test.c 11e36437b0f3f2266acea5b4787f615e4337a237
 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860
-F ext/fts3/fts3_tokenizer.c 4bd72f767f61c9ce5a7575c844e8d1ed2c3c561a
+F ext/fts3/fts3_tokenizer.c 3cf21cd2212db17a88d4ef7da0fd8a80275979a1
 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
 F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145
@@ -314,7 +314,7 @@ F src/insert.c 9ca97272e9f74ed0efddf3b4350ee12740cebbef
 F src/journal.c fe3a3e2559ce3ce9d371afd30fbabbc074174575
 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
 F src/loadext.c 9e2a41adcaff16ebc1ebff1f336cbf33de55396f
-F src/main.c d7415cd68121ef24c2e76b9e81ec96ffc90e6517
+F src/main.c be9309f442ec291177642d2e48e82290e0951f4b
 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b
@@ -351,15 +351,15 @@ F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20
 F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e
 F src/select.c 1bacfde7b7cec134d2b354cbcf67bafc67078431
 F src/shell.c 89b73e894e737cc2f21e4bce0feb3ea21cc61124
-F src/sqlite.h.in 42203c6bf167b8b13c4e6637cbdf8ad2cb2f8685
+F src/sqlite.h.in 6bf029bcb077c6db633a77b7fda5ffd5b7c950b7
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
-F src/sqliteInt.h b9ac8b9c9798f57d80a9756f86abf1dbd9424ec9
+F src/sqliteInt.h 63c0e1b5b5d608a1ba2303fe3a554b859a120406
 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
 F src/tclsqlite.c 13debcc6a5ca1217486f8903768c01114fbe8b58
-F src/test1.c 8b17b1ff53aad71e7f9318a2fda247beddeaa601
+F src/test1.c f14a6f9e2cff6cba4d83e2b0c52857f61886cead
 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b
 F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f
 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e
@@ -373,7 +373,7 @@ F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12
 F src/test_backup.c 2e6e6a081870150f20c526a2e9d0d29cda47d803
 F src/test_blob.c b2551a9b5573232db5f66f292307c37067937239
 F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f
-F src/test_config.c 7985332c806d1cece793475c75a6abcccde9d331
+F src/test_config.c 0dee90328e3dedf8ba002ee94b6a7e7ea7726fe4
 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852
 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
 F src/test_fs.c f10f840ca4f8c72e4837908bd8347ac4bcab074b
@@ -698,7 +698,7 @@ F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f
 F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
 F test/fts3ao.test 3e4e3d5e75c076520341d0bdf4eb17c00e8cbde2
-F test/fts3atoken.test 76262be798f23a390717d14266f0df551e52a7ee
+F test/fts3atoken.test 4b4c16fdcfc972f2cdbba212375a060a86ccf5f1
 F test/fts3auto.test b981fea19b132b4e6878f50d7c1f369b28f68eb9
 F test/fts3aux1.test f8f287a4a73f381f8fa15b6a70f36245f903d221
 F test/fts3aux2.test 7ae2b2c13aefdf4169279a27a5f51780ce57f6ba
@@ -745,7 +745,7 @@ F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01
 F test/fts4growth.test 60d6bb3f78e25b34f533797dd9f2f9402310a13a
 F test/fts4growth2.test 13ad4e76451af6e6906c95cdc725d01b00044269
 F test/fts4incr.test 4e353a0bd886ea984e56fce9e77724fc923b8d0d
-F test/fts4langid.test 8bd8759e0d4b04d71771544b861193a6841fee84
+F test/fts4langid.test 9794addcc8faaee85ac60eceecdb52feb0c70f68
 F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee
 F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891
 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7
@@ -1450,7 +1450,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 3ef6a3153267d5328202fea24fd29ff4d5409295
-R 77993d5bd700ce83f039b073c94a1fa4
+P ff3d7f845e1875d6729f64f5231db1c376892f31
+R 31d803939428fd2d10225002a384e77a
 U drh
-Z 9609a7717e93d89e1b3f63c437689c08
+Z 2070e36304d2e6c69aaa4c28fc3295af
index af3baca687f16684e5ab5388479840056fff5971..dcf6861a1e151e45d4cf44fbe7740522c551283f 100644 (file)
@@ -1 +1 @@
-ff3d7f845e1875d6729f64f5231db1c376892f31
\ No newline at end of file
+374b5108087a2eae03676c0f3469b37a272145bf
\ No newline at end of file
index 4ffc426b0893a4b3b446eb6f42525bf4ee592d65..2a258da662a4425504140043a3fb7f104618eb13 100644 (file)
@@ -796,8 +796,9 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){
         int op;      /* The opcode */
         u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */
       } aFlagOp[] = {
-        { SQLITE_DBCONFIG_ENABLE_FKEY,    SQLITE_ForeignKeys    },
-        { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger  },
+        { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },
+        { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },
+        { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer  },
       };
       unsigned int i;
       rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
@@ -2811,6 +2812,9 @@ static int openDatabase(
 #endif
 #if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)
                  | SQLITE_CellSizeCk
+#endif
+#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
+                 | SQLITE_Fts3Tokenizer
 #endif
       ;
   sqlite3HashInit(&db->aCollSeq);
index 829eeb86ce0e0285bb008017dbb61b5f6d17bd5d..60e2e3b61cacea331671e0783475b005f5ce72d9 100644 (file)
@@ -1904,11 +1904,25 @@ struct sqlite3_mem_methods {
 ** following this call.  The second parameter may be a NULL pointer, in
 ** which case the trigger setting is not reported back. </dd>
 **
+** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
+** <dd> ^This option is used to enable or disable the two-argument
+** version of the [fts3_tokenizer()] function which is part of the
+** [FTS3] full-text search engine extension.
+** There should be two additional arguments.
+** The first argument is an integer which is 0 to disable fts3_tokenizer() or
+** positive to enable fts3_tokenizer() or negative to leave the setting
+** unchanged.
+** The second parameter is a pointer to an integer into which
+** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
+** following this call.  The second parameter may be a NULL pointer, in
+** which case the new setting is not reported back. </dd>
+**
 ** </dl>
 */
-#define SQLITE_DBCONFIG_LOOKASIDE       1001  /* void* int int */
-#define SQLITE_DBCONFIG_ENABLE_FKEY     1002  /* int int* */
-#define SQLITE_DBCONFIG_ENABLE_TRIGGER  1003  /* int int* */
+#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
+#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
+#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */
+#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
 
 
 /*
index a62ffb6b6948445233fb335584da29e20e81d025..759d7ca5e114298a659ca1dd3c30475f279202c2 100644 (file)
@@ -1327,6 +1327,7 @@ struct sqlite3 {
 #define SQLITE_VdbeEQP        0x04000000  /* Debug EXPLAIN QUERY PLAN */
 #define SQLITE_Vacuum         0x08000000  /* Currently in a VACUUM */
 #define SQLITE_CellSizeCk     0x10000000  /* Check btree cell sizes on load */
+#define SQLITE_Fts3Tokenizer  0x20000000  /* Enable fts3_tokenizer(2) */
 
 
 /*
index 713152b824fb8c055867774fe3f41e4ec05cd2a1..744b400b2a9118dc82d313ee0f7507e0e8282495 100644 (file)
@@ -6920,6 +6920,53 @@ static int test_register_dbstat_vtab(
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
 }
 
+/*
+** tclcmd:   sqlite3_db_config DB SETTING VALUE
+**
+** Invoke sqlite3_db_config() for one of the setting values.
+*/
+static int test_sqlite3_db_config(
+  void *clientData,
+  Tcl_Interp *interp,
+  int objc,
+  Tcl_Obj *CONST objv[]
+){
+  static const struct {
+    const char *zName;
+    int eVal;
+  } aSetting[] = {
+    { "FKEY",            SQLITE_DBCONFIG_ENABLE_FKEY },
+    { "TRIGGER",         SQLITE_DBCONFIG_ENABLE_TRIGGER },
+    { "FTS3_TOKENIZER",  SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
+  };
+  int i;
+  int v;
+  const char *zSetting;
+  sqlite3 *db;
+
+  if( objc!=4 ){
+    Tcl_WrongNumArgs(interp, 1, objv, "DB SETTING VALUE");
+    return TCL_ERROR;
+  }
+  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+  zSetting = Tcl_GetString(objv[2]);
+  if( sqlite3_strglob("SQLITE_*", zSetting)==0 ) zSetting += 7;
+  if( sqlite3_strglob("DBCONFIG_*", zSetting)==0 ) zSetting += 9;
+  if( sqlite3_strglob("ENABLE_*", zSetting)==0 ) zSetting += 7;
+  for(i=0; i<ArraySize(aSetting); i++){
+    if( strcmp(zSetting, aSetting[i].zName)==0 ) break;
+  }
+  if( i>=ArraySize(aSetting) ){
+    Tcl_SetObjResult(interp,
+      Tcl_NewStringObj("unknown sqlite3_db_config setting", -1));
+    return TCL_ERROR;
+  }
+  if( Tcl_GetIntFromObj(interp, objv[3], &v) ) return TCL_ERROR;
+  sqlite3_db_config(db, aSetting[i].eVal, v, &v);
+  Tcl_SetObjResult(interp, Tcl_NewIntObj(v));
+  return TCL_OK;
+}
+
 /*
 ** Register commands with the TCL interpreter.
 */
@@ -6989,6 +7036,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
      Tcl_ObjCmdProc *xProc;
      void *clientData;
   } aObjCmd[] = {
+     { "sqlite3_db_config",             test_sqlite3_db_config, 0 },
      { "bad_behavior",                  test_bad_behavior,  (void*)&iZero },
      { "register_dbstat_vtab",          test_register_dbstat_vtab  },
      { "sqlite3_connection_pointer",    get_sqlite_pointer, 0 },
index 5db7117555a14b92b54a9fdc99252e7d94c85ecf..30b421e00b693566d26a09c18afa0ba9ae970051 100644 (file)
@@ -370,12 +370,6 @@ static void set_options(Tcl_Interp *interp){
   Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY);
 #endif
 
-#ifdef SQLITE_ENABLE_FTS3_TOKENIZER
-  Tcl_SetVar2(interp, "sqlite_options", "fts3_tokenizer", "1", TCL_GLOBAL_ONLY);
-#else
-  Tcl_SetVar2(interp, "sqlite_options", "fts3_tokenizer", "0", TCL_GLOBAL_ONLY);
-#endif
-
 #ifdef SQLITE_ENABLE_FTS5
   Tcl_SetVar2(interp, "sqlite_options", "fts5", "1", TCL_GLOBAL_ONLY);
 #else
index 2cdea79a98ca94e70c9ebeb0e5ab9bcb5f86ca87..4ce38762d6a9ce7d018f3c78dd543dbcdbfadbde 100644 (file)
@@ -56,40 +56,41 @@ proc escape_string {str} {
 #
 #   5: Test that the table created to use tokenizer 'blah' is usable.
 #
-ifcapable fts3_tokenizer {
-  do_test fts3atoken-1.1 {
-    catchsql {
-      CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
-    }
-  } {1 {unknown tokenizer: blah}}
-  do_test fts3atoken-1.2 {
-    execsql {
-      SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
-    }
-  } {0}
-  do_test fts3atoken-1.3 {
-    execsql {
-      SELECT fts3_tokenizer('blah') == fts3_tokenizer('simple');
-    }
-  } {1}
-  do_test fts3atoken-1.4 {
-    catchsql {
-      CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
-    }
-  } {0 {}}
-  do_test fts3atoken-1.5 {
-    execsql {
-      INSERT INTO t1(content) VALUES('There was movement at the station');
-      INSERT INTO t1(content) VALUES('For the word has passed around');
-      INSERT INTO t1(content) VALUES('That the colt from ol regret had got');
-      SELECT content FROM t1 WHERE content MATCH 'movement'
-    }
-  } {{There was movement at the station}}
-} else {
-  do_catchsql_test 1.6 {
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+do_test fts3atoken-1.1 {
+  catchsql {
+    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
+  }
+} {1 {unknown tokenizer: blah}}
+do_test fts3atoken-1.2 {
+  execsql {
     SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
-  } {1 {fts3tokenize: disabled - rebuild with -DSQLITE_ENABLE_FTS3_TOKENIZER}}
-}
+  }
+} {0}
+do_test fts3atoken-1.3 {
+  execsql {
+    SELECT fts3_tokenizer('blah') == fts3_tokenizer('simple');
+  }
+} {1}
+do_test fts3atoken-1.4 {
+  catchsql {
+    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);
+  }
+} {0 {}}
+do_test fts3atoken-1.5 {
+  execsql {
+    INSERT INTO t1(content) VALUES('There was movement at the station');
+    INSERT INTO t1(content) VALUES('For the word has passed around');
+    INSERT INTO t1(content) VALUES('That the colt from ol regret had got');
+    SELECT content FROM t1 WHERE content MATCH 'movement'
+  }
+} {{There was movement at the station}}
+
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 0
+do_catchsql_test 1.6 {
+  SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;
+} {1 {fts3tokenize disabled}}
+
 
 #--------------------------------------------------------------------------
 # Test cases fts3atoken-2.* test error cases in the scalar function based
@@ -212,14 +213,14 @@ do_catchsql_test 6.1.3 {
 do_catchsql_test 6.2.1 {
   SELECT fts3_tokenizer(NULL);
 } {1 {unknown tokenizer: }}
-ifcapable fts3_tokenizer {
-  do_catchsql_test 6.2.2 {
-    SELECT fts3_tokenizer(NULL, X'1234567812345678');
-  } {1 {argument type mismatch}}
-  do_catchsql_test 6.2.3 {
-    SELECT fts3_tokenizer(NULL, X'12345678');
-  } {1 {argument type mismatch}}
-}
+
+sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+do_catchsql_test 6.2.2 {
+  SELECT fts3_tokenizer(NULL, X'1234567812345678');
+} {1 {argument type mismatch}}
+do_catchsql_test 6.2.3 {
+  SELECT fts3_tokenizer(NULL, X'12345678');
+} {1 {argument type mismatch}}
 
 
 finish_test
index a3059931e7352fe6734e4be8c89270375b22c82f..eb3602b4b8922851185fac1f8594f6bcaab7cc5c 100644 (file)
@@ -358,31 +358,30 @@ proc build_multilingual_db_2 {db} {
   }
 }
 
-ifcapable fts3_tokenizer {
-  do_test 4.1.0 {
-    reset_db
-    set ptr [fts3_test_tokenizer]
-    execsql { SELECT fts3_tokenizer('testtokenizer', $ptr) }
-    build_multilingual_db_2 db
-  } {}
-  do_execsql_test 4.1.1 {
-    SELECT docid FROM t4 WHERE t4 MATCH 'quick';
-  } {0}
-  do_execsql_test 4.1.2 {
-    SELECT docid FROM t4 WHERE t4 MATCH 'quick' AND lid=1;
-  } {}
-  do_execsql_test 4.1.3 {
-    SELECT docid FROM t4 WHERE t4 MATCH 'Quick' AND lid=1;
-  } {1}
-  for {set i 0} {$i < 50} {incr i} {
-    do_execsql_test 4.1.4.$i {
-      SELECT count(*) FROM t4 WHERE t4 MATCH 'fox' AND lid=$i;
-    } [expr 0==($i%2)]
-  }
-  do_catchsql_test 4.1.5 {
-    INSERT INTO t4(content, lid) VALUES('hello world', 101)
-  } {1 {SQL logic error or missing database}}
-}
+do_test 4.1.0 {
+  reset_db
+  set ptr [fts3_test_tokenizer]
+  sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1
+  execsql { SELECT fts3_tokenizer('testtokenizer', $ptr) }
+  build_multilingual_db_2 db
+} {}
+do_execsql_test 4.1.1 {
+  SELECT docid FROM t4 WHERE t4 MATCH 'quick';
+} {0}
+do_execsql_test 4.1.2 {
+  SELECT docid FROM t4 WHERE t4 MATCH 'quick' AND lid=1;
+} {}
+do_execsql_test 4.1.3 {
+  SELECT docid FROM t4 WHERE t4 MATCH 'Quick' AND lid=1;
+} {1}
+for {set i 0} {$i < 50} {incr i} {
+  do_execsql_test 4.1.4.$i {
+    SELECT count(*) FROM t4 WHERE t4 MATCH 'fox' AND lid=$i;
+  } [expr 0==($i%2)]
+}
+do_catchsql_test 4.1.5 {
+  INSERT INTO t4(content, lid) VALUES('hello world', 101)
+} {1 {SQL logic error or missing database}}
 
 #-------------------------------------------------------------------------
 # Test cases 5.*