CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
fts4intck1.test76 linesDownload Raw Back to test
1# 2023-10-232#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 13set testdir [file dirname $argv0]14source $testdir/tester.tcl15 16ifcapable !fts3 { finish_test ; return }17 18set ::testprefix fts4intck119 20proc slang {in} {21  return [string map {th d e eh} $in]22}23 24db function slang -deterministic -innocuous slang25do_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 31do_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 37do_execsql_test 1.2 {38  PRAGMA integrity_check(t2);39} {ok}40 41db close42sqlite3 db test.db43do_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 47db function slang -deterministic -innocuous slang48do_execsql_test 2.2 {49  PRAGMA integrity_check(t2);50} {ok}51 52proc slang {in} {return $in}53do_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#60reset_db61do_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}66db close67sqlite3 db test.db -readonly 168 69do_execsql_test 3.1 {70  PRAGMA integrity_check;71} {ok}72 73 74 75finish_test76