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 #***********************************************************************
11 # This file tests that rollback journals for databases that use a
12 # page-size other than the default page-size can be rolled back Ok.
14 # $Id: crash6.test,v 1.2 2008/04/14 15:27:19 drh Exp $
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 ifcapable !crashtest {
24 for {set ii 0} {$ii < 10} {incr ii} {
26 forcedelete test.db test.db-journal
27 crashsql -delay 2 -file test.db {
28 PRAGMA auto_vacuum=OFF;
29 PRAGMA page_size=4096;
31 CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
34 CREATE TABLE def AS SELECT 1 AS d, 2 AS e, 3 AS f;
38 integrity_check crash6-1.$ii
41 for {set ii 0} {$ii < 10} {incr ii} {
43 forcedelete test.db test.db-journal
46 PRAGMA auto_vacuum=OFF;
47 PRAGMA page_size=2048;
49 CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;
53 crashsql -delay 1 -file test.db {
54 INSERT INTO abc VALUES(5, 6, 7);
57 integrity_check crash6-2.$ii
61 return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]
64 # Test case for crashing during database sync with page-size values
67 for {set ii 0} {$ii < 30} {incr ii} {
72 set pagesize [expr 1024 << ($ii % 4)]
73 if {$pagesize>$::SQLITE_MAX_PAGE_SIZE} {
74 set pagesize $::SQLITE_MAX_PAGE_SIZE
76 do_test crash6-3.$ii.0 {
77 execsql "pragma page_size = $pagesize"
78 execsql "pragma page_size"
81 do_test crash6-3.$ii.1 {
84 execsql {CREATE TABLE abc(a, b, c)}
85 for {set n 0} {$n < 1000} {incr n} {
86 execsql "INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])"
89 INSERT INTO abc SELECT * FROM abc;
90 INSERT INTO abc SELECT * FROM abc;
91 INSERT INTO abc SELECT * FROM abc;
92 INSERT INTO abc SELECT * FROM abc;
93 INSERT INTO abc SELECT * FROM abc;
96 expr ([file size test.db] / 1024) > 450
102 do_test crash6-3.$ii.2 {
103 crashsql -file test.db "
105 SELECT random() FROM abc LIMIT $ii;
106 INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;
107 DELETE FROM abc WHERE random()%2!=0;
110 } {1 {child process exited abnormally}}
112 do_test crash6-3.$ii.3 {