diff --git a/ext/fts3/fts3_aux.c b/ext/fts3/fts3_aux.c index 90190df2c5..6108689ae1 100644 --- a/ext/fts3/fts3_aux.c +++ b/ext/fts3/fts3_aux.c @@ -69,6 +69,8 @@ static int fts3auxConnectMethod( int rc; /* value returned by declare_vtab() */ Fts3auxTable *p; /* Virtual table object to return */ + UNUSED_PARAMETER(pUnused); + /* The user should specify a single argument - the name of an fts3 table. */ if( argc!=4 ){ *pzErr = sqlite3_mprintf( @@ -138,6 +140,8 @@ static int fts3auxBestIndexMethod( int iGe = -1; int iLe = -1; + UNUSED_PARAMETER(pVTab); + /* This vtab delivers always results in "ORDER BY term ASC" order. */ if( pInfo->nOrderBy==1 && pInfo->aOrderBy[0].iColumn==0 @@ -186,6 +190,8 @@ static int fts3auxBestIndexMethod( static int fts3auxOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){ Fts3auxCursor *pCsr; /* Pointer to cursor object to return */ + UNUSED_PARAMETER(pVTab); + pCsr = (Fts3auxCursor *)sqlite3_malloc(sizeof(Fts3auxCursor)); if( !pCsr ) return SQLITE_NOMEM; memset(pCsr, 0, sizeof(Fts3auxCursor)); @@ -335,6 +341,8 @@ static int fts3auxFilterMethod( int rc; int isScan; + UNUSED_PARAMETER(nVal); + assert( idxStr==0 ); assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0 || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT diff --git a/ext/icu/icu.c b/ext/icu/icu.c index e99f1424b5..ae28d70613 100644 --- a/ext/icu/icu.c +++ b/ext/icu/icu.c @@ -247,6 +247,8 @@ static void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){ UBool res; const UChar *zString = sqlite3_value_text16(apArg[1]); + (void)nArg; /* Unused parameter */ + /* If the left hand side of the regexp operator is NULL, ** then the result is also NULL. */ @@ -475,7 +477,7 @@ int sqlite3IcuInit(sqlite3 *db){ int rc = SQLITE_OK; int i; - for(i=0; rc==SQLITE_OK && i<(sizeof(scalars)/sizeof(struct IcuScalar)); i++){ + for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){ struct IcuScalar *p = &scalars[i]; rc = sqlite3_create_function( db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0 diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 13e5ea241c..ebf430a98c 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1268,7 +1268,7 @@ static int rtreeFilter( rc = SQLITE_NOMEM; }else{ memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc); - assert( (idxStr==0 && argc==0) || strlen(idxStr)==argc*2 ); + assert( (idxStr==0 && argc==0) || (int)strlen(idxStr)==argc*2 ); for(ii=0; iiaConstraint[ii]; p->op = idxStr[ii*2]; @@ -1361,7 +1361,7 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ UNUSED_PARAMETER(tab); assert( pIdxInfo->idxStr==0 ); - for(ii=0; iinConstraint && iIdx<(sizeof(zIdxStr)-1); ii++){ + for(ii=0; iinConstraint && iIdx<(int)(sizeof(zIdxStr)-1); ii++){ struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii]; if( p->usable && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){ diff --git a/manifest b/manifest index be3153a3f4..afb3dfd8b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Pull\sthe\slatest\strunk\schanges\s(and\shence\sthe\sschema-parse-refactor\schanges)\ninto\sthe\ssessions\sbranch. -D 2011-04-05T13:27:30.706 +C Merge\sthe\slatest\strunk\schanges\sinto\sthe\ssessions\sbranch. +D 2011-04-05T22:13:49.215 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -64,7 +64,7 @@ F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d F ext/fts3/fts3.c 5653c5654ac9b65bf3646af7e1d695c7e9b991a0 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 945926ea4b6a686c3e9834640a252d9870b7191e -F ext/fts3/fts3_aux.c 1b663dd269ea4c5e816633d9a3378ed30b004879 +F ext/fts3/fts3_aux.c 9e931f55eed8498dafe7bc1160f10cbb1a652fdf F ext/fts3/fts3_expr.c 5f49e0deaf723724b08100bb3ff40aab02ad0c93 F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec @@ -78,10 +78,10 @@ F ext/fts3/fts3_write.c 813495ed106eb9461044e3c0374f4db69b37eb09 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 -F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2 +F ext/icu/icu.c eb9ae1d79046bd7871aa97ee6da51eb770134b5a F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 48705ee892c30cc05cd40006d2509ad192530907 +F ext/rtree/rtree.c f5fa951eba03c41d292958064604a033021acdee F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test dbd4250ac0ad367a262eb9676f7e3080b0368206 F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -129,11 +129,11 @@ F src/attach.c 7cae2cf0c14762ce14c074a860ec52890a973a56 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef -F src/btmutex.c b81062220a4f91b0bd785d13d57205d68449be88 -F src/btree.c 107723ed4f9bdb55213ba6164c30c49af75f4bf9 -F src/btree.h c0e0ff5c85effe9fc757e3085bbdded6d1cca000 -F src/btreeInt.h 6714ce2f5e879eb9a904a6a4575dc4faa4f29991 -F src/build.c d809f57250b10e83586bc23921de02055890b239 +F src/btmutex.c 7907af20b954a8605766fbd2d87b47647422960e +F src/btree.c 6002f05e15aca2f22ab072a0be13b7394a8c0858 +F src/btree.h 221e186cd64127088890a878aaab154344380fe8 +F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 +F src/build.c b7c993274ee2a029937b0bc4815bdef80b330017 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 @@ -152,13 +152,13 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e -F src/main.c 50d70810f4cd625c7a8408030efad899aaccccad -F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 +F src/main.c 37608a8346394e52690368742d734f7b01330aaa +F src/malloc.c 788f2ed928786dfe305b6783d551d6b1a9080976 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3 -F src/mem5.c 72e0bc40f535ac38a11712aed01d0014f9300732 +F src/mem5.c c2c63b7067570b00bf33d751c39af24182316f7f F src/memjournal.c 0ebce851677a7ac035ba1512a7e65851b34530c6 F src/mutex.c 6949180803ff05a7d0e2b9334a95b4fb5a00e23f F src/mutex.h fe2ef5e1c4dae531d5a544f9241f19c56d26803d @@ -173,7 +173,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 2596fd2d5d0976c6c0c628d0c3c7c4e7a724f4cf F src/os_unix.c 32414676594a0a26cfccd7e02656230a3406eee7 F src/os_win.c 24d72407a90551969744cf9bcbb1b4c72c5fa845 -F src/pager.c 6aa906b60a59664ba58d3f746164bb010d407ce1 +F src/pager.c 055239dcdfe12b3f5d97f6f01f85da01e2d6d912 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -186,7 +186,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 -F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a +F src/shell.c a73b30067ec15f116d5d0c28880179898fbe3d0b F src/sqlite.h.in 235300cdca517ce148385d3ab816e7e8cf9e1ff3 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 0873a71099f763cdf24cfabf04a237ad100e20d0 @@ -244,11 +244,11 @@ F src/update.c 3f3f3bb734a0da1dffd0ed33e504642b35ed3605 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c cd997077bad039efc0597eb027c929658f93c018 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e -F src/vdbe.c f38def1fc23013c13d8e97a1551c2ed0e23136fe +F src/vdbe.c b6bcbe5663d942d49d7a2e25d437fed82da5b709 F src/vdbe.h 44fd57aeed86da0cd31206626c13cdde0e72cc0e -F src/vdbeInt.h 36dddc4cc333867d27f00d326e29af30062a102a -F src/vdbeapi.c 7ef519083e3420bf7793d8b4eae2961d894d98ab -F src/vdbeaux.c 12765fcaa529846f547f9e31a042968f84056dcd +F src/vdbeInt.h 3dec3d5b88173c6aad0a6bc23d58142636c6cb82 +F src/vdbeapi.c 8051038f7674c708f4515ab189fc3ea929e09a4c +F src/vdbeaux.c 88671caaee3ef9c5e600486b3961c395bc4ac493 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 @@ -256,7 +256,7 @@ F src/vtab.c b0abc931f95af94c9ffdf9f747eb191cda953123 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 176574bfeee13775761ce56416f773b0ec115d3f +F src/where.c 71e6808f74b9df913b5cdf242419b0edaf768310 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -870,7 +870,7 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d -F test/wal.test 973a4747a69247a43cc03292c44f59cc76f4df65 +F test/wal.test 084b086913a205eab4dde4b9a9cf8c781a576bb8 F test/wal2.test e561a8c6fdd1c2cd1876f3e39757934e7b7361f8 F test/wal3.test 5c396cc22497244d627306f4c1d360167353f8dd F test/wal4.test 3404b048fa5e10605facaf70384e6d2943412e30 @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 95d53c44320b9639f2623aa9cc88d0d3e1a3be8f 5db4511d8a77b74be3503a7c34257ef6b07541f5 -R 674c9237ca4fa927463c92020097f885 +P 03ca83422f0259ae5525aeecc14171811252a67d 3eeb0ff78d04891b5fd1a3d99a9fb8cfbed77a81 +R f0650bbd397ea127a3fadf071b0b957e U drh -Z 76b761508ba82daab535ead06aca81f1 +Z 199b5e50f9e261886cd6678fe8286ef5 diff --git a/manifest.uuid b/manifest.uuid index d499c43cc8..6a6f0c6b06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03ca83422f0259ae5525aeecc14171811252a67d \ No newline at end of file +45f20261720dcd73eb887f7e3df100723000418b \ No newline at end of file diff --git a/src/btmutex.c b/src/btmutex.c index 33b9f86a0c..ffe124fdd6 100644 --- a/src/btmutex.c +++ b/src/btmutex.c @@ -45,28 +45,10 @@ static void unlockBtreeMutex(Btree *p){ 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. ** @@ -111,24 +93,6 @@ void sqlite3BtreeEnter(Btree *p){ 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; iinDb; 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. @@ -222,30 +186,11 @@ void sqlite3BtreeLeaveCursor(BtCursor *pCur){ */ void sqlite3BtreeEnterAll(sqlite3 *db){ int i; - Btree *p, *pLater; + Btree *p; assert( sqlite3_mutex_held(db->mutex) ); for(i=0; inDb; i++){ p = db->aDb[i].pBt; - assert( !p || (p->locked==0 && p->sharable) || p->pBt->db==p->db ); - if( p && p->sharable ){ - p->wantToLock++; - if( !p->locked ){ - assert( p->wantToLock==1 ); - while( p->pPrev ) p = p->pPrev; - /* Reason for ALWAYS: There must be at least one unlocked Btree in - ** the chain. Otherwise the !p->locked test above would have failed */ - while( p->locked && ALWAYS(p->pNext) ) p = p->pNext; - for(pLater = p->pNext; pLater; pLater=pLater->pNext){ - if( pLater->locked ){ - unlockBtreeMutex(pLater); - } - } - while( p ){ - lockBtreeMutex(p); - p = p->pNext; - } - } - } + if( p ) sqlite3BtreeEnter(p); } } void sqlite3BtreeLeaveAll(sqlite3 *db){ @@ -254,13 +199,7 @@ void sqlite3BtreeLeaveAll(sqlite3 *db){ assert( sqlite3_mutex_held(db->mutex) ); for(i=0; inDb; i++){ p = db->aDb[i].pBt; - if( p && p->sharable ){ - assert( p->wantToLock>0 ); - p->wantToLock--; - if( p->wantToLock==0 ){ - unlockBtreeMutex(p); - } - } + if( p ) sqlite3BtreeLeave(p); } } diff --git a/src/btree.c b/src/btree.c index d86b9edad1..449ba6edea 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1228,7 +1228,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){ */ top -= nByte; put2byte(&data[hdr+5], top); - assert( top+nByte <= pPage->pBt->usableSize ); + assert( top+nByte <= (int)pPage->pBt->usableSize ); *pIdx = top; return SQLITE_OK; } @@ -1249,7 +1249,7 @@ static int freeSpace(MemPage *pPage, int start, int size){ assert( pPage->pBt!=0 ); assert( sqlite3PagerIswriteable(pPage->pDbPage) ); assert( start>=pPage->hdrOffset+6+pPage->childPtrSize ); - assert( (start + size)<=pPage->pBt->usableSize ); + assert( (start + size) <= (int)pPage->pBt->usableSize ); assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( size>=0 ); /* Minimum cell size is 4 */ @@ -1292,7 +1292,7 @@ static int freeSpace(MemPage *pPage, int start, int size){ while( (pbegin = get2byte(&data[addr]))>0 ){ int pnext, psize, x; assert( pbegin>addr ); - assert( pbegin<=pPage->pBt->usableSize-4 ); + assert( pbegin <= (int)pPage->pBt->usableSize-4 ); pnext = get2byte(&data[pbegin]); psize = get2byte(&data[pbegin+2]); if( pbegin + psize + 3 >= pnext && pnext>0 ){ @@ -5499,7 +5499,7 @@ static void insertCell( /* The allocateSpace() routine guarantees the following two properties ** if it returns success */ assert( idx >= end+2 ); - assert( idx+sz <= pPage->pBt->usableSize ); + assert( idx+sz <= (int)pPage->pBt->usableSize ); pPage->nCell++; pPage->nFree -= (u16)(2 + sz); memcpy(&data[idx+nSkip], pCell+nSkip, sz-nSkip); @@ -5542,7 +5542,8 @@ static void assemblePage( assert( pPage->nOverflow==0 ); assert( sqlite3_mutex_held(pPage->pBt->mutex) ); - assert( nCell>=0 && nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=10921); + assert( nCell>=0 && nCell<=(int)MX_CELL(pPage->pBt) + && (int)MX_CELL(pPage->pBt)<=10921); assert( sqlite3PagerIswriteable(pPage->pDbPage) ); /* Check that the page has just been zeroed by zeroPage() */ @@ -5756,7 +5757,7 @@ static void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){ assert( pFrom->isInit ); assert( pFrom->nFree>=iToHdr ); - assert( get2byte(&aFrom[iFromHdr+5])<=pBt->usableSize ); + assert( get2byte(&aFrom[iFromHdr+5]) <= (int)pBt->usableSize ); /* Copy the b-tree node content from page pFrom to page pTo. */ iData = get2byte(&aFrom[iFromHdr+5]); @@ -6023,7 +6024,7 @@ static int balance_nonroot( pTemp = &aSpace1[iSpace1]; iSpace1 += sz; assert( sz<=pBt->maxLocal+23 ); - assert( iSpace1<=pBt->pageSize ); + assert( iSpace1 <= (int)pBt->pageSize ); memcpy(pTemp, apDiv[i], sz); apCell[nCell] = pTemp+leafCorrection; assert( leafCorrection==0 || leafCorrection==4 ); @@ -6267,7 +6268,7 @@ static int balance_nonroot( } iOvflSpace += sz; assert( sz<=pBt->maxLocal+23 ); - assert( iOvflSpace<=pBt->pageSize ); + assert( iOvflSpace <= (int)pBt->pageSize ); insertCell(pParent, nxDiv, pCell, sz, pTemp, pNew->pgno, &rc); if( rc!=SQLITE_OK ) goto balance_cleanup; assert( sqlite3PagerIswriteable(pParent->pDbPage) ); @@ -6712,7 +6713,7 @@ int sqlite3BtreeInsert( rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew); if( rc ) goto end_insert; assert( szNew==cellSizePtr(pPage, newCell) ); - assert( szNew<=MX_CELL_SIZE(pBt) ); + assert( szNew <= MX_CELL_SIZE(pBt) ); idx = pCur->aiIdx[pCur->iPage]; if( loc==0 ){ u16 szOld; @@ -6852,7 +6853,7 @@ int sqlite3BtreeDelete(BtCursor *pCur){ pCell = findCell(pLeaf, pLeaf->nCell-1); nCell = cellSizePtr(pLeaf, pCell); - assert( MX_CELL_SIZE(pBt)>=nCell ); + assert( MX_CELL_SIZE(pBt) >= nCell ); allocateTempSpace(pBt); pTmp = pBt->pTmpSpace; diff --git a/src/btree.h b/src/btree.h index 3eebfe20b5..12ff746566 100644 --- a/src/btree.h +++ b/src/btree.h @@ -221,19 +221,17 @@ void sqlite3BtreeCursorList(Btree*); 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 diff --git a/src/btreeInt.h b/src/btreeInt.h index 2aee063d39..55469cff90 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -218,7 +218,7 @@ /* The following value is the maximum cell size assuming a maximum page ** size give above. */ -#define MX_CELL_SIZE(pBt) (pBt->pageSize-8) +#define MX_CELL_SIZE(pBt) ((int)(pBt->pageSize-8)) /* The maximum number of cells on a single page of the database. This ** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself @@ -435,7 +435,6 @@ struct BtShared { 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 */ }; diff --git a/src/build.c b/src/build.c index 7e73b6a8eb..8ab07c857c 100644 --- a/src/build.c +++ b/src/build.c @@ -414,14 +414,16 @@ void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){ /* Case 1: Reset the single schema identified by iDb */ Db *pDb = &db->aDb[iDb]; assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); - if( ALWAYS(pDb->pSchema) ){ - sqlite3SchemaClear(pDb->pSchema); - } + assert( pDb->pSchema!=0 ); + sqlite3SchemaClear(pDb->pSchema); + /* If any database other than TEMP is reset, then also reset TEMP ** since TEMP might be holding triggers that reference tables in the ** other database. */ - if( iDb!=1 && (pDb = &db->aDb[1])!=0 && ALWAYS(pDb->pSchema) ){ + if( iDb!=1 ){ + pDb = &db->aDb[1]; + assert( pDb->pSchema!=0 ); sqlite3SchemaClear(pDb->pSchema); } return; @@ -1410,7 +1412,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){ zSep = zSep2; identPut(zStmt, &k, pCol->zName); assert( pCol->affinity-SQLITE_AFF_TEXT >= 0 ); - assert( pCol->affinity-SQLITE_AFF_TEXT < sizeof(azType)/sizeof(azType[0]) ); + assert( pCol->affinity-SQLITE_AFF_TEXT < ArraySize(azType) ); testcase( pCol->affinity==SQLITE_AFF_TEXT ); testcase( pCol->affinity==SQLITE_AFF_NONE ); testcase( pCol->affinity==SQLITE_AFF_NUMERIC ); diff --git a/src/main.c b/src/main.c index 1d566fecb1..ffd4858785 100644 --- a/src/main.c +++ b/src/main.c @@ -891,7 +891,7 @@ static int sqliteDefaultBusyCallback( { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; static const u8 totals[] = { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; -# define NDELAY (sizeof(delays)/sizeof(delays[0])) +# define NDELAY ArraySize(delays) sqlite3 *db = (sqlite3 *)ptr; int timeout = db->busyTimeout; int delay, prior; diff --git a/src/malloc.c b/src/malloc.c index a3a9e0fe2c..50fdf524c5 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -404,7 +404,7 @@ void sqlite3ScratchFree(void *p){ pSlot->pNext = mem0.pScratchFree; mem0.pScratchFree = pSlot; mem0.nScratchFree++; - assert( mem0.nScratchFree<=sqlite3GlobalConfig.nScratch ); + assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch ); sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); sqlite3_mutex_leave(mem0.mutex); }else{ diff --git a/src/mem5.c b/src/mem5.c index 5d6a5b5806..783cef6176 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -127,7 +127,7 @@ static SQLITE_WSD struct Mem5Global { */ u8 *aCtrl; -} mem5 = { 0 }; +} mem5; /* ** Access the static variable through a macro for SQLITE_OMIT_WSD @@ -442,7 +442,7 @@ static int memsys5Roundup(int n){ */ static int memsys5Log(int iValue){ int iLog; - for(iLog=0; (iLog<((sizeof(int)*8)-1)) && (1<pDirty){ + if( p->pgno<=nTruncate ) ppNext = &p->pDirty; + } + assert( pList ); + } + if( pList->pgno==1 ) pager_write_changecounter(pList); rc = sqlite3WalFrames(pPager->pWal, pPager->pageSize, pList, nTruncate, isCommit, syncFlags @@ -2984,6 +2997,7 @@ static int pagerWalFrames( } #ifdef SQLITE_CHECK_PAGES + pList = sqlite3PcacheDirtyList(pPager->pPCache); for(p=pList; p; p=p->pDirty){ pager_set_pagehash(p); } diff --git a/src/shell.c b/src/shell.c index be4e0de281..78788a5bb9 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2200,7 +2200,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ /* convert testctrl text option to value. allow any unique prefix ** of the option name, or a numerical value. */ n = strlen(azArg[1]); - for(i=0; ixFunc)(&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 @@ -2670,7 +2669,6 @@ case OP_Savepoint: { if( p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){ sqlite3ExpirePreparedStatements(db); sqlite3ResetInternalSchema(db, -1); - sqlite3VdbeMutexResync(p); db->flags = (db->flags | SQLITE_InternChanges); } } @@ -2943,7 +2941,7 @@ case OP_VerifyCookie: { sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta); iGen = db->aDb[pOp->p1].pSchema->iGeneration; }else{ - iMeta = 0; + iGen = iMeta = 0; } if( iMeta!=pOp->p2 || iGen!=pOp->p3 ){ sqlite3DbFree(db, p->zErrMsg); @@ -5250,23 +5248,11 @@ case OP_AggStep: { 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; @@ -5290,11 +5276,8 @@ case OP_AggFinal: { 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); @@ -5369,24 +5352,6 @@ case OP_JournalMode: { /* out2-prerelease */ ); assert( pOp->p1>=0 && pOp->p1nDb ); - /* This opcode is used in two places: PRAGMA journal_mode and ATTACH. - ** In PRAGMA journal_mode, the sqlite3VdbeUsesBtree() routine is called - ** when the statement is prepared and so p->btreeMask!=0. All mutexes - ** are already acquired. But when used in ATTACH, sqlite3VdbeUsesBtree() - ** is not called when the statement is prepared because it requires the - ** iDb index of the database as a parameter, and the database has not - ** yet been attached so that index is unavailable. We have to wait - ** until runtime (now) to get the mutex on the newly attached database. - ** No other mutexes are required by the ATTACH command so this is safe - ** to do. - */ - if( p->btreeMask==0 ){ - /* This occurs right after ATTACH. Get a mutex on the newly ATTACHed - ** database. */ - sqlite3VdbeUsesBtree(p, pOp->p1); - sqlite3VdbeEnter(p); - } - pBt = db->aDb[pOp->p1].pBt; pPager = sqlite3BtreePager(pBt); eOld = sqlite3PagerGetJournalMode(pPager); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 05136cbeb9..94c3447251 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -303,7 +303,6 @@ struct Vdbe { 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 @@ -408,9 +407,14 @@ int sqlite3VdbeFrameRestore(VdbeFrame *); void sqlite3VdbeMemStoreType(Mem *pMem); void sqlite3VdbePreUpdateHook( Vdbe *, VdbeCursor *, int, const char*, Table *, i64, int); -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*); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 8af16e9ee3..8d6e862bcb 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -710,8 +710,26 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){ pOut = &pVm->pResultSet[i]; }else{ /* If the value passed as the second argument is out of range, return - ** a pointer to a static Mem object that contains the value SQL NULL. - */ + ** a pointer to the following static Mem object which contains the + ** value SQL NULL. Even though the Mem structure contains an element + ** of type i64, on certain architecture (x86) with certain compiler + ** switches (-Os), gcc may align this Mem object on a 4-byte boundary + ** instead of an 8-byte one. This all works fine, except that when + ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s + ** that a Mem structure is located on an 8-byte boundary. To prevent + ** this assert() from failing, when building with SQLITE_DEBUG defined + ** using gcc, force nullMem to be 8-byte aligned using the magical + ** __attribute__((aligned(8))) macro. */ + static const Mem nullMem +#if defined(SQLITE_DEBUG) && defined(__GNUC__) + __attribute__((aligned(8))) +#endif + = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, +#ifdef SQLITE_DEBUG + 0, 0, /* pScopyFrom, pFiller */ +#endif + 0, 0 }; + if( pVm && ALWAYS(pVm->db) ){ sqlite3_mutex_enter(pVm->db->mutex); sqlite3Error(pVm->db, SQLITE_RANGE, 0); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 488c1d60ce..e625b9541c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -956,36 +956,12 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ ** is maintained in p->btreeMask and is used for locking and other purposes. */ void sqlite3VdbeUsesBtree(Vdbe *p, int i){ - assert( i>=0 && idb->nDb && i=0 && idb->nDb && i<(int)sizeof(yDbMask)*8 ); assert( i<(int)sizeof(p->btreeMask)*8 ); p->btreeMask |= ((yDbMask)1)<db; - Db *aDb = db->aDb; - int nDb = db->nDb; - for(i=0, mask=1; ibtreeMask)!=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 @@ -1008,7 +984,6 @@ static u32 mutexCounterSum(Vdbe *p){ ** be a problem. */ void sqlite3VdbeEnter(Vdbe *p){ -#ifndef SQLITE_OMIT_SHARED_CACHE int i; yDbMask mask; sqlite3 *db = p->db; @@ -1019,63 +994,27 @@ void sqlite3VdbeEnter(Vdbe *p){ 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; ibtreeMask)!=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) /* @@ -2284,7 +2223,6 @@ int sqlite3VdbeHalt(Vdbe *p){ } /* Release the locks */ - sqlite3VdbeMutexResync(p); sqlite3VdbeLeave(p); } diff --git a/src/where.c b/src/where.c index 5d8b8f4ad5..ca1fcf6d36 100644 --- a/src/where.c +++ b/src/where.c @@ -399,7 +399,7 @@ static void whereSplit(WhereClause *pWC, Expr *pExpr, int op){ */ static Bitmask getMask(WhereMaskSet *pMaskSet, int iCursor){ int i; - assert( pMaskSet->n<=sizeof(Bitmask)*8 ); + assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 ); for(i=0; in; i++){ if( pMaskSet->ix[i]==iCursor ){ return ((Bitmask)1)<