github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/mmapwarm.test (about) 1 # 20 September 18 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 # 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 16 17 if 0 { 18 db close 19 sqlite3_shutdown 20 proc msg {args} { puts $args } 21 test_sqlite3_log msg 22 sqlite3 db test.db 23 } 24 25 set testprefix mmapwarm 26 27 28 do_execsql_test 1.0 { 29 PRAGMA auto_vacuum = 0; 30 CREATE TABLE t1(x, y); 31 WITH s(i) AS ( 32 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500 33 ) 34 INSERT INTO t1 SELECT randomblob(400), randomblob(500) FROM s; 35 PRAGMA page_count; 36 } {507} 37 db close 38 39 do_test 1.1 { 40 sqlite3 db test.db 41 db eval {PRAGMA mmap_size = 1000000} 42 sqlite3_mmap_warm db 43 } {SQLITE_OK} 44 45 do_test 1.2 { 46 db close 47 sqlite3 db test.db 48 db eval {PRAGMA mmap_size = 1000000} 49 sqlite3_mmap_warm db "main" 50 } {SQLITE_OK} 51 52 do_test 1.3 { 53 sqlite3 db test.db 54 sqlite3_mmap_warm db 55 } {SQLITE_OK} 56 57 do_test 1.4 { 58 db close 59 sqlite3 db test.db 60 sqlite3_mmap_warm db "main" 61 } {SQLITE_OK} 62 63 do_test 2.0 { 64 db close 65 sqlite3 db test.db 66 db eval BEGIN 67 sqlite3_mmap_warm db "main" 68 } {SQLITE_MISUSE} 69 70 do_faultsim_test 3 -faults oom* -prep { 71 sqlite3 db test.db 72 sqlite3_db_config_lookaside db 0 0 0 73 db eval { PRAGMA mmap_size = 1000000 } 74 db eval { SELECT * FROM sqlite_master } 75 } -body { 76 sqlite3_mmap_warm db "main" 77 } -test { 78 faultsim_test_result {0 SQLITE_OK} {0 SQLITE_NOMEM} 79 } 80 81 finish_test