fts5origintext4.test 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # 2023 November 22
  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. # Tests focused on phrase queries.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. set testprefix fts5origintext4
  16. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  17. ifcapable !fts5 {
  18. finish_test
  19. return
  20. }
  21. # The tests below verify that a doclist-index is used to limit the number
  22. # of pages loaded into the cache. It does this by querying sqlite3_db_status()
  23. # for the amount of memory used by the pager cache.
  24. #
  25. # memsubsys1 effectively limits the page-cache to 24 pages. Which masks
  26. # the effect tested by the tests in this file. And "mmap" prevents the
  27. # cache from being used, also preventing these tests from working.
  28. #
  29. if {[permutation]=="memsubsys1" || [permutation]=="mmap"} {
  30. finish_test
  31. return
  32. }
  33. sqlite3_fts5_register_origintext db
  34. do_execsql_test 1.0 {
  35. PRAGMA page_size = 4096;
  36. CREATE VIRTUAL TABLE ft USING fts5(
  37. x, tokenize="origintext unicode61", tokendata=1
  38. );
  39. }
  40. do_execsql_test 1.1 {
  41. BEGIN;
  42. INSERT INTO ft SELECT 'the first thing';
  43. WITH s(i) AS (
  44. SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<90000
  45. )
  46. INSERT INTO ft SELECT 'The second thing' FROM s;
  47. INSERT INTO ft SELECT 'the first thing';
  48. COMMIT;
  49. INSERT INTO ft(ft) VALUES('optimize');
  50. }
  51. foreach {tn sql expr} {
  52. 1 { SELECT rowid FROM ft('the') } {$mem > 250000}
  53. 2 { SELECT rowid FROM ft('first') } {$mem < 50000}
  54. 3 { SELECT rowid FROM ft('the first') } {$mem < 50000}
  55. } {
  56. db close
  57. sqlite3 db test.db
  58. sqlite3_fts5_register_origintext db
  59. execsql $sql
  60. do_test 1.2.$tn {
  61. set mem [lindex [sqlite3_db_status db CACHE_USED 0] 1]
  62. expr $expr
  63. } 1
  64. }
  65. proc b {x} { string map [list "\0" "."] $x }
  66. db func b b
  67. # execsql_pp { SELECT segid, b(term), pgno from ft_idx }
  68. finish_test