xref: /sqlite-3.40.0/test/sort3.test (revision 8daefc2a)
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 sort3
17
18# Sort roughly 20MB of data. Once with a mmap limit of 5MB and once without.
19#
20foreach {itest limit} {
21  1 5000000
22  2 0x7FFFFFFF
23} {
24  sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $limit
25  do_execsql_test 1.$itest {
26    WITH r(x,y) AS (
27        SELECT 1, randomblob(1000)
28        UNION ALL
29        SELECT x+1, randomblob(1000) FROM r
30        LIMIT 20000
31    )
32    SELECT count(*), sum(length(y)) FROM r GROUP BY (x%5);
33  } {
34    4000 4000000
35    4000 4000000
36    4000 4000000
37    4000 4000000
38    4000 4000000
39  }
40}
41
42# Sort more than 2GB of data. At one point this was causing a problem.
43# This test might take one minute or more to run.
44#
45do_execsql_test 2 {
46  PRAGMA cache_size = 20000;
47  WITH r(x,y) AS (
48    SELECT 1, randomblob(1000)
49    UNION ALL
50    SELECT x+1, randomblob(1000) FROM r
51    LIMIT 2200000
52  )
53  SELECT count(*), sum(length(y)) FROM r GROUP BY (x%5);
54} {
55  440000 440000000
56  440000 440000000
57  440000 440000000
58  440000 440000000
59  440000 440000000
60}
61
62finish_test
63
64