Remove a lot of the text describing extended format options from the
[sqlite.git] / test / bigmmap.test
blob9284bda37d8da4e31e2e6a9e68acc834e273151d
1 # 2017 August 07
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.  The
12 # focus of this script testing the ability of SQLite to use mmap
13 # to access files larger than 4GiB.
16 if {[file exists skip-big-file]} return
17 if {$tcl_platform(os)=="Darwin"} return
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
21 set testprefix bigmmap
23 ifcapable !mmap||!vtab {
24   finish_test
25   return
28 set mmap_limit 0
29 db eval { 
30   SELECT compile_options AS x FROM pragma_compile_options 
31   WHERE x LIKE 'max_mmap_size=%' 
32 } {
33   regexp {MAX_MMAP_SIZE=([0-9]*)} $x -> mmap_limit
35 if {$mmap_limit < [expr 8 * 1<<30]} {
36   puts "Skipping bigmmap.test - requires SQLITE_MAX_MMAP_SIZE >= 8G"
37   finish_test
38   return
42 #-------------------------------------------------------------------------
43 # Create the database file roughly 8GiB in size. Most pages are unused,
44 # except that there is a table and index clustered around each 1GiB
45 # boundary.
47 do_execsql_test 1.0 {
48   PRAGMA page_size = 4096;
49   CREATE TABLE t0(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
50   WITH  s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 100 )
51   INSERT INTO t0 SELECT i, 't0', randomblob(800) FROM s;
54 for {set i 1} {$i < 8} {incr i} {
55   fake_big_file [expr $i*1024] [get_pwd]/test.db
56   hexio_write test.db 28 [format %.8x [expr ($i*1024*1024*1024/4096) - 5]]
58   do_execsql_test 1.$i "
59     CREATE TABLE t$i (a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
60     WITH  s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 100 )
61       INSERT INTO t$i SELECT i, 't$i', randomblob(800) FROM s;
62   "
65 #-------------------------------------------------------------------------
66 # Check that data can be retrieved from the db with a variety of 
67 # configured mmap size limits.
69 for {set i 0} {$i < 9} {incr i} {
71   # Configure a memory mapping $i GB in size.
72   #
73   set val [expr $i*1024*1024*1024]
74   execsql "PRAGMA main.mmap_size = $val"
75   do_execsql_test 2.$i.0 {
76     PRAGMA main.mmap_size
77   } $val
79   for {set t 0} {$t < 8} {incr t} {
80     do_execsql_test 2.$i.$t.1 "
81       SELECT count(*) FROM t$t;
82       SELECT count(b || c) FROM t$t GROUP BY b;
83     " {100 100}
84   
85     do_execsql_test 2.$i.$t.2 "
86       SELECT * FROM t$t AS o WHERE 
87         NOT EXISTS( SELECT * FROM t$t AS i WHERE a=o.a AND +b=o.b AND +c=o.c )
88       ORDER BY b, c;
89     " {}
90     
91     do_eqp_test 2.$i.$t.3 "
92       SELECT * FROM t$t AS o WHERE 
93         NOT EXISTS( SELECT * FROM t$t AS i WHERE a=o.a AND +b=o.b AND +c=o.c )
94       ORDER BY b, c;
95     " "
96       0 0 0 {SCAN TABLE t$t AS o USING COVERING INDEX sqlite_autoindex_t${t}_1}
97       0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 1}
98       1 0 0 {SEARCH TABLE t$t AS i USING INTEGER PRIMARY KEY (rowid=?)}
99     "
100   }
103 finish_test