Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/fts4intck1.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / fts4intck1.test` 75 lines ยท 1842 bytes Raw Blame History 1 # 2023-10-23 2 # 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. 6 # 7 #*********************************************************************** 8 # 9 # Test PRAGMA integrity_check against and FTS3/FTS4 table. 10 # 11 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 16 ifcapable !fts3 { finish_test ; return } 17 18 set ::testprefix fts4intck1 19 20 proc slang {in} { 21 return [string map {th d e eh} $in] 22 } 23 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}} 30 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} 36 37 do_execsql_test 1.2 { 38 PRAGMA integrity_check(t2); 39 } {ok} 40 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}} 46 47 db function slang -deterministic -innocuous slang 48 do_execsql_test 2.2 { 49 PRAGMA integrity_check(t2); 50 } {ok} 51 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}} 56 57 #------------------------------------------------------------------------- 58 # Test that integrity-check works on a read-only database. 59 # 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'); 65 } 66 db close 67 sqlite3 db test.db -readonly 1 68 69 do_execsql_test 3.1 { 70 PRAGMA integrity_check; 71 } {ok} 72 73 74 75 finish_test