| OLD | NEW |
| 1 # 2010 April 13 | 1 # 2010 April 13 |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 if {$P(seconds) == 0} { | 124 if {$P(seconds) == 0} { |
| 125 puts "Skipping $P(testname)" | 125 puts "Skipping $P(testname)" |
| 126 return | 126 return |
| 127 } | 127 } |
| 128 | 128 |
| 129 puts "Running $P(testname) for $P(seconds) seconds..." | 129 puts "Running $P(testname) for $P(seconds) seconds..." |
| 130 | 130 |
| 131 catch { db close } | 131 catch { db close } |
| 132 file delete -force test.db test.db-journal test.db-wal | 132 forcedelete test.db test.db-journal test.db-wal |
| 133 | 133 |
| 134 sqlite3 db test.db | 134 sqlite3 db test.db |
| 135 eval $P(init) | 135 eval $P(init) |
| 136 catch { db close } | 136 catch { db close } |
| 137 | 137 |
| 138 foreach T $P(threads) { | 138 foreach T $P(threads) { |
| 139 set name [lindex $T 0] | 139 set name [lindex $T 0] |
| 140 set count [lindex $T 1] | 140 set count [lindex $T 1] |
| 141 set prg [lindex $T 2] | 141 set prg [lindex $T 2] |
| 142 | 142 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 || [lindex $results 1] != [lindex $results 2] | 270 || [lindex $results 1] != [lindex $results 2] |
| 271 || [lindex $results 2] != [lindex $results 3] | 271 || [lindex $results 2] != [lindex $results 3] |
| 272 } { | 272 } { |
| 273 error "Failed read transaction: $results" | 273 error "Failed read transaction: $results" |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 proc write_transaction {} { | 277 proc write_transaction {} { |
| 278 db eval { | 278 db eval { |
| 279 BEGIN; | 279 BEGIN; |
| 280 INSERT INTO t1 VALUES(randomblob(100)); | 280 INSERT INTO t1 VALUES(randomblob(101 + $::E(pid))); |
| 281 INSERT INTO t1 VALUES(randomblob(100)); | 281 INSERT INTO t1 VALUES(randomblob(101 + $::E(pid))); |
| 282 INSERT INTO t1 SELECT md5sum(x) FROM t1; | 282 INSERT INTO t1 SELECT md5sum(x) FROM t1; |
| 283 COMMIT; | 283 COMMIT; |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 # Turn off auto-checkpoint. Otherwise, an auto-checkpoint run by a | 287 # Turn off auto-checkpoint. Otherwise, an auto-checkpoint run by a |
| 288 # writer may cause the dedicated checkpoint thread to return an | 288 # writer may cause the dedicated checkpoint thread to return an |
| 289 # SQLITE_BUSY error. | 289 # SQLITE_BUSY error. |
| 290 # | 290 # |
| 291 db eval { PRAGMA wal_autocheckpoint = 0 } | 291 db eval { PRAGMA wal_autocheckpoint = 0 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 1024 */ | 501 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 1024 */ |
| 502 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2048 */ | 502 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2048 */ |
| 503 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4096 */ | 503 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4096 */ |
| 504 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8192 */ | 504 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8192 */ |
| 505 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16384 */ | 505 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16384 */ |
| 506 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32768 */ | 506 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32768 */ |
| 507 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 65536 */ | 507 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 65536 */ |
| 508 COMMIT; | 508 COMMIT; |
| 509 } | 509 } |
| 510 | 510 |
| 511 file copy -force test.db-wal bak.db-wal | 511 forcecopy test.db-wal bak.db-wal |
| 512 file copy -force test.db bak.db | 512 forcecopy test.db bak.db |
| 513 db close | 513 db close |
| 514 | 514 |
| 515 file copy -force bak.db-wal test.db-wal | 515 forcecopy bak.db-wal test.db-wal |
| 516 file copy -force bak.db test.db | 516 forcecopy bak.db test.db |
| 517 | 517 |
| 518 if {[file size test.db-wal] < [log_file_size [expr 64*1024] 1024]} { | 518 if {[file size test.db-wal] < [log_file_size [expr 64*1024] 1024]} { |
| 519 error "Somehow failed to create a large log file" | 519 error "Somehow failed to create a large log file" |
| 520 } | 520 } |
| 521 puts "Database with large log file recovered. Now running clients..." | 521 puts "Database with large log file recovered. Now running clients..." |
| 522 } -thread T 5 { | 522 } -thread T 5 { |
| 523 db eval { SELECT count(*) FROM t1 } | 523 db eval { SELECT count(*) FROM t1 } |
| 524 } | 524 } |
| 525 unset -nocomplain seconds | 525 unset -nocomplain seconds |
| 526 | 526 |
| 527 finish_test | 527 finish_test |
| OLD | NEW |