blob: 80595d95f7fd378e19cc848bcd391f9571b6fd63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# 2011 April 9
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix unordered
do_execsql_test 1.0 {
CREATE TABLE t1(a, b);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(1, 'xxx');
INSERT INTO t1 SELECT a+1, b FROM t1;
INSERT INTO t1 SELECT a+2, b FROM t1;
INSERT INTO t1 SELECT a+4, b FROM t1;
INSERT INTO t1 SELECT a+8, b FROM t1;
INSERT INTO t1 SELECT a+16, b FROM t1;
INSERT INTO t1 SELECT a+32, b FROM t1;
INSERT INTO t1 SELECT a+64, b FROM t1;
ANALYZE;
} {}
foreach idxmode {ordered unordered} {
catchsql { DELETE FROM sqlite_stat2 }
catchsql { DELETE FROM sqlite_stat3 }
if {$idxmode == "unordered"} {
execsql { UPDATE sqlite_stat1 SET stat = stat || ' unordered' }
}
db close
sqlite3 db test.db
foreach {tn sql r(ordered) r(unordered)} {
1 "SELECT * FROM t1 ORDER BY a"
{SCAN t1 USING INDEX i1}
{SCAN t1*USE TEMP B-TREE FOR ORDER BY}
2 "SELECT * FROM t1 WHERE a > 100"
{SEARCH t1 USING INDEX i1 (a>?)}
{SCAN t1}
3 "SELECT * FROM t1 WHERE a = ? ORDER BY rowid"
{SEARCH t1 USING INDEX i1 (a=?)}
{SEARCH t1 USING INDEX i1 (a=?)*USE TEMP B-TREE FOR ORDER BY}
4 "SELECT max(a) FROM t1"
{SEARCH t1 USING COVERING INDEX i1}
{SEARCH t1}
5 "SELECT group_concat(b) FROM t1 GROUP BY a"
{SCAN t1 USING INDEX i1}
{SCAN t1*USE TEMP B-TREE FOR GROUP BY}
6 "SELECT * FROM t1 WHERE a = ?"
{SEARCH t1 USING INDEX i1 (a=?)}
{SEARCH t1 USING INDEX i1 (a=?)}
7 "SELECT count(*) FROM t1"
{SCAN t1 USING COVERING INDEX i1}
{SCAN t1}
} {
do_eqp_test 1.$idxmode.$tn $sql $r($idxmode)
}
}
finish_test
|