fts5matchinfo.test 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. # 2015 August 05
  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. source [file join [file dirname [info script]] fts5_common.tcl]
  13. set testprefix fts5matchinfo
  14. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  15. ifcapable !fts5 { finish_test ; return }
  16. foreach_detail_mode $testprefix {
  17. proc mit {blob} {
  18. set scan(littleEndian) i*
  19. set scan(bigEndian) I*
  20. binary scan $blob $scan($::tcl_platform(byteOrder)) r
  21. return $r
  22. }
  23. db func mit mit
  24. sqlite3_fts5_register_matchinfo db
  25. do_execsql_test 1.0 {
  26. CREATE VIRTUAL TABLE t1 USING fts5(content, detail=%DETAIL%);
  27. }
  28. do_execsql_test 1.1 {
  29. INSERT INTO t1(content) VALUES('I wandered lonely as a cloud');
  30. INSERT INTO t1(content) VALUES('That floats on high o''er vales and hills,');
  31. INSERT INTO t1(content) VALUES('When all at once I saw a crowd,');
  32. INSERT INTO t1(content) VALUES('A host, of golden daffodils,');
  33. SELECT mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH 'I';
  34. } {{1 1 1 2 2} {1 1 1 2 2}}
  35. # Now create an FTS4 table that does not specify matchinfo=fts3.
  36. #
  37. do_execsql_test 1.2 {
  38. CREATE VIRTUAL TABLE t2 USING fts5(content, detail=%DETAIL%);
  39. INSERT INTO t2 SELECT * FROM t1;
  40. SELECT mit(matchinfo(t2)) FROM t2 WHERE t2 MATCH 'I';
  41. } {{1 1 1 2 2} {1 1 1 2 2}}
  42. #--------------------------------------------------------------------------
  43. # Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function.
  44. #
  45. # The first argument - $tn - is a test identifier. This may be either a
  46. # full identifier (i.e. "fts3matchinfo-1.1") or, if global var $testprefix
  47. # is set, just the numeric component (i.e. "1.1").
  48. #
  49. # The second argument is the name of an FTSX table. The third is the
  50. # full text of a WHERE/MATCH expression to query the table for
  51. # (i.e. "t1 MATCH 'abc'"). The final argument - $results - should be a
  52. # key-value list (serialized array) with matchinfo() format specifiers
  53. # as keys, and the results of executing the statement:
  54. #
  55. # SELECT matchinfo($tbl, '$key') FROM $tbl WHERE $expr
  56. #
  57. # For example:
  58. #
  59. # CREATE VIRTUAL TABLE t1 USING fts4;
  60. # INSERT INTO t1 VALUES('abc');
  61. # INSERT INTO t1 VALUES('def');
  62. # INSERT INTO t1 VALUES('abc abc');
  63. #
  64. # do_matchinfo_test 1.1 t1 "t1 MATCH 'abc'" {
  65. # n {3 3}
  66. # p {1 1}
  67. # c {1 1}
  68. # x {{1 3 2} {2 3 2}}
  69. # }
  70. #
  71. # If the $results list contains keys mapped to "-" instead of a matchinfo()
  72. # result, then this command computes the expected results based on other
  73. # mappings to test the matchinfo() function. For example, the command above
  74. # could be changed to:
  75. #
  76. # do_matchinfo_test 1.1 t1 "t1 MATCH 'abc'" {
  77. # n {3 3} p {1 1} c {1 1} x {{1 3 2} {2 3 2}}
  78. # pcx -
  79. # }
  80. #
  81. # And this command would compute the expected results for matchinfo(t1, 'pcx')
  82. # based on the results of matchinfo(t1, 'p'), matchinfo(t1, 'c') and
  83. # matchinfo(t1, 'x') in order to test 'pcx'.
  84. #
  85. proc do_matchinfo_test {tn tbl expr results} {
  86. foreach {fmt res} $results {
  87. if {$res == "-"} continue
  88. set resarray($fmt) $res
  89. }
  90. set nRow 0
  91. foreach {fmt res} [array get resarray] {
  92. if {[llength $res]>$nRow} { set nRow [llength $res] }
  93. }
  94. # Construct expected results for any formats for which the caller
  95. # supplied result is "-".
  96. #
  97. foreach {fmt res} $results {
  98. if {$res == "-"} {
  99. set res [list]
  100. for {set iRow 0} {$iRow<$nRow} {incr iRow} {
  101. set rowres [list]
  102. foreach c [split $fmt ""] {
  103. set rowres [concat $rowres [lindex $resarray($c) $iRow]]
  104. }
  105. lappend res $rowres
  106. }
  107. set resarray($fmt) $res
  108. }
  109. }
  110. # Test each matchinfo() request individually.
  111. #
  112. foreach {fmt res} [array get resarray] {
  113. set sql "SELECT mit(matchinfo($tbl, '$fmt')) FROM $tbl WHERE $expr"
  114. do_execsql_test $tn.$fmt $sql [normalize2 $res]
  115. }
  116. # Test them all executed together (multiple invocations of matchinfo()).
  117. #
  118. set exprlist [list]
  119. foreach {format res} [array get resarray] {
  120. lappend exprlist "mit(matchinfo($tbl, '$format'))"
  121. }
  122. set allres [list]
  123. for {set iRow 0} {$iRow<$nRow} {incr iRow} {
  124. foreach {format res} [array get resarray] {
  125. lappend allres [lindex $res $iRow]
  126. }
  127. }
  128. set sql "SELECT [join $exprlist ,] FROM $tbl WHERE $expr"
  129. do_execsql_test $tn.multi $sql [normalize2 $allres]
  130. }
  131. proc normalize2 {list_of_lists} {
  132. set res [list]
  133. foreach elem $list_of_lists {
  134. lappend res [list {*}$elem]
  135. }
  136. return $res
  137. }
  138. # Similar to [do_matchinfo_test], except that this is a no-op if the FTS5
  139. # mode is not detail=full.
  140. #
  141. proc do_matchinfo_p_test {tn tbl expr results} {
  142. if {[detail_is_full]} {
  143. uplevel [list do_matchinfo_test $tn $tbl $expr $results]
  144. }
  145. }
  146. do_execsql_test 4.1.0 {
  147. CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%);
  148. INSERT INTO t4 VALUES('a b c d e', 'f g h i j');
  149. INSERT INTO t4 VALUES('f g h i j', 'a b c d e');
  150. }
  151. do_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {
  152. s {{3 0} {0 3}}
  153. }
  154. do_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {
  155. p {3 3}
  156. x {
  157. {1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1}
  158. {0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1}
  159. }
  160. }
  161. do_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {
  162. p {3 3}
  163. c {2 2}
  164. x {
  165. {1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1}
  166. {0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1}
  167. }
  168. n {2 2}
  169. l {{5 5} {5 5}}
  170. a {{5 5} {5 5}}
  171. s {{3 0} {0 3}}
  172. xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -
  173. xpxsscplax -
  174. }
  175. do_matchinfo_p_test 4.1.2 t4 {t4 MATCH '"g h i"'} {
  176. p {1 1}
  177. c {2 2}
  178. x {
  179. {0 1 1 1 1 1}
  180. {1 1 1 0 1 1}
  181. }
  182. n {2 2}
  183. l {{5 5} {5 5}}
  184. a {{5 5} {5 5}}
  185. s {{0 1} {1 0}}
  186. xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -
  187. sxsxs -
  188. }
  189. do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} }
  190. do_matchinfo_p_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} }
  191. do_matchinfo_p_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} }
  192. do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} }
  193. do_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} {
  194. x {
  195. {0 1 1 1 1 1 0 0 0 0 0 0}
  196. {1 1 1 0 1 1 0 0 0 0 0 0}
  197. }
  198. }
  199. do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f NOT abcd'} {
  200. x {
  201. {0 1 1 1 1 1 0 0 0 0 0 0}
  202. {1 1 1 0 1 1 0 0 0 0 0 0}
  203. }
  204. }
  205. do_execsql_test 4.2.0 {
  206. CREATE VIRTUAL TABLE t5 USING fts5(content, detail=%DETAIL%);
  207. INSERT INTO t5 VALUES('a a a a a');
  208. INSERT INTO t5 VALUES('a b a b a');
  209. INSERT INTO t5 VALUES('c b c b c');
  210. INSERT INTO t5 VALUES('x x x x x');
  211. }
  212. do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'} {
  213. x {{5 8 2 5 8 2} {3 8 2 3 8 2}}
  214. s {2 1}
  215. }
  216. do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'} { s {2} }
  217. do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'} { s {3} }
  218. do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
  219. do_matchinfo_p_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
  220. do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1} }
  221. do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')";
  222. # It used to be that the second 'a' token would be deferred. That doesn't
  223. # work any longer.
  224. if 0 {
  225. do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} {
  226. x {{5 8 2 5 5 5} {3 8 2 3 5 5}}
  227. s {2 1}
  228. }
  229. }
  230. do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} }
  231. do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'} { s {3} }
  232. do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
  233. do_matchinfo_p_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
  234. do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} }
  235. do_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') }
  236. do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
  237. do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'} { s {2 1} }
  238. do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
  239. do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'} { s {3} }
  240. do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
  241. do_matchinfo_p_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
  242. do_execsql_test 4.5.0 {
  243. CREATE VIRTUAL TABLE t6 USING fts5(a, b, c, detail=%DETAIL%);
  244. INSERT INTO t6 VALUES('a', 'b', 'c');
  245. }
  246. do_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'} { s {{1 1 1}} }
  247. #-------------------------------------------------------------------------
  248. # Test the outcome of matchinfo() when used within a query that does not
  249. # use the full-text index (i.e. lookup by rowid or full-table scan).
  250. #
  251. do_execsql_test 7.1 {
  252. CREATE VIRTUAL TABLE t10 USING fts5(content, detail=%DETAIL%);
  253. INSERT INTO t10 VALUES('first record');
  254. INSERT INTO t10 VALUES('second record');
  255. }
  256. do_execsql_test 7.2 {
  257. SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10;
  258. } {blob 8 blob 8}
  259. do_execsql_test 7.3 {
  260. SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10 WHERE rowid=1;
  261. } {blob 8}
  262. do_execsql_test 7.4 {
  263. SELECT typeof(matchinfo(t10)), length(matchinfo(t10))
  264. FROM t10 WHERE t10 MATCH 'record'
  265. } {blob 20 blob 20}
  266. #-------------------------------------------------------------------------
  267. # Test a special case - matchinfo('nxa') with many zero length documents.
  268. # Special because "x" internally uses a statement used by both "n" and "a".
  269. # This was causing a problem at one point in the obscure case where the
  270. # total number of bytes of data stored in an fts3 table was greater than
  271. # the number of rows. i.e. when the following query returns true:
  272. #
  273. # SELECT sum(length(content)) < count(*) FROM fts4table;
  274. #
  275. do_execsql_test 8.1 {
  276. CREATE VIRTUAL TABLE t11 USING fts5(content, detail=%DETAIL%);
  277. INSERT INTO t11(t11, rank) VALUES('pgsz', 32);
  278. INSERT INTO t11 VALUES('quitealongstringoftext');
  279. INSERT INTO t11 VALUES('anotherquitealongstringoftext');
  280. INSERT INTO t11 VALUES('athirdlongstringoftext');
  281. INSERT INTO t11 VALUES('andonemoreforgoodluck');
  282. }
  283. do_test 8.2 {
  284. for {set i 0} {$i < 200} {incr i} {
  285. execsql { INSERT INTO t11 VALUES('') }
  286. }
  287. execsql { INSERT INTO t11(t11) VALUES('optimize') }
  288. } {}
  289. do_execsql_test 8.3 {
  290. SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
  291. } {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}}
  292. #-------------------------------------------------------------------------
  293. if {[detail_is_full]} {
  294. do_execsql_test 9.1 {
  295. CREATE VIRTUAL TABLE t12 USING fts5(content, detail=%DETAIL%);
  296. INSERT INTO t12 VALUES('a b c d');
  297. SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
  298. } {{0 1 1 0 1 1 1 1 1}}
  299. do_execsql_test 9.2 {
  300. INSERT INTO t12 VALUES('a d c d');
  301. SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
  302. } {
  303. {0 2 2 0 3 2 1 2 2} {1 2 2 1 3 2 1 2 2}
  304. }
  305. do_execsql_test 9.3 {
  306. INSERT INTO t12 VALUES('a d d a');
  307. SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
  308. } {
  309. {0 4 3 0 5 3 1 4 3} {1 4 3 1 5 3 1 4 3} {2 4 3 2 5 3 2 4 3}
  310. }
  311. }
  312. #---------------------------------------------------------------------------
  313. # Test for a memory leak
  314. #
  315. do_execsql_test 10.1 {
  316. DROP TABLE t10;
  317. CREATE VIRTUAL TABLE t10 USING fts5(idx, value, detail=%DETAIL%);
  318. INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');
  319. SELECT t10.rowid, t10.*
  320. FROM t10
  321. JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x
  322. WHERE t10 MATCH x.idx
  323. AND matchinfo(t10) not null
  324. GROUP BY t10.rowid
  325. ORDER BY 1;
  326. } {1 1 one 2 2 two 3 3 three}
  327. #---------------------------------------------------------------------------
  328. # Test the 'y' matchinfo flag
  329. #
  330. reset_db
  331. sqlite3_fts5_register_matchinfo db
  332. do_execsql_test 11.0 {
  333. CREATE VIRTUAL TABLE tt USING fts5(x, y, detail=%DETAIL%);
  334. INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1
  335. INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2
  336. INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3
  337. INSERT INTO tt VALUES('a c f f g d', 'd b f d e g'); -- 4
  338. INSERT INTO tt VALUES('g a c f c f', 'd g g b c c'); -- 5
  339. INSERT INTO tt VALUES('g a c e b b', 'd b f b g g'); -- 6
  340. INSERT INTO tt VALUES('f d a a f c', 'e e a d c f'); -- 7
  341. INSERT INTO tt VALUES('a c b b g f', 'a b a e d f'); -- 8
  342. INSERT INTO tt VALUES('b a f e c c', 'f d b b a b'); -- 9
  343. INSERT INTO tt VALUES('f d c e a c', 'f a f a a f'); -- 10
  344. }
  345. db func mit mit
  346. foreach {tn expr res} {
  347. 1 "a" {
  348. 1 {1 2} 2 {1 0} 3 {0 1} 4 {1 0} 5 {1 0}
  349. 6 {1 0} 7 {2 1} 8 {1 2} 9 {1 1} 10 {1 3}
  350. }
  351. 2 "b" {
  352. 1 {0 1} 2 {1 0} 3 {1 2} 4 {0 1} 5 {0 1}
  353. 6 {2 2} 8 {2 1} 9 {1 3}
  354. }
  355. 3 "y:a" {
  356. 1 {0 2} 3 {0 1}
  357. 7 {0 1} 8 {0 2} 9 {0 1} 10 {0 3}
  358. }
  359. 4 "x:a" {
  360. 1 {1 0} 2 {1 0} 4 {1 0} 5 {1 0}
  361. 6 {1 0} 7 {2 0} 8 {1 0} 9 {1 0} 10 {1 0}
  362. }
  363. 5 "a OR b" {
  364. 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
  365. 6 {1 0 2 2} 7 {2 1 0 0} 8 {1 2 2 1} 9 {1 1 1 3} 10 {1 3 0 0}
  366. }
  367. 6 "a AND b" {
  368. 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
  369. 6 {1 0 2 2} 8 {1 2 2 1} 9 {1 1 1 3}
  370. }
  371. 7 "a OR (a AND b)" {
  372. 1 {1 2 1 2 0 1} 2 {1 0 1 0 1 0} 3 {0 1 0 1 1 2} 4 {1 0 1 0 0 1}
  373. 5 {1 0 1 0 0 1} 6 {1 0 1 0 2 2} 7 {2 1 0 0 0 0} 8 {1 2 1 2 2 1}
  374. 9 {1 1 1 1 1 3} 10 {1 3 0 0 0 0}
  375. }
  376. } {
  377. if {[string match *:* $expr] && [detail_is_none]} continue
  378. do_execsql_test 11.1.$tn.1 {
  379. SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr
  380. } $res
  381. set r2 [list]
  382. foreach {rowid L} $res {
  383. lappend r2 $rowid
  384. set M [list]
  385. foreach {a b} $L {
  386. lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)]
  387. }
  388. lappend r2 $M
  389. }
  390. do_execsql_test 11.1.$tn.2 {
  391. SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
  392. } $r2
  393. do_execsql_test 11.1.$tn.2 {
  394. SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
  395. } $r2
  396. }
  397. #---------------------------------------------------------------------------
  398. # Test the 'b' matchinfo flag
  399. #
  400. reset_db
  401. sqlite3_fts5_register_matchinfo db
  402. db func mit mit
  403. do_test 12.0 {
  404. set cols [list]
  405. for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" }
  406. execsql "CREATE VIRTUAL TABLE tt USING fts5([join $cols ,], detail=%DETAIL%)"
  407. } {}
  408. do_execsql_test 12.1 {
  409. INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc');
  410. SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';
  411. } [list [list [expr 1<<4] [expr 1<<(45-32)]]]
  412. } ;# foreach_detail_mode
  413. #-------------------------------------------------------------------------
  414. # Test that a bad fts5() return is detected
  415. #
  416. reset_db
  417. proc xyz {} {}
  418. db func fts5 -argcount 1 xyz
  419. do_test 13.1 {
  420. list [catch { sqlite3_fts5_register_matchinfo db } msg] $msg
  421. } {1 SQLITE_ERROR}
  422. #-------------------------------------------------------------------------
  423. # Test that an invalid matchinfo() flag is detected
  424. #
  425. reset_db
  426. sqlite3_fts5_register_matchinfo db
  427. do_execsql_test 14.1 {
  428. CREATE VIRTUAL TABLE x1 USING fts5(z);
  429. INSERT INTO x1 VALUES('a b c a b c a b c');
  430. } {}
  431. do_catchsql_test 14.2 {
  432. SELECT matchinfo(x1, 'd') FROM x1('a b c');
  433. } {1 {unrecognized matchinfo flag: d}}
  434. #-------------------------------------------------------------------------
  435. # Test using matchinfo() and similar on a non-full-text query
  436. #
  437. do_execsql_test 15.0 {
  438. CREATE VIRTUAL TABLE t1 USING fts5(x, y);
  439. INSERT INTO t1 VALUES('a', 'b');
  440. INSERT INTO t1 VALUES('c', 'd');
  441. }
  442. if {$tcl_platform(byteOrder)=="littleEndian"} {
  443. set res {X'02000000'}
  444. } else {
  445. set res {X'00000002'}
  446. }
  447. do_execsql_test 15.1 {
  448. SELECT quote(matchinfo(t1, 'n')) FROM t1 LIMIT 1;
  449. } $res
  450. do_execsql_test 15.2 {
  451. DELETE FROM t1_content WHERE rowid=1;
  452. SELECT quote(matchinfo(t1, 'n')) FROM t1 LIMIT 1;
  453. } $res
  454. fts5_aux_test_functions db
  455. do_execsql_test 15.3 {
  456. SELECT fts5_test_all(t1) FROM t1 LIMIT 1;
  457. } {
  458. {columnsize {1 1} columntext {c d} columntotalsize {2 2} poslist {} tokenize {c d} rowcount 2}
  459. }
  460. finish_test