3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # This script attempts to reproduce the circumstances of ticket #2565.
14 # More specifically, this script attempts to generate rollback journals
15 # that contain headers with nRec==0 that are followed by additional
18 # $Id: tkt2565.test,v 1.2 2009/04/09 01:23:49 drh Exp $
20 set testdir [file dirname $argv0]
21 source $testdir/tester.tcl
23 # Use the alternative pcache and rig it to call pagerStress()
28 sqlite3_config_alt_pcache 1 100 0 1
30 # Open two database connections to database "test.db".
32 proc reopen_database {} {
43 # Open two database connections and create a single table in the db.
47 execsql { CREATE TABLE A(Id INTEGER, Name TEXT) }
50 for {set iFail 1} {$iFail<200} {incr iFail} {
52 execsql { pragma locking_mode=exclusive }
53 set nRow [db one {SELECT count(*) FROM a}]
55 # Dirty (at least) one of the pages in the cache.
56 do_test tkt2565-1.$iFail.1 {
59 INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');
63 # Now try to commit the transaction. Cause an IO error to occur
64 # within this operation, which moves the pager into the error state.
66 set ::sqlite_io_error_persist 1
67 set ::sqlite_io_error_pending $iFail
68 do_test tkt2565-1.$iFail.2 {
69 set rc [catchsql {COMMIT}]
72 set ::sqlite_io_error_persist 0
73 set ::sqlite_io_error_pending 0
74 if {!$::sqlite_io_error_hit} break
75 set ::sqlite_io_error_hit 0
78 # Make sure this test script doesn't leave any files open.
82 set sqlite_open_file_count
85 # Restore the pcache configuration for subsequent tests.
88 sqlite3_config_alt_pcache 0
90 autoinstall_test_functions