sl@0
|
1 |
# 2005 January 11
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# The author disclaims copyright to this source code. In place of
|
sl@0
|
4 |
# a legal notice, here is a blessing:
|
sl@0
|
5 |
#
|
sl@0
|
6 |
# May you do good and not evil.
|
sl@0
|
7 |
# May you find forgiveness for yourself and forgive others.
|
sl@0
|
8 |
# May you share freely, never taking more than you give.
|
sl@0
|
9 |
#
|
sl@0
|
10 |
#***********************************************************************
|
sl@0
|
11 |
# This file implements regression tests for SQLite library. The
|
sl@0
|
12 |
# focus of this file is testing the CREATE INDEX statement.
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# $Id: index2.test,v 1.3 2006/03/03 19:12:30 drh Exp $
|
sl@0
|
15 |
|
sl@0
|
16 |
set testdir [file dirname $argv0]
|
sl@0
|
17 |
source $testdir/tester.tcl
|
sl@0
|
18 |
|
sl@0
|
19 |
# Create a table with a large number of columns
|
sl@0
|
20 |
#
|
sl@0
|
21 |
do_test index2-1.1 {
|
sl@0
|
22 |
set sql {CREATE TABLE t1(}
|
sl@0
|
23 |
for {set i 1} {$i<1000} {incr i} {
|
sl@0
|
24 |
append sql "c$i,"
|
sl@0
|
25 |
}
|
sl@0
|
26 |
append sql "c1000);"
|
sl@0
|
27 |
execsql $sql
|
sl@0
|
28 |
} {}
|
sl@0
|
29 |
do_test index2-1.2 {
|
sl@0
|
30 |
set sql {INSERT INTO t1 VALUES(}
|
sl@0
|
31 |
for {set i 1} {$i<1000} {incr i} {
|
sl@0
|
32 |
append sql $i,
|
sl@0
|
33 |
}
|
sl@0
|
34 |
append sql {1000);}
|
sl@0
|
35 |
execsql $sql
|
sl@0
|
36 |
} {}
|
sl@0
|
37 |
do_test index2-1.3 {
|
sl@0
|
38 |
execsql {SELECT c123 FROM t1}
|
sl@0
|
39 |
} 123
|
sl@0
|
40 |
do_test index2-1.4 {
|
sl@0
|
41 |
execsql BEGIN
|
sl@0
|
42 |
for {set j 1} {$j<=100} {incr j} {
|
sl@0
|
43 |
set sql {INSERT INTO t1 VALUES(}
|
sl@0
|
44 |
for {set i 1} {$i<1000} {incr i} {
|
sl@0
|
45 |
append sql [expr {$j*10000+$i}],
|
sl@0
|
46 |
}
|
sl@0
|
47 |
append sql "[expr {$j*10000+1000}]);"
|
sl@0
|
48 |
execsql $sql
|
sl@0
|
49 |
}
|
sl@0
|
50 |
execsql COMMIT
|
sl@0
|
51 |
execsql {SELECT count(*) FROM t1}
|
sl@0
|
52 |
} 101
|
sl@0
|
53 |
do_test index2-1.5 {
|
sl@0
|
54 |
execsql {SELECT round(sum(c1000)) FROM t1}
|
sl@0
|
55 |
} {50601000.0}
|
sl@0
|
56 |
|
sl@0
|
57 |
# Create indices with many columns
|
sl@0
|
58 |
#
|
sl@0
|
59 |
do_test index2-2.1 {
|
sl@0
|
60 |
set sql "CREATE INDEX t1i1 ON t1("
|
sl@0
|
61 |
for {set i 1} {$i<1000} {incr i} {
|
sl@0
|
62 |
append sql c$i,
|
sl@0
|
63 |
}
|
sl@0
|
64 |
append sql c1000)
|
sl@0
|
65 |
execsql $sql
|
sl@0
|
66 |
} {}
|
sl@0
|
67 |
do_test index2-2.2 {
|
sl@0
|
68 |
ifcapable explain {
|
sl@0
|
69 |
execsql {EXPLAIN SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5}
|
sl@0
|
70 |
}
|
sl@0
|
71 |
execsql {SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5, c6 LIMIT 5}
|
sl@0
|
72 |
} {9 10009 20009 30009 40009}
|
sl@0
|
73 |
|
sl@0
|
74 |
finish_test
|