fts5vocab.test 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. # 2015 Apr 24
  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 fts5vocab module.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. set testprefix fts5vocab
  16. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  17. ifcapable !fts5 {
  18. finish_test
  19. return
  20. }
  21. foreach_detail_mode $testprefix {
  22. proc null_list_entries {iFirst nInterval L} {
  23. for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} {
  24. lset L $i {}
  25. }
  26. return $L
  27. }
  28. proc star_from_row {L} {
  29. if {[detail_is_full]==0} {
  30. set L [null_list_entries 2 3 $L]
  31. }
  32. return $L
  33. }
  34. proc star_from_col {L} {
  35. if {[detail_is_col]} {
  36. set L [null_list_entries 3 4 $L]
  37. }
  38. if {[detail_is_none]} {
  39. set L [null_list_entries 1 4 $L]
  40. set L [null_list_entries 3 4 $L]
  41. }
  42. return $L
  43. }
  44. proc row_to_col {L} {
  45. if {[detail_is_none]==0} { error "this is for detail=none mode" }
  46. set ret [list]
  47. foreach {a b c} $L {
  48. lappend ret $a {} $b {}
  49. }
  50. set ret
  51. }
  52. if 1 {
  53. do_execsql_test 1.1.1 {
  54. CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%);
  55. CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row');
  56. PRAGMA table_info = v1;
  57. } {
  58. 0 term {} 0 {} 0
  59. 1 doc {} 0 {} 0
  60. 2 cnt {} 0 {} 0
  61. }
  62. do_execsql_test 1.1.2 {
  63. CREATE VIRTUAL TABLE v2 USING fts5vocab(t1, 'col');
  64. PRAGMA table_info = v2;
  65. } {
  66. 0 term {} 0 {} 0
  67. 1 col {} 0 {} 0
  68. 2 doc {} 0 {} 0
  69. 3 cnt {} 0 {} 0
  70. }
  71. do_execsql_test 1.2.1 { SELECT * FROM v1 } {}
  72. do_execsql_test 1.2.2 { SELECT * FROM v2 } {}
  73. do_execsql_test 1.3 {
  74. INSERT INTO t1 VALUES('x y z');
  75. INSERT INTO t1 VALUES('x x x');
  76. }
  77. do_execsql_test 1.4.1 {
  78. SELECT * FROM v1;
  79. } [star_from_row {x 2 4 y 1 1 z 1 1}]
  80. do_execsql_test 1.4.2 {
  81. SELECT * FROM v2;
  82. } [star_from_col {x one 2 4 y one 1 1 z one 1 1}]
  83. do_execsql_test 1.5.1 {
  84. BEGIN;
  85. INSERT INTO t1 VALUES('a b c');
  86. SELECT * FROM v1 WHERE term<'d';
  87. } [star_from_row {a 1 1 b 1 1 c 1 1}]
  88. do_execsql_test 1.5.2 {
  89. SELECT * FROM v2 WHERE term<'d';
  90. COMMIT;
  91. } [star_from_col {a one 1 1 b one 1 1 c one 1 1}]
  92. do_execsql_test 1.6 {
  93. DELETE FROM t1 WHERE one = 'a b c';
  94. SELECT * FROM v1;
  95. } [star_from_row {x 2 4 y 1 1 z 1 1}]
  96. #-------------------------------------------------------------------------
  97. #
  98. do_execsql_test 2.0 {
  99. CREATE VIRTUAL TABLE tt USING fts5(a, b, detail=%DETAIL%);
  100. INSERT INTO tt VALUES('d g b f d f', 'f c e c d a');
  101. INSERT INTO tt VALUES('f a e a a b', 'e d c f d d');
  102. INSERT INTO tt VALUES('b c a a a b', 'f f c c b c');
  103. INSERT INTO tt VALUES('f d c a c e', 'd g d e g d');
  104. INSERT INTO tt VALUES('g d e f a g x', 'f f d a a b');
  105. INSERT INTO tt VALUES('g c f b c g', 'a g f d c b');
  106. INSERT INTO tt VALUES('c e c f g b', 'f e d b g a');
  107. INSERT INTO tt VALUES('g d e f d e', 'a c d b a g');
  108. INSERT INTO tt VALUES('e f a c c b', 'b f e a f d y');
  109. INSERT INTO tt VALUES('c c a a c f', 'd g a e b g');
  110. }
  111. set res_row [star_from_row {
  112. a 10 20 b 9 14 c 9 20 d 9 19
  113. e 8 13 f 10 20 g 7 14 x 1 1
  114. y 1 1
  115. }]
  116. set res_col [star_from_col {
  117. a a 6 11 a b 7 9
  118. b a 6 7 b b 7 7
  119. c a 6 12 c b 5 8
  120. d a 4 6 d b 9 13
  121. e a 6 7 e b 6 6
  122. f a 9 10 f b 7 10
  123. g a 5 7 g b 5 7
  124. x a 1 1 y b 1 1
  125. }]
  126. if {[detail_is_none]} {
  127. set res_col [row_to_col $res_row]
  128. }
  129. foreach {tn tbl resname} {
  130. 1 "fts5vocab(tt, 'col')" res_col
  131. 2 "fts5vocab(tt, 'row')" res_row
  132. 3 "fts5vocab(tt, \"row\")" res_row
  133. 4 "fts5vocab(tt, [row])" res_row
  134. 5 "fts5vocab(tt, `row`)" res_row
  135. 6 "fts5vocab('tt', 'row')" res_row
  136. 7 "fts5vocab(\"tt\", \"row\")" res_row
  137. 8 "fts5vocab([tt], [row])" res_row
  138. 9 "fts5vocab(`tt`, `row`)" res_row
  139. } {
  140. do_execsql_test 2.$tn "
  141. DROP TABLE IF EXISTS tv;
  142. CREATE VIRTUAL TABLE tv USING $tbl;
  143. SELECT * FROM tv;
  144. " [set $resname]
  145. }
  146. #-------------------------------------------------------------------------
  147. # Test errors in the CREATE VIRTUAL TABLE statement.
  148. #
  149. foreach {tn sql} {
  150. 1 { CREATE VIRTUAL TABLE aa USING fts5vocab() }
  151. 2 { CREATE VIRTUAL TABLE aa USING fts5vocab(x) }
  152. 3 { CREATE VIRTUAL TABLE aa USING fts5vocab(x,y,z) }
  153. 4 { CREATE VIRTUAL TABLE temp.aa USING fts5vocab(x,y,z,y) }
  154. } {
  155. do_catchsql_test 3.$tn $sql {1 {wrong number of vtable arguments}}
  156. }
  157. do_catchsql_test 4.0 {
  158. CREATE VIRTUAL TABLE cc USING fts5vocab(tbl, unknown);
  159. } {1 {fts5vocab: unknown table type: 'unknown'}}
  160. do_catchsql_test 4.1 {
  161. ATTACH 'test.db' AS aux;
  162. CREATE VIRTUAL TABLE aux.cc USING fts5vocab(main, tbl, row);
  163. } {1 {wrong number of vtable arguments}}
  164. #-------------------------------------------------------------------------
  165. # Test fts5vocab tables created in the temp schema.
  166. #
  167. reset_db
  168. forcedelete test.db2
  169. do_execsql_test 5.0 {
  170. ATTACH 'test.db2' AS aux;
  171. CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);
  172. CREATE VIRTUAL TABLE temp.t1 USING fts5(x, detail=%DETAIL%);
  173. CREATE VIRTUAL TABLE aux.t1 USING fts5(x, detail=%DETAIL%);
  174. INSERT INTO main.t1 VALUES('a b c');
  175. INSERT INTO main.t1 VALUES('d e f');
  176. INSERT INTO main.t1 VALUES('a e c');
  177. INSERT INTO temp.t1 VALUES('1 2 3');
  178. INSERT INTO temp.t1 VALUES('4 5 6');
  179. INSERT INTO temp.t1 VALUES('1 5 3');
  180. INSERT INTO aux.t1 VALUES('x y z');
  181. INSERT INTO aux.t1 VALUES('m n o');
  182. INSERT INTO aux.t1 VALUES('x n z');
  183. }
  184. do_execsql_test 5.1 {
  185. CREATE VIRTUAL TABLE temp.vm USING fts5vocab(main, t1, row);
  186. CREATE VIRTUAL TABLE temp.vt1 USING fts5vocab(t1, row);
  187. CREATE VIRTUAL TABLE temp.vt2 USING fts5vocab(temp, t1, row);
  188. CREATE VIRTUAL TABLE temp.va USING fts5vocab(aux, t1, row);
  189. }
  190. do_execsql_test 5.2 { SELECT * FROM vm } [star_from_row {
  191. a 2 2 b 1 1 c 2 2 d 1 1 e 2 2 f 1 1
  192. }]
  193. do_execsql_test 5.3 { SELECT * FROM vt1 } [star_from_row {
  194. 1 2 2 2 1 1 3 2 2 4 1 1 5 2 2 6 1 1
  195. }]
  196. do_execsql_test 5.4 { SELECT * FROM vt2 } [star_from_row {
  197. 1 2 2 2 1 1 3 2 2 4 1 1 5 2 2 6 1 1
  198. }]
  199. do_execsql_test 5.5 { SELECT * FROM va } [star_from_row {
  200. m 1 1 n 2 2 o 1 1 x 2 2 y 1 1 z 2 2
  201. }]
  202. #-------------------------------------------------------------------------
  203. #
  204. do_execsql_test 6.0 {
  205. CREATE TABLE iii(iii);
  206. CREATE TABLE jjj(x);
  207. }
  208. do_catchsql_test 6.1 {
  209. CREATE VIRTUAL TABLE vocab1 USING fts5vocab(iii, row);
  210. SELECT * FROM vocab1;
  211. } {1 {no such fts5 table: main.iii}}
  212. do_catchsql_test 6.2 {
  213. CREATE VIRTUAL TABLE vocab2 USING fts5vocab(jjj, row);
  214. SELECT * FROM vocab2;
  215. } {1 {no such fts5 table: main.jjj}}
  216. do_catchsql_test 6.2 {
  217. CREATE VIRTUAL TABLE vocab3 USING fts5vocab(lll, row);
  218. SELECT * FROM vocab3;
  219. } {1 {no such fts5 table: main.lll}}
  220. #-------------------------------------------------------------------------
  221. # Test single term queries on fts5vocab tables (i.e. those with term=?
  222. # constraints in the WHERE clause).
  223. #
  224. do_execsql_test 7.0 {
  225. CREATE VIRTUAL TABLE tx USING fts5(one, two, detail=%DETAIL%);
  226. INSERT INTO tx VALUES('g a ggg g a b eee', 'cc d aa ff g ee');
  227. INSERT INTO tx VALUES('dd fff i a i jjj', 'f fff hh jj e f');
  228. INSERT INTO tx VALUES('ggg a f f fff dd aa', 'd ggg f f j gg ddd');
  229. INSERT INTO tx VALUES('e bb h jjj ii gg', 'e aa e f c fff');
  230. INSERT INTO tx VALUES('j ff aa a h', 'h a j bbb bb');
  231. INSERT INTO tx VALUES('cc i ff c d f', 'dd ii fff f c cc d');
  232. INSERT INTO tx VALUES('jjj g i bb cc eee', 'hhh iii aaa b bbb aaa');
  233. INSERT INTO tx VALUES('hhh hhh hhh bb fff f', 'fff gg aa ii h a');
  234. INSERT INTO tx VALUES('b c cc aaa iii ggg f', 'iii ff ee a ff c cc');
  235. INSERT INTO tx VALUES('hhh b hhh aaa j i i', 'dd ee ee aa bbb iii');
  236. INSERT INTO tx VALUES('hh dd h b g ff i', 'ccc bb cc ccc f a d');
  237. INSERT INTO tx VALUES('g d b ggg jj', 'fff jj ff jj g gg ee');
  238. INSERT INTO tx VALUES('g ee ggg ggg cc bb eee', 'aa j jjj bbb dd eee ff');
  239. INSERT INTO tx VALUES('c jjj hh ddd dd h', 'e aaa h jjj gg');
  240. CREATE VIRTUAL TABLE txr USING fts5vocab(tx, row);
  241. CREATE VIRTUAL TABLE txc USING fts5vocab(tx, col);
  242. }
  243. proc cont {L elem} {
  244. set n 0
  245. foreach e $L { if {$elem==$e} {incr n} }
  246. set n
  247. }
  248. db func cont cont
  249. foreach {term} {
  250. a aa aaa
  251. b bb bbb
  252. c cc ccc
  253. d dd ddd
  254. e ee eee
  255. f ff fff
  256. g gg ggg
  257. h hh hhh
  258. i ii iii
  259. j jj jjj
  260. } {
  261. set resr [db eval {
  262. SELECT $term,
  263. sum(cont(one || ' ' || two, $term) > 0),
  264. sum(cont(one || ' ' || two, $term))
  265. FROM tx
  266. }]
  267. if {[lindex $resr 1]==0} {set resr [list]}
  268. set r1 [db eval {
  269. SELECT $term, 'one', sum(cont(one, $term)>0), sum(cont(one, $term)) FROM tx
  270. }]
  271. if {[lindex $r1 2]==0} {set r1 [list]}
  272. set r2 [db eval {
  273. SELECT $term, 'two', sum(cont(two, $term)>0), sum(cont(two, $term)) FROM tx
  274. }]
  275. if {[lindex $r2 2]==0} {set r2 [list]}
  276. set resc [concat $r1 $r2]
  277. set resc [star_from_col $resc]
  278. set resr [star_from_row $resr]
  279. if {[detail_is_none]} { set resc [row_to_col $resr] }
  280. do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc
  281. do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr
  282. }
  283. do_execsql_test 7.1 {
  284. CREATE TABLE txr_c AS SELECT * FROM txr;
  285. CREATE TABLE txc_c AS SELECT * FROM txc;
  286. }
  287. # Test range queries on the fts5vocab tables created above.
  288. #
  289. foreach {tn a b} {
  290. 1 a jjj
  291. 2 bb j
  292. 3 ccc ddd
  293. 4 dd xyz
  294. 5 xzy dd
  295. 6 h hh
  296. } {
  297. do_execsql_test 7.2.$tn.1 {
  298. SELECT * FROM txr WHERE term>=$a
  299. } [db eval {SELECT * FROM txr_c WHERE term>=$a}]
  300. do_execsql_test 7.2.$tn.2 {
  301. SELECT * FROM txr WHERE term<=$b
  302. } [db eval {SELECT * FROM txr_c WHERE term <=$b}]
  303. do_execsql_test 7.2.$tn.3 {
  304. SELECT * FROM txr WHERE term>=$a AND term<=$b
  305. } [db eval {SELECT * FROM txr_c WHERE term>=$a AND term <=$b}]
  306. do_execsql_test 7.2.$tn.4 {
  307. SELECT * FROM txc WHERE term>=$a
  308. } [db eval {SELECT * FROM txc_c WHERE term>=$a}]
  309. do_execsql_test 7.2.$tn.5 {
  310. SELECT * FROM txc WHERE term<=$b
  311. } [db eval {SELECT * FROM txc_c WHERE term <=$b}]
  312. do_execsql_test 7.2.$tn.6 {
  313. SELECT * FROM txc WHERE term>=$a AND term<=$b
  314. } [db eval {SELECT * FROM txc_c WHERE term>=$a AND term <=$b}]
  315. do_execsql_test 7.2.$tn.7 {
  316. SELECT * FROM txr WHERE term>$a
  317. } [db eval {SELECT * FROM txr_c WHERE term>$a}]
  318. do_execsql_test 7.2.$tn.8 {
  319. SELECT * FROM txr WHERE term<$b
  320. } [db eval {SELECT * FROM txr_c WHERE term<$b}]
  321. do_execsql_test 7.2.$tn.9 {
  322. SELECT * FROM txr WHERE term>$a AND term<$b
  323. } [db eval {SELECT * FROM txr_c WHERE term>$a AND term <$b}]
  324. do_execsql_test 7.2.$tn.10 {
  325. SELECT * FROM txc WHERE term>$a
  326. } [db eval {SELECT * FROM txc_c WHERE term>$a}]
  327. do_execsql_test 7.2.$tn.11 {
  328. SELECT * FROM txc WHERE term<$b
  329. } [db eval {SELECT * FROM txc_c WHERE term<$b}]
  330. do_execsql_test 7.2.$tn.12 {
  331. SELECT * FROM txc WHERE term>$a AND term<$b
  332. } [db eval {SELECT * FROM txc_c WHERE term>$a AND term <$b}]
  333. }
  334. do_execsql_test 7.3.1 {
  335. SELECT count(*) FROM txr, txr_c WHERE txr.term = txr_c.term;
  336. } {30}
  337. if {![detail_is_none]} {
  338. do_execsql_test 7.3.2 {
  339. SELECT count(*) FROM txc, txc_c
  340. WHERE txc.term = txc_c.term AND txc.col=txc_c.col;
  341. } {57}
  342. }
  343. }
  344. #-------------------------------------------------------------------------
  345. # Test the fts5vocab tables response to a specific types of corruption:
  346. # where the fts5 index contains hits for columns that do not exist.
  347. #
  348. do_execsql_test 8.0 {
  349. CREATE VIRTUAL TABLE x1 USING fts5(a, b, c, detail=%DETAIL%);
  350. INSERT INTO x1 VALUES('a b c', 'd e f', 'g h i');
  351. INSERT INTO x1 VALUES('g h i', 'a b c', 'd e f');
  352. INSERT INTO x1 VALUES('d e f', 'g h i', 'a b c');
  353. CREATE VIRTUAL TABLE x1_r USING fts5vocab(x1, row);
  354. CREATE VIRTUAL TABLE x1_c USING fts5vocab(x1, col);
  355. }
  356. set resr [star_from_row {a 3 3 b 3 3 c 3 3 d 3 3 e 3 3 f 3 3 g 3 3 h 3 3 i 3 3}]
  357. set resc [star_from_col {
  358. a a 1 1 a b 1 1 a c 1 1 b a 1 1
  359. b b 1 1 b c 1 1 c a 1 1 c b 1 1
  360. c c 1 1 d a 1 1 d b 1 1 d c 1 1
  361. e a 1 1 e b 1 1 e c 1 1 f a 1 1
  362. f b 1 1 f c 1 1 g a 1 1 g b 1 1
  363. g c 1 1 h a 1 1 h b 1 1 h c 1 1
  364. i a 1 1 i b 1 1 i c 1 1
  365. }]
  366. if {[detail_is_none]} { set resc [row_to_col $resr] }
  367. do_execsql_test 8.1.1 { SELECT * FROM x1_r; } $resr
  368. do_execsql_test 8.1.2 { SELECT * FROM x1_c } $resc
  369. sqlite3_db_config db DEFENSIVE 0
  370. do_execsql_test 8.2 {
  371. PRAGMA writable_schema = 1;
  372. UPDATE sqlite_master
  373. SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(a, detail=%DETAIL%)'
  374. WHERE name = 'x1';
  375. }
  376. db close
  377. sqlite3 db test.db
  378. sqlite3_fts5_may_be_corrupt 1
  379. do_execsql_test 8.2.1 { SELECT * FROM x1_r } $resr
  380. if {[detail_is_none]} {
  381. do_execsql_test 8.2.2 { SELECT * FROM x1_c } $resc
  382. } else {
  383. do_catchsql_test 8.2.2 {
  384. SELECT * FROM x1_c
  385. } {1 {database disk image is malformed}}
  386. }
  387. sqlite3_fts5_may_be_corrupt 0
  388. }
  389. #-------------------------------------------------------------------------
  390. # Test that both "ORDER BY term" and "ORDER BY term DESC" work.
  391. #
  392. reset_db
  393. do_execsql_test 9.1 {
  394. CREATE VIRTUAL TABLE x1 USING fts5(x);
  395. INSERT INTO x1 VALUES('def ABC ghi');
  396. INSERT INTO x1 VALUES('DEF abc GHI');
  397. }
  398. do_execsql_test 9.2 {
  399. CREATE VIRTUAL TABLE rrr USING fts5vocab(x1, row);
  400. SELECT * FROM rrr
  401. } {
  402. abc 2 2 def 2 2 ghi 2 2
  403. }
  404. do_execsql_test 9.3 {
  405. SELECT * FROM rrr ORDER BY term ASC
  406. } {
  407. abc 2 2 def 2 2 ghi 2 2
  408. }
  409. do_execsql_test 9.4 {
  410. SELECT * FROM rrr ORDER BY term DESC
  411. } {
  412. ghi 2 2 def 2 2 abc 2 2
  413. }
  414. do_test 9.5 {
  415. set e2 [db eval { EXPLAIN SELECT * FROM rrr ORDER BY term ASC }]
  416. expr [lsearch $e2 SorterSort]<0
  417. } 1
  418. do_test 9.6 {
  419. set e2 [db eval { EXPLAIN SELECT * FROM rrr ORDER BY term DESC }]
  420. expr [lsearch $e2 SorterSort]<0
  421. } 0
  422. #-------------------------------------------------------------------------
  423. do_execsql_test 10.0 {
  424. CREATE VIRTUAL TABLE ft USING fts5(a, b, c);
  425. CREATE VIRTUAL TABLE t2 USING fts5vocab('ft','row');
  426. CREATE VIRTUAL TABLE t3 USING fts5vocab('ft','row');
  427. }
  428. do_execsql_test 10.1 {
  429. BEGIN;
  430. INSERT INTO ft(b) VALUES('x y');
  431. }
  432. do_execsql_test 10.2 {
  433. SELECT t2.term FROM t2;
  434. } {x y}
  435. do_execsql_test 10.3 {
  436. SELECT t2.term, t3.term FROM t2, t3;
  437. } {x x x y y x y y}
  438. do_execsql_test 10.4 {
  439. COMMIT;
  440. }
  441. do_execsql_test 10.5 {
  442. BEGIN;
  443. INSERT INTO ft(a) VALUES('1 2 3');
  444. INSERT INTO ft(a) VALUES('4 5 6');
  445. INSERT INTO ft(a) VALUES('1 2 3');
  446. INSERT INTO ft(a) VALUES('4 5 6');
  447. INSERT INTO ft(a) VALUES('1 2 3');
  448. INSERT INTO ft(a) VALUES('4 5 6');
  449. }
  450. unset -nocomplain x res
  451. do_test 10.6 {
  452. set res [list]
  453. db eval { SELECT rowid FROM ft('4') } x {
  454. db eval { SELECT * FROM t2 }
  455. lappend res $x(rowid)
  456. }
  457. db eval COMMIT
  458. set res
  459. } {3 5 7}
  460. do_execsql_test 10.6.1 {
  461. SELECT * FROM t2 WHERE term<NULL;
  462. }
  463. do_execsql_test 10.6.2 {
  464. SELECT * FROM t2 WHERE term>NULL;
  465. }
  466. do_execsql_test 10.6.3 {
  467. SELECT * FROM t2 WHERE term=NULL;
  468. }
  469. do_execsql_test 10.7.1 {
  470. SELECT * FROM t2 WHERE term<?;
  471. }
  472. do_execsql_test 10.7.2 {
  473. SELECT * FROM t2 WHERE term>?;
  474. }
  475. do_execsql_test 10.7.3 {
  476. SELECT * FROM t2 WHERE term=?;
  477. }
  478. # 2020-02-16 Detect recursively define fts5vocab() tables.
  479. # Error found by dbsqlfuzz.
  480. #
  481. reset_db
  482. do_execsql_test 11.100 {
  483. CREATE VIRTUAL TABLE t3 USING fts5vocab(rowid , 'col');
  484. CREATE VIRTUAL TABLE rowid USING fts5vocab(rowid , 'instance');
  485. } {}
  486. do_catchsql_test 11.110 {
  487. SELECT rowid+1,rowid, * FROM t3 WHERE null>rowid ;
  488. } {1 {SQL logic error}}
  489. finish_test