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 #***********************************************************************
14 source [file join [file dirname [info script]] fts5_common.tcl]
15 set testprefix fts5corrupt4
17 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
22 sqlite3_fts5_may_be_corrupt 1
25 CREATE VIRTUAL TABLE ttt USING fts5(a, b);
27 VALUES('e ee eee e ee eee e ee eee', 'eee ee e e e ee eee ee ee');
28 INSERT INTO ttt SELECT a||a, b||b FROM ttt;
29 INSERT INTO ttt SELECT a||a, b||b FROM ttt;
34 proc mutate {blob i} {
35 set o [expr {$i % [string length $blob]}]
36 set a [string range $blob 0 $o-1]
37 set b [string range $blob $o+1 end]
38 set v [expr int(rand()*255) - 127]
39 return "$a[binary format c $v]$b"
43 for {set j 1000} {$j <= 5000} {incr j 1000} {
45 for {set i 0} {$i < 1000} {incr i} {
48 UPDATE ttt_data SET block = mutate(block, $i) WHERE id>10;
51 {SELECT snippet(ttt, -1, '.', '..', '[', ']'), * FROM ttt('e*')}
52 {SELECT snippet(ttt, -1, '.', '..', '[', ']'), * FROM ttt('e* NOT ee*')}
54 catch { execsql $sql }
61 sqlite3_fts5_may_be_corrupt 0