diff --git a/Makefile.msc b/Makefile.msc index 083e588d8f..2c4d13b9f8 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -9,53 +9,75 @@ TOP = . # Set this non-0 to create and use the SQLite amalgamation file. # +!IFNDEF USE_AMALGAMATION USE_AMALGAMATION = 1 +!ENDIF # Set this non-0 to use the International Components for Unicode (ICU). # +!IFNDEF USE_ICU USE_ICU = 0 +!ENDIF # Set this non-0 to dynamically link to the MSVC runtime library. # +!IFNDEF USE_CRT_DLL USE_CRT_DLL = 0 +!ENDIF # Set this non-0 to attempt setting the native compiler automatically # for cross-compiling the command line tools needed during the compilation # process. # +!IFNDEF XCOMPILE XCOMPILE = 0 +!ENDIF # Set this non-0 to use the native libraries paths for cross-compiling # the command line tools needed during the compilation process. # +!IFNDEF USE_NATIVE_LIBPATHS USE_NATIVE_LIBPATHS = 0 +!ENDIF # Set this 0 to skip the compiling and embedding of version resources. # +!IFNDEF USE_RC USE_RC = 1 +!ENDIF # Set this non-0 to compile binaries suitable for the WinRT environment. # This setting does not apply to any binaries that require Tcl to operate # properly (i.e. the text fixture, etc). # +!IFNDEF FOR_WINRT FOR_WINRT = 0 +!ENDIF # Set this non-0 to skip attempting to look for and/or link with the Tcl # runtime library. # +!IFNDEF NO_TCL NO_TCL = 0 +!ENDIF # Set this to non-0 to create and use PDBs. # +!IFNDEF SYMBOLS SYMBOLS = 1 +!ENDIF # Set this to non-0 to use the SQLite debugging heap subsystem. # +!IFNDEF MEMDEBUG MEMDEBUG = 0 +!ENDIF # Set this to non-0 to use the Win32 native heap subsystem. # +!IFNDEF WIN32HEAP WIN32HEAP = 0 +!ENDIF # Set this to one of the following values to enable various debugging # features. Each level includes the debugging options from the previous @@ -68,7 +90,9 @@ WIN32HEAP = 0 # 4 == SQLITE_DEBUG_OS_TRACE: Enables output from the OSTRACE() macros. # 5 == SQLITE_ENABLE_IOTRACE: Enables output from the IOTRACE() macros. # +!IFNDEF DEBUG DEBUG = 0 +!ENDIF # Check for the predefined command macro CC. This should point to the compiler # binary for the target platform. If it is not defined, simply define it to diff --git a/manifest b/manifest index 72157a1697..dd60773dd1 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Merge\sthe\slatest\strunk\schanges,\sespecially\sthe\sORDER\sBY\soptimizer\senhancements\nbut\salso\sother\sfixes,\sonto\sthe\ssessions\sbranch. -D 2012-10-09T14:58:15.175 +C Merge\sall\sthe\slatest\score\schanges\sinto\sthe\ssessions\sbranch. +D 2012-10-15T14:25:16.488 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc a26021086defb54e6cb61439a90be5960b713017 +F Makefile.msc eeacc62cbb02aa3ef6a5c8bdb5d4e6a70f5ca5b2 F Makefile.vxworks b18ad88e9a8c6a001f5cf4a389116a4f1a7ab45f F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION edab4af5a4623f8198833ea481ce98ab53750a8d @@ -130,13 +130,13 @@ F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168 F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410 F src/attach.c 34c15ecd686e58f08e5bb1389e28a0b65c2c83db F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c afc067b9a9050ff48b9d46285c53d096c556a73d +F src/backup.c cab40f2c1fe79d6eb93d3b4086c78c41ad2fa5d0 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 14de53ebb334633ee632ab3c5b9262cfe7cbe455 -F src/btree.h 078f76b28c338ab6eb6dd7324d63ee54463aeb6c +F src/btree.c 299377f0793038ad3ea322907fbda7fbea615094 +F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 -F src/build.c b21c130017820dfe8721e380325e128fd0c6e019 +F src/build.c f35dac52924a6e8e6346a90f0c195a84e28b6f21 F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e @@ -153,7 +153,7 @@ F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 6273647b67e27e3f81b7d1fd144307ea726841d0 F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f -F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 +F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d F src/main.c 5cee8048dde78b2b47f5c2090cbb31b10d190673 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 @@ -172,26 +172,26 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c a5a45a2857c43b37bac145b521064a85a544cd7a +F src/os_unix.c 0d3a39dd576c9f384fd7772a2dadc67b144c6ce7 F src/os_win.c 28bd027791252a4012dffd4d64355a1eb84d761c -F src/pager.c a7ad8c38809edf0be545e8f52da5bcbb88885b38 -F src/pager.h bdbc379557eb2e233dfec10986b3086877e72db7 +F src/pager.c 36642c0955c19840b5445e7e9da7b5b0d8235346 +F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9 -F src/pragma.c 4f31fe4ae4b885a8be8b1db9d94f9f5b6c8b5624 +F src/pragma.c 015723c48072781d2740e310ab04dc92956b76d1 F src/prepare.c 931ad0d852a0df48f79adcba6ce79ca5f475625c F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 -F src/resolve.c 9e28280ec98035f31900fdd1db01f86f68ca6c32 +F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 2a82736faeca1fe93315eda20c691d68ec13bb6c F src/shell.c 8ee5a3cb502e2d574f97b43972e6c1e275e7bec7 F src/sqlite.h.in d460ae07ecdd1c820272d9c217547c7b572cb4b7 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h fec16c0932b30aedf5d3b577aaf5f881589c8dd0 +F src/sqliteInt.h c00feec4f6debb1cb4bad802d2c7fe5050e744ca F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -258,10 +258,10 @@ F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 F src/vtab.c 9c64ae18af78c740610df841c6f49fc2d240a279 -F src/wal.c e1fe8f92a0ea0fef8faa87ec43a127a478589d22 +F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b -F src/where.c 410017c604713ab6c010a9e3731a7688a0c7a059 +F src/where.c 3e6c1f9efe4c6a029b0a750e0f6a63964f43bcce F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 0be144b453e0622a085fae8665c32f5676708e00 @@ -301,6 +301,7 @@ F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 F test/backcompat.test ecd841f3a3bfb81518721879cc56a760670e3198 F test/backup.test c9cdd23a495864b9edf75a9fa66f5cb7e10fcf62 F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf +F test/backup4.test 3c3639d28f3cdb4a123694a0a7c5fa7bfe304e2a F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0 F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450 F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f @@ -649,7 +650,7 @@ F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/orderby1.test ef4f7c40df81b9a4303a718433d34052f07db47d F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test 2163c6ef119f497a71a84137c957c63763e640ab +F test/pager1.test 07116f72a61960b882952e7472cc2846d161d6e2 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -954,6 +955,7 @@ F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437 F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd F test/wal8.test b3ee739fe8f7586aaebdc2367f477ebcf3e3b034 +F test/wal9.test b4eb5d27170c65ee9c8ff9c9e76babd902a13cfc F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877 F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434 @@ -983,12 +985,12 @@ F test/where9.test bcab47eff78f1412a6aec1d6b8a3939d4a9db098 F test/whereA.test 24c234263c8fe358f079d5e57d884fb569d2da0a F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/whereC.test 13ff5ec0dba407c0e0c075980c75b3275a6774e5 -F test/whereD.test 304ccbe3c77e0d0764f37c91d43b8c4792a5e02f +F test/whereD.test 3f3ee93825c94804f1fc91eef2de0d365981759a F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test e7f77fded01dfcdf92ac2c5400f1e35d7a21463c -F tool/build-all-msvc.bat cd505f24717ca4ecd94c651f763d7bb4e7fe68af x +F tool/build-all-msvc.bat 76b835e0ab91e30f22d8aa48db9dea4d2dc59e9f x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -1006,18 +1008,18 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 -F tool/mkvsix.tcl 19b2ab9ea16445953a76568a5bbe4cb864f92dfe +F tool/mkvsix.tcl a27951f30bb39c3504196610f17f687fc0b1c94d F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 2e28d8e499b016485672e9a7ac65dacc0d28ff69 +F tool/showdb.c aca2644aa4de7c0cad5821e50bbd55397e0974b8 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b -F tool/spaceanal.tcl e42273000686a4afbf6a5e5d7fb12be65e92afb1 +F tool/spaceanal.tcl 76f583a246a0b027f423252339e711f13198932e F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1032,7 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 6ca8eae1f89d19ee23cbc3a869d85b57d29b4a7d a02599ad85d02470c9effa51c02dbda7796bfa16 -R 05272e22ec105aad09507c576198ab3e +P f1fbb8c5bfa84e84e0b8e2872d83b06a0c0d5acc 8745530b9a877db77fe2ca3ea9c6bc99ce033055 +R 2fad70ce160d67d476b8ae23c3ce13a3 U drh -Z 8b270f262a5da1e0ba6e8c7b897dd596 +Z 004a84637f514b12189e7dcddda1b18b diff --git a/manifest.uuid b/manifest.uuid index f368e5856b..669e24dd0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f1fbb8c5bfa84e84e0b8e2872d83b06a0c0d5acc \ No newline at end of file +76767d651fe733614b1719aef9ad5ed4568234e4 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 6abc11c20c..b234716d61 100644 --- a/src/backup.c +++ b/src/backup.c @@ -413,7 +413,13 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ ** same schema version. */ if( rc==SQLITE_DONE ){ - rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1); + if( nSrcPage==0 ){ + rc = sqlite3BtreeNewDb(p->pDest); + nSrcPage = 1; + } + if( rc==SQLITE_OK || rc==SQLITE_DONE ){ + rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1); + } if( rc==SQLITE_OK ){ if( p->pDestDb ){ sqlite3ResetAllSchemasOfConnection(p->pDestDb); @@ -447,6 +453,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ }else{ nDestTruncate = nSrcPage * (pgszSrc/pgszDest); } + assert( nDestTruncate>0 ); sqlite3PagerTruncateImage(pDestPager, nDestTruncate); if( pgszSrc= iSize || ( + assert( nDestTruncate==0 + || (i64)nDestTruncate*(i64)pgszDest >= iSize || ( nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1) && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest )); diff --git a/src/btree.c b/src/btree.c index 4ee0c860a7..c0cda1281b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2531,6 +2531,20 @@ static int newDatabase(BtShared *pBt){ return SQLITE_OK; } +/* +** Initialize the first page of the database file (creating a database +** consisting of a single page and no schema objects). Return SQLITE_OK +** if successful, or an SQLite error code otherwise. +*/ +int sqlite3BtreeNewDb(Btree *p){ + int rc; + sqlite3BtreeEnter(p); + p->pBt->nPage = 0; + rc = newDatabase(p->pBt); + sqlite3BtreeLeave(p); + return rc; +} + /* ** Attempt to start a new transaction. A write-transaction ** is started if the second argument is nonzero, otherwise a read- diff --git a/src/btree.h b/src/btree.h index 0efa0cdcdc..d4c9fe37d7 100644 --- a/src/btree.h +++ b/src/btree.h @@ -117,6 +117,8 @@ void sqlite3BtreeTripAllCursors(Btree*, int); void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); +int sqlite3BtreeNewDb(Btree *p); + /* ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta ** should be one of the following values. The integer values are assigned diff --git a/src/build.c b/src/build.c index 00ff705f77..4c45a92727 100644 --- a/src/build.c +++ b/src/build.c @@ -2019,6 +2019,7 @@ static void destroyTable(Parse *pParse, Table *pTab){ return; }else{ int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); + assert( iDb>=0 && iDbdb->nDb ); destroyRootPage(pParse, iLargest, iDb); iDestroyed = iLargest; } diff --git a/src/lempar.c b/src/lempar.c index cb6025e87b..2afaa6cea6 100644 --- a/src/lempar.c +++ b/src/lempar.c @@ -608,6 +608,7 @@ static void yy_reduce( */ %% }; + assert( yyruleno>=0 && yyrulenoyyidx -= yysize; diff --git a/src/os_unix.c b/src/os_unix.c index 0852eb1a89..5fbac00713 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2086,13 +2086,13 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) { ** Close a file. Make sure the lock has been released before closing. */ static int dotlockClose(sqlite3_file *id) { - int rc; + int rc = SQLITE_OK; if( id ){ unixFile *pFile = (unixFile*)id; dotlockUnlock(id, NO_LOCK); sqlite3_free(pFile->lockingContext); + rc = closeUnixFile(id); } - rc = closeUnixFile(id); return rc; } /****************** End of the dot-file lock implementation ******************* @@ -2296,10 +2296,12 @@ static int flockUnlock(sqlite3_file *id, int eFileLock) { ** Close a file. */ static int flockClose(sqlite3_file *id) { + int rc = SQLITE_OK; if( id ){ flockUnlock(id, NO_LOCK); + rc = closeUnixFile(id); } - return closeUnixFile(id); + return rc; } #endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */ @@ -4098,7 +4100,7 @@ static int unixShmMap( if( pShmNode->h>=0 ){ pMem = mmap(0, szRegion, pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE, - MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion + MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion ); if( pMem==MAP_FAILED ){ rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename); diff --git a/src/pager.c b/src/pager.c index a767d747fe..cec0c8ff8e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5665,7 +5665,7 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ # define DIRECT_MODE isDirectMode #endif - if( !pPager->changeCountDone && pPager->dbSize>0 ){ + if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){ PgHdr *pPgHdr; /* Reference to page 1 */ assert( !pPager->tempFile && isOpen(pPager->fd) ); @@ -6916,6 +6916,8 @@ int sqlite3PagerCloseWal(Pager *pPager){ return rc; } +#endif /* !SQLITE_OMIT_WAL */ + #ifdef SQLITE_ENABLE_ZIPVFS /* ** A read-lock must be held on the pager when this function is called. If @@ -6945,6 +6947,4 @@ void *sqlite3PagerCodec(PgHdr *pPg){ } #endif /* SQLITE_HAS_CODEC */ -#endif /* !SQLITE_OMIT_WAL */ - #endif /* SQLITE_OMIT_DISKIO */ diff --git a/src/pager.h b/src/pager.h index 5fb0f0133f..90f8e6af78 100644 --- a/src/pager.h +++ b/src/pager.h @@ -138,11 +138,14 @@ int sqlite3PagerOpenSavepoint(Pager *pPager, int n); int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); int sqlite3PagerSharedLock(Pager *pPager); -int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); -int sqlite3PagerWalSupported(Pager *pPager); -int sqlite3PagerWalCallback(Pager *pPager); -int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); -int sqlite3PagerCloseWal(Pager *pPager); +#ifndef SQLITE_OMIT_WAL + int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*); + int sqlite3PagerWalSupported(Pager *pPager); + int sqlite3PagerWalCallback(Pager *pPager); + int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); + int sqlite3PagerCloseWal(Pager *pPager); +#endif + #ifdef SQLITE_ENABLE_ZIPVFS int sqlite3PagerWalFramesize(Pager *pPager); #endif diff --git a/src/pragma.c b/src/pragma.c index 8eaec51ec3..d3061b234f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1569,13 +1569,12 @@ void sqlite3Pragma( sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC); for(i=0; inDb; i++){ Btree *pBt; - Pager *pPager; const char *zState = "unknown"; int j; if( db->aDb[i].zName==0 ) continue; sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC); pBt = db->aDb[i].pBt; - if( pBt==0 || (pPager = sqlite3BtreePager(pBt))==0 ){ + if( pBt==0 || sqlite3BtreePager(pBt)==0 ){ zState = "closed"; }else if( sqlite3_file_control(db, i ? db->aDb[i].zName : 0, SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){ diff --git a/src/resolve.c b/src/resolve.c index b87d231ac2..0ffc633558 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -195,7 +195,7 @@ static int lookupName( assert( pNC ); /* the name context cannot be NULL. */ assert( zCol ); /* The Z in X.Y.Z cannot be NULL */ - assert( ~ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) ); /* Initialize the node to no-match */ pExpr->iTable = -1; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b440f8497f..9a34ec5fbe 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3196,8 +3196,10 @@ void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*); CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); int sqlite3TempInMemory(const sqlite3*); const char *sqlite3JournalModename(int); -int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); -int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); +#ifndef SQLITE_OMIT_WAL + int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); + int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); +#endif /* Declarations for functions in fkey.c. All of these are replaced by ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign diff --git a/src/wal.c b/src/wal.c index 8394bfa29f..0d7271bf04 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2518,7 +2518,7 @@ int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){ assert( walFramePgno(pWal, iFrame)!=1 ); rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame)); } - walCleanupHash(pWal); + if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal); } assert( rc==SQLITE_OK ); return rc; diff --git a/src/where.c b/src/where.c index 7a994943cd..b7663386ac 100644 --- a/src/where.c +++ b/src/where.c @@ -4605,7 +4605,7 @@ static Bitmask codeOneLoopStart( } } pLevel->u.pCovidx = pCov; - pLevel->iIdxCur = iCovCur; + if( pCov ) pLevel->iIdxCur = iCovCur; if( pAndExpr ){ pAndExpr->pLeft = 0; sqlite3ExprDelete(pParse->db, pAndExpr); diff --git a/test/backup4.test b/test/backup4.test new file mode 100644 index 0000000000..629718a750 --- /dev/null +++ b/test/backup4.test @@ -0,0 +1,106 @@ +# 2012 October 13 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# The tests in this file verify that if an empty database (zero bytes in +# size) is used as the source of a backup operation, the final destination +# database is one page in size. +# +# The destination must consist of at least one page as truncating a +# database file to zero bytes is equivalent to resetting the database +# schema cookie and change counter. Doing that could cause other clients +# to become confused and continue using out-of-date cache data. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix backup4 + +#------------------------------------------------------------------------- +# At one point this test was failing because [db] was using an out of +# date schema in test case 1.2. +# +do_execsql_test 1.0 { + CREATE TABLE t1(x, y, UNIQUE(x, y)); + INSERT INTO t1 VALUES('one', 'two'); + SELECT * FROM t1 WHERE x='one'; + PRAGMA integrity_check; +} {one two ok} + +do_test 1.1 { + sqlite3 db1 :memory: + db1 backup test.db + sqlite3 db1 test.db + db1 eval { + CREATE TABLE t1(x, y); + INSERT INTO t1 VALUES('one', 'two'); + } + db1 close +} {} + +do_execsql_test 1.2 { + SELECT * FROM t1 WHERE x='one'; + PRAGMA integrity_check; +} {one two ok} + +db close +forcedelete test.db +forcedelete test.db2 +sqlite3 db test.db + +#------------------------------------------------------------------------- +# Test that if the source is zero bytes, the destination database +# consists of a single page only. +# +do_execsql_test 2.1 { + CREATE TABLE t1(a, b); + CREATE INDEX i1 ON t1(a, b); +} + +do_test 2.2 { file size test.db } 3072 + +do_test 2.3 { + sqlite3 db1 test.db2 + db1 backup test.db + db1 close + file size test.db +} {1024} + +do_test 2.4 { file size test.db2 } 0 + +db close +forcedelete test.db +forcedelete test.db2 +sqlite3 db test.db + +#------------------------------------------------------------------------- +# Test that if the destination has a page-size larger than the implicit +# page-size of the source, the final destination database still consists +# of a single page. +# +do_execsql_test 3.1 { + PRAGMA page_size = 4096; + CREATE TABLE t1(a, b); + CREATE INDEX i1 ON t1(a, b); +} + +do_test 3.2 { file size test.db } 12288 + +do_test 3.3 { + sqlite3 db1 test.db2 + db1 backup test.db + db1 close + file size test.db +} {1024} + +do_test 3.4 { file size test.db2 } 0 + +finish_test + diff --git a/test/pager1.test b/test/pager1.test index 61a0c0ccdb..fac434037e 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -1365,7 +1365,7 @@ do_test pager1-9.4.1 { } {SQLITE_DONE SQLITE_OK} do_test pager1-9.4.2 { list [file size test.db2] [file size test.db] -} {0 0} +} {1024 0} db2 close #------------------------------------------------------------------------- diff --git a/test/wal9.test b/test/wal9.test new file mode 100644 index 0000000000..a219e30884 --- /dev/null +++ b/test/wal9.test @@ -0,0 +1,90 @@ +# 2012 October 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# This test case tests that a problem causing a failing assert() has +# been fixed. The problem occurred if a writer process with a subset +# of the *shm file mapped rolled back a transaction begun after the +# entire WAL file was checkpointed into the db file (i.e. a transaction +# that would have restarted the WAL file from the beginning). +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix wal9 + +sqlite3 db2 test.db + +do_execsql_test 1.0 { + PRAGMA page_size = 1024; + PRAGMA journal_mode = WAL; + PRAGMA wal_autocheckpoint = 0; + CREATE TABLE t(x); +} {wal 0} + +do_test 1.1 { + execsql "SELECT * FROM t" db2 +} {} + +do_execsql_test 1.2 { + BEGIN; + INSERT INTO t VALUES(randomblob(100)); + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + + INSERT INTO t SELECT randomblob(100) FROM t; + INSERT INTO t SELECT randomblob(100) FROM t; + COMMIT; +} {} + +# Check file sizes are as expected. The real requirement here is that +# the *shm file is now more than one chunk (>32KiB). +do_test 1.3 { file size test.db } {1024} +do_test 1.4 { file size test.db-wal } {15421352} +do_test 1.5 { file size test.db-shm } {131072} + +do_execsql_test 1.6 { PRAGMA wal_checkpoint } {0 14715 14715} + +# At this point connection [db2] has mapped the first 32KB of the *shm file +# only. Because the entire WAL file has been checkpointed, it is not +# necessary to map any more of the *-shm file to read or write the database +# (since all data will be read directly from the db file). +# +# However, at one point if a transaction that had not yet written to the +# WAL file was rolled back an assert() attempting to verify that the entire +# *-shm file was mapped would fail. If NDEBUG was defined (and the assert() +# disabled) this bug caused SQLite to ignore the return code of a mmap() +# call. +# +do_test 1.7 { + execsql { + BEGIN; + INSERT INTO t VALUES('hello'); + ROLLBACK; + } db2 +} {} +db2 close + +finish_test + diff --git a/test/whereD.test b/test/whereD.test index 9942890180..9ac5a68097 100644 --- a/test/whereD.test +++ b/test/whereD.test @@ -161,4 +161,29 @@ do_searchcount_test 3.5.2 { SELECT a, c FROM t3 WHERE (a=1 AND b='one') OR rowid=4 } {1 i 2 ii search 2} +# Ticket [d02e1406a58ea02d] (2012-10-04) +# LEFT JOIN with an OR in the ON clause causes segfault +# +do_test 4.1 { + db eval { + CREATE TABLE t41(a,b,c); + INSERT INTO t41 VALUES(1,2,3), (4,5,6); + CREATE TABLE t42(d,e,f); + INSERT INTO t42 VALUES(3,6,9), (4,8,12); + SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.e=x.b); + } +} {1 2 3 3 6 9 4 5 6 {} {} {}} +do_test 4.2 { + db eval { + CREATE INDEX t42d ON t42(d); + CREATE INDEX t42e ON t42(e); + SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.e=x.b); + } +} {1 2 3 3 6 9 4 5 6 {} {} {}} +do_test 4.3 { + db eval { + SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.d=x.b); + } +} {1 2 3 3 6 9 4 5 6 {} {} {}} + finish_test diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index 58e2dca3e3..989a2af795 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -10,6 +10,7 @@ SETLOCAL REM SET __ECHO=ECHO REM SET __ECHO2=ECHO +REM SET __ECHO3=ECHO IF NOT DEFINED _AECHO (SET _AECHO=REM) IF NOT DEFINED _CECHO (SET _CECHO=REM) IF NOT DEFINED _VECHO (SET _VECHO=REM) @@ -181,129 +182,144 @@ FOR %%P IN (%PLATFORMS%) DO ( REM SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot% - REM - REM NOTE: Launch a nested command shell to perform the following steps: - REM - REM 1. Setup the MSVC environment for this platform using the - REM official batch file. - REM - REM 2. Make sure that no stale build output files are present. - REM - REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this - REM platform. - REM - REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this - REM platform to the platform-specific directory beneath the - REM binary directory. - REM - "%ComSpec%" /C ( + FOR %%B IN (Debug Retail) DO ( REM - REM NOTE: Attempt to setup the MSVC environment for this platform. + REM NOTE: When preparing the debug build, set the DEBUG and MEMDEBUG + REM environment variables to be picked up by the MSVC makefile + REM itself. REM - %__ECHO% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P - - IF ERRORLEVEL 1 ( - ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P. - GOTO errors - ) - - REM - REM NOTE: If this batch file is not running in "what-if" mode, check to - REM be sure we were actually able to setup the MSVC environment as - REM current versions of their official batch file do not set the - REM exit code upon failure. - REM - IF NOT DEFINED __ECHO ( - IF NOT DEFINED WindowsSdkDir ( - ECHO Cannot build, Windows SDK not found for platform %%P. - GOTO errors - ) - ) - - REM - REM NOTE: When using MSVC 2012, the native SDK path cannot simply use - REM the "lib" sub-directory beneath the location specified in the - REM WindowsSdkDir environment variable because that location does - REM not actually contain the necessary library files for x86. - REM This must be done for each iteration because it relies upon - REM the WindowsSdkDir environment variable being set by the batch - REM file used to setup the MSVC environment. - REM - IF DEFINED SET_NSDKLIBPATH ( - CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH - CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86 - ) - - REM - REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC - REM makefile to clean any stale build output from previous - REM iterations of this loop and/or previous runs of this batch - REM file, etc. - REM - IF NOT DEFINED NOCLEAN ( - %__ECHO% nmake -f Makefile.msc clean - - IF ERRORLEVEL 1 ( - ECHO Failed to clean for platform %%P. - GOTO errors - ) + IF /I "%%B" == "Debug" ( + SET DEBUG=2 + SET MEMDEBUG=1 ) ELSE ( + CALL :fn_UnsetVariable DEBUG + CALL :fn_UnsetVariable MEMDEBUG + ) + + REM + REM NOTE: Launch a nested command shell to perform the following steps: + REM + REM 1. Setup the MSVC environment for this platform using the + REM official batch file. + REM + REM 2. Make sure that no stale build output files are present. + REM + REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this + REM platform. + REM + REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this + REM platform to the platform-specific directory beneath the + REM binary directory. + REM + "%ComSpec%" /C ( REM - REM NOTE: Even when the cleaning step has been disabled, we still need - REM to remove the build output for the files we are specifically - REM wanting to build for each platform. + REM NOTE: Attempt to setup the MSVC environment for this platform. REM - %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb - ) - - REM - REM NOTE: Invoke NMAKE with the MSVC makefile to build the "sqlite3.dll" - REM binary. The x86 compiler will be used to compile the native - REM command line tools needed during the build process itself. - REM Also, disable looking for and/or linking to the native Tcl - REM runtime library. - REM - %__ECHO% nmake -f Makefile.msc sqlite3.dll "NCC=""%VCINSTALLDIR%\bin\cl.exe""" USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS% - - IF ERRORLEVEL 1 ( - ECHO Failed to build "sqlite3.dll" for platform %%P. - GOTO errors - ) - - REM - REM NOTE: Copy the "sqlite3.dll" file to the platform-specific directory - REM beneath the binary directory. - REM - %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS% - - IF ERRORLEVEL 1 ( - ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%D\". - GOTO errors - ) - - REM - REM NOTE: Copy the "sqlite3.lib" file to the platform-specific directory - REM beneath the binary directory. - REM - %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS% - - IF ERRORLEVEL 1 ( - ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%D\". - GOTO errors - ) - - REM - REM NOTE: Copy the "sqlite3.pdb" file to the platform-specific directory - REM beneath the binary directory unless we are prevented from doing - REM so. - REM - IF NOT DEFINED NOSYMBOLS ( - %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS% + %__ECHO3% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P IF ERRORLEVEL 1 ( - ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%D\". + ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P. GOTO errors ) + + REM + REM NOTE: If this batch file is not running in "what-if" mode, check to + REM be sure we were actually able to setup the MSVC environment + REM as current versions of their official batch file do not set + REM the exit code upon failure. + REM + IF NOT DEFINED __ECHO ( + IF NOT DEFINED WindowsSdkDir ( + ECHO Cannot build, Windows SDK not found for platform %%P. + GOTO errors + ) + ) + + REM + REM NOTE: When using MSVC 2012, the native SDK path cannot simply use + REM the "lib" sub-directory beneath the location specified in the + REM WindowsSdkDir environment variable because that location does + REM not actually contain the necessary library files for x86. + REM This must be done for each iteration because it relies upon + REM the WindowsSdkDir environment variable being set by the batch + REM file used to setup the MSVC environment. + REM + IF DEFINED SET_NSDKLIBPATH ( + CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH + CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86 + ) + + REM + REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC + REM makefile to clean any stale build output from previous + REM iterations of this loop and/or previous runs of this batch + REM file, etc. + REM + IF NOT DEFINED NOCLEAN ( + %__ECHO% nmake -f Makefile.msc clean + + IF ERRORLEVEL 1 ( + ECHO Failed to clean for platform %%P. + GOTO errors + ) + ) ELSE ( + REM + REM NOTE: Even when the cleaning step has been disabled, we still + REM need to remove the build output for the files we are + REM specifically wanting to build for each platform. + REM + %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb + ) + + REM + REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.dll" + REM binary. The x86 compiler will be used to compile the native + REM command line tools needed during the build process itself. + REM Also, disable looking for and/or linking to the native Tcl + REM runtime library. + REM + %__ECHO% nmake -f Makefile.msc sqlite3.dll XCOMPILE=1 USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to build %%B "sqlite3.dll" for platform %%P. + GOTO errors + ) + + REM + REM NOTE: Copy the "sqlite3.dll" file to the appropriate directory for + REM the build and platform beneath the binary directory. + REM + %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%B\%%D\". + GOTO errors + ) + + REM + REM NOTE: Copy the "sqlite3.lib" file to the appropriate directory for + REM the build and platform beneath the binary directory. + REM + %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%B\%%D\". + GOTO errors + ) + + REM + REM NOTE: Copy the "sqlite3.pdb" file to the appropriate directory for + REM the build and platform beneath the binary directory unless we + REM are prevented from doing so. + REM + IF NOT DEFINED NOSYMBOLS ( + %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%B\%%D\" %FFLAGS% %DFLAGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%B\%%D\". + GOTO errors + ) + ) ) ) ) diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index a7517786c5..6a84758cc8 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -90,12 +90,13 @@ proc substFile { fileName } { return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]] } -proc replacePlatform { fileName platformName } { +proc replaceBuildAndPlatform { fileName buildName platformName } { # # NOTE: Returns the specified file name containing the platform name instead # of platform placeholder tokens. # - return [string map [list $platformName] $fileName] + return [string map [list $buildName $platformName] \ + $fileName] } set script [file normalize [info script]] @@ -249,12 +250,12 @@ if {![regexp -line -- $pattern $data dummy version]} then { if {![info exists fileNames(source)]} then { set fileNames(source) [list "" "" "" \ [file join $sourceDirectory sqlite3.h] \ - [file join $binaryDirectory sqlite3.lib] \ - [file join $binaryDirectory sqlite3.dll]] + [file join $binaryDirectory sqlite3.lib] \ + [file join $binaryDirectory sqlite3.dll]] if {![info exists no(symbols)]} then { lappend fileNames(source) \ - [file join $binaryDirectory sqlite3.pdb] + [file join $binaryDirectory sqlite3.pdb] } } @@ -262,27 +263,31 @@ if {![info exists fileNames(destination)]} then { set fileNames(destination) [list \ [file join $stagingDirectory extension.vsixmanifest] \ [file join $stagingDirectory SDKManifest.xml] \ - [file join $stagingDirectory DesignTime CommonConfiguration \ - SQLite.WinRT.props] \ - [file join $stagingDirectory DesignTime CommonConfiguration \ - sqlite3.h] \ - [file join $stagingDirectory DesignTime CommonConfiguration \ - sqlite3.lib] \ - [file join $stagingDirectory Redist CommonConfiguration \ - sqlite3.dll]] + [file join $stagingDirectory DesignTime \ + SQLite.WinRT.props] \ + [file join $stagingDirectory DesignTime sqlite3.h] \ + [file join $stagingDirectory DesignTime sqlite3.lib] \ + [file join $stagingDirectory Redist sqlite3.dll]] if {![info exists no(symbols)]} then { lappend fileNames(destination) \ - [file join $stagingDirectory Redist Debug \ - sqlite3.pdb] + [file join $stagingDirectory Redist sqlite3.pdb] } } -if {![info exists fileNames(neutral)]} then { - set fileNames(neutral) [list 1 1 1 1 0 0] +if {![info exists fileNames(buildNeutral)]} then { + set fileNames(buildNeutral) [list 1 1 1 1 0 0] if {![info exists no(symbols)]} then { - lappend fileNames(neutral) 0 + lappend fileNames(buildNeutral) 0 + } +} + +if {![info exists fileNames(platformNeutral)]} then { + set fileNames(platformNeutral) [list 1 1 1 1 0 0] + + if {![info exists no(symbols)]} then { + lappend fileNames(platformNeutral) 0 } } @@ -294,6 +299,31 @@ if {![info exists fileNames(subst)]} then { } } +if {![info exists fileNames(noDebug)]} then { + set fileNames(noDebug) [list 0 0 0 0 0 0] + + if {![info exists no(symbols)]} then { + lappend fileNames(noDebug) 0 + } +} + +if {![info exists fileNames(noRetail)]} then { + set fileNames(noRetail) [list 0 0 0 0 0 0] + + if {![info exists no(symbols)]} then { + lappend fileNames(noRetail) 1 + } +} + +############################################################################### + +# +# NOTE: Setup the list of builds supported by this script. +# +if {![info exists buildNames]} then { + set buildNames [list Debug Retail] +} + ############################################################################### # @@ -338,45 +368,63 @@ eval $extractCommand # foreach sourceFileName $fileNames(source) \ destinationFileName $fileNames(destination) \ - isNeutral $fileNames(neutral) useSubst $fileNames(subst) { + buildNeutral $fileNames(buildNeutral) platformNeutral \ + $fileNames(platformNeutral) useSubst $fileNames(subst) \ + noDebug $fileNames(noDebug) noRetail $fileNames(noRetail) { # - # NOTE: If the current file is platform-neutral, then only one platform will - # be processed for it, namely "neutral"; otherwise, each supported - # platform will be processed for it individually. + # NOTE: If the current file is build-neutral, then only one build will + # be processed for it, namely "CommonConfiguration"; otherwise, each + # supported build will be processed for it individually. # - foreach platformName [expr {$isNeutral ? [list neutral] : $platformNames}] { + foreach buildName \ + [expr {$buildNeutral ? [list CommonConfiguration] : $buildNames}] { # - # NOTE: Use the actual platform name in the destination file name. + # NOTE: Should the current file be skipped for this build? # - set newDestinationFileName [replacePlatform $destinationFileName \ - $platformName] - - # - # NOTE: Does the source file need to be copied to the destination file? - # - if {[string length $sourceFileName] > 0} then { - # - # NOTE: First, make sure the destination directory exists. - # - file mkdir [file dirname $newDestinationFileName] - - # - # NOTE: Then, copy the source file to the destination file verbatim. - # - file copy [replacePlatform $sourceFileName $platformName] \ - $newDestinationFileName + if {[info exists no${buildName}] && [set no${buildName}]} then { + continue } # - # NOTE: Does the destination file contain dynamic replacements that must - # be processed now? + # NOTE: If the current file is platform-neutral, then only one platform + # will be processed for it, namely "neutral"; otherwise, each + # supported platform will be processed for it individually. # - if {$useSubst} then { + foreach platformName \ + [expr {$platformNeutral ? [list neutral] : $platformNames}] { # - # NOTE: Perform any dynamic replacements contained in the destination - # file and then re-write it in-place. + # NOTE: Use the actual platform name in the destination file name. # - substFile $newDestinationFileName + set newDestinationFileName [replaceBuildAndPlatform \ + $destinationFileName $buildName $platformName] + + # + # NOTE: Does the source file need to be copied to the destination file? + # + if {[string length $sourceFileName] > 0} then { + # + # NOTE: First, make sure the destination directory exists. + # + file mkdir [file dirname $newDestinationFileName] + + # + # NOTE: Then, copy the source file to the destination file verbatim. + # + file copy [replaceBuildAndPlatform $sourceFileName $buildName \ + $platformName] $newDestinationFileName + } + + # + # NOTE: Does the destination file contain dynamic replacements that must + # be processed now? + # + if {$useSubst} then { + # + # NOTE: Perform any dynamic replacements contained in the destination + # file and then re-write it in-place. + # + substFile $newDestinationFileName + } } } } diff --git a/tool/showdb.c b/tool/showdb.c index d378d05d36..a100bba4f5 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -6,7 +6,11 @@ #include #include #include + +#if !defined(_MSC_VER) #include +#endif + #include #include #include "sqlite3.h" diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index fd59670ada..6988f6e8b9 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -30,32 +30,34 @@ foreach arg $argv { } } if {$file_to_analyze==""} usage -if {![file exists $file_to_analyze]} { - puts stderr "No such file: $file_to_analyze" +set root_filename $file_to_analyze +regexp {^file:(//)?([^?]*)} $file_to_analyze all x1 root_filename +if {![file exists $root_filename]} { + puts stderr "No such file: $root_filename" exit 1 } -if {![file readable $file_to_analyze]} { - puts stderr "File is not readable: $file_to_analyze" +if {![file readable $root_filename]} { + puts stderr "File is not readable: $root_filename" exit 1 } -set true_file_size [file size $file_to_analyze] +set true_file_size [file size $root_filename] if {$true_file_size<512} { - puts stderr "Empty or malformed database: $file_to_analyze" + puts stderr "Empty or malformed database: $root_filename" exit 1 } # Compute the total file size assuming test_multiplexor is being used. # Assume that SQLITE_ENABLE_8_3_NAMES might be enabled # -set extension [file extension $file_to_analyze] -set pattern $file_to_analyze +set extension [file extension $root_filename] +set pattern $root_filename append pattern {[0-3][0-9][0-9]} foreach f [glob -nocomplain $pattern] { incr true_file_size [file size $f] set extension {} } if {[string length $extension]>=2 && [string length $extension]<=4} { - set pattern [file rootname $file_to_analyze] + set pattern [file rootname $root_filename] append pattern {.[0-3][0-9][0-9]} foreach f [glob -nocomplain $pattern] { incr true_file_size [file size $f] @@ -64,7 +66,10 @@ if {[string length $extension]>=2 && [string length $extension]<=4} { # Open the database # -sqlite3 db $file_to_analyze +if {[catch {sqlite3 db $file_to_analyze -uri 1} msg]} { + puts stderr "error trying to open $file_to_analyze: $msg" + exit 1 +} register_dbstat_vtab db db eval {SELECT count(*) FROM sqlite_master} @@ -484,7 +489,7 @@ set user_percent [percent $user_payload $file_bytes] # Output the summary statistics calculated above. # -puts "/** Disk-Space Utilization Report For $file_to_analyze" +puts "/** Disk-Space Utilization Report For $root_filename" catch { puts "*** As of [clock format [clock seconds] -format {%Y-%b-%d %H:%M:%S}]" }