Omit the "noop(X)" test SQL function. Accomplish the same thing using
[sqlite.git] / test / fts4intck1.test
blob6596b2f99726fcf5aa887447d4dc81080221e2aa
1 # 2023-10-23
3 #    May you do good and not evil.
4 #    May you find forgiveness for yourself and forgive others.
5 #    May you share freely, never taking more than you give.
7 #***********************************************************************
8
9 # Test PRAGMA integrity_check against and FTS3/FTS4 table.
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
16 ifcapable !fts3 { finish_test ; return }
18 set ::testprefix fts4intck1
20 proc slang {in} {
21   return [string map {th d e eh} $in]
24 db function slang -deterministic -innocuous slang
25 do_execsql_test 1.0 {
26   CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT AS (slang(b)));
27   INSERT INTO t1(b) VALUES('the quick fox jumps over the lazy brown dog');
28   SELECT c FROM t1;
29 } {{deh quick fox jumps ovehr deh lazy brown dog}}
31 do_execsql_test 1.1 {
32   CREATE VIRTUAL TABLE t2 USING fts4(content="t1", c);
33   INSERT INTO t2(t2) VALUES('rebuild');
34   SELECT docid FROM t2 WHERE t2 MATCH 'deh';
35 } {1}
37 do_execsql_test 1.2 {
38   PRAGMA integrity_check(t2);
39 } {ok}
41 db close
42 sqlite3 db test.db
43 do_execsql_test 2.1 {
44   PRAGMA integrity_check(t2);
45 } {{unable to validate the inverted index for FTS4 table main.t2: SQL logic error}}
47 db function slang -deterministic -innocuous slang
48 do_execsql_test 2.2 {
49   PRAGMA integrity_check(t2);
50 } {ok}
52 proc slang {in} {return $in}
53 do_execsql_test 2.3 {
54   PRAGMA integrity_check(t2);
55 } {{malformed inverted index for FTS4 table main.t2}}
57 #-------------------------------------------------------------------------
58 # Test that integrity-check works on a read-only database.
60 reset_db
61 do_execsql_test 3.0 {
62   CREATE VIRTUAL TABLE x1 USING fts4(a, b);
63   INSERT INTO x1 VALUES('one', 'two');
64   INSERT INTO x1 VALUES('three', 'four');
66 db close
67 sqlite3 db test.db -readonly 1
69 do_execsql_test 3.1 {
70   PRAGMA integrity_check;
71 } {ok}
75 finish_test