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]] rbu_common.tcl]
14 if_no_rbu_support { finish_test ; return }
15 set ::testprefix rbucrash2
17 # Set up a target database and an rbu update database. The target
18 # db is the usual "test.db", the rbu db is "test.db2".
22 CREATE TABLE t1(a, b, c, PRIMARY KEY(a), UNIQUE(b));
23 INSERT INTO t1 VALUES(1, 2, 3);
24 INSERT INTO t1 VALUES(4, 5, 6);
25 INSERT INTO t1 VALUES(7, 8, 9);
27 ATTACH 'test.db2' AS rbu;
28 CREATE TABLE rbu.data_t1(a, b, c, rbu_control);
29 INSERT INTO data_t1 VALUES('one', randomblob(3500), NULL, 0);
30 INSERT INTO data_t1 VALUES('two', randomblob(3500), NULL, 0);
31 INSERT INTO data_t1 VALUES('three', randomblob(3500), NULL, 0);
32 INSERT INTO data_t1 VALUES('four', randomblob(3500), NULL, 0);
33 INSERT INTO data_t1 VALUES('five', randomblob(3500), NULL, 0);
34 INSERT INTO data_t1 VALUES('six', randomblob(3500), NULL, 0);
38 proc do_rbu_crash_test2 {tn script} {
47 for {set iDelay 1} {$bDone==0} {incr iDelay} {
48 forcedelete test.db2 test.db2-journal test.db test.db-oal test.db-wal
52 crashsql -file $f -delay $iDelay -tclbody $script -dflt 1 -opendb {} \
57 if {$res == "1 {child process exited abnormally}"} {
59 } elseif {$res != "0 {}"} {
60 error "unexected catchsql result: $res"
63 sqlite3rbu rbu test.db test.db2
64 while {[rbu step]=="SQLITE_OK"} {}
68 do_execsql_test $tn.delay=$iDelay.f=$f.blksz=$blksz {
69 PRAGMA integrity_check;
76 for {set x 1} {$x < 10} {incr x} {
77 do_rbu_crash_test2 1.$x {
78 sqlite3rbu rbu test.db test.db2
79 while {[rbu step]=="SQLITE_OK"} {
86 for {set x 1} {$x < 2} {incr x} {
87 do_rbu_crash_test2 2.$x {
88 sqlite3rbu rbu test.db test.db2
89 while {[rbu step]=="SQLITE_OK"} {
91 sqlite3rbu rbu test.db test.db2