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 #***********************************************************************
13 source [file join [file dirname [info script]] rbu_common.tcl]
14 if_no_rbu_support { finish_test ; return }
15 set ::testprefix rbupartial
19 foreach {tn without_rowid a b c d} {
21 2 "WITHOUT ROWID" aaa bbb ccc ddd
22 3 "WITHOUT ROWID" "\"hello\"" {"one'two"} {[c]} ddd
23 4 "WITHOUT ROWID" {`a b`} {"one'two"} {[c c c]} ddd
25 6 "" {'one''two'} b {"c""c"} {"d""d"}
27 eval [string map [list \
28 %WITHOUT_ROWID% $without_rowid %A% $a %B% $b %C% $c %D% $d
31 do_execsql_test $tn.1.0 {
32 CREATE TABLE t1(%A% PRIMARY KEY, %B%, %C%, %D%) %WITHOUT_ROWID% ;
33 CREATE INDEX i1b ON t1(%B%);
34 CREATE INDEX i1b2 ON t1(%B%) WHERE %C%<5;
35 CREATE INDEX i1b3 ON t1(%B%) WHERE %C%>=5;
37 CREATE INDEX i1c ON t1(%C%);
38 CREATE INDEX i1c2 ON t1(%C%) WHERE %C% IS NULL;
39 CREATE INDEX i1c3 ON t1(%C%) WHERE %C% IS NOT NULL;
41 CREATE INDEX i1c4 ON t1(%C%) WHERE %D% < 'd';
42 CREATE INDEX i1c5 ON t1(
43 %C% -- for (c = ... expressions
45 CREATE INDEX i1c6 ON t1(
46 %C% /* Again, for (c=... expr */, %D%
49 CREATE INDEX i1c7 ON t1(
50 %C% /* As before, for (c=... "expr */) WHERE %D% < 'd';
53 do_execsql_test $tn.1.1 {
54 INSERT INTO t1 VALUES(0, NULL, NULL, 'a');
55 INSERT INTO t1 VALUES(1, 2, 3, 'b');
56 INSERT INTO t1 VALUES(4, 5, 6, 'c');
57 INSERT INTO t1 VALUES(7, 8, 9, 'd');
64 CREATE TABLE data_t1(%A%, %B%, %C%, %D%, rbu_control);
66 INSERT INTO data_t1 VALUES(10, 11, 12, 'e', 0);
67 INSERT INTO data_t1 VALUES(13, 14, NULL, 'f', 0);
69 INSERT INTO data_t1 VALUES(0, NULL, NULL, NULL, 1);
70 INSERT INTO data_t1 VALUES(4, NULL, NULL, NULL, 1);
72 INSERT INTO data_t1 VALUES(7, NULL, 4, NULL, '..x.');
73 INSERT INTO data_t1 VALUES(1, 10, NULL, NULL, '.xx.');
79 run_rbu test.db rbu.db
80 execsql { PRAGMA integrity_check }
83 do_execsql_test $tn.1.4 {
84 SELECT * FROM t1 ORDER BY %A%;
86 1 10 {} b 7 8 4 d 10 11 12 e 13 14 {} f
90 do_rbu_vacuum_test $tn.1.5 0
93 execsql { PRAGMA integrity_check }