mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Merge in the latest trunk changes.
FossilOrigin-Name: ff86875ca35e04cea6c3d5e1b5117a4f227a6b15
This commit is contained in:
@@ -2003,32 +2003,6 @@ static void checkActiveVdbeCnt(sqlite3 *db){
|
||||
#define checkActiveVdbeCnt(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** For every Btree that in database connection db which
|
||||
** has been modified, "trip" or invalidate each cursor in
|
||||
** that Btree might have been modified so that the cursor
|
||||
** can never be used again. This happens when a rollback
|
||||
*** occurs. We have to trip all the other cursors, even
|
||||
** cursor from other VMs in different database connections,
|
||||
** so that none of them try to use the data at which they
|
||||
** were pointing and which now may have been changed due
|
||||
** to the rollback.
|
||||
**
|
||||
** Remember that a rollback can delete tables complete and
|
||||
** reorder rootpages. So it is not sufficient just to save
|
||||
** the state of the cursor. We have to invalidate the cursor
|
||||
** so that it is never used again.
|
||||
*/
|
||||
static void invalidateCursorsOnModifiedBtrees(sqlite3 *db){
|
||||
int i;
|
||||
for(i=0; i<db->nDb; i++){
|
||||
Btree *p = db->aDb[i].pBt;
|
||||
if( p && sqlite3BtreeIsInTrans(p) ){
|
||||
sqlite3BtreeTripAllCursors(p, SQLITE_ABORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** If the Vdbe passed as the first argument opened a statement-transaction,
|
||||
** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or
|
||||
@@ -2193,8 +2167,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
/* We are forced to roll back the active transaction. Before doing
|
||||
** so, abort any other statements this handle currently has active.
|
||||
*/
|
||||
invalidateCursorsOnModifiedBtrees(db);
|
||||
sqlite3RollbackAll(db);
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
sqlite3CloseSavepoints(db);
|
||||
db->autoCommit = 1;
|
||||
}
|
||||
@@ -2236,13 +2209,13 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
return SQLITE_BUSY;
|
||||
}else if( rc!=SQLITE_OK ){
|
||||
p->rc = rc;
|
||||
sqlite3RollbackAll(db);
|
||||
sqlite3RollbackAll(db, SQLITE_OK);
|
||||
}else{
|
||||
db->nDeferredCons = 0;
|
||||
sqlite3CommitInternalChanges(db);
|
||||
}
|
||||
}else{
|
||||
sqlite3RollbackAll(db);
|
||||
sqlite3RollbackAll(db, SQLITE_OK);
|
||||
}
|
||||
db->nStatement = 0;
|
||||
}else if( eStatementOp==0 ){
|
||||
@@ -2251,8 +2224,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
}else if( p->errorAction==OE_Abort ){
|
||||
eStatementOp = SAVEPOINT_ROLLBACK;
|
||||
}else{
|
||||
invalidateCursorsOnModifiedBtrees(db);
|
||||
sqlite3RollbackAll(db);
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
sqlite3CloseSavepoints(db);
|
||||
db->autoCommit = 1;
|
||||
}
|
||||
@@ -2272,8 +2244,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
sqlite3DbFree(db, p->zErrMsg);
|
||||
p->zErrMsg = 0;
|
||||
}
|
||||
invalidateCursorsOnModifiedBtrees(db);
|
||||
sqlite3RollbackAll(db);
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
sqlite3CloseSavepoints(db);
|
||||
db->autoCommit = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user