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 # This file contains tests for the RBU module. More specifically, it
13 # contains tests to ensure that the sqlite3rbu_vacuum() API works as
17 source [file join [file dirname [info script]] rbu_common.tcl]
18 if_no_rbu_support { finish_test ; return }
19 set testprefix rbuvacuum4
24 CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
25 INSERT INTO t1 VALUES(1, 2, 3);
26 INSERT INTO t1 VALUES(4, 5, 6);
27 INSERT INTO t1 VALUES(7, 8, 9);
29 do_rbu_vacuum_test 1.1 1
31 #-------------------------------------------------------------------------
35 CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b, c)) WITHOUT ROWID;
36 INSERT INTO t1 VALUES(1, 2, 3);
37 INSERT INTO t1 VALUES(4, 5, 6);
38 INSERT INTO t1 VALUES(7, 8, 9);
40 do_rbu_vacuum_test 2.1 1
45 #-------------------------------------------------------------------------
49 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
50 CREATE INDEX i1 oN t1(b, c);
51 INSERT INTO t1 VALUES(1, 2, 3);
52 INSERT INTO t1 VALUES(4, 5, 6);
53 INSERT INTO t1 VALUES(7, 8, 9);
55 CREATE TABLE t2(a, b, c INTEGER, PRIMARY KEY(c));
56 CREATE INDEX i2 oN t2(b, a);
57 INSERT INTO t2 VALUES('a', 'b', -1);
58 INSERT INTO t2 VALUES('c', 'd', -2);
59 INSERT INTO t2 VALUES('e', 'f', -3);
62 do_rbu_vacuum_test 3.1 1
67 } {1 2 3 4 5 6 7 8 9 e f -3 c d -2 a b -1}
69 #-------------------------------------------------------------------------
72 CREATE TABLE x1(a, b, c, d, PRIMARY KEY(c, b)) WITHOUT ROWID;
73 INSERT INTO x1 VALUES(1, 1, 1, 1);
74 INSERT INTO x1 VALUES(1, 1, 2, 1);
75 INSERT INTO x1 VALUES(1, 2, 2, 1);
77 INSERT INTO x1 VALUES(NULL, 2, 3, NULL);
78 INSERT INTO x1 VALUES(NULL, 2, 4, NULL);
79 INSERT INTO x1 VALUES(NULL, 2, 5, NULL);
81 CREATE INDEX x1ad ON x1(d, a);
82 CREATE INDEX x1null ON x1(d, a) WHERE d>15;
85 do_rbu_vacuum_test 4.1.1 1
88 SELECT count(*) fROM x1
92 do_rbu_vacuum_test 4.1.2 0
94 #-------------------------------------------------------------------------
97 CREATE TABLE "a b c"(a, "b b" PRIMARY KEY, "c c");
98 CREATE INDEX abc1 ON "a b c"(a, "c c");
100 INSERT INTO "a b c" VALUES(NULL, 'a', NULL);
101 INSERT INTO "a b c" VALUES(NULL, 'b', NULL);
102 INSERT INTO "a b c" VALUES(NULL, 'c', NULL);
104 INSERT INTO "a b c" VALUES(1, 2, 3);
105 INSERT INTO "a b c" VALUES(3, 9, 1);
106 INSERT INTO "a b c" VALUES('aaa', 'bbb', 'ccc');
108 CREATE INDEX abc2 ON "a b c"("c c" DESC, a);
111 INSERT INTO x VALUES('a'), ('b'), ('d');
112 CREATE UNIQUE INDEX y ON x(a);
115 do_rbu_vacuum_test 5.1 1