Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a typo in walfault.test. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
232dbe8ecec16485be5c5995fdf7a0ed |
User & Date: | dan 2010-05-04 11:06:03.000 |
Context
2010-05-04
| ||
14:47 | Fix problems with recovering wal files that use a page-size other than the default. (check-in: 1a391f3c55 user: dan tags: trunk) | |
11:06 | Fix a typo in walfault.test. (check-in: 232dbe8ece user: dan tags: trunk) | |
10:36 | Test that the correct number of padding frames are appended to the log file after committing a transaction in synchronous=FULL mode. (check-in: a60104aa7e user: dan tags: trunk) | |
Changes
Changes to src/wal.c.
︙ | ︙ | |||
569 570 571 572 573 574 575 576 577 578 579 580 581 | ** exist it is created by this call. ** ** A SHARED lock should be held on the database file when this function ** is called. The purpose of this SHARED lock is to prevent any other ** client from unlinking the log or wal-index file. If another process ** were to do this just after this client opened one of these files, the ** system would be badly broken. */ int sqlite3WalOpen( sqlite3_vfs *pVfs, /* vfs module to open wal and wal-index */ const char *zDb, /* Name of database file */ Wal **ppWal /* OUT: Allocated Wal handle */ ){ | > > > > | | | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | ** exist it is created by this call. ** ** A SHARED lock should be held on the database file when this function ** is called. The purpose of this SHARED lock is to prevent any other ** client from unlinking the log or wal-index file. If another process ** were to do this just after this client opened one of these files, the ** system would be badly broken. ** ** If the log file is successfully opened, SQLITE_OK is returned and ** *ppWal is set to point to a new WAL handle. If an error occurs, ** an SQLite error code is returned and *ppWal is left unmodified. */ int sqlite3WalOpen( sqlite3_vfs *pVfs, /* vfs module to open wal and wal-index */ const char *zDb, /* Name of database file */ Wal **ppWal /* OUT: Allocated Wal handle */ ){ int rc; /* Return Code */ Wal *pRet; /* Object to allocate and return */ int flags; /* Flags passed to OsOpen() */ char *zWal; /* Path to WAL file */ int nWal; /* Length of zWal in bytes */ assert( zDb ); if( pVfs->xShmOpen==0 ) return SQLITE_CANTOPEN_BKPT; /* Allocate an instance of struct Wal to return. */ *ppWal = 0; |
︙ | ︙ | |||
605 606 607 608 609 610 611 | /* Open file handle on the write-ahead log file. */ if( rc==SQLITE_OK ){ flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL); rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags); } if( rc!=SQLITE_OK ){ | < | | | | | < | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | /* Open file handle on the write-ahead log file. */ if( rc==SQLITE_OK ){ flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL); rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags); } if( rc!=SQLITE_OK ){ pVfs->xShmClose(pVfs, pRet->pWIndex, 0); sqlite3OsClose(pRet->pFd); sqlite3_free(pRet); }else{ *ppWal = pRet; } return rc; } static int walIteratorNext( WalIterator *p, /* Iterator */ u32 *piPage, /* OUT: Next db page to write */ u32 *piFrame /* OUT: Wal frame to read from */ |
︙ | ︙ |
Changes to test/fts3_common.tcl.
︙ | ︙ | |||
284 285 286 287 288 289 290 | } } } } ########################################################################## | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 284 285 286 287 288 289 290 | } } } } ########################################################################## |
Changes to test/fts3query.test.
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build does not include FTS3, skip the tests in this file. # ifcapable !fts3 { finish_test ; return } source $testdir/fts3_common.tcl set DO_MALLOC_TEST 0 do_test fts3query-1.1 { execsql { CREATE VIRTUAL TABLE t1 USING fts3(x); BEGIN; | > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build does not include FTS3, skip the tests in this file. # ifcapable !fts3 { finish_test ; return } source $testdir/malloc_common.tcl source $testdir/fts3_common.tcl set DO_MALLOC_TEST 0 do_test fts3query-1.1 { execsql { CREATE VIRTUAL TABLE t1 USING fts3(x); BEGIN; |
︙ | ︙ |
Changes to test/fts3rnd.test.
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build does not include FTS3, skip the tests in this file. # ifcapable !fts3 { finish_test ; return } source $testdir/fts3_common.tcl set G(nVocab) 100 set nVocab 100 set lVocab [list] expr srand(0) | > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build does not include FTS3, skip the tests in this file. # ifcapable !fts3 { finish_test ; return } source $testdir/fts3_common.tcl source $testdir/malloc_common.tcl set G(nVocab) 100 set nVocab 100 set lVocab [list] expr srand(0) |
︙ | ︙ |
Changes to test/malloc_common.tcl.
︙ | ︙ | |||
163 164 165 166 167 168 169 | catch [list uplevel #0 $::mallocopts(-cleanup)] msg } } } unset ::mallocopts sqlite3_memdebug_fail -1 } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | catch [list uplevel #0 $::mallocopts(-cleanup)] msg } } } unset ::mallocopts sqlite3_memdebug_fail -1 } #------------------------------------------------------------------------- # This proc is used to test a single SELECT statement. Parameter $name is # passed a name for the test case (i.e. "fts3_malloc-1.4.1") and parameter # $sql is passed the text of the SELECT statement. Parameter $result is # set to the expected output if the SELECT statement is successfully # executed using [db eval]. # # Example: # # do_select_test testcase-1.1 "SELECT 1+1, 1+2" {1 2} # # If global variable DO_MALLOC_TEST is set to a non-zero value, or if # it is not defined at all, then OOM testing is performed on the SELECT # statement. Each OOM test case is said to pass if either (a) executing # the SELECT statement succeeds and the results match those specified # by parameter $result, or (b) TCL throws an "out of memory" error. # # If DO_MALLOC_TEST is defined and set to zero, then the SELECT statement # is executed just once. In this case the test case passes if the results # match the expected results passed via parameter $result. # proc do_select_test {name sql result} { uplevel [list doPassiveTest 0 $name $sql [list 0 $result]] } proc do_restart_select_test {name sql result} { uplevel [list doPassiveTest 1 $name $sql [list 0 $result]] } proc do_error_test {name sql error} { uplevel [list doPassiveTest 0 $name $sql [list 1 $error]] } proc doPassiveTest {isRestart name sql catchres} { if {![info exists ::DO_MALLOC_TEST]} { set ::DO_MALLOC_TEST 1 } switch $::DO_MALLOC_TEST { 0 { # No malloc failures. do_test $name [list set {} [uplevel [list catchsql $sql]]] $catchres return } 1 { # Simulate transient failures. set nRepeat 1 set zName "transient" set nStartLimit 100000 set nBackup 1 } 2 { # Simulate persistent failures. set nRepeat 1 set zName "persistent" set nStartLimit 100000 set nBackup 1 } 3 { # Simulate transient failures with extra brute force. set nRepeat 100000 set zName "ridiculous" set nStartLimit 1 set nBackup 10 } } # The set of acceptable results from running [catchsql $sql]. # set answers [list {1 {out of memory}} $catchres] set str [join $answers " OR "] set nFail 1 for {set iLimit $nStartLimit} {$nFail} {incr iLimit} { for {set iFail 1} {$nFail && $iFail<=$iLimit} {incr iFail} { for {set iTest 0} {$iTest<$nBackup && ($iFail-$iTest)>0} {incr iTest} { if {$isRestart} { sqlite3 db test.db } sqlite3_memdebug_fail [expr $iFail-$iTest] -repeat $nRepeat set res [uplevel [list catchsql $sql]] if {[lsearch -exact $answers $res]>=0} { set res $str } set testname "$name.$zName.$iFail" do_test "$name.$zName.$iLimit.$iFail" [list set {} $res] $str set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign] } } } } #------------------------------------------------------------------------- # Test a single write to the database. In this case a "write" is a # DELETE, UPDATE or INSERT statement. # # If OOM testing is performed, there are several acceptable outcomes: # # 1) The write succeeds. No error is returned. # # 2) An "out of memory" exception is thrown and: # # a) The statement has no effect, OR # b) The current transaction is rolled back, OR # c) The statement succeeds. This can only happen if the connection # is in auto-commit mode (after the statement is executed, so this # includes COMMIT statements). # # If the write operation eventually succeeds, zero is returned. If a # transaction is rolled back, non-zero is returned. # # Parameter $name is the name to use for the test case (or test cases). # The second parameter, $tbl, should be the name of the database table # being modified. Parameter $sql contains the SQL statement to test. # proc do_write_test {name tbl sql} { if {![info exists ::DO_MALLOC_TEST]} { set ::DO_MALLOC_TEST 1 } # Figure out an statement to get a checksum for table $tbl. db eval "SELECT * FROM $tbl" V break set cksumsql "SELECT md5sum([join [concat rowid $V(*)] ,]) FROM $tbl" # Calculate the initial table checksum. set cksum1 [db one $cksumsql] if {$::DO_MALLOC_TEST } { set answers [list {1 {out of memory}} {0 {}}] if {$::DO_MALLOC_TEST==1} { set modes {100000 transient} } else { set modes {1 persistent} } } else { set answers [list {0 {}}] set modes [list 0 nofail] } set str [join $answers " OR "] foreach {nRepeat zName} $modes { for {set iFail 1} 1 {incr iFail} { if {$::DO_MALLOC_TEST} {sqlite3_memdebug_fail $iFail -repeat $nRepeat} set res [uplevel [list catchsql $sql]] set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign] if {$nFail==0} { do_test $name.$zName.$iFail [list set {} $res] {0 {}} return } else { if {[lsearch $answers $res]>=0} { set res $str } do_test $name.$zName.$iFail [list set {} $res] $str set cksum2 [db one $cksumsql] if {$cksum1 != $cksum2} return } } } } |
Changes to test/walfault.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 | ifcapable !wal {finish_test ; return } do_malloc_test walfault-oom-1 -sqlbody { PRAGMA journal_mode = WAL; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ifcapable !wal {finish_test ; return } do_malloc_test walfault-oom-1 -sqlbody { PRAGMA journal_mode = WAL; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); PRAGMA wal_checkpoint; } do_malloc_test walfault-oom-2 -tclprep { execsql { PRAGMA journal_mode = WAL; BEGIN; CREATE TABLE x(y, z, UNIQUE(y, z)); |
︙ | ︙ |