/ Check-in [38e04d67]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Another test case to test a specific kind of database corruption. (CVS 5352)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 38e04d67635d49661f9b95338fc1cb8197bf0bc7
User & Date: danielk1977 2008-07-07 17:04:23
Context
2008-07-07
17:13
Fix an error checked in as part of (5350). (CVS 5353) check-in: acfb2b41 user: danielk1977 tags: trunk
17:04
Another test case to test a specific kind of database corruption. (CVS 5352) check-in: 38e04d67 user: danielk1977 tags: trunk
15:39
Add a test case to test corruption discovered as part of the ptrmapPut() routine. (CVS 5351) check-in: cbb9536f user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/corrupt2.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests to make sure SQLite does not crash or
    14     14   # segfault if it sees a corrupt database file.
    15     15   #
    16         -# $Id: corrupt2.test,v 1.6 2008/07/07 15:39:11 danielk1977 Exp $
           16  +# $Id: corrupt2.test,v 1.7 2008/07/07 17:04:23 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # The following tests - corrupt2-1.* - create some databases corrupted in
    22     22   # specific ways and ensure that SQLite detects them as corrupt.
    23     23   #
................................................................................
   165    165     puts -nonewline $fd "\00\00\00\00" 
   166    166     close $fd
   167    167   
   168    168     sqlite3 db2 corrupt.db 
   169    169     catchsql {
   170    170       DROP TABLE t1;
   171    171     } db2
   172         -} {1 {malformed database schema (a3) - index a3 already exists}}
          172  +} {1 {database disk image is malformed}}
          173  +
          174  +do_test corrupt2-4.1 {
          175  +  file delete -force corrupt.db
          176  +  file delete -force corrupt.db-journal
          177  +  sqlite3 db2 corrupt.db 
          178  +
          179  +  execsql {
          180  +    PRAGMA page_size = 1024;
          181  +    CREATE TABLE t1(a, b, c);
          182  +    CREATE TABLE t2(a, b, c);
          183  +    INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100));
          184  +    INSERT INTO t2 SELECT * FROM t2;
          185  +    INSERT INTO t2 SELECT * FROM t2;
          186  +    INSERT INTO t2 SELECT * FROM t2;
          187  +    INSERT INTO t2 SELECT * FROM t2;
          188  +    INSERT INTO t1 SELECT * FROM t2;
          189  +  } db2
          190  +
          191  +  db2 close
          192  +
          193  +  # This block links a page from table t2 into the t1 table structure.
          194  +  #
          195  +  set fd [open corrupt.db r+]
          196  +  fconfigure $fd -encoding binary -translation binary
          197  +  seek $fd [expr 1024 + 12]
          198  +  set zCelloffset [read $fd 2]
          199  +  binary scan $zCelloffset S iCelloffset
          200  +  seek $fd [expr 1024 + $iCelloffset]
          201  +  set zChildPage [read $fd 4]
          202  +  seek $fd [expr 2*1024 + 12]
          203  +  set zCelloffset [read $fd 2]
          204  +  binary scan $zCelloffset S iCelloffset
          205  +  seek $fd [expr 2*1024 + $iCelloffset]
          206  +  puts -nonewline $fd $zChildPage
          207  +  close $fd
          208  +
          209  +  sqlite3 db2 corrupt.db 
          210  +  db2 eval {SELECT rowid FROM t1} {
          211  +    set result [db2 eval {pragma integrity_check}]
          212  +    break
          213  +  }
          214  +  set result
          215  +} {{*** in database main ***
          216  +Page 10: sqlite3BtreeInitPage() returns error code 11
          217  +On tree page 3 cell 1: Child page depth differs
          218  +On tree page 2 cell 0: 2nd reference to page 10
          219  +On tree page 2 cell 1: Child page depth differs
          220  +Page 4 is never used}}
   173    221   
   174    222   db2 close
   175    223   
   176    224   finish_test