interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / rbu / rbuexpr.test

88 lines · 2197 bytes Raw Blame History
1# 2014 August 30
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11#
12
13source [file join [file dirname [info script]] rbu_common.tcl]
14if_no_rbu_support { finish_test ; return }
15set ::testprefix rbuexpr
16
17do_execsql_test 1.0 {
18 CREATE TABLE t1(a, b, c PRIMARY KEY);
19 CREATE INDEX i1 ON t1(a, null, b+1);
20 CREATE INDEX i2 ON t1(a+1, b+1, c+1);
21
22 INSERT INTO t1 VALUES(1, 2, 3);
23 INSERT INTO t1 VALUES(4, 5, 6);
24 INSERT INTO t1 VALUES(7, 8, 9);
25 INSERT INTO t1 VALUES(10, 11, 12);
26
27 PRAGMA integrity_check;
28} {ok}
29
30forcedelete rbu.db
31sqlite3 db2 rbu.db
32do_execsql_test -db db2 1.1 {
33 CREATE TABLE data_t1(a, b, c, rbu_control);
34 INSERT INTO data_t1 VALUES(13, 14, 15, 0);
35 INSERT INTO data_t1 VALUES(NULL, NULL, 6, 1);
36 INSERT INTO data_t1 VALUES(NULL, 'three', 3, '.x.');
37}
38db2 close
39db close
40
41do_test 1.2 {
42 run_rbu test.db rbu.db
43} {SQLITE_DONE}
44
45sqlite3 db test.db
46
47do_execsql_test 1.3 {
48 SELECT * FROM t1 WHERE a=4;
49}
50
51integrity_check 1.4
52
53#-------------------------------------------------------------------------
54#
55reset_db
56do_execsql_test 2.0 {
57 CREATE TABLE t1(c1, c2, c3, i INTEGER PRIMARY KEY);
58 INSERT INTO t1 VALUES('one', 'one', 'one', 1);
59 INSERT INTO t1 VALUES('two', 'two', 'two', 2);
60 INSERT INTO t1 VALUES('three', 'three', 'three', 3);
61 INSERT INTO t1 VALUES('four', 'four', 'four', 4);
62
63 CREATE INDEX i1 ON t1( substr(c1, 1, 2) );
64 CREATE INDEX i2 ON t1( c1 || c2 || c3 );
65 CREATE INDEX i3 ON t1( length(c1) + length(c2) - 1, c3||i );
66}
67
68forcedelete rbu.db
69sqlite3 db2 rbu.db
70do_execsql_test -db db2 2.1 {
71 CREATE TABLE data_t1(c1, c2, c3, i, rbu_control);
72 INSERT INTO data_t1 VALUES(NULL, NULL, NULL, 2, 1);
73 INSERT INTO data_t1 VALUES('thirty', NULL, NULL, 3, 'xx..');
74 INSERT INTO data_t1 VALUES('five', 'five', 'five', 5, 0);
75}
76db2 close
77
78db close
79
80do_test 2.2 {
81 run_rbu test.db rbu.db
82} {SQLITE_DONE}
83
84sqlite3 db test.db
85integrity_check 2.3
86
87finish_test
88