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 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix corruptI
17 if {[permutation]=="mmap"} {
22 # Do not use a codec for tests in this file, as the database file is
23 # manipulated directly using tcl scripts (using the [hexio_write] command).
26 database_may_be_corrupt
28 # Initialize the database.
31 PRAGMA page_size=1024;
34 CREATE INDEX i1 ON t1(a);
35 INSERT INTO t1 VALUES('abcdefghijklmnop');
40 set offset [hexio_get_int [hexio_read test.db [expr 2*1024 + 8] 2]]
41 set off [expr 2*1024 + $offset + 1]
42 hexio_write test.db $off 7f06
44 catchsql { SELECT * FROM t1 WHERE a = 10 }
49 set offset [hexio_get_int [hexio_read test.db [expr 2*1024 + 8] 2]]
50 set off [expr 2*1024 + $offset + 1]
51 hexio_write test.db $off FFFF7f02
53 catchsql { SELECT * FROM t1 WHERE a = 10 }
54 } {1 {database disk image is malformed}}
59 INSERT INTO r VALUES('ABCDEFGHIJK');
60 CREATE INDEX r1 ON r(x);
62 set pg [db one {SELECT rootpage FROM sqlite_master WHERE name = 'r1'}]
67 set offset [hexio_get_int [hexio_read test.db [expr (5-1)*1024 + 8] 2]]
68 set off [expr (5-1)*1024 + $offset + 1]
69 hexio_write test.db $off FFFF0004
71 catchsql { SELECT * FROM r WHERE x >= 10.0 }
72 } {1 {database disk image is malformed}}
75 catchsql { SELECT * FROM r WHERE x >= 10 }
76 } {1 {database disk image is malformed}}
78 if {[db one {SELECT sqlite_compileoption_used('ENABLE_OVERSIZE_CELL_CHECK')}]} {
79 # The following tests only work if OVERSIZE_CELL_CHECK is disabled
84 PRAGMA page_size = 512;
85 CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
87 SELECT 2, 'abcdefghij'
89 SELECT a+2, b FROM s WHERe a < 40
91 INSERT INTO t1 SELECT * FROM s;
95 hexio_write test.db [expr 512+3] 0054
98 execsql { INSERT INTO t1 VALUES(5, 'klmnopqrst') }
99 execsql { INSERT INTO t1 VALUES(7, 'klmnopqrst') }
104 do_catchsql_test 3.3 {
105 INSERT INTO t1 VALUES(9, 'klmnopqrst');
106 } {1 {database disk image is malformed}}
107 } ;# end-if !defined(ENABLE_OVERSIZE_CELL_CHECK)