diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/btree.c b/src/btree.c index 27e20e8ac..20cc3eb10 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3375,6 +3375,11 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){ 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; } } } @@ -3424,17 +3429,8 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){ } } } - }else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){ - /* Even if there was no transaction opened when this function was - ** called, a race condition may cause an SQLITE_BUSY_SNAPSHOT error - ** in wal mode (since the code above opens a read-transaction and then - ** upgrades it to a write-transaction - it does not take the write lock - ** atomically). In this case change the error code to SQLITE_BUSY. */ - assert( wrflag ); - rc = SQLITE_BUSY; } - trans_begun: if( rc==SQLITE_OK ){ if( pSchemaVersion ){ |