| 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 #*********************************************************************** |
| 11 # This file implements regression tests for SQLite library. The | 11 # This file implements regression tests for SQLite library. The |
| 12 # focus of this file is testing the operation of "blocking-checkpoint" | 12 # focus of this file is testing the operation of "blocking-checkpoint" |
| 13 # operations. | 13 # operations. |
| 14 # | 14 # |
| 15 | 15 |
| 16 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
| 17 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
| 18 source $testdir/lock_common.tcl | 18 source $testdir/lock_common.tcl |
| 19 source $testdir/wal_common.tcl | 19 source $testdir/wal_common.tcl |
| 20 ifcapable !wal {finish_test ; return } | 20 ifcapable !wal {finish_test ; return } |
| 21 do_not_use_codec |
| 21 | 22 |
| 22 set testprefix wal5 | 23 set testprefix wal5 |
| 23 | 24 |
| 24 proc db_page_count {{file test.db}} { expr [file size $file] / 1024 } | 25 proc db_page_count {{file test.db}} { expr [file size $file] / 1024 } |
| 25 proc wal_page_count {{file test.db}} { wal_frame_count ${file}-wal 1024 } | 26 proc wal_page_count {{file test.db}} { wal_frame_count ${file}-wal 1024 } |
| 26 | 27 |
| 27 | 28 |
| 28 # A checkpoint may be requested either using the C API or by executing | 29 # A checkpoint may be requested either using the C API or by executing |
| 29 # an SQL PRAGMA command. To test both methods, all tests in this file are | 30 # an SQL PRAGMA command. To test both methods, all tests in this file are |
| 30 # run twice - once using each method to request checkpoints. | 31 # run twice - once using each method to request checkpoints. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } {6 12 6} | 134 } {6 12 6} |
| 134 do_test 1.$tn.6 { | 135 do_test 1.$tn.6 { |
| 135 set ::nBusyHandler 0 | 136 set ::nBusyHandler 0 |
| 136 sql1 { INSERT INTO t1 VALUES(5, zeroblob(1200)) } | 137 sql1 { INSERT INTO t1 VALUES(5, zeroblob(1200)) } |
| 137 list [db_page_count] [wal_page_count] $::nBusyHandler | 138 list [db_page_count] [wal_page_count] $::nBusyHandler |
| 138 } {6 12 0} | 139 } {6 12 0} |
| 139 | 140 |
| 140 do_test 1.$tn.7 { | 141 do_test 1.$tn.7 { |
| 141 reopen_all | 142 reopen_all |
| 142 list [db_page_count] [wal_page_count] $::nBusyHandler | 143 list [db_page_count] [wal_page_count] $::nBusyHandler |
| 143 } {7 0 0} | 144 } [expr {[nonzero_reserved_bytes]?"/# # 0/":"7 0 0"}] |
| 144 | 145 |
| 145 do_test 1.$tn.8 { sql2 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5} | 146 do_test 1.$tn.8 { sql2 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5} |
| 146 do_test 1.$tn.9 { | 147 do_test 1.$tn.9 { |
| 147 sql1 { INSERT INTO t1 VALUES(6, zeroblob(1200)) } | 148 sql1 { INSERT INTO t1 VALUES(6, zeroblob(1200)) } |
| 148 list [db_page_count] [wal_page_count] $::nBusyHandler | 149 list [db_page_count] [wal_page_count] $::nBusyHandler |
| 149 } {7 5 0} | 150 } [expr {[nonzero_reserved_bytes]?"/# # #/":"7 5 0"}] |
| 150 do_test 1.$tn.10 { sql3 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5 6} | 151 do_test 1.$tn.10 { sql3 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5 6} |
| 151 | 152 |
| 152 set ::busy_handler_script { | 153 set ::busy_handler_script { |
| 153 if {$n==5} { sql2 COMMIT } | 154 if {$n==5} { sql2 COMMIT } |
| 154 if {$n==6} { set ::db_file_size [db_page_count] } | 155 if {$n==6} { set ::db_file_size [db_page_count] } |
| 155 if {$n==7} { sql3 COMMIT } | 156 if {$n==7} { sql3 COMMIT } |
| 156 } | 157 } |
| 157 do_test 1.$tn.11 { | 158 do_test 1.$tn.11 { |
| 158 code1 { do_wal_checkpoint db -mode restart } | 159 code1 { do_wal_checkpoint db -mode restart } |
| 159 list [db_page_count] [wal_page_count] $::nBusyHandler | 160 list [db_page_count] [wal_page_count] $::nBusyHandler |
| 160 } {10 5 8} | 161 } [expr {[nonzero_reserved_bytes]?"/# # #/":"10 5 8"}] |
| 161 do_test 1.$tn.12 { set ::db_file_size } 10 | 162 do_test 1.$tn.12 { set ::db_file_size } 10 |
| 162 } | 163 } |
| 163 | 164 |
| 164 #------------------------------------------------------------------------- | 165 #------------------------------------------------------------------------- |
| 165 # This block of tests explores checkpoint operations on more than one | 166 # This block of tests explores checkpoint operations on more than one |
| 166 # database file. | 167 # database file. |
| 167 # | 168 # |
| 168 proc setup_and_attach_aux {} { | 169 proc setup_and_attach_aux {} { |
| 169 sql1 { ATTACH 'test.db2' AS aux } | 170 sql1 { ATTACH 'test.db2' AS aux } |
| 170 sql2 { ATTACH 'test.db2' AS aux } | 171 sql2 { ATTACH 'test.db2' AS aux } |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 do_test 5.$tn.19 { file size test.db-wal } [wal_file_size 4 1024] | 469 do_test 5.$tn.19 { file size test.db-wal } [wal_file_size 4 1024] |
| 469 | 470 |
| 470 do_test 5.$tn.20 { do_wal_checkpoint db -mode truncate } {0 0 0} | 471 do_test 5.$tn.20 { do_wal_checkpoint db -mode truncate } {0 0 0} |
| 471 do_test 5.$tn.21 { file size test.db-wal } 0 | 472 do_test 5.$tn.21 { file size test.db-wal } 0 |
| 472 } | 473 } |
| 473 | 474 |
| 474 } | 475 } |
| 475 | 476 |
| 476 | 477 |
| 477 finish_test | 478 finish_test |
| OLD | NEW |