| OLD | NEW |
| 1 # 2010 May 03 | 1 # 2010 May 03 |
| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } -body { | 116 } -body { |
| 117 db eval { | 117 db eval { |
| 118 DELETE FROM abc; | 118 DELETE FROM abc; |
| 119 PRAGMA wal_checkpoint; | 119 PRAGMA wal_checkpoint; |
| 120 } | 120 } |
| 121 set {} {} | 121 set {} {} |
| 122 } -test { | 122 } -test { |
| 123 faultsim_test_result {0 {}} | 123 faultsim_test_result {0 {}} |
| 124 } | 124 } |
| 125 | 125 |
| 126 | |
| 127 #-------------------------------------------------------------------------- | 126 #-------------------------------------------------------------------------- |
| 128 # | 127 # |
| 129 if {[permutation] != "inmemory_journal"} { | 128 if {[permutation] != "inmemory_journal"} { |
| 130 faultsim_delete_and_reopen | 129 faultsim_delete_and_reopen |
| 131 faultsim_save_and_close | 130 faultsim_save_and_close |
| 132 do_faultsim_test walfault-4 -prep { | 131 do_faultsim_test walfault-4 -prep { |
| 133 faultsim_restore_and_reopen | 132 faultsim_restore_and_reopen |
| 134 } -body { | 133 } -body { |
| 135 execsql { | 134 execsql { |
| 136 PRAGMA auto_vacuum = 0; | 135 PRAGMA auto_vacuum = 0; |
| 137 PRAGMA journal_mode = WAL; | 136 PRAGMA journal_mode = WAL; |
| 138 CREATE TABLE t1(a PRIMARY KEY, b); | 137 CREATE TABLE t1(a PRIMARY KEY, b); |
| 139 INSERT INTO t1 VALUES('a', 'b'); | 138 INSERT INTO t1 VALUES('a', 'b'); |
| 140 PRAGMA wal_checkpoint; | 139 PRAGMA wal_checkpoint; |
| 141 SELECT * FROM t1; | 140 SELECT * FROM t1; |
| 142 } | 141 } |
| 143 } -test { | 142 } -test { |
| 144 faultsim_test_result {0 {wal 0 7 7 a b}} | 143 # Update: The following changed from {0 {wal 0 7 7 a b}} as a result |
| 144 # of PSOW being set by default. |
| 145 faultsim_test_result {0 {wal 0 5 5 a b}} |
| 145 faultsim_integrity_check | 146 faultsim_integrity_check |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| 149 #-------------------------------------------------------------------------- | 150 #-------------------------------------------------------------------------- |
| 150 # | 151 # |
| 151 do_test walfault-5-pre-1 { | 152 do_test walfault-5-pre-1 { |
| 152 faultsim_delete_and_reopen | 153 faultsim_delete_and_reopen |
| 153 execsql { | 154 execsql { |
| 154 PRAGMA page_size = 512; | 155 PRAGMA page_size = 512; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 execsql { | 459 execsql { |
| 459 PRAGMA journal_mode = WAL; | 460 PRAGMA journal_mode = WAL; |
| 460 PRAGMA wal_autocheckpoint = 0; | 461 PRAGMA wal_autocheckpoint = 0; |
| 461 BEGIN; | 462 BEGIN; |
| 462 CREATE TABLE abc(a PRIMARY KEY); | 463 CREATE TABLE abc(a PRIMARY KEY); |
| 463 INSERT INTO abc VALUES(randomblob(1500)); | 464 INSERT INTO abc VALUES(randomblob(1500)); |
| 464 INSERT INTO abc VALUES(randomblob(1500)); | 465 INSERT INTO abc VALUES(randomblob(1500)); |
| 465 COMMIT; | 466 COMMIT; |
| 466 } | 467 } |
| 467 faultsim_save_and_close | 468 faultsim_save_and_close |
| 468 file delete sv_test.db-shm | 469 delete_file sv_test.db-shm |
| 469 } {} | 470 } {} |
| 470 | 471 |
| 471 do_faultsim_test walfault-13.1 -prep { | 472 do_faultsim_test walfault-13.1 -prep { |
| 472 faultsim_restore_and_reopen | 473 faultsim_restore_and_reopen |
| 473 } -body { | 474 } -body { |
| 474 db eval { PRAGMA locking_mode = exclusive } | 475 db eval { PRAGMA locking_mode = exclusive } |
| 475 db eval { SELECT count(*) FROM abc } | 476 db eval { SELECT count(*) FROM abc } |
| 476 } -test { | 477 } -test { |
| 477 faultsim_test_result {0 2} | 478 faultsim_test_result {0 2} |
| 478 if {[file exists test.db-shm]} { error "Not using heap-memory mode" } | 479 if {[file exists test.db-shm]} { error "Not using heap-memory mode" } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 faultsim_save_and_close | 536 faultsim_save_and_close |
| 536 } {} | 537 } {} |
| 537 do_faultsim_test walfault-14 -prep { | 538 do_faultsim_test walfault-14 -prep { |
| 538 faultsim_restore_and_reopen | 539 faultsim_restore_and_reopen |
| 539 } -body { | 540 } -body { |
| 540 db eval { | 541 db eval { |
| 541 PRAGMA wal_checkpoint = full; | 542 PRAGMA wal_checkpoint = full; |
| 542 INSERT INTO abc VALUES(randomblob(1500)); | 543 INSERT INTO abc VALUES(randomblob(1500)); |
| 543 } | 544 } |
| 544 } -test { | 545 } -test { |
| 545 faultsim_test_result {0 {0 10 10}} | 546 faultsim_test_result {0 {0 9 9}} |
| 546 faultsim_integrity_check | 547 faultsim_integrity_check |
| 547 set nRow [db eval {SELECT count(*) FROM abc}] | 548 set nRow [db eval {SELECT count(*) FROM abc}] |
| 548 if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" } | 549 if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" } |
| 549 } | 550 } |
| 550 | 551 |
| 552 #------------------------------------------------------------------------- |
| 553 # Test fault-handling when switching out of exclusive-locking mode. |
| 554 # |
| 555 do_test walfault-14-pre { |
| 556 faultsim_delete_and_reopen |
| 557 execsql { |
| 558 PRAGMA auto_vacuum = 0; |
| 559 PRAGMA journal_mode = WAL; |
| 560 BEGIN; |
| 561 CREATE TABLE abc(a PRIMARY KEY); |
| 562 INSERT INTO abc VALUES(randomblob(1500)); |
| 563 INSERT INTO abc VALUES(randomblob(1500)); |
| 564 COMMIT; |
| 565 } |
| 566 faultsim_save_and_close |
| 567 } {} |
| 568 do_faultsim_test walfault-14 -prep { |
| 569 faultsim_restore_and_reopen |
| 570 execsql { |
| 571 SELECT count(*) FROM abc; |
| 572 PRAGMA locking_mode = exclusive; |
| 573 BEGIN; |
| 574 INSERT INTO abc VALUES(randomblob(1500)); |
| 575 COMMIT; |
| 576 } |
| 577 } -body { |
| 578 db eval { |
| 579 PRAGMA locking_mode = normal; |
| 580 BEGIN; |
| 581 INSERT INTO abc VALUES(randomblob(1500)); |
| 582 COMMIT; |
| 583 } |
| 584 } -test { |
| 585 faultsim_integrity_check |
| 586 set nRow [db eval {SELECT count(*) FROM abc}] |
| 587 if {$nRow!=3 && $nRow!=4} { error "Bad db content" } |
| 588 } |
| 589 |
| 551 finish_test | 590 finish_test |
| OLD | NEW |