3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # This file tests that FTS5 handles corrupt databases (i.e. internal
13 # inconsistencies in the backing tables) correctly. In this case
14 # "correctly" means without crashing.
17 source [file join [file dirname [info script]] fts5_common.tcl]
18 set testprefix fts5corrupt6
20 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
25 sqlite3_fts5_may_be_corrupt 1
26 database_may_be_corrupt
28 proc editblock {block} {
29 binary format Sa* 20000 [string range $block 2 end]
31 db func editblock editblock
34 CREATE VIRTUAL TABLE ft USING fts5(abc, def);
36 SELECT 1 UNION ALL SELECT i+1 FROM a WHERE i<1000
39 'abc abc abc abc abc abc abc abc abc abc',
40 'def def def def def def def def def def'
42 UPDATE ft_data SET block = editblock(block) WHERE id=(
43 SELECT id FROM ft_data ORDER BY id LIMIT 1 OFFSET 5
47 do_catchsql_test 1.1 {
48 SELECT rowid FROM ft('def') ORDER BY rowid DESC LIMIT 1 OFFSET 9999;
49 } {1 {database disk image is malformed}}
52 sqlite3_fts5_may_be_corrupt 0