From 0d8bba982d43e32222650e0c795b09b34442c5fc Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Apr 2011 14:22:48 +0000 Subject: [PATCH 1/7] Fix a documentation typo. FossilOrigin-Name: d25c17ef6e2b916923489dccaaa018a2d6525401 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e0e1861928..2b406206a1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\sscheme-parse-refactor\schanges\sinto\strunk:\s(1)\sadded\nsqlite3SchemaMutexHeld()\sasserts,\s(2)\sUse\s-1\sinstead\sof\s0\sto\smean\n"all"\sin\ssqlite3ResetInternalSchema(),\sand\sother\scosmetic\schanges. -D 2011-04-05T13:12:28.885 +C Fix\sa\sdocumentation\stypo. +D 2011-04-05T14:22:48.053 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a -F src/sqlite.h.in e047f69a61d604d4f8be6cf1d1bdfc68be9ba7e5 +F src/sqlite.h.in 923630d8249b66cf8a266dd53d4d094cace80164 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 7b0150bfdab049b11bb2d055d065051ff734d113 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P bf664b206bf6f5c1941da1986dfe2c0d1831d5e4 2aff1b0ca87a99b8ec80e696b9e8a48bb43db2c2 -R 22cfdab389baca0a36a30b474bcbf649 +P 5db4511d8a77b74be3503a7c34257ef6b07541f5 +R f66ac9973277650bde436573608ca94f U drh -Z d9847e96611c99287cdc62e449a97608 +Z c91a504724af14c0a00d31f50ea2afef diff --git a/manifest.uuid b/manifest.uuid index b996a954a3..b15abcdb11 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5db4511d8a77b74be3503a7c34257ef6b07541f5 \ No newline at end of file +d25c17ef6e2b916923489dccaaa018a2d6525401 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index c4dc4a6ef9..2604f67c07 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1129,7 +1129,7 @@ int sqlite3_config(int, ...); ** [database connection] (specified in the first argument). ** ** The second argument to sqlite3_db_config(D,V,...) is the -** [SQLITE_DBCONIG_LOOKASIDE | configuration verb] - an integer code +** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code ** that indicates what aspect of the [database connection] is being configured. ** Subsequent arguments vary depending on the configuration verb. ** From ce8e5ffe1c393127300059512b8b5d6e17efa6c6 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 Apr 2011 16:09:08 +0000 Subject: [PATCH 2/7] When committing a WAL transaction, do not write any pages to the WAL file with page numbers greater than the size of the database image in pages. FossilOrigin-Name: 311d0b613d9cfa2dbcbb9ef2450041b1fd48770a --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pager.c | 14 ++++++++++++++ test/wal.test | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2b406206a1..70ae57dd5d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sdocumentation\stypo. -D 2011-04-05T14:22:48.053 +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 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -164,7 +164,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 @@ -860,7 +860,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 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 5db4511d8a77b74be3503a7c34257ef6b07541f5 -R f66ac9973277650bde436573608ca94f -U drh -Z c91a504724af14c0a00d31f50ea2afef +P d25c17ef6e2b916923489dccaaa018a2d6525401 +R c888a09e2325a742237e83457c23e497 +U dan +Z 881050430264f599344995b52c518cce diff --git a/manifest.uuid b/manifest.uuid index b15abcdb11..7db1b81310 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d25c17ef6e2b916923489dccaaa018a2d6525401 \ No newline at end of file +311d0b613d9cfa2dbcbb9ef2450041b1fd48770a \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index da13ddc6fe..94f647dcc9 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2972,6 +2972,19 @@ static int pagerWalFrames( } #endif + if( isCommit ){ + /* If a WAL transaction is being committed, there is no point in writing + ** any pages with page numbers greater than nTruncate into the WAL file. + ** They will never be read by any client. So remove them from the pDirty + ** list here. */ + PgHdr *p; + PgHdr **ppNext = &pList; + for(p=pList; (*ppNext = p); p=p->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/test/wal.test b/test/wal.test index 257a87b092..ff88f314d2 100644 --- a/test/wal.test +++ b/test/wal.test @@ -19,6 +19,8 @@ source $testdir/lock_common.tcl source $testdir/malloc_common.tcl source $testdir/wal_common.tcl +set testprefix wal + ifcapable !wal {finish_test ; return } proc reopen_db {} { @@ -1504,6 +1506,54 @@ do_test wal-23.4 { set ::log } [list SQLITE_OK "Recovered $nPage frames from WAL file $walfile"] + +ifcapable autovacuum { + # This block tests that if the size of a database is reduced by a + # transaction (because of an incremental or auto-vacuum), that no + # data is written to the WAL file for the truncated pages as part + # of the commit. e.g. if a transaction reduces the size of a database + # to N pages, data for page N+1 should not be written to the WAL file + # when committing the transaction. At one point such data was being + # written. + # + catch {db close} + forcedelete test.db + sqlite3 db test.db + do_execsql_test 24.1 { + PRAGMA auto_vacuum = 2; + PRAGMA journal_mode = WAL; + PRAGMA page_size = 1024; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(randomblob(5000)); + INSERT INTO t1 SELECT * FROM t1; + INSERT INTO t1 SELECT * FROM t1; + INSERT INTO t1 SELECT * FROM t1; + INSERT INTO t1 SELECT * FROM t1; + } {wal} + do_execsql_test 24.2 { + DELETE FROM t1; + PRAGMA wal_checkpoint; + } {0 109 109} + do_test 24.3 { + db close + sqlite3 db test.db + file exists test.db-wal + } 0 + do_test 24.4 { + file size test.db + } [expr 84 * 1024] + do_test 24.5 { + execsql { + PRAGMA incremental_vacuum; + PRAGMA wal_checkpoint; + } + file size test.db + } [expr 3 * 1024] + do_test 24.6 { + file size test.db-wal + } 2128 +} + db close sqlite3_shutdown test_sqlite3_log From e54e051800948da6bc223e51981cfb437d53911b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Apr 2011 17:31:56 +0000 Subject: [PATCH 3/7] Remove the mutex counter and the logic that attempts to verify that btree mutexes are held continuously. We are not making that assumption at this time. FossilOrigin-Name: 242ce7cff416a87d57d4eb624cb79fa4e2215559 --- manifest | 24 +++++++++--------- manifest.uuid | 2 +- src/btmutex.c | 36 -------------------------- src/btree.h | 4 +-- src/btreeInt.h | 1 - src/vdbe.c | 17 ------------- src/vdbeInt.h | 12 ++++++--- src/vdbeaux.c | 68 +++----------------------------------------------- 8 files changed, 25 insertions(+), 139 deletions(-) diff --git a/manifest b/manifest index 70ae57dd5d..ffcff16331 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 @@ -120,10 +120,10 @@ 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/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 @@ -235,11 +235,11 @@ F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 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 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 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 diff --git a/manifest.uuid b/manifest.uuid index 7db1b81310..1d771e4bfb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -311d0b613d9cfa2dbcbb9ef2450041b1fd48770a \ No newline at end of file +242ce7cff416a87d57d4eb624cb79fa4e2215559 \ No newline at end of file diff --git a/src/btmutex.c b/src/btmutex.c index 33b9f86a0c..1de9db07e7 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. 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..fd3091b941 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -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/vdbe.c b/src/vdbe.c index 94fd0ff62b..d2e60a570e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1394,7 +1394,6 @@ case OP_Function: { 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 @@ -2660,7 +2659,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); } } @@ -5198,23 +5196,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; @@ -5238,11 +5224,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); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 15e4a812a7..13faa0a292 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 @@ -387,9 +386,14 @@ int sqlite3VdbeCloseStatement(Vdbe *, int); 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*); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7313ad5c38..ad6e41c3fd 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -960,31 +960,7 @@ void sqlite3VdbeUsesBtree(Vdbe *p, int i){ 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 @@ -1007,7 +983,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; @@ -1018,63 +993,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) /* @@ -2283,7 +2222,6 @@ int sqlite3VdbeHalt(Vdbe *p){ } /* Release the locks */ - sqlite3VdbeMutexResync(p); sqlite3VdbeLeave(p); } From 8d4991e7ba4e79fabcb3e0f4f6919b9d25d95401 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Apr 2011 18:34:10 +0000 Subject: [PATCH 4/7] Remove dead code from the OP_JournalMode opcode in the VDBE. This code seems to have been useless since [f88c6367d2] on [20010-08-07]. FossilOrigin-Name: a89f24e2c9591d09cbe329895ceec87885059184 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 18 ------------------ 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index ffcff16331..50fd159d4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 +C Remove\sdead\scode\sfrom\sthe\sOP_JournalMode\sopcode\sin\sthe\sVDBE.\nThis\scode\sseems\sto\shave\sbeen\suseless\ssince\s[f88c6367d2]\son\s[20010-08-07]. +D 2011-04-05T18:34:10.447 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -235,7 +235,7 @@ F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c cd997077bad039efc0597eb027c929658f93c018 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e -F src/vdbe.c b239d70f6862f1d0d3896c96efe7d6fabae1c56c +F src/vdbe.c 228aa30631e8055bc945cfbb8db8f7919c4ef5fb F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 F src/vdbeInt.h 53dfcaf5b83297c24f537c4a54c1f35fd655b0a2 F src/vdbeapi.c a09ad9164cafc505250d5dd6b69660c960f1308c @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 311d0b613d9cfa2dbcbb9ef2450041b1fd48770a -R f2efb954b9e1d86872be6fb2ad3e5711 +P 242ce7cff416a87d57d4eb624cb79fa4e2215559 +R 4126212ea9377af4a6c83d929ba0db43 U drh -Z c70542c8d51f5c49bbcf63ab42aa4a3a +Z 5632e38bce7132d08196aa617cc89aa5 diff --git a/manifest.uuid b/manifest.uuid index 1d771e4bfb..828e0e81f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -242ce7cff416a87d57d4eb624cb79fa4e2215559 \ No newline at end of file +a89f24e2c9591d09cbe329895ceec87885059184 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index d2e60a570e..ce62d7f12b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -5300,24 +5300,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); From d3ef5ae05f75fd070be6480e47d45645b8f3d135 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Apr 2011 19:26:30 +0000 Subject: [PATCH 5/7] Simplifications to the sqlite3ResetInternalSchema() logic to eliminate unreachable branches. FossilOrigin-Name: a4c3ac989d4e93f0279172901b9ece822d137700 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 50fd159d4c..e1a02097f3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sdead\scode\sfrom\sthe\sOP_JournalMode\sopcode\sin\sthe\sVDBE.\nThis\scode\sseems\sto\shave\sbeen\suseless\ssince\s[f88c6367d2]\son\s[20010-08-07]. -D 2011-04-05T18:34:10.447 +C Simplifications\sto\sthe\ssqlite3ResetInternalSchema()\slogic\sto\seliminate\nunreachable\sbranches. +D 2011-04-05T19:26:30.895 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/btmutex.c 1f951523accdfa1d204b06150e016b5b69529b8a F src/btree.c 107723ed4f9bdb55213ba6164c30c49af75f4bf9 F src/btree.h 221e186cd64127088890a878aaab154344380fe8 F src/btreeInt.h b5e339df994d12bcd9067d04f9125c8792de51ac -F src/build.c d809f57250b10e83586bc23921de02055890b239 +F src/build.c 8fc7133b6c1e757ac40c4c0d9bae106a9aac55ee F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 242ce7cff416a87d57d4eb624cb79fa4e2215559 -R 4126212ea9377af4a6c83d929ba0db43 +P a89f24e2c9591d09cbe329895ceec87885059184 +R 4633b95d671699f85d5e19626e085a29 U drh -Z 5632e38bce7132d08196aa617cc89aa5 +Z a7a8333914941d20132af834f7ba9e5c diff --git a/manifest.uuid b/manifest.uuid index 828e0e81f9..eaf1aefc85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a89f24e2c9591d09cbe329895ceec87885059184 \ No newline at end of file +a4c3ac989d4e93f0279172901b9ece822d137700 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 7e73b6a8eb..e45697b9f0 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; From 1a86f50d85bdce2d8e766ba2f45a458b9952661b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Apr 2011 19:27:41 +0000 Subject: [PATCH 6/7] Simplifications to the sqlite3BtreeEnterAll() and LeaveAll() routines. Just have them call BtreeEnter and BtreeLeave() repeatedly rather than trying to be clever. FossilOrigin-Name: 51039b3578f948c23a810d176e81fa51a278fb28 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btmutex.c | 31 +++---------------------------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index e1a02097f3..949247b639 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\ssqlite3ResetInternalSchema()\slogic\sto\seliminate\nunreachable\sbranches. -D 2011-04-05T19:26:30.895 +C Simplifications\sto\sthe\ssqlite3BtreeEnterAll()\sand\sLeaveAll()\sroutines.\nJust\shave\sthem\scall\sBtreeEnter\sand\sBtreeLeave()\srepeatedly\srather\sthan\ntrying\sto\sbe\sclever. +D 2011-04-05T19:27:41.740 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -120,7 +120,7 @@ F src/attach.c 7cae2cf0c14762ce14c074a860ec52890a973a56 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef -F src/btmutex.c 1f951523accdfa1d204b06150e016b5b69529b8a +F src/btmutex.c 7907af20b954a8605766fbd2d87b47647422960e F src/btree.c 107723ed4f9bdb55213ba6164c30c49af75f4bf9 F src/btree.h 221e186cd64127088890a878aaab154344380fe8 F src/btreeInt.h b5e339df994d12bcd9067d04f9125c8792de51ac @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a89f24e2c9591d09cbe329895ceec87885059184 -R 4633b95d671699f85d5e19626e085a29 +P a4c3ac989d4e93f0279172901b9ece822d137700 +R b358e3039856b3a4cedf9c746c6172be U drh -Z a7a8333914941d20132af834f7ba9e5c +Z 63f8b79eae39a68f25008b0134502554 diff --git a/manifest.uuid b/manifest.uuid index eaf1aefc85..811f3eeeb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4c3ac989d4e93f0279172901b9ece822d137700 \ No newline at end of file +51039b3578f948c23a810d176e81fa51a278fb28 \ No newline at end of file diff --git a/src/btmutex.c b/src/btmutex.c index 1de9db07e7..ffe124fdd6 100644 --- a/src/btmutex.c +++ b/src/btmutex.c @@ -186,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){ @@ -218,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); } } From fcd71b6010ef105b61f18de5a579024174356172 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Apr 2011 22:08:24 +0000 Subject: [PATCH 7/7] Suppress many harmless compiler warnings, mostly signed/unsigned comparisons within asserts or unused parameters in extensions. FossilOrigin-Name: 3eeb0ff78d04891b5fd1a3d99a9fb8cfbed77a81 --- ext/fts3/fts3_aux.c | 8 ++++++++ ext/icu/icu.c | 4 +++- ext/rtree/rtree.c | 4 ++-- manifest | 38 +++++++++++++++++++------------------- manifest.uuid | 2 +- src/btree.c | 21 +++++++++++---------- src/btreeInt.h | 2 +- src/build.c | 2 +- src/main.c | 2 +- src/malloc.c | 2 +- src/mem5.c | 4 ++-- src/shell.c | 2 +- src/vdbe.c | 2 +- src/vdbeapi.c | 6 +++++- src/vdbeaux.c | 2 +- src/where.c | 2 +- 16 files changed, 59 insertions(+), 44 deletions(-) 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 949247b639..ffd971b88a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\ssqlite3BtreeEnterAll()\sand\sLeaveAll()\sroutines.\nJust\shave\sthem\scall\sBtreeEnter\sand\sBtreeLeave()\srepeatedly\srather\sthan\ntrying\sto\sbe\sclever. -D 2011-04-05T19:27:41.740 +C Suppress\smany\sharmless\scompiler\swarnings,\smostly\ssigned/unsigned\scomparisons\s\nwithin\sasserts\sor\sunused\sparameters\sin\sextensions. +D 2011-04-05T22:08:24.148 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 @@ -121,10 +121,10 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c b7529a6691f0fd534ae8ff622203c46a7f1b626b F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 7907af20b954a8605766fbd2d87b47647422960e -F src/btree.c 107723ed4f9bdb55213ba6164c30c49af75f4bf9 +F src/btree.c 6002f05e15aca2f22ab072a0be13b7394a8c0858 F src/btree.h 221e186cd64127088890a878aaab154344380fe8 -F src/btreeInt.h b5e339df994d12bcd9067d04f9125c8792de51ac -F src/build.c 8fc7133b6c1e757ac40c4c0d9bae106a9aac55ee +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 @@ -143,13 +143,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 83cb6a9f1404d59b4dc06ef58cf20401ac1f2261 -F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 +F src/main.c 5dad851457fdd249a4d4f41e94fe9cb11aedf1f2 +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 @@ -177,7 +177,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 923630d8249b66cf8a266dd53d4d094cace80164 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 7b0150bfdab049b11bb2d055d065051ff734d113 @@ -235,11 +235,11 @@ F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c cd997077bad039efc0597eb027c929658f93c018 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e -F src/vdbe.c 228aa30631e8055bc945cfbb8db8f7919c4ef5fb +F src/vdbe.c ee58240a9b352db350d2848212ee9142a821c387 F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 F src/vdbeInt.h 53dfcaf5b83297c24f537c4a54c1f35fd655b0a2 -F src/vdbeapi.c a09ad9164cafc505250d5dd6b69660c960f1308c -F src/vdbeaux.c 64304e50c6d4ccca586410184927baa9faca6ecc +F src/vdbeapi.c e0e2672e0a96ae3f8575c8ecd02912a3e8a554a1 +F src/vdbeaux.c 3170e917af38835621deddee560e53e188147f5b F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 @@ -247,7 +247,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 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a4c3ac989d4e93f0279172901b9ece822d137700 -R b358e3039856b3a4cedf9c746c6172be +P 51039b3578f948c23a810d176e81fa51a278fb28 +R 18530986ff3caac2d2c1acc5867b1dce U drh -Z 63f8b79eae39a68f25008b0134502554 +Z 767e18c513ceaeb424f39c58cb8c31a7 diff --git a/manifest.uuid b/manifest.uuid index 811f3eeeb6..f64fd90592 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -51039b3578f948c23a810d176e81fa51a278fb28 \ No newline at end of file +3eeb0ff78d04891b5fd1a3d99a9fb8cfbed77a81 \ No newline at end of file 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/btreeInt.h b/src/btreeInt.h index fd3091b941..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 diff --git a/src/build.c b/src/build.c index e45697b9f0..8ab07c857c 100644 --- a/src/build.c +++ b/src/build.c @@ -1412,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 e05c3885b0..1f923f57c3 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<aDb[pOp->p1].pSchema->iGeneration; }else{ - iMeta = 0; + iGen = iMeta = 0; } if( iMeta!=pOp->p2 || iGen!=pOp->p3 ){ sqlite3DbFree(db, p->zErrMsg); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 76cd9215a6..90baaccc68 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -704,7 +704,11 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){ #if defined(SQLITE_DEBUG) && defined(__GNUC__) __attribute__((aligned(8))) #endif - = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, 0, 0 }; + = {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); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index ad6e41c3fd..f6ea876c12 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -955,7 +955,7 @@ 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)<n<=sizeof(Bitmask)*8 ); + assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 ); for(i=0; in; i++){ if( pMaskSet->ix[i]==iCursor ){ return ((Bitmask)1)<