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 # Test RBU with virtual tables. And tables with no PRIMARY KEY declarations.
15 if {![info exists testdir]} {
16 set testdir [file join [file dirname [info script]] .. .. test]
18 source $testdir/tester.tcl
27 CREATE VIRTUAL TABLE f1 USING fts4(a, b, c);
28 INSERT INTO f1(rowid, a, b, c) VALUES(11, 'a', 'b', 'c');
29 INSERT INTO f1(rowid, a, b, c) VALUES(12, 'd', 'e', 'f');
30 INSERT INTO f1(rowid, a, b, c) VALUES(13, 'g', 'h', 'i');
37 CREATE TABLE data_f1(rbu_rowid, a, b, c, rbu_control);
38 INSERT INTO data_f1 VALUES(14, 'x', 'y', 'z', 0); -- INSERT
39 INSERT INTO data_f1 VALUES(11, NULL, NULL, NULL, 1); -- DELETE
40 INSERT INTO data_f1 VALUES(13, NULL, NULL, 'X', '..x'); -- UPDATE
47 sqlite3rbu rbu test.db rbu.db
49 if {$rc != "SQLITE_OK"} break
55 do_execsql_test 1.2.2 { SELECT rowid, * FROM f1 } {
60 do_execsql_test 1.2.3 { INSERT INTO f1(f1) VALUES('integrity-check') }
63 #-------------------------------------------------------------------------
64 # Tables with no PK declaration.
67 # Run the RBU in file $rbu on target database $target until completion.
69 proc run_rbu {target rbu} {
70 sqlite3rbu rbu $target $rbu
71 while { [rbu step]=="SQLITE_OK" } {}
78 CREATE INDEX i1 ON t1(a);
81 CREATE INDEX i1 ON t1(b, c);
82 CREATE INDEX i2 ON t1(c, b);
83 CREATE INDEX i3 ON t1(a, a, a, b, b, b, c, c, c);
88 do_execsql_test 2.$tn.1 {
89 CREATE TABLE t1(a, b, c);
90 INSERT INTO t1 VALUES(1, 2, 3);
91 INSERT INTO t1 VALUES(4, 5, 6);
92 INSERT INTO t1(rowid, a, b, c) VALUES(-1, 'a', 'b', 'c');
93 INSERT INTO t1(rowid, a, b, c) VALUES(-2, 'd', 'e', 'f');
102 CREATE TABLE data_t1(rbu_rowid, a, b, c, rbu_control);
103 INSERT INTO data_t1 VALUES(3, 'x', 'y', 'z', 0);
104 INSERT INTO data_t1 VALUES(NULL, 'X', 'Y', 'Z', 0);
105 INSERT INTO data_t1 VALUES('1', NULL, NULL, NULL, 1);
106 INSERT INTO data_t1 VALUES(-2, NULL, NULL, 'fff', '..x');
111 run_rbu test.db rbu.db
113 do_execsql_test 2.$tn.3 {
114 SELECT rowid, a, b, c FROM t1 ORDER BY rowid;
123 integrity_check 2.$tn.4