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 #***********************************************************************
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.
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19 set ::testprefix whereE
21 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
22 ifcapable !altertable {
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);
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;
53 CREATE UNIQUE INDEX t2zx ON t2(z,x);
55 EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;
56 } {/.*SCAN t1.*SEARCH t2.*/}
58 EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;
59 } {/.*SCAN t1.*SEARCH t2.*/}
62 EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;
63 } {/.*SCAN t1.*SEARCH t2.*/}
65 EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;
66 } {/.*SCAN t1.*SEARCH t2.*/}