Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -3373,10 +3373,15 @@ rc = SQLITE_READONLY; }else{ rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db)); if( rc==SQLITE_OK ){ rc = newDatabase(pBt); + }else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){ + /* if there was no transaction opened when this function was + ** called and SQLITE_BUSY_SNAPSHOT is returned, change the error + ** code to SQLITE_BUSY. */ + rc = SQLITE_BUSY; } } } if( rc!=SQLITE_OK ){ @@ -3423,11 +3428,10 @@ put4byte(&pPage1->aData[28], pBt->nPage); } } } } - trans_begun: if( rc==SQLITE_OK ){ if( pSchemaVersion ){ *pSchemaVersion = get4byte(&pBt->pPage1->aData[40]); Index: test/walprotocol2.test ================================================================== --- test/walprotocol2.test +++ test/walprotocol2.test @@ -70,11 +70,11 @@ do_catchsql_test 2.2 { BEGIN EXCLUSIVE; } {1 {database is locked}} do_test 2.3 { sqlite3_extended_errcode db -} {SQLITE_BUSY_SNAPSHOT} +} {SQLITE_BUSY} #--------------------------------------------------------------- # Same again, but with a busy-handler. This time, following the # SQLITE_BUSY_SNAPSHOT error the busy-handler is invoked and then the # whole thing retried from the beginning. This time it succeeds.