Debian Codegraph @

ext/rbu/rbu8.test

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