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 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/malloc_common.tcl
20 set testprefix mmapfault
22 set a_string_counter 1
24 global a_string_counter
26 string range [string repeat "${a_string_counter}." $n] 1 $n
28 db func a_string a_string
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;
37 faultsim_save_and_close
41 do_faultsim_test 1 -prep {
42 faultsim_restore_and_reopen
43 db func a_string a_string
45 PRAGMA mmap_size = 1000000;
46 PRAGMA cache_size = 5;
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;
54 execsql { INSERT INTO t1 VALUES(a_string(200), a_string(300)) }
56 faultsim_test_result {0 {}}
58 if {[sqlite3_get_autocommit db]} {
60 set nRow [db2 one {SELECT count(*) FROM t1}]
61 if {$nRow!=4} { error "Database content appears incorrect (1)" }
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)"
71 catch { execsql COMMIT }