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 if {![info exists testdir]} {
14 set testdir [file join [file dirname [info script]] .. .. test]
16 source $testdir/tester.tcl
17 set ::testprefix rbucrash2
20 forcedelete test.db-oal rbu.db
25 # Set up a target database and an rbu update database. The target
26 # db is the usual "test.db", the rbu db is "test.db2".
30 CREATE TABLE t1(a, b, c, PRIMARY KEY(a), UNIQUE(b));
31 INSERT INTO t1 VALUES(1, 2, 3);
32 INSERT INTO t1 VALUES(4, 5, 6);
33 INSERT INTO t1 VALUES(7, 8, 9);
35 ATTACH 'test.db2' AS rbu;
36 CREATE TABLE rbu.data_t1(a, b, c, rbu_control);
37 INSERT INTO data_t1 VALUES('one', randomblob(3500), NULL, 0);
38 INSERT INTO data_t1 VALUES('two', randomblob(3500), NULL, 0);
39 INSERT INTO data_t1 VALUES('three', randomblob(3500), NULL, 0);
40 INSERT INTO data_t1 VALUES('four', randomblob(3500), NULL, 0);
41 INSERT INTO data_t1 VALUES('five', randomblob(3500), NULL, 0);
42 INSERT INTO data_t1 VALUES('six', randomblob(3500), NULL, 0);
46 proc do_rbu_crash_test2 {tn script} {
55 for {set iDelay 1} {$bDone==0} {incr iDelay} {
56 forcedelete test.db2 test.db2-journal test.db test.db-oal test.db-wal
60 crashsql -file $f -delay $iDelay -tclbody $script -dflt 1 -opendb {} \
65 if {$res == "1 {child process exited abnormally}"} {
67 } elseif {$res != "0 {}"} {
68 error "unexected catchsql result: $res"
71 sqlite3rbu rbu test.db test.db2
72 while {[rbu step]=="SQLITE_OK"} {}
76 do_execsql_test $tn.delay=$iDelay.f=$f.blksz=$blksz {
77 PRAGMA integrity_check;
84 for {set x 1} {$x < 10} {incr x} {
85 do_rbu_crash_test2 1.$x {
86 sqlite3rbu rbu test.db test.db2
87 while {[rbu step]=="SQLITE_OK"} {
94 for {set x 1} {$x < 2} {incr x} {
95 do_rbu_crash_test2 2.$x {
96 sqlite3rbu rbu test.db test.db2
97 while {[rbu step]=="SQLITE_OK"} {
99 sqlite3rbu rbu test.db test.db2