fts4unicode.test 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. # 2012 May 25
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #*************************************************************************
  11. #
  12. # The tests in this file focus on testing the "unicode" FTS tokenizer.
  13. #
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. ifcapable !fts3_unicode { finish_test ; return }
  17. set ::testprefix fts4unicode
  18. proc do_unicode_token_test {tn input res} {
  19. set input [string map {' ''} $input]
  20. uplevel [list do_execsql_test $tn "
  21. SELECT fts3_tokenizer_test('unicode61', 'remove_diacritics=0', '$input');
  22. " [list [list {*}$res]]]
  23. }
  24. proc do_unicode_token_test2 {tn input res} {
  25. set input [string map {' ''} $input]
  26. uplevel [list do_execsql_test $tn "
  27. SELECT fts3_tokenizer_test('unicode61', '$input');
  28. " [list [list {*}$res]]]
  29. }
  30. proc do_unicode_token_test3 {tn args} {
  31. set res [lindex $args end]
  32. set sql "SELECT fts3_tokenizer_test('unicode61'"
  33. foreach a [lrange $args 0 end-1] {
  34. append sql ", '"
  35. append sql [string map {' ''} $a]
  36. append sql "'"
  37. }
  38. append sql ")"
  39. uplevel [list do_execsql_test $tn $sql [list [list {*}$res]]]
  40. }
  41. do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D}
  42. do_unicode_token_test 1.1 "\uC4 \uD6 \uDC" \
  43. "0 \uE4 \uC4 1 \uF6 \uD6 2 \uFC \uDC"
  44. do_unicode_token_test 1.2 "x\uC4x x\uD6x x\uDCx" \
  45. "0 x\uE4x x\uC4x 1 x\uF6x x\uD6x 2 x\uFCx x\uDCx"
  46. # 0x00DF is a small "sharp s". 0x1E9E is a capital sharp s.
  47. do_unicode_token_test 1.3 "\uDF" "0 \uDF \uDF"
  48. do_unicode_token_test 1.4 "\u1E9E" "0 \uDF \u1E9E"
  49. do_unicode_token_test 1.5 "The quick brown fox" {
  50. 0 the The 1 quick quick 2 brown brown 3 fox fox
  51. }
  52. do_unicode_token_test 1.6 "The\u00bfquick\u224ebrown\u2263fox" {
  53. 0 the The 1 quick quick 2 brown brown 3 fox fox
  54. }
  55. do_unicode_token_test2 1.7 {a B c D} {0 a a 1 b B 2 c c 3 d D}
  56. do_unicode_token_test2 1.8 "\uC4 \uD6 \uDC" "0 a \uC4 1 o \uD6 2 u \uDC"
  57. do_unicode_token_test2 1.9 "x\uC4x x\uD6x x\uDCx" \
  58. "0 xax x\uC4x 1 xox x\uD6x 2 xux x\uDCx"
  59. # Check that diacritics are removed if remove_diacritics=1 is specified.
  60. # And that they do not break tokens.
  61. do_unicode_token_test2 1.10 "xx\u0301xx" "0 xxxx xx\u301xx"
  62. # Title-case mappings work
  63. do_unicode_token_test 1.11 "\u01c5" "0 \u01c6 \u01c5"
  64. #-------------------------------------------------------------------------
  65. #
  66. set docs [list {
  67. Enhance the INSERT syntax to allow multiple rows to be inserted via the
  68. VALUES clause.
  69. } {
  70. Enhance the CREATE VIRTUAL TABLE command to support the IF NOT EXISTS clause.
  71. } {
  72. Added the sqlite3_stricmp() interface as a counterpart to sqlite3_strnicmp().
  73. } {
  74. Added the sqlite3_db_readonly() interface.
  75. } {
  76. Added the SQLITE_FCNTL_PRAGMA file control, giving VFS implementations the
  77. ability to add new PRAGMA statements or to override built-in PRAGMAs.
  78. } {
  79. Queries of the form: "SELECT max(x), y FROM table" returns the value of y on
  80. the same row that contains the maximum x value.
  81. } {
  82. Added support for the FTS4 languageid option.
  83. } {
  84. Documented support for the FTS4 content option. This feature has actually
  85. been in the code since version 3.7.9 but is only now considered to be
  86. officially supported.
  87. } {
  88. Pending statements no longer block ROLLBACK. Instead, the pending statement
  89. will return SQLITE_ABORT upon next access after the ROLLBACK.
  90. } {
  91. Improvements to the handling of CSV inputs in the command-line shell
  92. } {
  93. Fix a bug introduced in version 3.7.10 that might cause a LEFT JOIN to be
  94. incorrectly converted into an INNER JOIN if the WHERE clause indexable terms
  95. connected by OR.
  96. }]
  97. set map(a) [list "\u00C4" "\u00E4"] ; # LATIN LETTER A WITH DIAERESIS
  98. set map(e) [list "\u00CB" "\u00EB"] ; # LATIN LETTER E WITH DIAERESIS
  99. set map(i) [list "\u00CF" "\u00EF"] ; # LATIN LETTER I WITH DIAERESIS
  100. set map(o) [list "\u00D6" "\u00F6"] ; # LATIN LETTER O WITH DIAERESIS
  101. set map(u) [list "\u00DC" "\u00FC"] ; # LATIN LETTER U WITH DIAERESIS
  102. set map(y) [list "\u0178" "\u00FF"] ; # LATIN LETTER Y WITH DIAERESIS
  103. set map(h) [list "\u1E26" "\u1E27"] ; # LATIN LETTER H WITH DIAERESIS
  104. set map(w) [list "\u1E84" "\u1E85"] ; # LATIN LETTER W WITH DIAERESIS
  105. set map(x) [list "\u1E8C" "\u1E8D"] ; # LATIN LETTER X WITH DIAERESIS
  106. foreach k [array names map] {
  107. lappend mappings [string toupper $k] [lindex $map($k) 0]
  108. lappend mappings $k [lindex $map($k) 1]
  109. }
  110. proc mapdoc {doc} {
  111. set doc [regsub -all {[[:space:]]+} $doc " "]
  112. string map $::mappings [string trim $doc]
  113. }
  114. do_test 2.0 {
  115. execsql { CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61, x); }
  116. foreach doc $docs {
  117. set d [mapdoc $doc]
  118. execsql { INSERT INTO t2 VALUES($d) }
  119. }
  120. } {}
  121. do_test 2.1 {
  122. set q [mapdoc "row"]
  123. execsql { SELECT * FROM t2 WHERE t2 MATCH $q }
  124. } [list [mapdoc {
  125. Queries of the form: "SELECT max(x), y FROM table" returns the value of y on
  126. the same row that contains the maximum x value.
  127. }]]
  128. foreach {tn query snippet} {
  129. 2 "row" {
  130. ...returns the value of y on the same [row] that contains
  131. the maximum x value.
  132. }
  133. 3 "ROW" {
  134. ...returns the value of y on the same [row] that contains
  135. the maximum x value.
  136. }
  137. 4 "rollback" {
  138. ...[ROLLBACK]. Instead, the pending statement
  139. will return SQLITE_ABORT upon next access after the [ROLLBACK].
  140. }
  141. 5 "rOllback" {
  142. ...[ROLLBACK]. Instead, the pending statement
  143. will return SQLITE_ABORT upon next access after the [ROLLBACK].
  144. }
  145. 6 "lang*" {
  146. Added support for the FTS4 [languageid] option.
  147. }
  148. } {
  149. do_test 2.$tn {
  150. set q [mapdoc $query]
  151. execsql { SELECT snippet(t2, '[', ']', '...') FROM t2 WHERE t2 MATCH $q }
  152. } [list [mapdoc $snippet]]
  153. }
  154. #-------------------------------------------------------------------------
  155. # Make sure the unicode61 tokenizer does not crash if it is passed a
  156. # NULL pointer.
  157. reset_db
  158. do_execsql_test 3.1 {
  159. CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61, x, y);
  160. INSERT INTO t1 VALUES(NULL, 'a b c');
  161. }
  162. do_execsql_test 3.2 {
  163. SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'b'
  164. } {{a [b] c}}
  165. do_execsql_test 3.3 {
  166. BEGIN;
  167. DELETE FROM t1;
  168. INSERT INTO t1 VALUES('b b b b b b b b b b b', 'b b b b b b b b b b b b b');
  169. INSERT INTO t1 SELECT * FROM t1;
  170. INSERT INTO t1 SELECT * FROM t1;
  171. INSERT INTO t1 SELECT * FROM t1;
  172. INSERT INTO t1 SELECT * FROM t1;
  173. INSERT INTO t1 SELECT * FROM t1;
  174. INSERT INTO t1 SELECT * FROM t1;
  175. INSERT INTO t1 SELECT * FROM t1;
  176. INSERT INTO t1 SELECT * FROM t1;
  177. INSERT INTO t1 SELECT * FROM t1;
  178. INSERT INTO t1 SELECT * FROM t1;
  179. INSERT INTO t1 SELECT * FROM t1;
  180. INSERT INTO t1 SELECT * FROM t1;
  181. INSERT INTO t1 SELECT * FROM t1;
  182. INSERT INTO t1 SELECT * FROM t1;
  183. INSERT INTO t1 SELECT * FROM t1;
  184. INSERT INTO t1 SELECT * FROM t1;
  185. INSERT INTO t1 VALUES('a b c', NULL);
  186. INSERT INTO t1 VALUES('a x c', NULL);
  187. COMMIT;
  188. }
  189. do_execsql_test 3.4 {
  190. SELECT * FROM t1 WHERE t1 MATCH 'a b';
  191. } {{a b c} {}}
  192. #-------------------------------------------------------------------------
  193. #
  194. reset_db
  195. do_test 4.1 {
  196. set a "abc\uFFFEdef"
  197. set b "abc\uD800def"
  198. set c "\uFFFEdef"
  199. set d "\uD800def"
  200. execsql {
  201. CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61, x);
  202. INSERT INTO t1 VALUES($a);
  203. INSERT INTO t1 VALUES($b);
  204. INSERT INTO t1 VALUES($c);
  205. INSERT INTO t1 VALUES($d);
  206. }
  207. } {}
  208. do_test 4.2 {
  209. set a [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0x62}]
  210. set b [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0x62}]
  211. set c [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]
  212. set d [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]
  213. execsql {
  214. INSERT INTO t1 VALUES($a);
  215. INSERT INTO t1 VALUES($b);
  216. INSERT INTO t1 VALUES($c);
  217. INSERT INTO t1 VALUES($d);
  218. }
  219. } {}
  220. do_test 4.3 {
  221. set a [binary format c* {0xF7 0xBF 0xBF 0xBF}]
  222. set b [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF}]
  223. set c [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF}]
  224. set d [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF}]
  225. execsql {
  226. INSERT INTO t1 VALUES($a);
  227. INSERT INTO t1 VALUES($b);
  228. INSERT INTO t1 VALUES($c);
  229. INSERT INTO t1 VALUES($d);
  230. }
  231. } {}
  232. #-------------------------------------------------------------------------
  233. do_unicode_token_test3 5.1 {tokenchars=} {
  234. sqlite3_reset sqlite3_column_int
  235. } {
  236. 0 sqlite3 sqlite3
  237. 1 reset reset
  238. 2 sqlite3 sqlite3
  239. 3 column column
  240. 4 int int
  241. }
  242. do_unicode_token_test3 5.2 {tokenchars=_} {
  243. sqlite3_reset sqlite3_column_int
  244. } {
  245. 0 sqlite3_reset sqlite3_reset
  246. 1 sqlite3_column_int sqlite3_column_int
  247. }
  248. do_unicode_token_test3 5.3 {separators=xyz} {
  249. Laotianxhorseyrunszfast
  250. } {
  251. 0 laotian Laotian
  252. 1 horse horse
  253. 2 runs runs
  254. 3 fast fast
  255. }
  256. do_unicode_token_test3 5.4 {tokenchars=xyz} {
  257. Laotianxhorseyrunszfast
  258. } {
  259. 0 laotianxhorseyrunszfast Laotianxhorseyrunszfast
  260. }
  261. do_unicode_token_test3 5.5 {tokenchars=_} {separators=zyx} {
  262. sqlite3_resetxsqlite3_column_intyhonda_phantom
  263. } {
  264. 0 sqlite3_reset sqlite3_reset
  265. 1 sqlite3_column_int sqlite3_column_int
  266. 2 honda_phantom honda_phantom
  267. }
  268. do_unicode_token_test3 5.6 "separators=\u05D1" "abc\u05D1def" {
  269. 0 abc abc 1 def def
  270. }
  271. do_unicode_token_test3 5.7 \
  272. "tokenchars=\u2444\u2445" \
  273. "separators=\u05D0\u05D1\u05D2" \
  274. "\u2444fre\u2445sh\u05D0water\u05D2fish.\u2445timer" \
  275. [list \
  276. 0 \u2444fre\u2445sh \u2444fre\u2445sh \
  277. 1 water water \
  278. 2 fish fish \
  279. 3 \u2445timer \u2445timer \
  280. ]
  281. # Check that it is not possible to add a standalone diacritic codepoint
  282. # to either separators or tokenchars.
  283. do_unicode_token_test3 5.8 "separators=\u0301" \
  284. "hello\u0301world \u0301helloworld" \
  285. "0 helloworld hello\u0301world 1 helloworld helloworld"
  286. do_unicode_token_test3 5.9 "tokenchars=\u0301" \
  287. "hello\u0301world \u0301helloworld" \
  288. "0 helloworld hello\u0301world 1 helloworld helloworld"
  289. do_unicode_token_test3 5.10 "separators=\u0301" \
  290. "remove_diacritics=0" \
  291. "hello\u0301world \u0301helloworld" \
  292. "0 hello\u0301world hello\u0301world 1 helloworld helloworld"
  293. do_unicode_token_test3 5.11 "tokenchars=\u0301" \
  294. "remove_diacritics=0" \
  295. "hello\u0301world \u0301helloworld" \
  296. "0 hello\u0301world hello\u0301world 1 helloworld helloworld"
  297. #-------------------------------------------------------------------------
  298. proc do_tokenize {tokenizer txt} {
  299. set res [list]
  300. foreach {a b c} [db one {SELECT fts3_tokenizer_test($tokenizer, $txt)}] {
  301. lappend res $b
  302. }
  303. set res
  304. }
  305. # Argument $lCodepoint must be a list of codepoints (integers) that
  306. # correspond to whitespace characters. This command creates a string
  307. # $W from the codepoints, then tokenizes "${W}hello{$W}world${W}"
  308. # using tokenizer $tokenizer. The test passes if the tokenizer successfully
  309. # extracts the two 5 character tokens.
  310. #
  311. proc do_isspace_test {tn tokenizer lCp} {
  312. set whitespace [format [string repeat %c [llength $lCp]] {*}$lCp]
  313. set txt "${whitespace}hello${whitespace}world${whitespace}"
  314. uplevel [list do_test $tn [list do_tokenize $tokenizer $txt] {hello world}]
  315. }
  316. set tokenizers [list unicode61]
  317. ifcapable icu { lappend tokenizers icu }
  318. # Some tests to check that the tokenizers can both identify white-space
  319. # codepoints. All codepoints tested below are of type "Zs" in the
  320. # UnicodeData.txt file.
  321. foreach T $tokenizers {
  322. do_isspace_test 6.$T.1 $T 32
  323. do_isspace_test 6.$T.2 $T 160
  324. do_isspace_test 6.$T.3 $T 5760
  325. do_isspace_test 6.$T.4 $T 6158
  326. do_isspace_test 6.$T.5 $T 8192
  327. do_isspace_test 6.$T.6 $T 8193
  328. do_isspace_test 6.$T.7 $T 8194
  329. do_isspace_test 6.$T.8 $T 8195
  330. do_isspace_test 6.$T.9 $T 8196
  331. do_isspace_test 6.$T.10 $T 8197
  332. do_isspace_test 6.$T.11 $T 8198
  333. do_isspace_test 6.$T.12 $T 8199
  334. do_isspace_test 6.$T.13 $T 8200
  335. do_isspace_test 6.$T.14 $T 8201
  336. do_isspace_test 6.$T.15 $T 8202
  337. do_isspace_test 6.$T.16 $T 8239
  338. do_isspace_test 6.$T.17 $T 8287
  339. do_isspace_test 6.$T.18 $T 12288
  340. do_isspace_test 6.$T.19 $T {32 160 5760 6158}
  341. do_isspace_test 6.$T.20 $T {8192 8193 8194 8195}
  342. do_isspace_test 6.$T.21 $T {8196 8197 8198 8199}
  343. do_isspace_test 6.$T.22 $T {8200 8201 8202 8239}
  344. do_isspace_test 6.$T.23 $T {8287 12288}
  345. }
  346. #-------------------------------------------------------------------------
  347. # Test that the private use ranges are treated as alphanumeric.
  348. #
  349. breakpoint
  350. foreach {tn1 c} {
  351. 1 \ue000 2 \ue001 3 \uf000 4 \uf8fe 5 \uf8ff
  352. } {
  353. foreach {tn2 config res} {
  354. 1 "" "0 hello*world hello*world"
  355. 2 "separators=*" "0 hello hello 1 world world"
  356. } {
  357. set config [string map [list * $c] $config]
  358. set input [string map [list * $c] "hello*world"]
  359. set output [string map [list * $c] $res]
  360. do_unicode_token_test3 7.$tn1.$tn2 {*}$config $input $output
  361. }
  362. }
  363. #-------------------------------------------------------------------------
  364. # Cursory test of remove_diacritics=0.
  365. #
  366. # 00C4;LATIN CAPITAL LETTER A WITH DIAERESIS
  367. # 00D6;LATIN CAPITAL LETTER O WITH DIAERESIS
  368. # 00E4;LATIN SMALL LETTER A WITH DIAERESIS
  369. # 00F6;LATIN SMALL LETTER O WITH DIAERESIS
  370. #
  371. do_execsql_test 8.1.1 "
  372. CREATE VIRTUAL TABLE t3 USING fts4(tokenize=unicode61 'remove_diacritics=1');
  373. INSERT INTO t3 VALUES('o');
  374. INSERT INTO t3 VALUES('a');
  375. INSERT INTO t3 VALUES('O');
  376. INSERT INTO t3 VALUES('A');
  377. INSERT INTO t3 VALUES('\xD6');
  378. INSERT INTO t3 VALUES('\xC4');
  379. INSERT INTO t3 VALUES('\xF6');
  380. INSERT INTO t3 VALUES('\xE4');
  381. "
  382. do_execsql_test 8.1.2 {
  383. SELECT rowid FROM t3 WHERE t3 MATCH 'o';
  384. } {1 3 5 7}
  385. do_execsql_test 8.1.3 {
  386. SELECT rowid FROM t3 WHERE t3 MATCH 'a';
  387. } {2 4 6 8}
  388. do_execsql_test 8.2.1 {
  389. CREATE VIRTUAL TABLE t4 USING fts4(tokenize=unicode61 "remove_diacritics=0");
  390. INSERT INTO t4 SELECT * FROM t3;
  391. }
  392. do_execsql_test 8.2.2 {
  393. SELECT rowid FROM t4 WHERE t4 MATCH 'o';
  394. } {1 3}
  395. do_execsql_test 8.2.3 {
  396. SELECT rowid FROM t4 WHERE t4 MATCH 'a';
  397. } {2 4}
  398. #-------------------------------------------------------------------------
  399. #
  400. foreach {tn sql} {
  401. 1 {
  402. CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 [tokenchars= .]);
  403. CREATE VIRTUAL TABLE t6 USING fts4(
  404. tokenize=unicode61 [tokenchars=="] "tokenchars=[]");
  405. CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 [separators=x\xC4]);
  406. }
  407. 2 {
  408. CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 "tokenchars= .");
  409. CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 "tokenchars=[=""]");
  410. CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 "separators=x\xC4");
  411. }
  412. 3 {
  413. CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 'tokenchars= .');
  414. CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 'tokenchars=="[]');
  415. CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 'separators=x\xC4');
  416. }
  417. 4 {
  418. CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 `tokenchars= .`);
  419. CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 `tokenchars=[="]`);
  420. CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 `separators=x\xC4`);
  421. }
  422. } {
  423. do_execsql_test 9.$tn.0 {
  424. DROP TABLE IF EXISTS t5;
  425. DROP TABLE IF EXISTS t5aux;
  426. DROP TABLE IF EXISTS t6;
  427. DROP TABLE IF EXISTS t6aux;
  428. DROP TABLE IF EXISTS t7;
  429. DROP TABLE IF EXISTS t7aux;
  430. }
  431. do_execsql_test 9.$tn.1 $sql
  432. do_execsql_test 9.$tn.2 {
  433. CREATE VIRTUAL TABLE t5aux USING fts4aux(t5);
  434. INSERT INTO t5 VALUES('one two three/four.five.six');
  435. SELECT * FROM t5aux;
  436. } {
  437. four.five.six * 1 1 four.five.six 0 1 1
  438. {one two three} * 1 1 {one two three} 0 1 1
  439. }
  440. do_execsql_test 9.$tn.3 {
  441. CREATE VIRTUAL TABLE t6aux USING fts4aux(t6);
  442. INSERT INTO t6 VALUES('alpha=beta"gamma/delta[epsilon]zeta');
  443. SELECT * FROM t6aux;
  444. } {
  445. {alpha=beta"gamma} * 1 1 {alpha=beta"gamma} 0 1 1
  446. {delta[epsilon]zeta} * 1 1 {delta[epsilon]zeta} 0 1 1
  447. }
  448. do_execsql_test 9.$tn.4 {
  449. CREATE VIRTUAL TABLE t7aux USING fts4aux(t7);
  450. INSERT INTO t7 VALUES('alephxbeth\xC4gimel');
  451. SELECT * FROM t7aux;
  452. } {
  453. aleph * 1 1 aleph 0 1 1
  454. beth * 1 1 beth 0 1 1
  455. gimel * 1 1 gimel 0 1 1
  456. }
  457. }
  458. # Check that multiple options are handled correctly.
  459. #
  460. do_execsql_test 10.1 {
  461. DROP TABLE IF EXISTS t1;
  462. CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61
  463. "tokenchars=xyz" "tokenchars=.=" "separators=.=" "separators=xy"
  464. "separators=a" "separators=a" "tokenchars=a" "tokenchars=a"
  465. );
  466. INSERT INTO t1 VALUES('oneatwoxthreeyfour');
  467. INSERT INTO t1 VALUES('a.single=word');
  468. CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);
  469. SELECT * FROM t1aux;
  470. } {
  471. .single=word * 1 1 .single=word 0 1 1
  472. four * 1 1 four 0 1 1
  473. one * 1 1 one 0 1 1
  474. three * 1 1 three 0 1 1
  475. two * 1 1 two 0 1 1
  476. }
  477. # Test that case folding happens after tokenization, not before.
  478. #
  479. do_execsql_test 10.2 {
  480. DROP TABLE IF EXISTS t2;
  481. CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61 "separators=aB");
  482. INSERT INTO t2 VALUES('oneatwoBthree');
  483. INSERT INTO t2 VALUES('onebtwoAthree');
  484. CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);
  485. SELECT * FROM t2aux;
  486. } {
  487. one * 1 1 one 0 1 1
  488. onebtwoathree * 1 1 onebtwoathree 0 1 1
  489. three * 1 1 three 0 1 1
  490. two * 1 1 two 0 1 1
  491. }
  492. # Test that the tokenchars and separators options work with the
  493. # fts3tokenize table.
  494. #
  495. do_execsql_test 11.1 {
  496. CREATE VIRTUAL TABLE ft1 USING fts3tokenize(
  497. "unicode61", "tokenchars=@.", "separators=1234567890"
  498. );
  499. SELECT token FROM ft1 WHERE input = 'berlin@street123sydney.road';
  500. } {
  501. berlin@street sydney.road
  502. }
  503. finish_test