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 that an RBU data_xxx table may be a view instead of a regular
16 source [file join [file dirname [info script]] rbu_common.tcl]
17 if_no_rbu_support { finish_test ; return }
18 source $testdir/lock_common.tcl
19 set ::testprefix rbu14
24 CREATE TABLE t1(a PRIMARY KEY, b, c);
25 CREATE TABLE t2(a PRIMARY KEY, b, c);
28 CREATE TABLE t1(a PRIMARY KEY, b, c);
29 CREATE TABLE t2(a PRIMARY KEY, b, c);
30 CREATE INDEX i1 ON t1(b, c);
31 CREATE INDEX i2 ON t2(b, c);
34 CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
35 CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
38 CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
39 CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
40 CREATE INDEX i1 ON t1(b, c);
41 CREATE INDEX i2 ON t2(b, c);
48 INSERT INTO t1 VALUES(50, 50, 50);
49 INSERT INTO t1 VALUES(51, 51, 51);
50 INSERT INTO t2 VALUES(50, 50, 50);
51 INSERT INTO t2 VALUES(51, 51, 51);
55 do_execsql_test $tn.1 {
56 ATTACH 'rbu.db' AS rbu;
57 CREATE TABLE rbu.stuff(tbl, a, b, c, rbu_control);
58 INSERT INTO stuff VALUES
59 ('t1', 1, 2, 3, 0), -- insert into t1
60 ('t2', 4, 5, 6, 0), -- insert into t2
61 ('t1', 50, NULL, NULL, 1), -- delete from t1
62 ('t2', 51, NULL, NULL, 1); -- delete from t2
64 CREATE VIEW rbu.data_t1 AS
65 SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t1';
66 CREATE VIEW rbu.data_t2 AS
67 SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t2';
72 sqlite3rbu rbu test.db rbu.db
75 if {$rc != "SQLITE_OK"} break
80 do_execsql_test $tn.3.1 {
81 SELECT * FROM t1 ORDER BY a;
84 do_execsql_test $tn.3.2 {
85 SELECT * FROM t2 ORDER BY a;