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 recoverfault
17 #--------------------------------------------------------------------------
18 proc compare_result {db1 db2 sql} {
19 set r1 [$db1 eval $sql]
20 set r2 [$db2 eval $sql]
24 error "mismatch for $sql"
29 proc compare_dbs {db1 db2} {
30 compare_result $db1 $db2 "SELECT sql FROM sqlite_master ORDER BY 1"
31 foreach tbl [$db1 eval {SELECT name FROM sqlite_master WHERE type='table'}] {
32 compare_result $db1 $db2 "SELECT * FROM $tbl"
35 #--------------------------------------------------------------------------
38 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
39 INSERT INTO t1 VALUES(1, 2, 3);
40 INSERT INTO t1 VALUES(2, hex(randomblob(1000)), randomblob(2000));
41 CREATE INDEX i1 ON t1(b, c);
44 faultsim_save_and_close
46 do_faultsim_test 1 -faults oom* -prep {
48 faultsim_restore_and_reopen
50 set R [sqlite3_recover_init db main test.db2]
54 faultsim_test_result {0 {}} {1 {}}
62 faultsim_restore_and_reopen
64 CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
65 INSERT INTO t2 VALUES(1, 2, 3);
66 INSERT INTO t2 VALUES(2, hex(randomblob(1000)), hex(randomblob(2000)));
67 PRAGMA writable_schema = 1;
68 DELETE FROM sqlite_schema WHERE name='t2';
70 faultsim_save_and_close
72 do_faultsim_test 2 -faults oom* -prep {
73 faultsim_restore_and_reopen
75 set R [sqlite3_recover_init db main test.db2]
76 $R config lostandfound lost_and_found
80 faultsim_test_result {0 {}} {1 {}}