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 #***********************************************************************
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
21 return [string map {th d e eh} $in]
24 db function slang -deterministic -innocuous slang
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');
29 } {{deh quick fox jumps ovehr deh lazy brown dog}}
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';
38 PRAGMA integrity_check(t2);
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
49 PRAGMA integrity_check(t2);
52 proc slang {in} {return $in}
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.
62 CREATE VIRTUAL TABLE x1 USING fts4(a, b);
63 INSERT INTO x1 VALUES('one', 'two');
64 INSERT INTO x1 VALUES('three', 'four');
67 sqlite3 db test.db -readonly 1
70 PRAGMA integrity_check;