/ Check-in [17447062]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add new test file "bigmmap.test". For testing builds with -DSQLITE_MAX_MMAP_SIZE > 2GB.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 17447062799239ee978bedbf7fcc67f4c7d2cad2e82dcf9349a966fc8f67d390
User & Date: dan 2017-08-07 17:14:30
Context
2017-08-07
17:28
Fix an out-of-order test number. check-in: 38f30091 user: mistachkin tags: trunk
17:14
Add new test file "bigmmap.test". For testing builds with -DSQLITE_MAX_MMAP_SIZE > 2GB. check-in: 17447062 user: dan tags: trunk
2017-08-05
16:15
Fix a segfault in swarmvtab that could occur if there was an error in the SQL statement passed to the constructor. Add other test cases. check-in: 6ce8b7ca user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/bigmmap.test.

            1  +# 2017 August 07
            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.  The
           12  +# focus of this script testing the ability of SQLite to use mmap
           13  +# to access files larger than 4GiB.
           14  +#
           15  +
           16  +if {[file exists skip-big-file]} return
           17  +if {$tcl_platform(os)=="Darwin"} return
           18  +
           19  +set testdir [file dirname $argv0]
           20  +source $testdir/tester.tcl
           21  +set testprefix bigmmap
           22  +
           23  +ifcapable !mmap {
           24  +  finish_test
           25  +  return
           26  +}
           27  +
           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=(.*)} $x -> mmap_limit
           34  +}
           35  +if {$mmap_limit < [expr 8 * 1<<30]} {
           36  +  puts "Skipping bigmmap.test - requires SQLITE_MAX_MMAP_SIZE >= 8G"
           37  +  finish_test
           38  +  return
           39  +}
           40  +
           41  +
           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.
           46  +#
           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;
           52  +}
           53  +
           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]]
           57  +
           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  +  "
           63  +}
           64  +
           65  +#-------------------------------------------------------------------------
           66  +# Check that data can be retrieved from the db with a variety of 
           67  +# configured mmap size limits.
           68  +#
           69  +for {set i 0} {$i < 9} {incr i} {
           70  +
           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
           78  +
           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  +  }
          101  +}
          102  +
          103  +finish_test
          104  +