sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / rtree / rtreeI.test
| 1 | # 2019-12-05 |
| 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 | # Additional test cases |
| 12 | |
| 13 | if {![info exists testdir]} { |
| 14 | set testdir [file join [file dirname [info script]] .. .. test] |
| 15 | } |
| 16 | source [file join [file dirname [info script]] rtree_util.tcl] |
| 17 | source $testdir/tester.tcl |
| 18 | set testprefix rtreeI |
| 19 | ifcapable !rtree { finish_test ; return } |
| 20 | |
| 21 | # The following is a test of rowvalue handling on virtual tables that |
| 22 | # deal with inequalities and that set the OMIT flag on terms of the |
| 23 | # WHERE clause. This is not specific to rtree. We just use rtree because |
| 24 | # it is a convenient test platform since it has all the right |
| 25 | # characteristics. |
| 26 | # |
| 27 | do_execsql_test rtreeI-1.10 { |
| 28 | CREATE TABLE t1(a); |
| 29 | INSERT INTO t1 VALUES(2); |
| 30 | CREATE VIRTUAL TABLE t2 USING rtree(id,x0,x1); |
| 31 | INSERT INTO t2(id,x0,x1) VALUES(1,2,3); |
| 32 | } {} |
| 33 | do_execsql_test rtreeI-1.20 { |
| 34 | SELECT 123 FROM t1, t2 WHERE (a,0)>(x0,0); |
| 35 | } {} |
| 36 | do_execsql_test rtreeI-1.21 { |
| 37 | SELECT 123 FROM t1, t2 WHERE (a,0.1)>(x0,0); |
| 38 | } {123} |
| 39 | do_execsql_test rtreeI-1.22 { |
| 40 | SELECT 123 FROM t1, t2 WHERE (a,0)>=(x0,0); |
| 41 | } {123} |
| 42 | do_execsql_test rtreeI-1.23 { |
| 43 | SELECT 123 FROM t1, t2 WHERE (a,0)<=(x0,0); |
| 44 | } {123} |
| 45 | do_execsql_test rtreeI-1.24 { |
| 46 | SELECT 123 FROM t1, t2 WHERE (a,0)<(x0,0); |
| 47 | } {} |
| 48 | do_execsql_test rtreeI-1.30 { |
| 49 | SELECT 123 FROM t1, t2 WHERE (x0,0)<(a,0); |
| 50 | } {} |
| 51 | do_execsql_test rtreeI-1.31 { |
| 52 | SELECT 123 FROM t1, t2 WHERE (x0,0)<(a,0.1); |
| 53 | } {123} |
| 54 | do_execsql_test rtreeI-1.40 { |
| 55 | SELECT 123 FROM t1, t2 WHERE x1<5 AND id<99 AND (a,0)>(x0,0); |
| 56 | } {} |
| 57 | do_execsql_test rtreeI-1.41 { |
| 58 | SELECT 123 FROM t1, t2 WHERE x1<5 AND id<99 AND (a,0.5)>(x0,0); |
| 59 | } {123} |
| 60 | do_execsql_test rtreeI-1.42 { |
| 61 | SELECT 123 FROM t1, t2 WHERE x1<5 AND id<99 AND (a,0)>=(x0,0); |
| 62 | } {123} |
| 63 | do_execsql_test rtreeI-1.43 { |
| 64 | SELECT 123 FROM t1, t2 WHERE x1<5 AND id<99 AND (a,0)<(x0,0); |
| 65 | } {} |
| 66 | do_execsql_test rtreeI-1.50 { |
| 67 | SELECT 123 FROM t1, t2 WHERE 5>x1 AND 99>id AND (x0,0)<(a,0); |
| 68 | } {} |
| 69 | do_execsql_test rtreeI-1.51 { |
| 70 | SELECT 123 FROM t1, t2 WHERE 5>x1 AND 99>id AND (x0,0)<(a,0.5); |
| 71 | } {123} |
| 72 | |
| 73 | #------------------------------------------------------------------------- |
| 74 | # |
| 75 | reset_db |
| 76 | do_execsql_test 2.0 { |
| 77 | PRAGMA page_size = 4096; |
| 78 | CREATE TABLE zero(x INTEGER PRIMARY KEY); |
| 79 | CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2); |
| 80 | |
| 81 | WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<51) |
| 82 | INSERT INTO t1 SELECT i,i,i+1,i,i+1 FROM c; |
| 83 | |
| 84 | CREATE TRIGGER tr BEFORE INSERT ON t1_node BEGIN |
| 85 | SELECT raise(IGNORE); |
| 86 | END; |
| 87 | } {} |
| 88 | |
| 89 | db close |
| 90 | sqlite3 db test.db |
| 91 | |
| 92 | do_execsql_test 2.1 { |
| 93 | PRAGMA integrity_check |
| 94 | } {ok} |
| 95 | |
| 96 | do_catchsql_test 2.2 { |
| 97 | INSERT INTO t1 VALUES(1000, 0, 1, 0, 1); |
| 98 | } {1 {database disk image is malformed}} |
| 99 | |
| 100 | do_execsql_test 2.3 { |
| 101 | SELECT * FROM t1 WHERE id=25 |
| 102 | } {25 25.0 26.0 25.0 26.0} |
| 103 | |
| 104 | |
| 105 | |
| 106 | finish_test |