1# 2014 March 25. 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 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. 9# 10#*********************************************************************** 11# This file implements regression tests for SQLite library. 12# 13 14set testdir [file dirname $argv0] 15source $testdir/tester.tcl 16set testprefix sort2 17 18foreach {tn script} { 19 1 { } 20 2 { 21 catch { db close } 22 sqlite3_shutdown 23 sqlite3_config_worker_threads 7 24 reset_db 25 } 26} { 27 28 eval $script 29 30 do_execsql_test $tn.1 { 31 PRAGMA cache_size = 5; 32 WITH r(x,y) AS ( 33 SELECT 1, randomblob(100) 34 UNION ALL 35 SELECT x+1, randomblob(100) FROM r 36 LIMIT 100000 37 ) 38 SELECT count(x), length(y) FROM r GROUP BY (x%5) 39 } { 40 20000 100 20000 100 20000 100 20000 100 20000 100 41 } 42 43 do_execsql_test $tn.2.1 { 44 CREATE TABLE t1(a, b); 45 WITH r(x,y) AS ( 46 SELECT 1, randomblob(100) 47 UNION ALL 48 SELECT x+1, randomblob(100) FROM r 49 LIMIT 10000 50 ) INSERT INTO t1 SELECT * FROM r; 51 } 52 53 do_execsql_test $tn.2.2 { 54 CREATE UNIQUE INDEX i1 ON t1(b, a); 55 } 56 57 do_execsql_test $tn.2.3 { 58 CREATE UNIQUE INDEX i2 ON t1(a); 59 } 60 61 do_execsql_test $tn.2.4 { PRAGMA integrity_check } {ok} 62 63 breakpoint 64 do_execsql_test $tn.3 { 65 PRAGMA cache_size = 5; 66 WITH r(x,y) AS ( 67 SELECT 1, randomblob(100) 68 UNION ALL 69 SELECT x+1, randomblob(100) FROM r 70 LIMIT 1000000 71 ) 72 SELECT count(x), length(y) FROM r GROUP BY (x%5) 73 } { 74 200000 100 200000 100 200000 100 200000 100 200000 100 75 } 76 77 db close 78 sqlite3_shutdown 79 sqlite3_config_worker_threads 0 80 sqlite3_initialize 81 82} 83 84finish_test 85 86