Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/recover/recovercorrupt4.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / recover / recovercorrupt4.test` 101 lines ยท 2904 bytes Raw Blame History 1 # 2024 May 15 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 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. 9 # 10 #*********************************************************************** 11 # 12 13 source [file join [file dirname [info script]] recover_common.tcl] 14 set testprefix recovercorrupt4 15 16 database_may_be_corrupt 17 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". 23 do_execsql_test 1.0 { 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)); 30 } 31 32 db close 33 34 do_test 1.1 { 35 set sz [expr [file size test.db] - 1024] 36 set fd [open test.db] 37 fconfigure $fd -translation binary 38 39 set data [read $fd $sz] 40 set fd2 [open test.db2 w] 41 fconfigure $fd2 -translation binary 42 puts -nonewline $fd2 $data 43 close $fd2 44 set {} {} 45 } {} 46 47 do_test 1.2 { 48 forcedelete test.db3 49 sqlite3 db test.db2 50 set R [sqlite3_recover_init db main test.db3] 51 $R run 52 $R finish 53 } {} 54 55 do_test 1.3 { 56 sqlite3 db test.db3 57 execsql { 58 SELECT indexed, unindexed FROM rows 59 } 60 } {1 1 2 2 4 4 8 8} 61 } 62 catch {close $fd} 63 db close 64 65 # Bug 2026-10-25T12:08:19Z 66 # 67 reset_db 68 do_execsql_test 2.0 { 69 PRAGMA auto_vacuum=OFF; 70 PRAGMA page_size=4096; 71 CREATE TABLE x(a); INSERT INTO x VALUES(1); 72 PRAGMA writable_schema=ON; 73 DELETE FROM sqlite_schema WHERE name='x'; 74 INSERT INTO sqlite_schema VALUES('table','aa','aa',0, 75 'CREATE TEMP TABLE tb(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17)'); 76 INSERT INTO sqlite_schema VALUES('table','ab','ab',0,'CREATE INDEX temp.x ON tb(c17)'); 77 INSERT INTO sqlite_schema VALUES('table','x','x',2,'CREATE TABLE x(a)'); 78 PRAGMA writable_schema=RESET; 79 } 80 do_catchsql_test 2.1 { 81 PRAGMA integrity_check; 82 } {1 {malformed database schema (aa)}} 83 do_test 2.3 { 84 forcedelete test.db2 85 set R [sqlite3_recover_init db main test.db2] 86 $R run 87 $R finish 88 } {} 89 do_test 2.4 { 90 sqlite3 db2 test.db2 91 db2 eval {PRAGMA integrity_check} 92 } {ok} 93 94 # TODO: Different answers for --config Android and 95 # for --config Device-Two. 96 # 97 #do_test 2.5 { 98 # db2 eval {SELECT * FROM x} 99 #} {1} 100 101 finish_test