| 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 |
|
| 13 |
source [file join [file dirname [info script]] rbu_common.tcl] |
| 14 |
if_no_rbu_support { finish_test ; return } |
| 15 |
set ::testprefix rbuexpr |
| 16 |
|
| 17 |
do_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 |
|
| 30 |
forcedelete rbu.db |
| 31 |
sqlite3 db2 rbu.db |
| 32 |
do_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 |
} |
| 38 |
db2 close |
| 39 |
db close |
| 40 |
|
| 41 |
do_test 1.2 { |
| 42 |
run_rbu test.db rbu.db |
| 43 |
} {SQLITE_DONE} |
| 44 |
|
| 45 |
sqlite3 db test.db |
| 46 |
|
| 47 |
do_execsql_test 1.3 { |
| 48 |
SELECT * FROM t1 WHERE a=4; |
| 49 |
} |
| 50 |
|
| 51 |
integrity_check 1.4 |
| 52 |
|
| 53 |
#------------------------------------------------------------------------- |
| 54 |
# |
| 55 |
reset_db |
| 56 |
do_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 |
|
| 68 |
forcedelete rbu.db |
| 69 |
sqlite3 db2 rbu.db |
| 70 |
do_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 |
} |
| 76 |
db2 close |
| 77 |
|
| 78 |
db close |
| 79 |
|
| 80 |
do_test 2.2 { |
| 81 |
run_rbu test.db rbu.db |
| 82 |
} {SQLITE_DONE} |
| 83 |
|
| 84 |
sqlite3 db test.db |
| 85 |
integrity_check 2.3 |
| 86 |
|
| 87 |
finish_test |
| 88 |
|