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
23 INSERT INTO t1 VALUES(1,10), (2,20), (3,30), (2,22), (3, 33);
24 INSERT INTO t1 SELECT * FROM t1;
25 INSERT INTO t1 SELECT * FROM t1;
26 INSERT INTO t1 SELECT * FROM t1;
27 INSERT INTO t1 SELECT * FROM t1;
28 INSERT INTO t1 SELECT * FROM t1;
29 INSERT INTO t1 SELECT * FROM t1;
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 ALTER TABLE t1 ADD COLUMN c;
35 UPDATE t1 SET c=a*rowid+10000;
36 CREATE INDEX t1ab ON t1(a,b);
39 INSERT INTO t2 VALUES(4,44),(5,55),(6,66),(7,77);
40 INSERT INTO t2 SELECT x+4, (x+4)*11 FROM t2;
41 INSERT INTO t2 SELECT x+8, (x+8)*11 FROM t2;
42 INSERT INTO t2 SELECT x+16, (x+16)*11 FROM t2;
43 INSERT INTO t2 SELECT x+32, (x+32)*11 FROM t2;
44 INSERT INTO t2 SELECT x+64, (x+32)*11 FROM t2;
45 ALTER TABLE t2 ADD COLUMN z;
47 CREATE UNIQUE INDEX t2zx ON t2(z,x);
49 EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;
50 } {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}
52 EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;
53 } {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}
56 EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;
57 } {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}
59 EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;
60 } {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}