aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-05-17 10:58:08 +0000
committerdrh <drh@noemail.net>2013-05-17 10:58:08 +0000
commit466af9baae3da0ac018a31237cde5dd0963bc4be (patch)
treef0d700132218dd9d4b988a332b1c2255f9e09144 /src/main.c
parentad1818d9ede86ed01ea5a32e55adf8dde5a18f89 (diff)
parent4c5aeecc907f4cb36247322fd181eec9d578e9db (diff)
downloadsqlite-466af9baae3da0ac018a31237cde5dd0963bc4be.tar.gz
sqlite-466af9baae3da0ac018a31237cde5dd0963bc4be.zip
Update the sessions branch to the latest 3.7.17 beta.
FossilOrigin-Name: af8057ef5dcaa72dc0d2ab5d1553b06757449fa1
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index d53503aec..39ef5bfb5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -848,12 +848,6 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){
return SQLITE_BUSY;
}
- /* If a transaction is open, roll it back. This also ensures that if
- ** any database schemas have been modified by the current transaction
- ** they are reset. And that the required b-tree mutex is held to make
- ** the the pager rollback and schema reset an atomic operation. */
- sqlite3RollbackAll(db, SQLITE_OK);
-
#ifdef SQLITE_ENABLE_SQLLOG
if( sqlite3GlobalConfig.xSqllog ){
/* Closing the handle. Fourth parameter is passed the value 2. */
@@ -908,6 +902,12 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){
** go ahead and free all resources.
*/
+ /* If a transaction is open, roll it back. This also ensures that if
+ ** any database schemas have been modified by an uncommitted transaction
+ ** they are reset. And that the required b-tree mutex is held to make
+ ** the pager rollback and schema reset an atomic operation. */
+ sqlite3RollbackAll(db, SQLITE_OK);
+
/* Free any outstanding Savepoint structures. */
sqlite3CloseSavepoints(db);
@@ -1008,7 +1008,15 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){
int inTrans = 0;
assert( sqlite3_mutex_held(db->mutex) );
sqlite3BeginBenignMalloc();
+
+ /* Obtain all b-tree mutexes before making any calls to BtreeRollback().
+ ** This is important in case the transaction being rolled back has
+ ** modified the database schema. If the b-tree mutexes are not taken
+ ** here, then another shared-cache connection might sneak in between
+ ** the database rollback and schema reset, which can cause false
+ ** corruption reports in some cases. */
sqlite3BtreeEnterAll(db);
+
for(i=0; i<db->nDb; i++){
Btree *p = db->aDb[i].pBt;
if( p ){