sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | # 2012 November 9 |
| 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 | # This file implements regression tests for SQLite library. The |
| 12 | # focus of this file is testing the query planner to make sure it |
| 13 | # is making good planning decisions. |
| 14 | # |
| 15 | |
| 16 | |
| 17 | set testdir [file dirname $argv0] |
| 18 | source $testdir/tester.tcl |
| 19 | set ::testprefix whereE |
| 20 | |
| 21 | # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. |
| 22 | ifcapable !altertable { |
| 23 | finish_test |
| 24 | return |
| 25 | } |
| 26 | |
| 27 | do_execsql_test 1.1 { |
| 28 | CREATE TABLE t1(a,b); |
| 29 | INSERT INTO t1 VALUES(1,10), (2,20), (3,30), (2,22), (3, 33); |
| 30 | INSERT INTO t1 SELECT * FROM t1; |
| 31 | INSERT INTO t1 SELECT * FROM t1; |
| 32 | INSERT INTO t1 SELECT * FROM t1; |
| 33 | INSERT INTO t1 SELECT * FROM t1; |
| 34 | INSERT INTO t1 SELECT * FROM t1; |
| 35 | INSERT INTO t1 SELECT * FROM t1; |
| 36 | INSERT INTO t1 SELECT * FROM t1; |
| 37 | INSERT INTO t1 SELECT * FROM t1; |
| 38 | INSERT INTO t1 SELECT * FROM t1; |
| 39 | INSERT INTO t1 SELECT * FROM t1; |
| 40 | ALTER TABLE t1 ADD COLUMN c; |
| 41 | UPDATE t1 SET c=a*rowid+10000; |
| 42 | CREATE INDEX t1ab ON t1(a,b); |
| 43 | |
| 44 | CREATE TABLE t2(x,y); |
| 45 | INSERT INTO t2 VALUES(4,44),(5,55),(6,66),(7,77); |
| 46 | INSERT INTO t2 SELECT x+4, (x+4)*11 FROM t2; |
| 47 | INSERT INTO t2 SELECT x+8, (x+8)*11 FROM t2; |
| 48 | INSERT INTO t2 SELECT x+16, (x+16)*11 FROM t2; |
| 49 | INSERT INTO t2 SELECT x+32, (x+32)*11 FROM t2; |
| 50 | INSERT INTO t2 SELECT x+64, (x+32)*11 FROM t2; |
| 51 | ALTER TABLE t2 ADD COLUMN z; |
| 52 | UPDATE t2 SET z=2; |
| 53 | CREATE UNIQUE INDEX t2zx ON t2(z,x); |
| 54 | |
| 55 | EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x; |
| 56 | } {/.*SCAN t1.*SEARCH t2.*/} |
| 57 | do_execsql_test 1.2 { |
| 58 | EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x; |
| 59 | } {/.*SCAN t1.*SEARCH t2.*/} |
| 60 | do_execsql_test 1.3 { |
| 61 | ANALYZE; |
| 62 | EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x; |
| 63 | } {/.*SCAN t1.*SEARCH t2.*/} |
| 64 | do_execsql_test 1.4 { |
| 65 | EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x; |
| 66 | } {/.*SCAN t1.*SEARCH t2.*/} |
| 67 | |
| 68 | finish_test |