UPDATE aa_docsize SET sz = X'44' WHERE rowid = 3;
INSERT INTO aa(aa) VALUES('integrity-check');
} {1 {database disk image is malformed}}
+do_execsql_test 4.2.1 {
+ PRAGMA integrity_check(aa);
+} {{malformed inverted index for FTS5 table main.aa}}
do_catchsql_test 4.3 {
ROLLBACK;
INSERT INTO vt0(vt0) VALUES('integrity-check');
} {0 {}}
+reset_db
+proc slang {in} {return [string map {th d e eh} $in]}
+db function slang -deterministic -innocuous slang
+do_execsql_test 11.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT AS (slang(b)));
+ INSERT INTO t1(b) VALUES('the quick fox jumps over the lazy brown dog');
+ SELECT c FROM t1;
+} {{deh quick fox jumps ovehr deh lazy brown dog}}
+
+do_execsql_test 11.1 {
+ CREATE VIRTUAL TABLE t2 USING fts5(content="t1", c);
+ INSERT INTO t2(t2) VALUES('rebuild');
+ SELECT rowid FROM t2 WHERE t2 MATCH 'deh';
+} {1}
+
+do_execsql_test 11.2 {
+ PRAGMA integrity_check(t2);
+} {ok}
+db close
+sqlite3 db test.db
+
+# FIX ME?
+#
+# FTS5 integrity-check does not care if the content table is unreadable or
+# does not exist. It only looks for internal inconsistencies in the
+# inverted index.
+#
+do_execsql_test 11.3 {
+ PRAGMA integrity_check(t2);
+} {ok}
+do_execsql_test 11.4 {
+ DROP TABLE t1;
+ PRAGMA integrity_check(t2);
+} {ok}
+
finish_test
-C Fix\smutex1.test\sto\stake\sinto\saccount\sthat\sthe\sprng\smutex\sis\snot\s(as\sof\s[c84e4483cb4])\staken\swhen\swriting\sa\sheader\sto\san\sin-memory\sjournal.
-D 2023-10-23T14:24:09.506
+C New\stest\scases\sfor\sPRAGMA\sintegrity_check\sagainst\sFTS4\sand\sFTS5\stables.
+D 2023-10-23T15:23:10.612
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717
F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e
F ext/fts5/test/fts5hash.test dc7bc7e0cdeb42cfce31294ad2f8fcf43192bfd0145bb7f3ecc5465d8c72696f
-F ext/fts5/test/fts5integrity.test 62147a1e85405b986691177e0312be5a64ec9e67b17994e83892d9afa6247600
+F ext/fts5/test/fts5integrity.test 0d249d351163e17e2227aa9850e68193f88a7813d16cc7d51287e554bf915b3d
F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227
F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28
F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad
F test/fts4growth.test 289833c34ad45a5e6e6133b53b6a71647231fb89d36ddcb8d9c87211b6721d7f
F test/fts4growth2.test 13ad4e76451af6e6906c95cdc725d01b00044269
F test/fts4incr.test 4e353a0bd886ea984e56fce9e77724fc923b8d0d
+F test/fts4intck1.test 43774c641fdf6607c6ee90c3db8af065a37434d55d6eaf13bafe515e8b0c5729 w test/fts3intck1.test
F test/fts4langid.test 4be912f42454998e239a2e877600263e0394afbaba03e06cedcc5a08693a345a
F test/fts4lastrowid.test 185835895948d5325c7710649824042373b2203149abe8024a9319d25234dfd7
F test/fts4merge.test 57d093660a5093ae6e9fbd2d17592a88b45bbd66db2703c4b640b28828dbe38b
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P df69abc0823f4dd9c051f8d5993d2f447ee0dadab5cef73d670107b1071db255
-R 611df081e24061644e6f30e57e810029
-U dan
-Z 7831d77f323d5adc3ceef85612180a2c
+P c9e37417fcc41f1e975290bf583113ff8f4144c056e8fcd9fafcb432c1a26b18
+R ba3d69ad06944bd91d6a7d5a800b7cbd
+U drh
+Z 3f6a89abc7bdbc780a8926e481872b03
# Remove this line to create a well-formed Fossil manifest.
-c9e37417fcc41f1e975290bf583113ff8f4144c056e8fcd9fafcb432c1a26b18
\ No newline at end of file
+3950d20c3a4433543546ce4495ae07aab3d6cefb163b1f30813a9776c5b962e8
\ No newline at end of file
--- /dev/null
+# 2023-10-23
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test PRAGMA integrity_check against and FTS3/FTS4 table.
+#
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !fts3 { finish_test ; return }
+
+set ::testprefix fts4intck1
+
+proc slang {in} {
+ return [string map {th d e eh} $in]
+}
+
+db function slang -deterministic -innocuous slang
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT AS (slang(b)));
+ INSERT INTO t1(b) VALUES('the quick fox jumps over the lazy brown dog');
+ SELECT c FROM t1;
+} {{deh quick fox jumps ovehr deh lazy brown dog}}
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t2 USING fts4(content="t1", c);
+ INSERT INTO t2(t2) VALUES('rebuild');
+ SELECT docid FROM t2 WHERE t2 MATCH 'deh';
+} {1}
+
+do_execsql_test 1.2 {
+ PRAGMA integrity_check(t2);
+} {ok}
+
+db close
+sqlite3 db test.db
+do_execsql_test 2.1 {
+ PRAGMA integrity_check(t2);
+} {{unable to validate the inverted index for FTS4 table main.t2: SQL logic error}}
+
+db function slang -deterministic -innocuous slang
+do_execsql_test 2.2 {
+ PRAGMA integrity_check(t2);
+} {ok}
+
+proc slang {in} {return $in}
+do_execsql_test 2.3 {
+ PRAGMA integrity_check(t2);
+} {{malformed inverted index for FTS4 table main.t2}}
+
+
+finish_test