-C When\scommitting\sa\sWAL\stransaction,\sdo\snot\swrite\sany\spages\sto\sthe\sWAL\sfile\swith\spage\snumbers\sgreater\sthan\sthe\ssize\sof\sthe\sdatabase\simage\sin\spages.
-D 2011-04-05T16:09:08.127
+C Remove\sthe\smutex\scounter\sand\sthe\slogic\sthat\sattempts\sto\sverify\sthat\sbtree\nmutexes\sare\sheld\scontinuously.\s\sWe\sare\snot\smaking\sthat\sassumption\sat\sthis\ntime.
+D 2011-04-05T17:31:56.106
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b
F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef
-F src/btmutex.c b81062220a4f91b0bd785d13d57205d68449be88
+F src/btmutex.c 1f951523accdfa1d204b06150e016b5b69529b8a
F src/btree.c 107723ed4f9bdb55213ba6164c30c49af75f4bf9
-F src/btree.h c0e0ff5c85effe9fc757e3085bbdded6d1cca000
-F src/btreeInt.h 6714ce2f5e879eb9a904a6a4575dc4faa4f29991
+F src/btree.h 221e186cd64127088890a878aaab154344380fe8
+F src/btreeInt.h b5e339df994d12bcd9067d04f9125c8792de51ac
F src/build.c d809f57250b10e83586bc23921de02055890b239
F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60
F src/util.c cd997077bad039efc0597eb027c929658f93c018
F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e
-F src/vdbe.c 0140a57f9cbd50351219bfc4e44ef3de64bd65b8
+F src/vdbe.c b239d70f6862f1d0d3896c96efe7d6fabae1c56c
F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797
-F src/vdbeInt.h 7e2f028ecc1a9faa6f253e7aa8d89cae03662bae
+F src/vdbeInt.h 53dfcaf5b83297c24f537c4a54c1f35fd655b0a2
F src/vdbeapi.c a09ad9164cafc505250d5dd6b69660c960f1308c
-F src/vdbeaux.c e1ea6edc07b4f33a339cc45a2fbe0a36067d2d8b
+F src/vdbeaux.c 64304e50c6d4ccca586410184927baa9faca6ecc
F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562
F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b
F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P d25c17ef6e2b916923489dccaaa018a2d6525401
-R c888a09e2325a742237e83457c23e497
-U dan
-Z 881050430264f599344995b52c518cce
+P 311d0b613d9cfa2dbcbb9ef2450041b1fd48770a
+R f2efb954b9e1d86872be6fb2ad3e5711
+U drh
+Z c70542c8d51f5c49bbcf63ab42aa4a3a
-311d0b613d9cfa2dbcbb9ef2450041b1fd48770a
\ No newline at end of file
+242ce7cff416a87d57d4eb624cb79fa4e2215559
\ No newline at end of file
assert( sqlite3_mutex_held(p->db->mutex) );
assert( p->db==pBt->db );
- pBt->iMutexCounter++;
sqlite3_mutex_leave(pBt->mutex);
p->locked = 0;
}
-#ifdef SQLITE_DEBUG
-/*
-** Return the number of times that the mutex has been exited for
-** the given btree.
-**
-** This is a small circular counter that wraps around to zero on
-** overflow. It is used only for sanity checking - to verify that
-** mutexes are held continously by asserting that the value of
-** this counter at the beginning of a region is the same as at
-** the end.
-*/
-u32 sqlite3BtreeMutexCounter(Btree *p){
- assert( p->locked==1 || p->sharable==0 );
- return p->pBt->iMutexCounter;
-}
-#endif
-
/*
** Enter a mutex on the given BTree object.
**
p->wantToLock++;
if( p->locked ) return;
- /* Increment the mutex counter on all locked btrees in the same
- ** database connection. This simulates the unlocking that would
- ** occur on a worst-case mutex dead-lock avoidance scenario.
- */
-#ifdef SQLITE_DEBUG
- {
- int ii;
- sqlite3 *db = p->db;
- Btree *pOther;
- for(ii=0; ii<db->nDb; ii++){
- if( ii==1 ) continue;
- pOther = db->aDb[ii].pBt;
- if( pOther==0 || pOther->sharable==0 || pOther->locked==0 ) continue;
- pOther->pBt->iMutexCounter++;
- }
- }
-#endif
-
/* In most cases, we should be able to acquire the lock we
** want without having to go throught the ascending lock
** procedure that follows. Just be sure not to block.
int sqlite3BtreeHoldsMutex(Btree*);
int sqlite3BtreeHoldsAllMutexes(sqlite3*);
int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);
- u32 sqlite3BtreeMutexCounter(Btree*);
#endif
#else
# define sqlite3BtreeLeave(X)
-# define sqlite3BtreeMutexCounter(X) 0
# define sqlite3BtreeEnterCursor(X)
# define sqlite3BtreeLeaveCursor(X)
# define sqlite3BtreeLeaveAll(X)
# define sqlite3BtreeHoldsMutex(X) 1
# define sqlite3BtreeHoldsAllMutexes(X) 1
-# define sqlite3BtreeSchemaMutexHeld(X,Y) 1
+# define sqlite3SchemaMutexHeld(X,Y,Z) 1
#endif
Btree *pWriter; /* Btree with currently open write transaction */
u8 isExclusive; /* True if pWriter has an EXCLUSIVE lock on the db */
u8 isPending; /* If waiting for read-locks to clear */
- u16 iMutexCounter; /* The number of mutex_leave(mutex) calls */
#endif
u8 *pTmpSpace; /* BtShared.pageSize bytes of space for tmp use */
};
ctx.pColl = pOp[-1].p4.pColl;
}
(*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */
- sqlite3VdbeMutexResync(p);
if( db->mallocFailed ){
/* Even though a malloc() has failed, the implementation of the
** user function may have called an sqlite3_result_XXX() function
if( p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){
sqlite3ExpirePreparedStatements(db);
sqlite3ResetInternalSchema(db, -1);
- sqlite3VdbeMutexResync(p);
db->flags = (db->flags | SQLITE_InternChanges);
}
}
ctx.pColl = pOp[-1].p4.pColl;
}
(ctx.pFunc->xStep)(&ctx, n, apVal); /* IMP: R-24505-23230 */
- sqlite3VdbeMutexResync(p);
if( ctx.isError ){
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s));
rc = ctx.isError;
}
- /* The app-defined function has done something that as caused this
- ** statement to expire. (Perhaps the function called sqlite3_exec()
- ** with a CREATE TABLE statement.)
- */
-#if 0
- if( p->expired ){
- rc = SQLITE_ABORT;
- break;
- }
-#endif
-
sqlite3VdbeMemRelease(&ctx.s);
break;
pMem = &aMem[pOp->p1];
assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
- sqlite3VdbeMutexResync(p);
if( rc ){
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(pMem));
- }else if( p->expired ){
- rc = SQLITE_ABORT;
}
sqlite3VdbeChangeEncoding(pMem, encoding);
UPDATE_MAX_BLOBSIZE(pMem);
u8 isPrepareV2; /* True if prepared with prepare_v2() */
int nChange; /* Number of db changes made since last reset */
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
- u32 iMutexCounter; /* Mutex counter upon sqlite3VdbeEnter() */
int iStatement; /* Statement number (or 0 if has not opened stmt) */
int aCounter[3]; /* Counters used by sqlite3_stmt_status() */
#ifndef SQLITE_OMIT_TRACE
void sqlite3VdbeFrameDelete(VdbeFrame*);
int sqlite3VdbeFrameRestore(VdbeFrame *);
void sqlite3VdbeMemStoreType(Mem *pMem);
-void sqlite3VdbeEnter(Vdbe*);
-void sqlite3VdbeLeave(Vdbe*);
-void sqlite3VdbeMutexResync(Vdbe*);
+
+#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0
+ void sqlite3VdbeEnter(Vdbe*);
+ void sqlite3VdbeLeave(Vdbe*);
+#else
+# define sqlite3VdbeEnter(X)
+# define sqlite3VdbeLeave(X)
+#endif
#ifdef SQLITE_DEBUG
void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem*);
p->btreeMask |= ((yDbMask)1)<<i;
}
-/*
-** Compute the sum of all mutex counters for all btrees in the
-** given prepared statement.
-*/
-#ifndef SQLITE_OMIT_SHARED_CACHE
-static u32 mutexCounterSum(Vdbe *p){
- u32 cntSum = 0;
-#ifdef SQLITE_DEBUG
- int i;
- yDbMask mask;
- sqlite3 *db = p->db;
- Db *aDb = db->aDb;
- int nDb = db->nDb;
- for(i=0, mask=1; i<nDb; i++, mask += mask){
- if( i!=1 && (mask & p->btreeMask)!=0 && ALWAYS(aDb[i].pBt!=0) ){
- cntSum += sqlite3BtreeMutexCounter(aDb[i].pBt);
- }
- }
-#else
- UNUSED_PARAMETER(p);
-#endif
- return cntSum;
-}
-#endif
-
+#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0
/*
** If SQLite is compiled to support shared-cache mode and to be threadsafe,
** this routine obtains the mutex associated with each BtShared structure
** be a problem.
*/
void sqlite3VdbeEnter(Vdbe *p){
-#ifndef SQLITE_OMIT_SHARED_CACHE
int i;
yDbMask mask;
sqlite3 *db = p->db;
sqlite3BtreeEnter(aDb[i].pBt);
}
}
- p->iMutexCounter = mutexCounterSum(p);
-#else
- UNUSED_PARAMETER(p);
-#endif
}
+#endif
+#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0
/*
** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter().
*/
void sqlite3VdbeLeave(Vdbe *p){
-#ifndef SQLITE_OMIT_SHARED_CACHE
int i;
yDbMask mask;
sqlite3 *db = p->db;
Db *aDb = db->aDb;
int nDb = db->nDb;
- /* Assert that the all mutexes have been held continously since
- ** the most recent sqlite3VdbeEnter() or sqlite3VdbeMutexResync().
- */
- assert( mutexCounterSum(p) == p->iMutexCounter );
-
for(i=0, mask=1; i<nDb; i++, mask += mask){
if( i!=1 && (mask & p->btreeMask)!=0 && ALWAYS(aDb[i].pBt!=0) ){
sqlite3BtreeLeave(aDb[i].pBt);
}
}
-#else
- UNUSED_PARAMETER(p);
-#endif
}
-
-/*
-** Recompute the sum of the mutex counters on all btrees used by the
-** prepared statement p.
-**
-** Call this routine while holding a sqlite3VdbeEnter() after doing something
-** that might cause one or more of the individual mutexes held by the
-** prepared statement to be released. Calling sqlite3BtreeEnter() on
-** any BtShared mutex which is not used by the prepared statement is one
-** way to cause one or more of the mutexes in the prepared statement
-** to be temporarily released. The anti-deadlocking logic in
-** sqlite3BtreeEnter() can cause mutexes to be released temporarily then
-** reacquired.
-**
-** Calling this routine is an acknowledgement that some of the individual
-** mutexes in the prepared statement might have been released and reacquired.
-** So checks to verify that mutex-protected content did not change
-** unexpectedly should accompany any call to this routine.
-*/
-void sqlite3VdbeMutexResync(Vdbe *p){
-#if !defined(SQLITE_OMIT_SHARED_CACHE) && defined(SQLITE_DEBUG)
- p->iMutexCounter = mutexCounterSum(p);
-#else
- UNUSED_PARAMETER(p);
#endif
-}
#if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
/*
}
/* Release the locks */
- sqlite3VdbeMutexResync(p);
sqlite3VdbeLeave(p);
}