OLD | NEW |
1 # 2013 March 20 | 1 # 2013 March 20 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 15 matching lines...) Expand all Loading... |
26 db_leave $db | 26 db_leave $db |
27 # puts [array get stats] | 27 # puts [array get stats] |
28 return $stats(read) | 28 return $stats(read) |
29 } | 29 } |
30 | 30 |
31 proc register_rblob_code {dbname seed} { | 31 proc register_rblob_code {dbname seed} { |
32 return [subst -nocommands { | 32 return [subst -nocommands { |
33 set ::rcnt $seed | 33 set ::rcnt $seed |
34 proc rblob {n} { | 34 proc rblob {n} { |
35 set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF] | 35 set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF] |
36 set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]] | 36 set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]] |
37 string range [string repeat [set str] [expr [set n]/4]] 1 [set n] | 37 string range [string repeat [set str] [expr [set n]/4]] 1 [set n] |
38 } | 38 } |
39 $dbname func rblob rblob | 39 $dbname func rblob rblob |
40 }] | 40 }] |
41 } | 41 } |
42 | 42 |
43 # For cases 1.1 and 1.4, the number of pages read using xRead() is 4 on | 43 # For cases 1.1 and 1.4, the number of pages read using xRead() is 4 on |
44 # unix and 9 on windows. The difference is that windows only ever maps | 44 # unix and 9 on windows. The difference is that windows only ever maps |
45 # an integer number of OS pages (i.e. creates mappings that are a multiple | 45 # an integer number of OS pages (i.e. creates mappings that are a multiple |
46 # of 4KB in size). Whereas on unix any sized mapping may be created. | 46 # of 4KB in size). Whereas on unix any sized mapping may be created. |
47 # | 47 # |
48 foreach {t mmap_size nRead c2init} { | 48 foreach {t mmap_size nRead c2init} { |
49 1.1 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 0} | 49 1.1 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 0} |
50 1.2 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 0} | 50 1.2 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 0} |
51 1.3 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 0} | 51 1.3 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 0} |
52 1.4 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 67108864 } | 52 1.4 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 67108864 } |
53 1.5 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 67108864 } | 53 1.5 { PRAGMA mmap_size = 53248 } 150 {PRAGMA mmap_size = 67108864 } |
54 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 67108864 } | 54 1.6 { PRAGMA mmap_size = 0 } 344 {PRAGMA mmap_size = 67108864 } |
55 } { | 55 } { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 # Check that the number of pages read by connection 1 indicates that the | 100 # Check that the number of pages read by connection 1 indicates that the |
101 # "PRAGMA mmap_size" command worked. | 101 # "PRAGMA mmap_size" command worked. |
102 do_test $t.$tn.5 { nRead db } $nRead | 102 do_test $t.$tn.5 { nRead db } $nRead |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 set ::rcnt 0 | 106 set ::rcnt 0 |
107 proc rblob {n} { | 107 proc rblob {n} { |
108 set ::rcnt [expr (($::rcnt << 3) + $::rcnt + 456) & 0xFFFFFFFF] | 108 set ::rcnt [expr (($::rcnt << 3) + $::rcnt + 456) & 0xFFFFFFFF] |
109 set str [format %.8x [expr $::rcnt ^ 0xbdf20da3]] | 109 set str [format %.8x [expr $::rcnt ^ 0xbdf20da3]] |
110 string range [string repeat $str [expr $n/4]] 1 $n | 110 string range [string repeat $str [expr $n/4]] 1 $n |
111 } | 111 } |
112 | 112 |
113 reset_db | 113 reset_db |
114 db func rblob rblob | 114 db func rblob rblob |
115 | 115 |
116 do_execsql_test 2.1 { | 116 ifcapable wal { |
117 PRAGMA auto_vacuum = 1; | 117 do_execsql_test 2.1 { |
118 PRAGMA mmap_size = 67108864; | 118 PRAGMA auto_vacuum = 1; |
119 PRAGMA journal_mode = wal; | 119 PRAGMA mmap_size = 67108864; |
120 CREATE TABLE t1(a, b, UNIQUE(a, b)); | 120 PRAGMA journal_mode = wal; |
121 INSERT INTO t1 VALUES(rblob(500), rblob(500)); | 121 CREATE TABLE t1(a, b, UNIQUE(a, b)); |
122 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 2 | 122 INSERT INTO t1 VALUES(rblob(500), rblob(500)); |
123 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 4 | 123 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 2 |
124 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 8 | 124 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 4 |
125 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16 | 125 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 8 |
126 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 32 | 126 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16 |
127 PRAGMA wal_checkpoint; | 127 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 32 |
128 } {67108864 wal 0 103 103} | 128 PRAGMA wal_checkpoint; |
| 129 } {67108864 wal 0 103 103} |
129 | 130 |
130 do_execsql_test 2.2 { | 131 do_execsql_test 2.2 { |
131 PRAGMA auto_vacuum; | 132 PRAGMA auto_vacuum; |
132 SELECT count(*) FROM t1; | 133 SELECT count(*) FROM t1; |
133 } {1 32} | 134 } {1 32} |
134 | 135 |
135 if {[permutation] != "inmemory_journal"} { | 136 if {[permutation] != "inmemory_journal"} { |
136 do_test 2.3 { | 137 do_test 2.3 { |
137 sqlite3 db2 test.db | 138 sqlite3 db2 test.db |
138 db2 func rblob rblob | 139 db2 func rblob rblob |
139 db2 eval { | 140 db2 eval { |
140 DELETE FROM t1 WHERE (rowid%4); | 141 DELETE FROM t1 WHERE (rowid%4); |
141 PRAGMA wal_checkpoint; | 142 PRAGMA wal_checkpoint; |
142 } | 143 } |
143 db2 eval { | 144 db2 eval { |
144 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16 | 145 INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; -- 16 |
145 SELECT count(*) FROM t1; | 146 SELECT count(*) FROM t1; |
146 } | 147 } |
147 } {16} | 148 } {16} |
148 | 149 |
149 do_execsql_test 2.4 { | 150 do_execsql_test 2.4 { |
150 PRAGMA wal_checkpoint; | 151 PRAGMA wal_checkpoint; |
151 } {0 24 24} | 152 } {0 24 24} |
152 db2 close | 153 db2 close |
| 154 } |
153 } | 155 } |
154 | 156 |
155 reset_db | 157 reset_db |
156 execsql { PRAGMA mmap_size = 67108864; } | 158 execsql { PRAGMA mmap_size = 67108864; } |
157 db func rblob rblob | 159 db func rblob rblob |
158 do_execsql_test 3.1 { | 160 do_execsql_test 3.1 { |
159 PRAGMA auto_vacuum = 1; | 161 PRAGMA auto_vacuum = 1; |
160 | 162 |
161 CREATE TABLE t1(a, b, UNIQUE(a, b)); | 163 CREATE TABLE t1(a, b, UNIQUE(a, b)); |
162 INSERT INTO t1 VALUES(rblob(500), rblob(500)); | 164 INSERT INTO t1 VALUES(rblob(500), rblob(500)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 set res | 222 set res |
221 } [list $eee $eee $eee] | 223 } [list $eee $eee $eee] |
222 | 224 |
223 do_test 4.4 { | 225 do_test 4.4 { |
224 sqlite3_finalize $::STMT | 226 sqlite3_finalize $::STMT |
225 } SQLITE_OK | 227 } SQLITE_OK |
226 | 228 |
227 do_execsql_test 4.5 { COMMIT } | 229 do_execsql_test 4.5 { COMMIT } |
228 | 230 |
229 #------------------------------------------------------------------------- | 231 #------------------------------------------------------------------------- |
230 # Ensure that existing cursors holding xFetch() references are not | 232 # Ensure that existing cursors holding xFetch() references are not |
231 # confused if those pages are moved to make way for the root page of a | 233 # confused if those pages are moved to make way for the root page of a |
232 # new table or index. | 234 # new table or index. |
233 # | 235 # |
234 reset_db | 236 reset_db |
235 execsql { PRAGMA mmap_size = 67108864; } | 237 execsql { PRAGMA mmap_size = 67108864; } |
236 do_execsql_test 5.1 { | 238 do_execsql_test 5.1 { |
237 PRAGMA auto_vacuum = 2; | 239 PRAGMA auto_vacuum = 2; |
238 PRAGMA page_size = 1024; | 240 PRAGMA page_size = 1024; |
239 CREATE TABLE t1(x); | 241 CREATE TABLE t1(x); |
240 INSERT INTO t1 VALUES($aaa); | 242 INSERT INTO t1 VALUES($aaa); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 CREATE TABLE t2(x); | 291 CREATE TABLE t2(x); |
290 INSERT INTO t2 VALUES(''); | 292 INSERT INTO t2 VALUES(''); |
291 } | 293 } |
292 | 294 |
293 code1 [register_rblob_code db 0] | 295 code1 [register_rblob_code db 0] |
294 code2 [register_rblob_code db2 444] | 296 code2 [register_rblob_code db2 444] |
295 | 297 |
296 sql1 "PRAGMA mmap_size = $mmap1" | 298 sql1 "PRAGMA mmap_size = $mmap1" |
297 sql2 "PRAGMA mmap_size = $mmap2" | 299 sql2 "PRAGMA mmap_size = $mmap2" |
298 | 300 |
299 do_test $tn1.$tn { | 301 do_test $tn1.$tn { |
300 for {set i 1} {$i <= 100} {incr i} { | 302 for {set i 1} {$i <= 100} {incr i} { |
301 if {$i % 2} { | 303 if {$i % 2} { |
302 set c1 sql1 | 304 set c1 sql1 |
303 set c2 sql2 | 305 set c2 sql2 |
304 } else { | 306 } else { |
305 set c1 sql2 | 307 set c1 sql2 |
306 set c2 sql1 | 308 set c2 sql1 |
307 } | 309 } |
308 | 310 |
309 $c1 { | 311 $c1 { |
310 INSERT INTO t1 VALUES( rblob(5000) ); | 312 INSERT INTO t1 VALUES( rblob(5000) ); |
311 UPDATE t2 SET x = (SELECT md5sum(a) FROM t1); | 313 UPDATE t2 SET x = (SELECT md5sum(a) FROM t1); |
312 } | 314 } |
313 | 315 |
314 set res [$c2 { | 316 set res [$c2 { |
315 SELECT count(*) FROM t1; | 317 SELECT count(*) FROM t1; |
316 SELECT x == (SELECT md5sum(a) FROM t1) FROM t2; | 318 SELECT x == (SELECT md5sum(a) FROM t1) FROM t2; |
317 PRAGMA integrity_check; | 319 PRAGMA integrity_check; |
318 }] | 320 }] |
319 if {$res != [list $i 1 ok]} { | 321 if {$res != [list $i 1 ok]} { |
320 do_test $tn1.$tn.$i { | 322 do_test $tn1.$tn.$i { |
321 set ::res | 323 set ::res |
322 } [list $i 1 ok] | 324 } [list $i 1 ok] |
323 } | 325 } |
324 } | 326 } |
325 set res 1 | 327 set res 1 |
326 } {1} | 328 } {1} |
327 } | 329 } |
328 } | 330 } |
329 | 331 |
330 | 332 |
331 finish_test | 333 finish_test |
OLD | NEW |