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 #***********************************************************************
13 source [file join [file dirname [info script]] fts5_common.tcl]
14 set testprefix fts5corrupt7
16 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
21 sqlite3_fts5_may_be_corrupt 1
24 CREATE VIRTUAL TABLE t1 USING fts5(x);
25 INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
28 set doc [string repeat "a b " 30]
32 INSERT INTO t1(rowid, x) VALUES(123, $doc);
33 INSERT INTO t1(rowid, x) VALUES(124, $doc);
38 SELECT id, fts5_decode(id, block), quote(block) FROM t1_data
41 set rows [db eval { SELECT rowid FROM t1_data }]
49 set out [lreplace $in 0 1 255 255]
52 db func edit_block edit_block
54 do_execsql_test 1.2.$r.1 {
55 UPDATE t1_data SET block = edit_block(block) WHERE rowid=$r;
58 do_execsql_test 1.2.$r.2 {
59 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
63 catchsql { DELETE FROM t1 WHERE rowid=123; }
64 catchsql { DELETE FROM t1 WHERE rowid=124; }
77 set out [lreplace $in end end 127]
80 db func edit_block edit_block
82 do_execsql_test 1.2.$r.1 {
83 UPDATE t1_data SET block = edit_block(block) WHERE rowid=$r;
86 do_execsql_test 1.2.$r.2 {
87 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
91 catchsql { DELETE FROM t1 WHERE rowid=124; }
92 catchsql { DELETE FROM t1 WHERE rowid=123; }
99 #-------------------------------------------------------------------------
101 do_execsql_test 2.0 {
102 CREATE VIRTUAL TABLE t1 USING fts5(x);
104 INSERT INTO t1 VALUES('abc');
105 INSERT INTO t1 VALUES('b d d d');
107 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
111 SELECT id, quote(block) FROM t1_data
114 do_execsql_test 2.1 {
115 SELECT quote(block) FROM t1_data WHERE id > 10;
116 } {X'0000001A04306162630102020101620202020101640206030303040806'}
118 do_execsql_test 2.2 {
120 block=X'0000001A04306162630102025501620202020101640206030303040806'
124 do_catchsql_test 2.3 {
125 DELETE FROM t1 WHERE rowid = 1
126 } {1 {database disk image is malformed}}