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 if {![info exists testdir]} {
17 set testdir [file join [file dirname [info script]] .. .. test]
19 source $testdir/tester.tcl
20 source $testdir/lock_common.tcl
21 set ::testprefix rbu14
26 CREATE TABLE t1(a PRIMARY KEY, b, c);
27 CREATE TABLE t2(a PRIMARY KEY, b, c);
30 CREATE TABLE t1(a PRIMARY KEY, b, c);
31 CREATE TABLE t2(a PRIMARY KEY, b, c);
32 CREATE INDEX i1 ON t1(b, c);
33 CREATE INDEX i2 ON t2(b, c);
36 CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
37 CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
40 CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
41 CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
42 CREATE INDEX i1 ON t1(b, c);
43 CREATE INDEX i2 ON t2(b, c);
50 INSERT INTO t1 VALUES(50, 50, 50);
51 INSERT INTO t1 VALUES(51, 51, 51);
52 INSERT INTO t2 VALUES(50, 50, 50);
53 INSERT INTO t2 VALUES(51, 51, 51);
57 do_execsql_test $tn.1 {
58 ATTACH 'rbu.db' AS rbu;
59 CREATE TABLE rbu.stuff(tbl, a, b, c, rbu_control);
60 INSERT INTO stuff VALUES
61 ('t1', 1, 2, 3, 0), -- insert into t1
62 ('t2', 4, 5, 6, 0), -- insert into t2
63 ('t1', 50, NULL, NULL, 1), -- delete from t1
64 ('t2', 51, NULL, NULL, 1); -- delete from t2
66 CREATE VIEW rbu.data_t1 AS
67 SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t1';
68 CREATE VIEW rbu.data_t2 AS
69 SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t2';
74 sqlite3rbu rbu test.db rbu.db
77 if {$rc != "SQLITE_OK"} break
82 do_execsql_test $tn.3.1 {
83 SELECT * FROM t1 ORDER BY a;
86 do_execsql_test $tn.3.2 {
87 SELECT * FROM t2 ORDER BY a;