1# 2014 November 20 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# Test the rbu_delta() feature. 13# 14 15if {![info exists testdir]} { 16 set testdir [file join [file dirname [info script]] .. .. test] 17} 18source $testdir/tester.tcl 19set ::testprefix rbu8 20 21do_execsql_test 1.0 { 22 CREATE TABLE t1(x, y PRIMARY KEY, z); 23 INSERT INTO t1 VALUES(NULL, 1, 'one'); 24 INSERT INTO t1 VALUES(NULL, 2, 'two'); 25 INSERT INTO t1 VALUES(NULL, 3, 'three'); 26 CREATE INDEX i1z ON t1(z, x); 27} 28 29do_test 1.1 { 30 forcedelete rbu.db 31 sqlite3 db2 rbu.db 32 db2 eval { 33 CREATE TABLE data_t1(x, y, z, rbu_control); 34 INSERT INTO data_t1 VALUES('a', 1, '_i' , 'x.d'); 35 INSERT INTO data_t1 VALUES('b', 2, 2 , '..x'); 36 INSERT INTO data_t1 VALUES('_iii', 3, '-III' , 'd.d'); 37 } 38 db2 close 39} {} 40 41do_test 1.2.1 { 42 sqlite3rbu rbu test.db rbu.db 43 rbu step 44} {SQLITE_ERROR} 45do_test 1.2.2 { 46 list [catch {rbu close} msg] $msg 47} {1 {SQLITE_ERROR - no such function: rbu_delta}} 48 49proc rbu_delta {orig new} { 50 return "${orig}${new}" 51} 52 53do_test 1.3.1 { 54 while 1 { 55 sqlite3rbu rbu test.db rbu.db 56 rbu create_rbu_delta 57 set rc [rbu step] 58 if {$rc != "SQLITE_OK"} break 59 rbu close 60 } 61 rbu close 62} {SQLITE_DONE} 63 64do_execsql_test 1.3.2 { 65 SELECT * FROM t1 66} { 67 a 1 one_i 68 {} 2 2 69 _iii 3 three-III 70} 71integrity_check 1.3.3 72 73 74finish_test 75