Index: src/pager.c ================================================================== --- src/pager.c +++ src/pager.c @@ -16,11 +16,11 @@ ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.296 2007/03/26 10:27:19 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.297 2007/03/26 12:26:27 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include "os.h" #include "pager.h" @@ -872,10 +872,11 @@ ** database file. This is a no-op if the pager has already entered ** the error-state. */ static void pagerUnlockAndRollback(Pager *p){ if( p->errCode ) return; + assert( p->state>=PAGER_RESERVED || p->journalOpen==0 ); if( p->state>=PAGER_RESERVED ){ sqlite3PagerRollback(p); } pager_unlock(p); assert( p->errCode || !p->journalOpen || (p->exclusiveMode&&!p->journalOff) ); @@ -2720,10 +2721,13 @@ */ rc = pager_playback(pPager, 1); if( rc!=SQLITE_OK ){ return pager_error(pPager, rc); } + assert(pPager->state==PAGER_SHARED || + (pPager->exclusiveMode && pPager->state>PAGER_SHARED) + ); } if( pPager->pAll ){ PgHdr *pPage1 = pager_lookup(pPager, 1); if( pPage1 ){ @@ -2745,11 +2749,14 @@ } pPager->iChangeCount = iChangeCount; } } } - pPager->state = PAGER_SHARED; + assert( pPager->exclusiveMode || pPager->state<=PAGER_SHARED ); + if( pPager->state==PAGER_UNLOCK ){ + pPager->state = PAGER_SHARED; + } } return rc; } Index: test/malloc.test ================================================================== --- test/malloc.test +++ test/malloc.test @@ -12,11 +12,11 @@ # When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special # command (sqlite_malloc_fail N) which causes the N-th malloc to fail. This # special feature is used to see what happens in the library if a malloc # were to really fail due to an out-of-memory situation. # -# $Id: malloc.test,v 1.37 2007/03/17 10:26:59 danielk1977 Exp $ +# $Id: malloc.test,v 1.38 2007/03/26 12:26:27 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. @@ -332,10 +332,11 @@ # This block tests malloc() failures that occur while opening a # connection to a database. do_malloc_test 10 -sqlprep { CREATE TABLE abc(a, b, c); } -tclbody { + db close sqlite3 db2 test.db db2 eval {SELECT * FROM sqlite_master} db2 close } @@ -351,11 +352,11 @@ do_malloc_test 12 -tclbody { set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"] append sql16 "\00\00" set ::STMT [sqlite3_prepare16 $::DB $sql16 -1 DUMMY] sqlite3_finalize $::STMT -} +} # Test malloc errors when replaying two hot journals from a 2-file # transaction. ifcapable crashtest { do_malloc_test 13 -tclprep { Index: test/quick.test ================================================================== --- test/quick.test +++ test/quick.test @@ -4,11 +4,11 @@ # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # -# $Id: quick.test,v 1.48 2007/03/17 10:26:59 danielk1977 Exp $ +# $Id: quick.test,v 1.49 2007/03/26 12:26:27 danielk1977 Exp $ proc lshift {lvar} { upvar $lvar l set ret [lindex $l 0] set l [lrange $l 1 end] @@ -42,10 +42,11 @@ btree5.test btree6.test corrupt.test crash.test crash2.test + exclusive3.test loadext.test malloc.test malloc2.test malloc3.test memleak.test