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 #***********************************************************************
14 # This file contains tests of multiple RBU operations running
15 # concurrently within the same process.
18 source [file join [file dirname [info script]] rbu_common.tcl]
19 if_no_rbu_support { finish_test ; return }
20 set ::testprefix rbumulti
24 autoinstall_test_functions
28 CREATE TABLE t1(a PRIMARY KEY, b, c);
29 CREATE INDEX i1 ON t1(b);
30 CREATE INDEX i2 ON t1(c);
32 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500 )
34 SELECT randomblob(10), randomblob(100), randomblob(100) FROM s;
40 CREATE TABLE data_t1(a, b, c, rbu_control);
41 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 )
43 SELECT randomblob(10), randomblob(100), randomblob(100), 0 FROM s;
47 proc step_rbu2 {bOpenClose openr1 openr2} {
49 forcedelete teststate.db1
50 forcedelete teststate.db2
52 if {$bOpenClose!=0 && $bOpenClose!=1} { error $bOpenClose }
61 while {$b1==0 || $b2==0} {
63 if {$b1==0} { eval $openr1 teststate.db1 }
64 if {$b2==0} { eval $openr2 teststate.db2 }
68 if {$rc1 != "SQLITE_OK"} { set b1 1 }
72 if {$rc2 != "SQLITE_OK"} { set b2 1 }
75 if {$b1==0} { r1 close }
76 if {$b2==0} { r2 close }
87 for {set i 0} {$i<=3} {incr i} {
90 sqlite3rbu_create_vfs -default myrbu ""
92 set bOpenClose [expr $i>>1]
115 set m1 [db eval {SELECT md5sum(a, b, c) FROM t1}]
116 set m2 [db2 eval {SELECT md5sum(a, b, c) FROM t1}]
119 step_rbu2 $bOpenClose {
120 sqlite3rbu r1 test.db rbu.db
122 sqlite3rbu r2 test.db2 rbu.db2
124 } {SQLITE_DONE SQLITE_DONE}
126 do_execsql_test -db db 1.$i.2.1 { PRAGMA integrity_check } ok
127 do_execsql_test -db db2 1.$i.2.2 { PRAGMA integrity_check } ok
129 do_execsql_test -db db 1.$i.3.1 { SELECT md5sum(a, b, c)==$m1 FROM t1 } 0
130 do_execsql_test -db db2 1.$i.3.2 { SELECT md5sum(a, b, c)==$m2 FROM t1 } 0
134 #-----------------------------------------------------------------------
149 set m1 [db eval {SELECT md5sum(a, b, c) FROM t1}]
150 set m2 [db2 eval {SELECT md5sum(a, b, c) FROM t1}]
153 step_rbu2 $bOpenClose {
154 sqlite3rbu_vacuum r1 test.db
156 sqlite3rbu r2 test.db2 rbu.db2
158 } {SQLITE_DONE SQLITE_DONE}
160 do_execsql_test -db db 1.$i.6.1 { SELECT md5sum(a, b, c)==$m1 FROM t1 } 1
161 do_execsql_test -db db2 1.$i.6.2 { SELECT md5sum(a, b, c)==$m2 FROM t1 } 0
163 do_execsql_test -db db 1.$i.7.1 { PRAGMA integrity_check } ok
164 do_execsql_test -db db2 1.$i.7.2 { PRAGMA integrity_check } ok
169 sqlite3rbu_destroy_vfs myrbu