# 2001 September 15 # # 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. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc1.test,v 1.1 2001/09/18 22:17:45 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test the creation and use of tables that have a large number # of columns. # do_test misc1-1.1 { set cmd "CREATE TABLE manycol(x0 text" for {set i 1} {$i<=99} {incr i} { append cmd ",x$i text" } append cmd ")"; execsql $cmd set cmd "INSERT INTO manycol VALUES(0" for {set i 1} {$i<=99} {incr i} { append cmd ",$i" } append cmd ")"; execsql $cmd execsql "SELECT x99 FROM manycol" } 99 do_test misc1-1.2 { execsql {SELECT x0, x10, x25, x50, x75 FROM manycol} } {0 10 25 50 75} do_test misc1-1.3 { for {set j 100} {$j<=1000} {incr j 100} { set cmd "INSERT INTO manycol VALUES($j" for {set i 1} {$i<=99} {incr i} { append cmd ",[expr {$i+$j}]" } append cmd ")" execsql $cmd } execsql {SELECT x50 FROM manycol ORDER BY x80} } {50 150 250 350 450 550 650 750 850 950 1050} do_test misc1-1.4 { execsql {SELECT x75 FROM manycol WHERE x50=350} } 375 do_test misc1-1.5 { execsql {SELECT x50 FROM manycol WHERE x99=599} } 550 do_test misc1-1.6 { execsql {CREATE INDEX manycol_idx1 ON manycol(x99)} execsql {SELECT x50 FROM manycol WHERE x99=899} } 850 do_test misc1-1.7 { execsql {SELECT count(*) FROM manycol} } 11 do_test misc1-1.8 { execsql {DELETE FROM manycol WHERE x98=1234} execsql {SELECT count(*) FROM manycol} } 11 do_test misc1-1.9 { execsql {DELETE FROM manycol WHERE x98=998} execsql {SELECT count(*) FROM manycol} } 10 do_test misc1-1.10 { execsql {DELETE FROM manycol WHERE x99=500} execsql {SELECT count(*) FROM manycol} } 10 do_test misc1-1.11 { execsql {DELETE FROM manycol WHERE x99=599} execsql {SELECT count(*) FROM manycol} } 9 # Check GROUP BY expressions that name two or more columns. # do_test misc1-2.1 { execsql { BEGIN TRANSACTION; CREATE TABLE agger(one text, two text, three text, four text); INSERT INTO agger VALUES(1, 'one', 'hello', 'yes'); INSERT INTO agger VALUES(2, 'two', 'howdy', 'no'); INSERT INTO agger VALUES(3, 'thr', 'howareya', 'yes'); INSERT INTO agger VALUES(4, 'two', 'lothere', 'yes'); INSERT INTO agger VALUES(5, 'one', 'atcha', 'yes'); INSERT INTO agger VALUES(6, 'two', 'hello', 'no'); COMMIT } execsql {SELECT count(*) FROM agger} } 6 do_test misc1-2.2 { execsql {SELECT sum(one), two, four FROM agger GROUP BY two, four ORDER BY sum(one) desc} } {8 two no 6 one yes 4 two yes 3 thr yes} finish_test