Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add experimental fix for corruption detection problem. This may well be revised yet. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1cc4be7ebc463921827e61da724f0de9 |
User & Date: | dan 2010-02-25 19:09:16.000 |
Original User & Date: | dan 2010-02-25 12:09:16.000 |
Context
2010-02-25
| ||
21:27 | Test coverage enhancements. Additional documentation detail on the new sqlite3_log() interface. (check-in: d986e92893 user: drh tags: trunk) | |
19:09 | Add experimental fix for corruption detection problem. This may well be revised yet. (check-in: 1cc4be7ebc user: dan tags: trunk) | |
16:09 | Fixed numbering of a few tests; minor tweaks on others; added a couple new tests to stress previous simplifications to compile-time option reporting functions. (check-in: 9b18dfd19e user: shaneh tags: trunk) | |
Changes
Changes to src/btree.c.
︙ | ︙ | |||
5057 5058 5059 5060 5061 5062 5063 | ** file the database must be corrupt. */ return SQLITE_CORRUPT_BKPT; } if( nOvfl ){ rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext); if( rc ) return rc; } | > > > > > > > > > > > > > > > > | > > | 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 | ** file the database must be corrupt. */ return SQLITE_CORRUPT_BKPT; } if( nOvfl ){ rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext); if( rc ) return rc; } if( (pOvfl || (pOvfl = btreePageLookup(pBt, ovflPgno))) && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1 ){ /* There is no reason any cursor should have an outstanding reference ** to an overflow page belonging to a cell that is being deleted/updated. ** So if there exists more than one reference to this page, then it ** must not really be an overflow page and the database must be corrupt. ** It is helpful to detect this before calling freePage2(), as ** freePage2() may zero the page contents if secure-delete mode is ** enabled. If this 'overflow' page happens to be a page that the ** caller is iterating through or using in some other way, this ** can be problematic. */ rc = SQLITE_CORRUPT_BKPT; }else{ rc = freePage2(pBt, pOvfl, ovflPgno); } if( pOvfl ){ sqlite3PagerUnref(pOvfl->pDbPage); } if( rc ) return rc; ovflPgno = iNext; } return SQLITE_OK; |
︙ | ︙ |
Changes to test/corrupt.test.
|
| | | 1 2 3 4 5 6 7 8 | # 2004 August 30 {} # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. |
︙ | ︙ | |||
67 68 69 70 71 72 73 | while {[string length $junk]<256} {append junk $junk} set junk [string range $junk 0 255] # Go through the database and write garbage data into each 256 segment # of the file. Then do various operations on the file to make sure that # the database engine can recover gracefully from the corruption. # | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | while {[string length $junk]<256} {append junk $junk} set junk [string range $junk 0 255] # Go through the database and write garbage data into each 256 segment # of the file. Then do various operations on the file to make sure that # the database engine can recover gracefully from the corruption. # for {set i [expr {1*256}]} {0 && $i<$fsize-256} {incr i 256} { set tn [expr {$i/256}] db close copy_file test.bu test.db set fd [open test.db r+] fconfigure $fd -translation binary seek $fd $i puts -nonewline $fd $junk |
︙ | ︙ | |||
307 308 309 310 311 312 313 314 | do_test corrupt-7.3 { catchsql { INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A'); } } {1 {database disk image is malformed}} } finish_test | > > > > > > > > > > > > > > > > > > | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | do_test corrupt-7.3 { catchsql { INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A'); } } {1 {database disk image is malformed}} } db close file delete -force test.db test.db-journal do_test corrupt-8.1 { sqlite3 db test.db execsql { PRAGMA page_size = 1024; PRAGMA secure_delete = on; PRAGMA auto_vacuum = 0; CREATE TABLE t1(x INTEGER PRIMARY KEY, y); INSERT INTO t1 VALUES(5, randomblob(1900)); } hexio_write test.db 2044 [hexio_render_int32 2] hexio_write test.db 24 [hexio_render_int32 45] catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) } } {1 {database disk image is malformed}} finish_test |