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 #***********************************************************************
12 # This file tests the effect of the mmap() or mremap() system calls
13 # returning an error on the library.
15 # If either mmap() or mremap() fails, SQLite should log an error
16 # message, then continue accessing the database using read() and
17 # write() exclusively.
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
25 source $testdir/lock_common.tcl
28 # Return a Tcl script that registers a user-defined scalar function
29 # named rblob() with database handle $dbname. The function returns a
30 # sequence of pseudo-random blobs based on seed value $seed.
32 proc register_rblob_code {dbname seed} {
33 return [subst -nocommands {
36 set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]
37 set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]]
38 string range [string repeat [set str] [expr [set n]/4]] 1 [set n]
40 $dbname func rblob rblob
44 #-------------------------------------------------------------------------
45 # Test various mmap_size settings.
47 foreach {tn1 mmap1 mmap2} {
60 do_multiclient_test tn {
62 CREATE TABLE t1(a PRIMARY KEY);
64 INSERT INTO t2 VALUES('');
67 code1 [register_rblob_code db 0]
68 code2 [register_rblob_code db2 444]
70 sql1 "PRAGMA mmap_size = $mmap1"
71 sql2 "PRAGMA mmap_size = $mmap2"
74 for {set i 1} {$i <= 100} {incr i} {
84 INSERT INTO t1 VALUES( rblob(5000) );
85 UPDATE t2 SET x = (SELECT md5sum(a) FROM t1);
89 SELECT count(*) FROM t1;
90 SELECT x == (SELECT md5sum(a) FROM t1) FROM t2;
91 PRAGMA integrity_check;
93 if {$res != [list $i 1 ok]} {