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# Specifically, the tests in this file attempt to verify that 14# multi-threaded sorting works. 15# 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19set testprefix sort2 20 21foreach {tn script} { 22 1 { } 23 2 { 24 catch { db close } 25 reset_db 26 catch { db eval {PRAGMA threads=7} } 27 } 28} { 29 30 eval $script 31 32 do_execsql_test $tn.1 { 33 PRAGMA cache_size = 5; 34 WITH r(x,y) AS ( 35 SELECT 1, randomblob(100) 36 UNION ALL 37 SELECT x+1, randomblob(100) FROM r 38 LIMIT 100000 39 ) 40 SELECT count(x), length(y) FROM r GROUP BY (x%5) 41 } { 42 20000 100 20000 100 20000 100 20000 100 20000 100 43 } 44 45 do_execsql_test $tn.2.1 { 46 CREATE TABLE t1(a, b); 47 WITH r(x,y) AS ( 48 SELECT 1, randomblob(100) 49 UNION ALL 50 SELECT x+1, randomblob(100) FROM r 51 LIMIT 10000 52 ) INSERT INTO t1 SELECT * FROM r; 53 } 54 55 do_execsql_test $tn.2.2 { 56 CREATE UNIQUE INDEX i1 ON t1(b, a); 57 } 58 59 do_execsql_test $tn.2.3 { 60 CREATE UNIQUE INDEX i2 ON t1(a); 61 } 62 63 do_execsql_test $tn.2.4 { PRAGMA integrity_check } {ok} 64 65 do_execsql_test $tn.3 { 66 PRAGMA cache_size = 5; 67 WITH r(x,y) AS ( 68 SELECT 1, randomblob(100) 69 UNION ALL 70 SELECT x+1, randomblob(100) FROM r 71 LIMIT 1000000 72 ) 73 SELECT count(x), length(y) FROM r GROUP BY (x%5) 74 } { 75 200000 100 200000 100 200000 100 200000 100 200000 100 76 } 77} 78 79finish_test 80