1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/index2.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,74 @@
1.4 +# 2005 January 11
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library. The
1.15 +# focus of this file is testing the CREATE INDEX statement.
1.16 +#
1.17 +# $Id: index2.test,v 1.3 2006/03/03 19:12:30 drh Exp $
1.18 +
1.19 +set testdir [file dirname $argv0]
1.20 +source $testdir/tester.tcl
1.21 +
1.22 +# Create a table with a large number of columns
1.23 +#
1.24 +do_test index2-1.1 {
1.25 + set sql {CREATE TABLE t1(}
1.26 + for {set i 1} {$i<1000} {incr i} {
1.27 + append sql "c$i,"
1.28 + }
1.29 + append sql "c1000);"
1.30 + execsql $sql
1.31 +} {}
1.32 +do_test index2-1.2 {
1.33 + set sql {INSERT INTO t1 VALUES(}
1.34 + for {set i 1} {$i<1000} {incr i} {
1.35 + append sql $i,
1.36 + }
1.37 + append sql {1000);}
1.38 + execsql $sql
1.39 +} {}
1.40 +do_test index2-1.3 {
1.41 + execsql {SELECT c123 FROM t1}
1.42 +} 123
1.43 +do_test index2-1.4 {
1.44 + execsql BEGIN
1.45 + for {set j 1} {$j<=100} {incr j} {
1.46 + set sql {INSERT INTO t1 VALUES(}
1.47 + for {set i 1} {$i<1000} {incr i} {
1.48 + append sql [expr {$j*10000+$i}],
1.49 + }
1.50 + append sql "[expr {$j*10000+1000}]);"
1.51 + execsql $sql
1.52 + }
1.53 + execsql COMMIT
1.54 + execsql {SELECT count(*) FROM t1}
1.55 +} 101
1.56 +do_test index2-1.5 {
1.57 + execsql {SELECT round(sum(c1000)) FROM t1}
1.58 +} {50601000.0}
1.59 +
1.60 +# Create indices with many columns
1.61 +#
1.62 +do_test index2-2.1 {
1.63 + set sql "CREATE INDEX t1i1 ON t1("
1.64 + for {set i 1} {$i<1000} {incr i} {
1.65 + append sql c$i,
1.66 + }
1.67 + append sql c1000)
1.68 + execsql $sql
1.69 +} {}
1.70 +do_test index2-2.2 {
1.71 + ifcapable explain {
1.72 + execsql {EXPLAIN SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5}
1.73 + }
1.74 + execsql {SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5, c6 LIMIT 5}
1.75 +} {9 10009 20009 30009 40009}
1.76 +
1.77 +finish_test