Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/rbu/rbusave.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / rbu / rbusave.test` 102 lines ยท 2515 bytes Raw Blame History 1 # 2015 August 14 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 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. 9 # 10 #*********************************************************************** 11 # 12 13 source [file join [file dirname [info script]] rbu_common.tcl] 14 if_no_rbu_support { finish_test ; return } 15 set ::testprefix rbusave 16 17 do_execsql_test 1.0 { 18 CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID; 19 CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c); 20 CREATE INDEX i1 ON t1(b); 21 CREATE INDEX i2 ON t2(c, b); 22 23 INSERT INTO t1 VALUES(1, 1, 1); 24 INSERT INTO t1 VALUES(2, 2, 2); 25 INSERT INTO t1 VALUES(3, 3, 3); 26 27 INSERT INTO t2 VALUES(1, 1, 1); 28 INSERT INTO t2 VALUES(2, 2, 2); 29 INSERT INTO t2 VALUES(3, 3, 3); 30 } 31 32 do_test 1.1 { 33 forcedelete test.db2 34 sqlite3 db2 test.db2 35 db2 eval { 36 CREATE TABLE data_t1(a, b, c, rbu_control); 37 INSERT INTO data_t1 VALUES(4, 4, 4, 0); 38 INSERT INTO data_t1 VALUES(2, NULL, NULL, 1); 39 INSERT INTO data_t1 VALUES(1, 'one', NULL, '.x.'); 40 41 CREATE TABLE data_t2(a, b, c, rbu_control); 42 INSERT INTO data_t2 VALUES(4, 4, 4, 0); 43 INSERT INTO data_t2 VALUES(2, NULL, NULL, 1); 44 INSERT INTO data_t2 VALUES(1, 'one', NULL, '.x.'); 45 } 46 } {} 47 48 proc test_to_bak {} { 49 foreach f { 50 test.db test.db-wal test.db-oal test.db-journal 51 test.db2 test.db2-wal test.db2-oal test.db2-journal 52 } { 53 set t [string map {test bak} $f] 54 forcedelete $t 55 if {[file exists $f]} { forcecopy $f $t } 56 } 57 } 58 59 do_test 1.2 { 60 test_to_bak 61 sqlite3rbu rrr bak.db bak.db2 62 set nStep 0 63 while {[rrr step]=="SQLITE_OK"} {incr nStep} 64 set res2 [rrr close] 65 } {SQLITE_DONE} 66 67 68 sqlite3rbu rbu test.db test.db2 69 set res "SQLITE_OK" 70 for {set i 1} {$res=="SQLITE_OK"} {incr i} { 71 set res [rbu step] 72 73 do_test 1.3.$i.1 { 74 rbu savestate 75 test_to_bak 76 sqlite3rbu rrr bak.db bak.db2 77 set nRem 0 78 while {[rrr step]=="SQLITE_OK"} {incr nRem} 79 set res2 [rrr close] 80 } {SQLITE_DONE} 81 82 do_test 1.3.$i.3 { expr $nRem+$i } [expr {$nStep + ($res=="SQLITE_DONE")}] 83 84 do_test 1.3.$i.3 { 85 sqlite3 bak bak.db 86 bak eval { 87 SELECT * FROM t1; 88 SELECT * FROM t2; 89 } 90 } {1 one 1 3 3 3 4 4 4 1 one 1 3 3 3 4 4 4} 91 92 bak close 93 } 94 95 do_test 1.4 { rbu close } {SQLITE_DONE} 96 97 do_execsql_test 1.5 { 98 SELECT * FROM t1; 99 SELECT * FROM t2; 100 } {1 one 1 3 3 3 4 4 4 1 one 1 3 3 3 4 4 4} 101 102 finish_test