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.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
17 set testprefix unordered
20 CREATE TABLE t1(a, b);
21 CREATE INDEX i1 ON t1(a);
22 INSERT INTO t1 VALUES(1, 'xxx');
23 INSERT INTO t1 SELECT a+1, b FROM t1;
24 INSERT INTO t1 SELECT a+2, b FROM t1;
25 INSERT INTO t1 SELECT a+4, b FROM t1;
26 INSERT INTO t1 SELECT a+8, b FROM t1;
27 INSERT INTO t1 SELECT a+16, b FROM t1;
28 INSERT INTO t1 SELECT a+32, b FROM t1;
29 INSERT INTO t1 SELECT a+64, b FROM t1;
33 foreach idxmode {ordered unordered} {
34 catchsql { DELETE FROM sqlite_stat2 }
35 catchsql { DELETE FROM sqlite_stat3 }
36 if {$idxmode == "unordered"} {
37 execsql { UPDATE sqlite_stat1 SET stat = stat || ' unordered' }
41 foreach {tn sql r(ordered) r(unordered)} {
42 1 "SELECT * FROM t1 ORDER BY a"
43 {SCAN TABLE t1 USING INDEX i1}
44 {SCAN TABLE t1*USE TEMP B-TREE FOR ORDER BY}
45 2 "SELECT * FROM t1 WHERE a > 100"
46 {SEARCH TABLE t1 USING INDEX i1 (a>?)}
48 3 "SELECT * FROM t1 WHERE a = ? ORDER BY rowid"
49 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
50 {SEARCH TABLE t1 USING INDEX i1 (a=?)*USE TEMP B-TREE FOR ORDER BY}
51 4 "SELECT max(a) FROM t1"
52 {SEARCH TABLE t1 USING COVERING INDEX i1}
54 5 "SELECT group_concat(b) FROM t1 GROUP BY a"
55 {SCAN TABLE t1 USING INDEX i1}
56 {SCAN TABLE t1*USE TEMP B-TREE FOR GROUP BY}
58 6 "SELECT * FROM t1 WHERE a = ?"
59 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
60 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
61 7 "SELECT count(*) FROM t1"
62 {SCAN TABLE t1 USING COVERING INDEX i1}
65 do_eqp_test 1.$idxmode.$tn $sql $r($idxmode)