Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/mmapfault.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / mmapfault.test` 76 lines ยท 2014 bytes Raw Blame History 1 # 2013-05-23 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 source $testdir/malloc_common.tcl 16 ifcapable !mmap { 17 finish_test 18 return 19 } 20 set testprefix mmapfault 21 22 set a_string_counter 1 23 proc a_string {n} { 24 global a_string_counter 25 incr a_string_counter 26 string range [string repeat "${a_string_counter}." $n] 1 $n 27 } 28 db func a_string a_string 29 30 do_test 1-pre { 31 execsql { 32 CREATE TABLE t1(a UNIQUE, b UNIQUE); 33 INSERT INTO t1 VALUES(a_string(200), a_string(300)); 34 INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1; 35 INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1; 36 } 37 faultsim_save_and_close 38 } {} 39 40 41 do_faultsim_test 1 -prep { 42 faultsim_restore_and_reopen 43 db func a_string a_string 44 execsql { 45 PRAGMA mmap_size = `1000000`; 46 PRAGMA cache_size = 5; 47 BEGIN; 48 INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1; 49 INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1; 50 INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1; 51 INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1; 52 } 53 } -body { 54 execsql { INSERT INTO t1 VALUES(a_string(200), a_string(300)) } 55 } -test { 56 faultsim_test_result {0 {}} 57 58 if {[sqlite3_get_autocommit db]} { 59 sqlite3 db2 test.db 60 set nRow [db2 one {SELECT count(*) FROM t1}] 61 if {$nRow!=4} { error "Database content appears incorrect (1)" } 62 db2 close 63 } 64 65 execsql { INSERT INTO t1 VALUES(a_string(201), a_string(301)) } 66 set nRow [db one {SELECT count(*) FROM t1}] 67 if {$nRow!=5 && $nRow!=66 && $nRow!=65} { 68 error "Database content appears incorrect (2) ($nRow)" 69 } 70 71 catch { execsql COMMIT } 72 } 73 74 75 76 finish_test