interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / fts5 / test / fts5origintext4.test

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