| OLD | NEW |
| 1 # 2001 September 15 | 1 # 2001 September 15 |
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 DELETE FROM abc WHERE a = 4; | 112 DELETE FROM abc WHERE a = 4; |
| 113 } | 113 } |
| 114 } {0 {}} | 114 } {0 {}} |
| 115 do_test crash-1.11 { | 115 do_test crash-1.11 { |
| 116 catchsql { | 116 catchsql { |
| 117 SELECT * FROM abc; | 117 SELECT * FROM abc; |
| 118 } | 118 } |
| 119 } {0 {}} | 119 } {0 {}} |
| 120 | 120 |
| 121 #-------------------------------------------------------------------------- | 121 #-------------------------------------------------------------------------- |
| 122 # The following tests test recovery when both the database file and the the | 122 # The following tests test recovery when both the database file and the |
| 123 # journal file contain corrupt data. This can happen after pages are | 123 # journal file contain corrupt data. This can happen after pages are |
| 124 # written to the database file before a transaction is committed due to | 124 # written to the database file before a transaction is committed due to |
| 125 # cache-pressure. | 125 # cache-pressure. |
| 126 # | 126 # |
| 127 # crash-2.1: Insert 18 pages of data into the database. | 127 # crash-2.1: Insert 18 pages of data into the database. |
| 128 # crash-2.2: Check the database file size looks ok. | 128 # crash-2.2: Check the database file size looks ok. |
| 129 # crash-2.3: Delete 15 or so pages (with a 10 page page-cache), then crash. | 129 # crash-2.3: Delete 15 or so pages (with a 10 page page-cache), then crash. |
| 130 # crash-2.4: Ensure the database is in the same state as after crash-2.1. | 130 # crash-2.4: Ensure the database is in the same state as after crash-2.1. |
| 131 # | 131 # |
| 132 # Test cases crash-2.5 and crash-2.6 check that the database is OK if the | 132 # Test cases crash-2.5 and crash-2.6 check that the database is OK if the |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 # | 208 # |
| 209 # crash-4.1.*: Test recovery when crash occurs during sync() of the | 209 # crash-4.1.*: Test recovery when crash occurs during sync() of the |
| 210 # main database journal file. | 210 # main database journal file. |
| 211 # crash-4.2.*: Test recovery when crash occurs during sync() of an | 211 # crash-4.2.*: Test recovery when crash occurs during sync() of an |
| 212 # attached database journal file. | 212 # attached database journal file. |
| 213 # crash-4.3.*: Test recovery when crash occurs during sync() of the master | 213 # crash-4.3.*: Test recovery when crash occurs during sync() of the master |
| 214 # journal file. | 214 # journal file. |
| 215 # | 215 # |
| 216 ifcapable attach { | 216 ifcapable attach { |
| 217 do_test crash-4.0 { | 217 do_test crash-4.0 { |
| 218 file delete -force test2.db | 218 forcedelete test2.db |
| 219 file delete -force test2.db-journal | 219 forcedelete test2.db-journal |
| 220 execsql { | 220 execsql { |
| 221 ATTACH 'test2.db' AS aux; | 221 ATTACH 'test2.db' AS aux; |
| 222 PRAGMA aux.default_cache_size = 10; | 222 PRAGMA aux.default_cache_size = 10; |
| 223 CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc; | 223 CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc; |
| 224 } | 224 } |
| 225 expr ([file size test2.db] / 1024) > 450 | 225 expr ([file size test2.db] / 1024) > 450 |
| 226 } {1} | 226 } {1} |
| 227 | 227 |
| 228 set fin 0 | 228 set fin 0 |
| 229 for {set i 1} {$i<$repeats} {incr i} { | 229 for {set i 1} {$i<$repeats} {incr i} { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 #-------------------------------------------------------------------------- | 314 #-------------------------------------------------------------------------- |
| 315 # The following test cases - crash-5.* - exposes a bug that existed in the | 315 # The following test cases - crash-5.* - exposes a bug that existed in the |
| 316 # sqlite3pager_movepage() API used by auto-vacuum databases. | 316 # sqlite3pager_movepage() API used by auto-vacuum databases. |
| 317 # database when a crash occurs during a multi-file transaction. See comments | 317 # database when a crash occurs during a multi-file transaction. See comments |
| 318 # in test crash-5.3 for details. | 318 # in test crash-5.3 for details. |
| 319 # | 319 # |
| 320 db close | 320 db close |
| 321 file delete -force test.db | 321 forcedelete test.db |
| 322 sqlite3 db test.db | 322 sqlite3 db test.db |
| 323 do_test crash-5.1 { | 323 do_test crash-5.1 { |
| 324 execsql { | 324 execsql { |
| 325 CREATE TABLE abc(a, b, c); -- Root page 3 | 325 CREATE TABLE abc(a, b, c); -- Root page 3 |
| 326 INSERT INTO abc VALUES(randstr(1500,1500), 0, 0); -- Overflow page 4 | 326 INSERT INTO abc VALUES(randstr(1500,1500), 0, 0); -- Overflow page 4 |
| 327 INSERT INTO abc SELECT * FROM abc; | 327 INSERT INTO abc SELECT * FROM abc; |
| 328 INSERT INTO abc SELECT * FROM abc; | 328 INSERT INTO abc SELECT * FROM abc; |
| 329 INSERT INTO abc SELECT * FROM abc; | 329 INSERT INTO abc SELECT * FROM abc; |
| 330 } | 330 } |
| 331 } {} | 331 } {} |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 fconfigure $f -encoding binary | 402 fconfigure $f -encoding binary |
| 403 seek $f [expr [file size test.db-journal] - 12] | 403 seek $f [expr [file size test.db-journal] - 12] |
| 404 puts -nonewline $f "\00\00\00\00" | 404 puts -nonewline $f "\00\00\00\00" |
| 405 close $f | 405 close $f |
| 406 } {} | 406 } {} |
| 407 do_test crash-7.2 { | 407 do_test crash-7.2 { |
| 408 signature | 408 signature |
| 409 } $sig | 409 } $sig |
| 410 | 410 |
| 411 finish_test | 411 finish_test |
| OLD | NEW |