aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2009-10-16 14:55:03 +0000
committerdan <dan@noemail.net>2009-10-16 14:55:03 +0000
commitfa401def25caa6066f171d09c165b9d654f59d12 (patch)
tree52d6fd5872e3413780a03027741fdc68097cbf92 /src
parented1f8787aa85ff21ade0d82e2df50bb5884ea8a2 (diff)
downloadsqlite-fa401def25caa6066f171d09c165b9d654f59d12.tar.gz
sqlite-fa401def25caa6066f171d09c165b9d654f59d12.zip
Experimental fix for [f777251dc7]. This may be changed yet.
FossilOrigin-Name: 174477bca05d019e663fd2b7cd031189ab2e010a
Diffstat (limited to 'src')
-rw-r--r--src/btree.c13
-rw-r--r--src/vacuum.c6
-rw-r--r--src/vdbe.c6
3 files changed, 16 insertions, 9 deletions
diff --git a/src/btree.c b/src/btree.c
index a9ab44504..218c96835 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -2965,18 +2965,13 @@ int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){
*/
static void btreeEndTransaction(Btree *p){
BtShared *pBt = p->pBt;
- BtCursor *pCsr;
assert( sqlite3BtreeHoldsMutex(p) );
- /* Search for a cursor held open by this b-tree connection. If one exists,
- ** then the transaction will be downgraded to a read-only transaction
- ** instead of actually concluded. A subsequent call to CommitPhaseTwo()
- ** or Rollback() will finish the transaction and unlock the database. */
- for(pCsr=pBt->pCursor; pCsr && pCsr->pBtree!=p; pCsr=pCsr->pNext);
- assert( pCsr==0 || p->inTrans>TRANS_NONE );
-
btreeClearHasContent(pBt);
- if( pCsr ){
+ if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){
+ /* If there are other active statements that belong to this database
+ ** handle, downgrade to a read-only transaction. The other statements
+ ** may still be reading from the database. */
downgradeAllSharedCacheTableLocks(p);
p->inTrans = TRANS_READ;
}else{
diff --git a/src/vacuum.c b/src/vacuum.c
index 00f3511d8..8f9221e5c 100644
--- a/src/vacuum.c
+++ b/src/vacuum.c
@@ -130,6 +130,12 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
pTemp = db->aDb[db->nDb-1].pBt;
+ /* The call to execSql() to attach the temp database has left the file
+ ** locked (as there was more than one active statement when the transaction
+ ** to read the schema was concluded. Unlock it here so that this doesn't
+ ** cause problems for the call to BtreeSetPageSize() below. */
+ sqlite3BtreeCommit(pTemp);
+
nRes = sqlite3BtreeGetReserve(pMain);
/* A VACUUM cannot change the pagesize of an encrypted database. */
diff --git a/src/vdbe.c b/src/vdbe.c
index c89dbd7bc..19d24af20 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -2855,6 +2855,7 @@ case OP_SetCookie: { /* in3 */
/* Invalidate all prepared statements whenever the TEMP database
** schema is changed. Ticket #1644 */
sqlite3ExpirePreparedStatements(db);
+ p->expired = 0;
}
break;
}
@@ -2972,6 +2973,11 @@ case OP_OpenWrite: {
VdbeCursor *pCur;
Db *pDb;
+ if( p->expired ){
+ rc = SQLITE_ABORT;
+ break;
+ }
+
nField = 0;
pKeyInfo = 0;
p2 = pOp->p2;