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 #***********************************************************************
13 source [file join [file dirname [info script]] recover_common.tcl]
14 set testprefix recovercorrupt4
16 database_may_be_corrupt
18 if {[permutation]!="inmemory_journal"} {
19 # This test cannot be run with the inmemory_journal permutation, as it
20 # must open a truncated, corrupt, database file. With the inmemory_journal
21 # permutation, this fails (SQLITE_CORRUPT error) when the [sqlite3] wrapper
22 # executes "PRAGMA journal_mode = memory".
24 CREATE TABLE rows(indexed INTEGER NOT NULL, unindexed INTEGER NOT NULL, filler BLOB NOT NULL DEFAULT 13);
25 -- CREATE UNIQUE INDEX rows_index ON rows(indexed);
26 INSERT INTO rows(indexed, unindexed, filler) VALUES(1, 1, x'31');
27 INSERT INTO rows(indexed, unindexed, filler) VALUES(2, 2, x'32');
28 INSERT INTO rows(indexed, unindexed, filler) VALUES(4, 4, x'34');
29 INSERT INTO rows(indexed, unindexed, filler) VALUES(8, 8, randomblob(2048));
35 set sz [expr [file size test.db] - 1024]
37 fconfigure $fd -encoding binary -translation binary
39 set data [read $fd $sz]
40 set fd2 [open test.db2 w]
41 fconfigure $fd2 -encoding binary -translation binary
42 puts -nonewline $fd2 $data
50 set R [sqlite3_recover_init db main test.db3]
58 SELECT indexed, unindexed FROM rows