xref: /sqlite-3.40.0/test/bigsort.test (revision cfce889c)
10a79238bSdan# 2014 November 26
20a79238bSdan#
30a79238bSdan# The author disclaims copyright to this source code.  In place of
40a79238bSdan# a legal notice, here is a blessing:
50a79238bSdan#
60a79238bSdan#    May you do good and not evil.
70a79238bSdan#    May you find forgiveness for yourself and forgive others.
80a79238bSdan#    May you share freely, never taking more than you give.
90a79238bSdan#
100a79238bSdan#***********************************************************************
110a79238bSdan#
120a79238bSdan
130a79238bSdanset testdir [file dirname $argv0]
140a79238bSdansource $testdir/tester.tcl
150a79238bSdanset testprefix bigsort
160a79238bSdan
170a79238bSdan#--------------------------------------------------------------------
180a79238bSdan# At one point there was an overflow problem if the product of the
190a79238bSdan# cache-size and page-size was larger than 2^31. Causing an infinite
200a79238bSdan# loop if the product was also an integer multiple of 2^32, or
210a79238bSdan# inefficiency otherwise.
220a79238bSdan#
232e5021d5Sdrh# This test causes thrashing on machines with smaller amounts of
242e5021d5Sdrh# memory.  Make sure the host has at least 8GB available before running
252e5021d5Sdrh# this test.
262e5021d5Sdrh#
27*cfce889cSdan# Update: https://sqlite.org/src/info/7c96a56 adds assert() statements
28*cfce889cSdan# that make this test too slow to run with SQLITE_DEBUG builds.
29*cfce889cSdan#
302e5021d5Sdrhif {[catch {exec free | grep Mem:} out] || [lindex $out 1]<8000000} {
312e5021d5Sdrh  finish_test
322e5021d5Sdrh  return
332e5021d5Sdrh}
34*cfce889cSdanifcapable debug {
35*cfce889cSdan  finish_test
36*cfce889cSdan  return
37*cfce889cSdan}
382e5021d5Sdrh
390a79238bSdando_execsql_test 1.0 {
400a79238bSdan  PRAGMA page_size = 1024;
410a79238bSdan  CREATE TABLE t1(a, b);
420a79238bSdan  BEGIN;
430a79238bSdan  WITH data(x,y) AS (
440a79238bSdan    SELECT 1, zeroblob(10000)
450a79238bSdan    UNION ALL
460a79238bSdan    SELECT x+1, y FROM data WHERE x < 300000
470a79238bSdan  )
480a79238bSdan  INSERT INTO t1 SELECT * FROM data;
490a79238bSdan  COMMIT;
500a79238bSdan}
510a79238bSdando_execsql_test 1.1 {
520a79238bSdan  PRAGMA cache_size = 4194304;
530a79238bSdan  CREATE INDEX i1 ON t1(a, b);
540a79238bSdan}
550a79238bSdan
560a79238bSdan
570a79238bSdanfinish_test
58