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 #***********************************************************************
12 # This file contains tests for the RBU module. Specifically, it tests the
13 # outcome of some other client writing to the database while an RBU update
16 source [file join [file dirname [info script]] rbu_common.tcl]
17 if_no_rbu_support { finish_test ; return }
23 CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
24 CREATE TABLE t2(a INTEGER PRIMARY KEY, b UNIQUE);
25 CREATE TABLE t3(a INTEGER PRIMARY KEY, b UNIQUE);
32 CREATE TABLE data_t1(a, b, rbu_control);
33 CREATE TABLE data_t2(a, b, rbu_control);
34 CREATE TABLE data_t3(a, b, rbu_control);
35 INSERT INTO data_t1 VALUES(1, 't1', 0);
36 INSERT INTO data_t2 VALUES(2, 't2', 0);
37 INSERT INTO data_t3 VALUES(3, 't3', 0);
42 # Test the outcome of some other client writing the db while the *-oal
43 # file is being generated. Once this has happened, the update cannot be
46 for {set nStep 1} {$nStep < 8} {incr nStep} {
49 sqlite3rbu rbu test.db rbu.db
50 for {set i 0} {$i<$nStep} {incr i} {rbu step}
54 execsql { INSERT INTO t1 VALUES(5, 'hello') }
55 sqlite3rbu rbu test.db rbu.db
62 list [file exists test.db-oal] [file exists test.db-wal]
65 list [catch { rbu close } msg] $msg
66 } {1 {SQLITE_BUSY - database modified during rbu update}}
69 # Test the outcome of some other client writing the db after the *-oal
70 # file has been copied to the *-wal path. Once this has happened, any
71 # other client writing to the db causes RBU to consider its job finished.
73 for {set nStep 8} {$nStep < 20} {incr nStep} {
76 sqlite3rbu rbu test.db rbu.db
77 for {set i 0} {$i<$nStep} {incr i} {rbu step}
80 execsql { INSERT INTO t1 VALUES(5, 'hello') }
81 sqlite3rbu rbu test.db rbu.db
88 file exists test.db-oal
91 list [catch { rbu close } msg] $msg
94 do_execsql_test 1.$nStep.5 {