fts3expr.test 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. # 2006 September 9
  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. # This file implements regression tests for SQLite library. The
  12. # focus of this script is testing the FTS3 module.
  13. #
  14. # $Id: fts3expr.test,v 1.9 2009/07/28 16:44:26 danielk1977 Exp $
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. # If SQLITE_ENABLE_FTS3 is defined, omit this file.
  19. ifcapable !fts3 {
  20. finish_test
  21. return
  22. }
  23. set sqlite_fts3_enable_parentheses 1
  24. proc test_fts3expr {expr} {
  25. db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
  26. }
  27. do_test fts3expr-1.0 {
  28. test_fts3expr "abcd"
  29. } {PHRASE 3 0 abcd}
  30. do_test fts3expr-1.1 {
  31. test_fts3expr " tag "
  32. } {PHRASE 3 0 tag}
  33. do_test fts3expr-1.2 {
  34. test_fts3expr "ab AND cd"
  35. } {AND {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  36. do_test fts3expr-1.2.1 {
  37. test_fts3expr "ab cd"
  38. } {AND {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  39. do_test fts3expr-1.3 {
  40. test_fts3expr "ab OR cd"
  41. } {OR {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  42. do_test fts3expr-1.4 {
  43. test_fts3expr "ab NOT cd"
  44. } {NOT {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  45. do_test fts3expr-1.5 {
  46. test_fts3expr "ab NEAR cd"
  47. } {NEAR/10 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  48. do_test fts3expr-1.6.1 {
  49. test_fts3expr "ab NEAR/5 cd"
  50. } {NEAR/5 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  51. do_test fts3expr-1.6.2 {
  52. test_fts3expr "ab NEAR/87654321 cd"
  53. } {NEAR/87654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  54. do_test fts3expr-1.6.3 {
  55. test_fts3expr "ab NEAR/7654321 cd"
  56. } {NEAR/7654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  57. do_test fts3expr-1.6.4 {
  58. test_fts3expr "ab NEAR/654321 cd"
  59. } {NEAR/654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  60. do_test fts3expr-1.6.5 {
  61. test_fts3expr "ab NEAR/54321 cd"
  62. } {NEAR/54321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  63. do_test fts3expr-1.6.6 {
  64. test_fts3expr "ab NEAR/4321 cd"
  65. } {NEAR/4321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  66. do_test fts3expr-1.6.7 {
  67. test_fts3expr "ab NEAR/321 cd"
  68. } {NEAR/321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  69. do_test fts3expr-1.6.8 {
  70. test_fts3expr "ab NEAR/21 cd"
  71. } {NEAR/21 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}
  72. do_test fts3expr-1.7 {
  73. test_fts3expr {"one two three"}
  74. } {PHRASE 3 0 one two three}
  75. do_test fts3expr-1.8.1 {
  76. test_fts3expr {zero "one two three" four}
  77. } {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
  78. do_test fts3expr-1.8.2 {
  79. test_fts3expr {zero AND "one two three" four}
  80. } {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
  81. do_test fts3expr-1.8.3 {
  82. test_fts3expr {zero "one two three" AND four}
  83. } {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
  84. do_test fts3expr-1.8.4 {
  85. test_fts3expr {zero AND "one two three" AND four}
  86. } {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}
  87. do_test fts3expr-1.9.1 {
  88. test_fts3expr {"one* two three"}
  89. } {PHRASE 3 0 one+ two three}
  90. do_test fts3expr-1.9.2 {
  91. test_fts3expr {"one two* three"}
  92. } {PHRASE 3 0 one two+ three}
  93. do_test fts3expr-1.9.3 {
  94. test_fts3expr {"one* two* three"}
  95. } {PHRASE 3 0 one+ two+ three}
  96. do_test fts3expr-1.9.4 {
  97. test_fts3expr {"one two three*"}
  98. } {PHRASE 3 0 one two three+}
  99. do_test fts3expr-1.9.5 {
  100. test_fts3expr {"one* two three*"}
  101. } {PHRASE 3 0 one+ two three+}
  102. do_test fts3expr-1.9.6 {
  103. test_fts3expr {"one two* three*"}
  104. } {PHRASE 3 0 one two+ three+}
  105. do_test fts3expr-1.9.7 {
  106. test_fts3expr {"one* two* three*"}
  107. } {PHRASE 3 0 one+ two+ three+}
  108. do_test fts3expr-1.10 {
  109. test_fts3expr {one* two}
  110. } {AND {PHRASE 3 0 one+} {PHRASE 3 0 two}}
  111. do_test fts3expr-1.11 {
  112. test_fts3expr {one two*}
  113. } {AND {PHRASE 3 0 one} {PHRASE 3 0 two+}}
  114. do_test fts3expr-1.14 {
  115. test_fts3expr {a:one two}
  116. } {AND {PHRASE 0 0 one} {PHRASE 3 0 two}}
  117. do_test fts3expr-1.15.1 {
  118. test_fts3expr {one b:two}
  119. } {AND {PHRASE 3 0 one} {PHRASE 1 0 two}}
  120. do_test fts3expr-1.15.2 {
  121. test_fts3expr {one B:two}
  122. } {AND {PHRASE 3 0 one} {PHRASE 1 0 two}}
  123. do_test fts3expr-1.16 {
  124. test_fts3expr {one AND two AND three AND four AND five}
  125. } [list AND \
  126. [list AND \
  127. [list AND \
  128. [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  129. {PHRASE 3 0 three} \
  130. ] \
  131. {PHRASE 3 0 four} \
  132. ] \
  133. {PHRASE 3 0 five} \
  134. ]
  135. do_test fts3expr-1.17 {
  136. test_fts3expr {(one AND two) AND ((three AND four) AND five)}
  137. } [list AND \
  138. [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  139. [list AND \
  140. [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  141. {PHRASE 3 0 five} \
  142. ] \
  143. ]
  144. do_test fts3expr-1.18 {
  145. test_fts3expr {(one AND two) OR ((three AND four) AND five)}
  146. } [list OR \
  147. [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  148. [list AND \
  149. [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  150. {PHRASE 3 0 five} \
  151. ] \
  152. ]
  153. do_test fts3expr-1.19 {
  154. test_fts3expr {(one AND two) AND ((three AND four) OR five)}
  155. } [list AND \
  156. [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  157. [list OR \
  158. [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  159. {PHRASE 3 0 five} \
  160. ] \
  161. ]
  162. do_test fts3expr-1.20 {
  163. test_fts3expr {(one OR two) AND ((three OR four) AND five)}
  164. } [list AND \
  165. [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  166. [list AND \
  167. [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  168. {PHRASE 3 0 five} \
  169. ] \
  170. ]
  171. do_test fts3expr-1.21 {
  172. test_fts3expr {(one OR two) AND ((three NOT four) AND five)}
  173. } [list AND \
  174. [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  175. [list AND \
  176. [list NOT {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  177. {PHRASE 3 0 five} \
  178. ] \
  179. ]
  180. do_test fts3expr-1.22 {
  181. test_fts3expr {(one OR two) NOT ((three OR four) AND five)}
  182. } [list NOT \
  183. [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  184. [list AND \
  185. [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  186. {PHRASE 3 0 five} \
  187. ] \
  188. ]
  189. do_test fts3expr-1.23 {
  190. test_fts3expr {(((((one OR two))))) NOT (((((three OR four))) AND five))}
  191. } [list NOT \
  192. [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  193. [list AND \
  194. [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  195. {PHRASE 3 0 five} \
  196. ] \
  197. ]
  198. do_test fts3expr-1.24 {
  199. test_fts3expr {one NEAR two}
  200. } [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]
  201. do_test fts3expr-1.25 {
  202. test_fts3expr {(one NEAR two)}
  203. } [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]
  204. do_test fts3expr-1.26 {
  205. test_fts3expr {((((((one NEAR two))))))}
  206. } [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]
  207. do_test fts3expr-1.27 {
  208. test_fts3expr {(one NEAR two) OR ((three OR four) AND five)}
  209. } [list OR \
  210. [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  211. [list AND \
  212. [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  213. {PHRASE 3 0 five} \
  214. ] \
  215. ]
  216. do_test fts3expr-1.28 {
  217. test_fts3expr {(one NEAR/321 two) OR ((three OR four) AND five)}
  218. } [list OR \
  219. [list NEAR/321 {PHRASE 3 0 one} {PHRASE 3 0 two}] \
  220. [list AND \
  221. [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \
  222. {PHRASE 3 0 five} \
  223. ] \
  224. ]
  225. proc strip_phrase_data {L} {
  226. if {[lindex $L 0] eq "PHRASE"} {
  227. return [lrange $L 3 end]
  228. }
  229. return [list \
  230. [lindex $L 0] \
  231. [strip_phrase_data [lindex $L 1]] \
  232. [strip_phrase_data [lindex $L 2]] \
  233. ]
  234. }
  235. proc test_fts3expr2 {expr} {
  236. strip_phrase_data [
  237. db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}
  238. ]
  239. }
  240. do_test fts3expr-2.1 {
  241. test_fts3expr2 "ab OR cd AND ef"
  242. } {OR ab {AND cd ef}}
  243. do_test fts3expr-2.2 {
  244. test_fts3expr2 "cd AND ef OR ab"
  245. } {OR {AND cd ef} ab}
  246. do_test fts3expr-2.3 {
  247. test_fts3expr2 "ab AND cd AND ef OR gh"
  248. } {OR {AND {AND ab cd} ef} gh}
  249. do_test fts3expr-2.4 {
  250. test_fts3expr2 "ab AND cd OR ef AND gh"
  251. } {OR {AND ab cd} {AND ef gh}}
  252. do_test fts3expr-2.5 {
  253. test_fts3expr2 "ab cd"
  254. } {AND ab cd}
  255. do_test fts3expr-3.1 {
  256. test_fts3expr2 "(ab OR cd) AND ef"
  257. } {AND {OR ab cd} ef}
  258. do_test fts3expr-3.2 {
  259. test_fts3expr2 "ef AND (ab OR cd)"
  260. } {AND ef {OR ab cd}}
  261. do_test fts3expr-3.3 {
  262. test_fts3expr2 "(ab OR cd)"
  263. } {OR ab cd}
  264. do_test fts3expr-3.4 {
  265. test_fts3expr2 "(((ab OR cd)))"
  266. } {OR ab cd}
  267. do_test fts3expr-3.5 {
  268. test_fts3expr2 "one AND (two NEAR three)"
  269. } {AND one {NEAR/10 two three}}
  270. do_test fts3expr-3.6 {
  271. test_fts3expr2 "one (two NEAR three)"
  272. } {AND one {NEAR/10 two three}}
  273. do_test fts3expr-3.7 {
  274. test_fts3expr2 "(two NEAR three) one"
  275. } {AND {NEAR/10 two three} one}
  276. do_test fts3expr-3.8 {
  277. test_fts3expr2 "(two NEAR three) AND one"
  278. } {AND {NEAR/10 two three} one}
  279. do_test fts3expr-3.9 {
  280. test_fts3expr2 "(two NEAR three) (four five)"
  281. } {AND {NEAR/10 two three} {AND four five}}
  282. do_test fts3expr-3.10 {
  283. test_fts3expr2 "(two NEAR three) AND (four five)"
  284. } {AND {NEAR/10 two three} {AND four five}}
  285. do_test fts3expr-3.11 {
  286. test_fts3expr2 "(two NEAR three) (four NEAR five)"
  287. } {AND {NEAR/10 two three} {NEAR/10 four five}}
  288. do_test fts3expr-3.12 {
  289. test_fts3expr2 "(two NEAR three) OR (four NEAR five)"
  290. } {OR {NEAR/10 two three} {NEAR/10 four five}}
  291. do_test fts3expr-3.13 {
  292. test_fts3expr2 "(two NEAR/1a three)"
  293. } {AND {AND {AND two near} 1a} three}
  294. do_test fts3expr-3.14 {
  295. test_fts3expr2 "(two NEAR// three)"
  296. } {AND {AND two near} three}
  297. do_test fts3expr-3.15 {
  298. test_fts3expr2 "(two NEAR/: three)"
  299. } {AND {AND two near} three}
  300. do_test fts3expr-3.16 {
  301. test_fts3expr2 "(two NEAR three)OR(four NEAR five)"
  302. } {OR {NEAR/10 two three} {NEAR/10 four five}}
  303. do_test fts3expr-3.17 {
  304. test_fts3expr2 "(two NEAR three)OR\"four five\""
  305. } {OR {NEAR/10 two three} {four five}}
  306. do_test fts3expr-3.18 {
  307. test_fts3expr2 "one \u0080wo"
  308. } "AND one \u0080wo"
  309. #------------------------------------------------------------------------
  310. # The following tests, fts3expr-4.*, test the parsers response to syntax
  311. # errors in query expressions. This is done using a real fts3 table and
  312. # MATCH clauses, not the parser test interface.
  313. #
  314. do_test fts3expr-4.1 {
  315. execsql { CREATE VIRTUAL TABLE t1 USING fts3(a, b, c) }
  316. } {}
  317. # Mismatched parenthesis:
  318. do_test fts3expr-4.2.1 {
  319. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world))' }
  320. } {1 {malformed MATCH expression: [example AND (hello OR world))]}}
  321. do_test fts3expr-4.2.2 {
  322. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world' }
  323. } {1 {malformed MATCH expression: [example AND (hello OR world]}}
  324. do_test fts3expr-4.2.3 {
  325. catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello' }
  326. } {1 {malformed MATCH expression: [(hello]}}
  327. do_test fts3expr-4.2.4 {
  328. catchsql { SELECT * FROM t1 WHERE t1 MATCH '(' }
  329. } {1 {malformed MATCH expression: [(]}}
  330. do_test fts3expr-4.2.5 {
  331. catchsql { SELECT * FROM t1 WHERE t1 MATCH ')' }
  332. } {1 {malformed MATCH expression: [)]}}
  333. do_test fts3expr-4.2.6 {
  334. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example (hello world' }
  335. } {1 {malformed MATCH expression: [example (hello world]}}
  336. # Unterminated quotation marks:
  337. do_test fts3expr-4.3.1 {
  338. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR "hello world' }
  339. } {1 {malformed MATCH expression: [example OR "hello world]}}
  340. do_test fts3expr-4.3.2 {
  341. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR hello world"' }
  342. } {1 {malformed MATCH expression: [example OR hello world"]}}
  343. # Binary operators without the required operands.
  344. do_test fts3expr-4.4.1 {
  345. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'OR hello world' }
  346. } {1 {malformed MATCH expression: [OR hello world]}}
  347. do_test fts3expr-4.4.2 {
  348. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'hello world OR' }
  349. } {1 {malformed MATCH expression: [hello world OR]}}
  350. do_test fts3expr-4.4.3 {
  351. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (hello world OR) two' }
  352. } {1 {malformed MATCH expression: [one (hello world OR) two]}}
  353. do_test fts3expr-4.4.4 {
  354. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (OR hello world) two' }
  355. } {1 {malformed MATCH expression: [one (OR hello world) two]}}
  356. # NEAR operators with something other than phrases as arguments.
  357. do_test fts3expr-4.5.1 {
  358. catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello OR world) NEAR one' }
  359. } {1 {malformed MATCH expression: [(hello OR world) NEAR one]}}
  360. do_test fts3expr-4.5.2 {
  361. catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one NEAR (hello OR world)' }
  362. } {1 {malformed MATCH expression: [one NEAR (hello OR world)]}}
  363. #------------------------------------------------------------------------
  364. # The following OOM tests are designed to cover cases in fts3_expr.c.
  365. #
  366. source $testdir/malloc_common.tcl
  367. do_malloc_test fts3expr-malloc-1 -sqlbody {
  368. SELECT fts3_exprtest('simple', 'a b c "d e f"', 'a', 'b', 'c')
  369. }
  370. do_malloc_test fts3expr-malloc-2 -tclprep {
  371. set sqlite_fts3_enable_parentheses 0
  372. } -sqlbody {
  373. SELECT fts3_exprtest('simple', 'a -b', 'a', 'b', 'c')
  374. } -cleanup {
  375. set sqlite_fts3_enable_parentheses 1
  376. }
  377. #------------------------------------------------------------------------
  378. # The following tests are not very important. They cover error handling
  379. # cases in the test code, which makes test coverage easier to measure.
  380. #
  381. do_test fts3expr-5.1 {
  382. catchsql { SELECT fts3_exprtest('simple', 'a b') }
  383. } {1 {Usage: fts3_exprtest(tokenizer, expr, col1, ...}}
  384. do_test fts3expr-5.2 {
  385. catchsql { SELECT fts3_exprtest('doesnotexist', 'a b', 'c') }
  386. } {1 {No such tokenizer module}}
  387. do_test fts3expr-5.3 {
  388. catchsql { SELECT fts3_exprtest('simple', 'a b OR', 'c') }
  389. } {1 {Error parsing expression}}
  390. #------------------------------------------------------------------------
  391. # The next set of tests verifies that things actually work as they are
  392. # supposed to when using the new syntax.
  393. #
  394. do_test fts3expr-6.1 {
  395. execsql {
  396. CREATE VIRTUAL TABLE t1 USING fts3(a);
  397. }
  398. for {set ii 1} {$ii < 32} {incr ii} {
  399. set v [list]
  400. if {$ii & 1} { lappend v one }
  401. if {$ii & 2} { lappend v two }
  402. if {$ii & 4} { lappend v three }
  403. if {$ii & 8} { lappend v four }
  404. if {$ii & 16} { lappend v five }
  405. execsql { INSERT INTO t1 VALUES($v) }
  406. }
  407. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'five four one' ORDER BY rowid}
  408. } {25 27 29 31}
  409. foreach {id expr res} {
  410. 2 "five four NOT one" {24 26 28 30}
  411. 3 "five AND four OR one"
  412. {1 3 5 7 9 11 13 15 17 19 21 23 24 25 26 27 28 29 30 31}
  413. 4 "five AND (four OR one)" {17 19 21 23 24 25 26 27 28 29 30 31}
  414. 5 "five NOT (four OR one)" {16 18 20 22}
  415. 6 "(five NOT (four OR one)) OR (five AND (four OR one))"
  416. {16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
  417. 7 "(five OR one) AND two AND three" {7 15 22 23 30 31}
  418. 8 "five OR one AND two AND three"
  419. {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
  420. 9 "five OR one two three"
  421. {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
  422. 10 "five OR \"one two three\""
  423. {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
  424. 11 "one two OR four five NOT three" {3 7 11 15 19 23 24 25 26 27 31}
  425. 12 "(one two OR four five) NOT three" {3 11 19 24 25 26 27}
  426. 13 "((((((one two OR four five)))))) NOT three" {3 11 19 24 25 26 27}
  427. } {
  428. do_test fts3expr-6.1.$id {
  429. execsql { SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid }
  430. } $res
  431. }
  432. set sqlite_fts3_enable_parentheses 0
  433. foreach {id expr res} {
  434. 1 "one -two three" {5 13 21 29}
  435. 2 "-two one three" {5 13 21 29}
  436. 3 "one three -two" {5 13 21 29}
  437. 4 "-one -two three" {4 12 20 28}
  438. 5 "three -one -two" {4 12 20 28}
  439. 6 "-one three -two" {4 12 20 28}
  440. } {
  441. do_test fts3expr-6.2.$id {
  442. execsql { SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid }
  443. } $res
  444. }
  445. set sqlite_fts3_enable_parentheses 1
  446. do_test fts3expr-7.1 {
  447. execsql {
  448. CREATE VIRTUAL TABLE test USING fts3 (keyword);
  449. INSERT INTO test VALUES ('abc');
  450. SELECT * FROM test WHERE keyword MATCH '""';
  451. }
  452. } {}
  453. set sqlite_fts3_enable_parentheses 0
  454. finish_test