From 42fbf32108a7e9c9884511ac0e30400c4cd2444b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 Oct 2012 16:24:07 +0000 Subject: [PATCH 01/28] Dequote column names generated by the query flattener. FossilOrigin-Name: 5526e0aa3ccb24988a4f351ac994907b6e89018a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 0c609fcf26..7a0481882d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfailing\sassert()\sin\swal.c. -D 2012-10-15T11:28:24.947 +C Dequote\scolumn\snames\sgenerated\sby\sthe\squery\sflattener. +D 2012-10-15T16:24:07.585 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -174,7 +174,7 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 2a82736faeca1fe93315eda20c691d68ec13bb6c +F src/select.c 9b759521f805e25e97baa2dd64037157fe365817 F src/shell.c 8ee5a3cb502e2d574f97b43972e6c1e275e7bec7 F src/sqlite.h.in c7be05ad191d2634292fcc77bdb2bcfa4526eb98 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 @@ -1021,7 +1021,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 ca86138bda26c5ac5a7e67351acbd19fbd39b0ae -R 1adb0472104019713641ff3149a537e4 -U dan -Z 82a77f3539e233996c3bcae559658f67 +P 8745530b9a877db77fe2ca3ea9c6bc99ce033055 +R 695fea8e01da23e7ae53b29020bcbd82 +U drh +Z 09ce5f99475f4fd2d49afd9b8510012d diff --git a/manifest.uuid b/manifest.uuid index 96923ec6e5..c85b3e5f91 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8745530b9a877db77fe2ca3ea9c6bc99ce033055 \ No newline at end of file +5526e0aa3ccb24988a4f351ac994907b6e89018a \ No newline at end of file diff --git a/src/select.c b/src/select.c index 51847ffbdb..ea85d1d71d 100644 --- a/src/select.c +++ b/src/select.c @@ -3098,10 +3098,9 @@ static int flattenSubquery( pList = pParent->pEList; for(i=0; inExpr; i++){ if( pList->a[i].zName==0 ){ - const char *zSpan = pList->a[i].zSpan; - if( ALWAYS(zSpan) ){ - pList->a[i].zName = sqlite3DbStrDup(db, zSpan); - } + char *zName = sqlite3DbStrDup(db, pList->a[i].zSpan); + sqlite3Dequote(zName); + pList->a[i].zName = zName; } } substExprList(db, pParent->pEList, iParent, pSub->pEList); From 07973a65817bf7cd6dba310a0bb6f4f963e95489 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 15 Oct 2012 18:02:57 +0000 Subject: [PATCH 02/28] Hold the mutex on the shared-cache for the duration of a VACUUM operation. FossilOrigin-Name: 629a42d47a0d8f73de900f469845ce800bdb8959 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vacuum.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7a0481882d..772853f009 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Dequote\scolumn\snames\sgenerated\sby\sthe\squery\sflattener. -D 2012-10-15T16:24:07.585 +C Hold\sthe\smutex\son\sthe\sshared-cache\sfor\sthe\sduration\sof\sa\sVACUUM\soperation. +D 2012-10-15T18:02:57.236 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -235,7 +235,7 @@ F src/trigger.c 3f258307040173aff383eb23fb74c44fe829078c F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 -F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd +F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 F src/vdbe.c 31523df2b986fc6c959dd54ca640ba865884641b F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h 573a43ab5697b648a1e8f3dfc7d8667d5ca55729 @@ -1021,7 +1021,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 8745530b9a877db77fe2ca3ea9c6bc99ce033055 -R 695fea8e01da23e7ae53b29020bcbd82 -U drh -Z 09ce5f99475f4fd2d49afd9b8510012d +P 5526e0aa3ccb24988a4f351ac994907b6e89018a +R ae9cdd994bee7b7367d1b3e8955984b7 +U dan +Z a44ad9d15114468612331138128e563b diff --git a/manifest.uuid b/manifest.uuid index c85b3e5f91..e486088ca6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5526e0aa3ccb24988a4f351ac994907b6e89018a \ No newline at end of file +629a42d47a0d8f73de900f469845ce800bdb8959 \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 401d41dfb7..7ed2478326 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -85,6 +85,7 @@ void sqlite3Vacuum(Parse *pParse){ Vdbe *v = sqlite3GetVdbe(pParse); if( v ){ sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0); + sqlite3VdbeUsesBtree(v, 0); } return; } From 21890127cd0a074200bf0fa75a8c20c5eae0f888 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 15 Oct 2012 20:28:22 +0000 Subject: [PATCH 03/28] Correct comments and enhance readability of the mkvsix tool. FossilOrigin-Name: 2c3af657fee6153842d660a6ce29aa7d791ebd38 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mkvsix.tcl | 37 ++++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 772853f009..be0f0a1ebc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Hold\sthe\smutex\son\sthe\sshared-cache\sfor\sthe\sduration\sof\sa\sVACUUM\soperation. -D 2012-10-15T18:02:57.236 +C Correct\scomments\sand\senhance\sreadability\sof\sthe\smkvsix\stool. +D 2012-10-15T20:28:22.029 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -995,7 +995,7 @@ 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 a27951f30bb39c3504196610f17f687fc0b1c94d +F tool/mkvsix.tcl adc17f82e3812787fdb015098d006e31804d6aa5 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1021,7 +1021,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 5526e0aa3ccb24988a4f351ac994907b6e89018a -R ae9cdd994bee7b7367d1b3e8955984b7 -U dan -Z a44ad9d15114468612331138128e563b +P 629a42d47a0d8f73de900f469845ce800bdb8959 +R c7830c7c0cb344c8cb6a175c95e5eb7f +U mistachkin +Z f2086ddd83e8b281e8d53ba90c91d2db diff --git a/manifest.uuid b/manifest.uuid index e486088ca6..915ba49368 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -629a42d47a0d8f73de900f469845ce800bdb8959 \ No newline at end of file +2c3af657fee6153842d660a6ce29aa7d791ebd38 \ No newline at end of file diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 6a84758cc8..82dae2f691 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -354,23 +354,30 @@ eval $extractCommand ############################################################################### # -# NOTE: Process each file in the master file list. There are actually four -# parallel lists that contain the source file names, destination file -# names, the platform-neutral flags, and the use-subst flags. When the +# NOTE: Process each file in the master file list. There are actually seven +# parallel lists that contain the source file names, the destination file +# names, the build-neutral flags, the platform-neutral flags, the +# use-subst flags, the no-debug flags, and the no-retail flags. If the # platform-neutral flag is non-zero, the file is not platform-specific. -# When the use-subst flag is non-zero, the file is considered to be a -# text file that may contain Tcl variable and/or command replacements, -# to be dynamically replaced during processing. If the source file name -# is an empty string, then the destination file name will be assumed to -# already exist in the staging directory and will not be copied; however, -# dynamic replacements may still be performed on the destination file -# prior to the package being re-zipped. +# If the build-neutral flag is non-zero, the file is not build-specific. +# If the use-subst flag is non-zero, the file is considered to be a text +# file that may contain Tcl variable and/or command replacements, to be +# dynamically replaced during processing. If the no-debug flag is +# non-zero, the file will be skipped when processing for the debug build. +# If the no-retail flag is non-zero, the file will be skipped when +# processing for the retail build. If the source file name is an empty +# string, then the destination file name will be assumed to already exist +# in the staging directory and will not be copied; however, dynamic +# replacements may still be performed on the destination file prior to +# the package being re-zipped. # -foreach sourceFileName $fileNames(source) \ - destinationFileName $fileNames(destination) \ - buildNeutral $fileNames(buildNeutral) platformNeutral \ - $fileNames(platformNeutral) useSubst $fileNames(subst) \ - noDebug $fileNames(noDebug) noRetail $fileNames(noRetail) { +foreach sourceFileName $fileNames(source) \ + destinationFileName $fileNames(destination) \ + buildNeutral $fileNames(buildNeutral) \ + platformNeutral $fileNames(platformNeutral) \ + useSubst $fileNames(subst) \ + noDebug $fileNames(noDebug) \ + noRetail $fileNames(noRetail) { # # NOTE: If the current file is build-neutral, then only one build will # be processed for it, namely "CommonConfiguration"; otherwise, each From c0a23e5c9c07e9b1d96fb8b454c077fd54cd1ed0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 17 Oct 2012 13:15:02 +0000 Subject: [PATCH 04/28] Remove an incorrect "#ifndef SQLITE_OMIT_AUTOVACUUM" from pager. FossilOrigin-Name: bf44d73d3e4ec403947d361d2fa150cc240c4d45 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index be0f0a1ebc..b49c331c10 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\scomments\sand\senhance\sreadability\sof\sthe\smkvsix\stool. -D 2012-10-15T20:28:22.029 +C Remove\san\sincorrect\s"#ifndef\sSQLITE_OMIT_AUTOVACUUM"\sfrom\spager. +D 2012-10-17T13:15:02.029 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -162,7 +162,7 @@ F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 0d3a39dd576c9f384fd7772a2dadc67b144c6ce7 F src/os_win.c 28bd027791252a4012dffd4d64355a1eb84d761c -F src/pager.c 36642c0955c19840b5445e7e9da7b5b0d8235346 +F src/pager.c ee59fef31673d5124413c5a801cfd9ef3e6766d3 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -1021,7 +1021,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 629a42d47a0d8f73de900f469845ce800bdb8959 -R c7830c7c0cb344c8cb6a175c95e5eb7f -U mistachkin -Z f2086ddd83e8b281e8d53ba90c91d2db +P 2c3af657fee6153842d660a6ce29aa7d791ebd38 +R d55cc10c39c57d8a9dc0166111e15a7c +U drh +Z 4c6ce6c173b785cd15d66fe798355adb diff --git a/manifest.uuid b/manifest.uuid index 915ba49368..8b9d309d8c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2c3af657fee6153842d660a6ce29aa7d791ebd38 \ No newline at end of file +bf44d73d3e4ec403947d361d2fa150cc240c4d45 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index cec0c8ff8e..a96dc45b82 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5885,7 +5885,7 @@ int sqlite3PagerCommitPhaseOne( /* If this transaction has made the database smaller, then all pages ** being discarded by the truncation must be written to the journal - ** file. This can only happen in auto-vacuum mode. + ** file. ** ** Before reading the pages with page numbers larger than the ** current value of Pager.dbSize, set dbSize back to the value @@ -5893,7 +5893,6 @@ int sqlite3PagerCommitPhaseOne( ** calls to sqlite3PagerGet() return zeroed pages instead of ** reading data from the database file. */ - #ifndef SQLITE_OMIT_AUTOVACUUM if( pPager->dbSizedbOrigSize && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){ @@ -5913,7 +5912,6 @@ int sqlite3PagerCommitPhaseOne( } pPager->dbSize = dbSize; } - #endif /* Write the master journal name into the journal file. If a master ** journal file name has already been written to the journal file, From ce5c42be280e37bd8c42af160656c7040b4c5021 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Oct 2012 15:28:26 +0000 Subject: [PATCH 05/28] Change the way the tcl crash-test code works to avoid triggering an assert() in os_unix.c. FossilOrigin-Name: b8b7b8f9e97a5c34f0f199b46347e0bf85005a4d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test6.c | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index b49c331c10..c2392483ed 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\s"#ifndef\sSQLITE_OMIT_AUTOVACUUM"\sfrom\spager. -D 2012-10-17T13:15:02.029 +C Change\sthe\sway\sthe\stcl\scrash-test\scode\sworks\sto\savoid\striggering\san\sassert()\sin\sos_unix.c. +D 2012-10-17T15:28:26.766 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 -F src/test6.c 417e1e214734393c24a8ee80b41485a9c4169123 +F src/test6.c 0e47537ba157896ffaab64228fbf3bc1bd13622e F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 F src/test8.c 8bcce65e5ee027fbfd7da41d28371aabbfd369ff F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -1021,7 +1021,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 2c3af657fee6153842d660a6ce29aa7d791ebd38 -R d55cc10c39c57d8a9dc0166111e15a7c -U drh -Z 4c6ce6c173b785cd15d66fe798355adb +P bf44d73d3e4ec403947d361d2fa150cc240c4d45 +R 952a26a9f71a580bdba3323d9c78b6cc +U dan +Z f98feedce000e0221af4d7c87f85bbd8 diff --git a/manifest.uuid b/manifest.uuid index 8b9d309d8c..e0ee1470d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf44d73d3e4ec403947d361d2fa150cc240c4d45 \ No newline at end of file +b8b7b8f9e97a5c34f0f199b46347e0bf85005a4d \ No newline at end of file diff --git a/src/test6.c b/src/test6.c index bae6b65dc2..a6054891b0 100644 --- a/src/test6.c +++ b/src/test6.c @@ -628,18 +628,19 @@ static int cfOpen( ** to read data from the 512-byte locking region of a file opened ** with the SQLITE_OPEN_MAIN_DB flag. This region of a database file ** never contains valid data anyhow. So avoid doing such a read here. + ** + ** UPDATE: It also contains an assert() verifying that each call + ** to the xRead() method reads less than 128KB of data. */ const int isDb = (flags&SQLITE_OPEN_MAIN_DB); - i64 iChunk = pWrapper->iSize; - if( iChunk>PENDING_BYTE && isDb ){ - iChunk = PENDING_BYTE; - } + i64 iOff; + memset(pWrapper->zData, 0, pWrapper->nData); - rc = sqlite3OsRead(pReal, pWrapper->zData, (int)iChunk, 0); - if( SQLITE_OK==rc && pWrapper->iSize>(PENDING_BYTE+512) && isDb ){ - i64 iOff = PENDING_BYTE+512; - iChunk = pWrapper->iSize - iOff; - rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], (int)iChunk, iOff); + for(iOff=0; iOffiSize; iOff += 512){ + int nRead = pWrapper->iSize - iOff; + if( nRead>512 ) nRead = 512; + if( isDb && iOff==PENDING_BYTE ) continue; + rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], nRead, iOff); } }else{ rc = SQLITE_NOMEM; From 1e3e41858f331716d651d8e09e07959f78dc99b8 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Oct 2012 16:20:36 +0000 Subject: [PATCH 06/28] Add a test for the problem fixed by [bf44d73d3e]. FossilOrigin-Name: db9b1fa5973d79e29885817d5aedc3a886c2589a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test6.c | 4 ++-- test/crash7.test | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index c2392483ed..b562ace384 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sway\sthe\stcl\scrash-test\scode\sworks\sto\savoid\striggering\san\sassert()\sin\sos_unix.c. -D 2012-10-17T15:28:26.766 +C Add\sa\stest\sfor\sthe\sproblem\sfixed\sby\s[bf44d73d3e]. +D 2012-10-17T16:20:36.056 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 -F src/test6.c 0e47537ba157896ffaab64228fbf3bc1bd13622e +F src/test6.c e0fc0551afc349acd081a7264627354c682629ca F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 F src/test8.c 8bcce65e5ee027fbfd7da41d28371aabbfd369ff F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -358,7 +358,7 @@ F test/crash3.test 8f5de9d32ab9ab95475a9efe7f47a940aa889418 F test/crash4.test fe2821baf37168dc59dd733dcf7dba2a401487bc F test/crash5.test 13b9ca94e048194bca070e26160ce76b406c56be F test/crash6.test 4c56f1e40d0291e1110790a99807aa875b1647ba -F test/crash7.test 6c6a369af266af2ef50ab34df8f94d719065e2c1 +F test/crash7.test 1a194c4900a255258cf94b7fcbfd29536db572df F test/crash8.test 38767cb504bbe491de6be4a7006b154973a2309f F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 @@ -1021,7 +1021,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 bf44d73d3e4ec403947d361d2fa150cc240c4d45 -R 952a26a9f71a580bdba3323d9c78b6cc +P b8b7b8f9e97a5c34f0f199b46347e0bf85005a4d +R a4dfd3d078e8ee41afe324f37d50f373 U dan -Z f98feedce000e0221af4d7c87f85bbd8 +Z 88b5376feb5c14bb90a0188d33469c69 diff --git a/manifest.uuid b/manifest.uuid index e0ee1470d7..e3805131ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8b7b8f9e97a5c34f0f199b46347e0bf85005a4d \ No newline at end of file +db9b1fa5973d79e29885817d5aedc3a886c2589a \ No newline at end of file diff --git a/src/test6.c b/src/test6.c index a6054891b0..02d8624403 100644 --- a/src/test6.c +++ b/src/test6.c @@ -312,8 +312,8 @@ static int writeListSync(CrashFile *pFile, int isCrash){ assert(pWrite->zBuf); #ifdef TRACE_CRASHTEST - printf("Trashing %d sectors @ sector %d (%s)\n", - 1+iLast-iFirst, iFirst, pWrite->pFile->zName + printf("Trashing %d sectors @ %d (sector %d) (%s)\n", + 1+iLast-iFirst, pWrite->iOffset, iFirst, pWrite->pFile->zName ); #endif diff --git a/test/crash7.test b/test/crash7.test index 4554a2ac58..482999cbfd 100644 --- a/test/crash7.test +++ b/test/crash7.test @@ -13,6 +13,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix crash7 ifcapable !crashtest { finish_test @@ -79,4 +80,37 @@ foreach f [list test.db test.db-journal] { } } +db close +forcedelete test.db +sqlite3 db test.db +do_execsql_test 2.0 { + CREATE TABLE t1(a, b, UNIQUE(a, b)); + INSERT INTO t1 VALUES(randomblob(100), randomblob(100)); + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1; + DELETE FROM t1 WHERE rowid%2; +} +db_save_and_close + +for {set i 0} {$i < 20} {incr i} { + db_restore_and_reopen + do_test 2.[expr $i+1].1 { + crashsql -file test.db -seed $i {VACUUM} + } {1 {child process exited abnormally}} + do_execsql_test 2.[expr $i+1].2 { PRAGMA integrity_check } {ok} +} + + finish_test From 6c42aa4a0e5ef9648252f8c0a718beb9ddbd9c24 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Oct 2012 20:15:10 +0000 Subject: [PATCH 07/28] Initialize variables used as outputs of custom tokenizer method calls in fts4. FossilOrigin-Name: 514505a84bcc677518d60a42896598f85ed78265 --- ext/fts3/fts3_expr.c | 4 ++-- ext/fts3/fts3_snippet.c | 22 +++++++++++----------- ext/fts3/fts3_tokenizer.c | 8 ++++---- ext/fts3/fts3_write.c | 20 ++++++++++---------- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/ext/fts3/fts3_expr.c b/ext/fts3/fts3_expr.c index a6e3492242..7612789de5 100644 --- a/ext/fts3/fts3_expr.c +++ b/ext/fts3/fts3_expr.c @@ -185,7 +185,7 @@ static int getNextToken( rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, n, &pCursor); if( rc==SQLITE_OK ){ const char *zToken; - int nToken, iStart, iEnd, iPosition; + int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0; int nByte; /* total space to allocate */ rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition); @@ -300,7 +300,7 @@ static int getNextString( int ii; for(ii=0; rc==SQLITE_OK; ii++){ const char *zByte; - int nByte, iBegin, iEnd, iPos; + int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0; rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos); if( rc==SQLITE_OK ){ Fts3PhraseToken *pToken; diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 6fce3d0a69..058ee2ed30 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -576,7 +576,7 @@ static int fts3SnippetShift( return rc; } while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){ - const char *ZDUMMY; int DUMMY1, DUMMY2, DUMMY3; + const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0; rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent); } pMod->xClose(pC); @@ -620,8 +620,6 @@ static int fts3SnippetText( int iCol = pFragment->iCol+1; /* Query column to extract text from */ sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */ sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor open on zDoc/nDoc */ - const char *ZDUMMY; /* Dummy argument used with tokenizer */ - int DUMMY1; /* Dummy argument used with tokenizer */ zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol); if( zDoc==0 ){ @@ -640,9 +638,11 @@ static int fts3SnippetText( } while( rc==SQLITE_OK ){ - int iBegin; /* Offset in zDoc of start of token */ - int iFin; /* Offset in zDoc of end of token */ - int isHighlight; /* True for highlighted terms */ + const char *ZDUMMY; /* Dummy argument used with tokenizer */ + int DUMMY1 = -1; /* Dummy argument used with tokenizer */ + int iBegin = 0; /* Offset in zDoc of start of token */ + int iFin = 0; /* Offset in zDoc of end of token */ + int isHighlight = 0; /* True for highlighted terms */ rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent); if( rc!=SQLITE_OK ){ @@ -1333,8 +1333,6 @@ void sqlite3Fts3Offsets( ){ Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab; sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule; - const char *ZDUMMY; /* Dummy argument used with xNext() */ - int NDUMMY; /* Dummy argument used with xNext() */ int rc; /* Return Code */ int nToken; /* Number of tokens in query */ int iCol; /* Column currently being processed */ @@ -1367,9 +1365,11 @@ void sqlite3Fts3Offsets( */ for(iCol=0; iColnColumn; iCol++){ sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */ - int iStart; - int iEnd; - int iCurrent; + const char *ZDUMMY; /* Dummy argument used with xNext() */ + int NDUMMY = 0; /* Dummy argument used with xNext() */ + int iStart = 0; + int iEnd = 0; + int iCurrent = 0; const char *zDoc; int nDoc; diff --git a/ext/fts3/fts3_tokenizer.c b/ext/fts3/fts3_tokenizer.c index 4a7a17567a..8241be81fc 100644 --- a/ext/fts3/fts3_tokenizer.c +++ b/ext/fts3/fts3_tokenizer.c @@ -251,10 +251,10 @@ static void testFunc( const char *azArg[64]; const char *zToken; - int nToken; - int iStart; - int iEnd; - int iPos; + int nToken = 0; + int iStart = 0; + int iEnd = 0; + int iPos = 0; int i; Tcl_Obj *pRet; diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index c9f1743210..7869e638c5 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -779,13 +779,13 @@ static int fts3PendingTermsAdd( u32 *pnWord /* OUT: Number of tokens inserted */ ){ int rc; - int iStart; - int iEnd; - int iPos; + int iStart = 0; + int iEnd = 0; + int iPos = 0; int nWord = 0; char const *zToken; - int nToken; + int nToken = 0; sqlite3_tokenizer *pTokenizer = p->pTokenizer; sqlite3_tokenizer_module const *pModule = pTokenizer->pModule; @@ -4934,9 +4934,9 @@ static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT); while( rc==SQLITE_OK ){ char const *zToken; /* Buffer containing token */ - int nToken; /* Number of bytes in token */ - int iDum1, iDum2; /* Dummy variables */ - int iPos; /* Position of token in zText */ + int nToken = 0; /* Number of bytes in token */ + int iDum1 = 0, iDum2 = 0; /* Dummy variables */ + int iPos = 0; /* Position of token in zText */ rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos); if( rc==SQLITE_OK ){ @@ -5103,9 +5103,9 @@ int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){ rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC); while( rc==SQLITE_OK ){ char const *zToken; /* Buffer containing token */ - int nToken; /* Number of bytes in token */ - int iDum1, iDum2; /* Dummy variables */ - int iPos; /* Position of token in zText */ + int nToken = 0; /* Number of bytes in token */ + int iDum1 = 0, iDum2 = 0; /* Dummy variables */ + int iPos = 0; /* Position of token in zText */ rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos); for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){ diff --git a/manifest b/manifest index b562ace384..0d683dbb3c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sfor\sthe\sproblem\sfixed\sby\s[bf44d73d3e]. -D 2012-10-17T16:20:36.056 +C Initialize\svariables\sused\sas\soutputs\sof\scustom\stokenizer\smethod\scalls\sin\sfts4. +D 2012-10-17T20:15:10.788 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -59,20 +59,20 @@ F ext/fts3/fts3.c ab90126ee0163539d21d0618d22afa2eb645f7e2 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 1e58825246b56259267382d2f9902774c049460a F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e -F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551 +F ext/fts3/fts3_expr.c ceefcaf91344abbf6ceb3cadf404eef5be6924e6 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c b85eca4a52e5ec11b94392de5167974c11906d4a F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 -F ext/fts3/fts3_snippet.c bf67520ae9d2352a65368ed101729ff701c08808 +F ext/fts3/fts3_snippet.c 776facfe762142c5f0e1707a3bff45afa6ec6b20 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 F ext/fts3/fts3_test.c 348f7d08cae05285794e23dc4fe8b8fdf66e264a -F ext/fts3/fts3_tokenizer.c e94a8b901066031437ccfe4769fc76370257cede +F ext/fts3/fts3_tokenizer.c 3664bb8836ab7633cf9da786c9d6fd366be5ae2c F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c 49e36e6ba59f79e6bd6a8bfe434570fe48d20559 F ext/fts3/fts3_unicode2.c a863f05f758af36777dffc2facc898bc73fec896 -F ext/fts3/fts3_write.c c30c49f3debb9497a07f15cc4c042815e35474ef +F ext/fts3/fts3_write.c ba0bb0a91ca792fba5101bd82fa14d8a00a96365 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/tool/fts3view.c 6cfc5b67a5f0e09c0d698f9fd012c784bfaa9197 @@ -1021,7 +1021,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 b8b7b8f9e97a5c34f0f199b46347e0bf85005a4d -R a4dfd3d078e8ee41afe324f37d50f373 +P db9b1fa5973d79e29885817d5aedc3a886c2589a +R 46675ce9c095beeab174116848331a09 U dan -Z 88b5376feb5c14bb90a0188d33469c69 +Z 8a9b2ab3f9fc72155da917dba29d509a diff --git a/manifest.uuid b/manifest.uuid index e3805131ff..dfcbe9fbae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -db9b1fa5973d79e29885817d5aedc3a886c2589a \ No newline at end of file +514505a84bcc677518d60a42896598f85ed78265 \ No newline at end of file From 1276cd0ba84ba8cb1c0222dda878329acb55a632 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Oct 2012 20:28:52 +0000 Subject: [PATCH 08/28] Add a comment to fts3_snippet.c. FossilOrigin-Name: b5f5ba3103e6fcf117fb69d5379fa70f691a652d --- ext/fts3/fts3_snippet.c | 11 +++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 058ee2ed30..4bee014dcc 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -644,6 +644,17 @@ static int fts3SnippetText( int iFin = 0; /* Offset in zDoc of end of token */ int isHighlight = 0; /* True for highlighted terms */ + /* Variable DUMMY1 is initialized to a negative value above. Elsewhere + ** in the FTS code the variable that the third argument to xNext points to + ** is initialized to zero before the first (*but not necessarily + ** subsequent*) call to xNext(). This is done for a particular application + ** that needs to know whether or not the tokenizer is being used for + ** snippet generation or for some other purpose. + ** + ** Extreme care is required when writing code to depend on this + ** initialization. It is not a documented part of the tokenizer interface. + ** If a tokenizer is used directly by any code outside of FTS, this + ** convention might not be respected. */ rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent); if( rc!=SQLITE_OK ){ if( rc==SQLITE_DONE ){ diff --git a/manifest b/manifest index 0d683dbb3c..3738b93a02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initialize\svariables\sused\sas\soutputs\sof\scustom\stokenizer\smethod\scalls\sin\sfts4. -D 2012-10-17T20:15:10.788 +C Add\sa\scomment\sto\sfts3_snippet.c. +D 2012-10-17T20:28:52.286 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -64,7 +64,7 @@ F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c b85eca4a52e5ec11b94392de5167974c11906d4a F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 -F ext/fts3/fts3_snippet.c 776facfe762142c5f0e1707a3bff45afa6ec6b20 +F ext/fts3/fts3_snippet.c f6ebb3536069ceaa27e9f178f4a59379db44ac10 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 F ext/fts3/fts3_test.c 348f7d08cae05285794e23dc4fe8b8fdf66e264a F ext/fts3/fts3_tokenizer.c 3664bb8836ab7633cf9da786c9d6fd366be5ae2c @@ -1021,7 +1021,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 db9b1fa5973d79e29885817d5aedc3a886c2589a -R 46675ce9c095beeab174116848331a09 +P 514505a84bcc677518d60a42896598f85ed78265 +R 8bd41a2c439b9257ed0c53b5b5e0e2b7 U dan -Z 8a9b2ab3f9fc72155da917dba29d509a +Z 16efc8c4916610ff9f4669700be42910 diff --git a/manifest.uuid b/manifest.uuid index dfcbe9fbae..873f29b186 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -514505a84bcc677518d60a42896598f85ed78265 \ No newline at end of file +b5f5ba3103e6fcf117fb69d5379fa70f691a652d \ No newline at end of file From e1b461bd10a3243abce65ecfec58c6bbf130f1d6 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 18 Oct 2012 09:39:16 +0000 Subject: [PATCH 09/28] Fix harmless compiler warnings. FossilOrigin-Name: 018e09c70347b9e0c76246ae65d57ef5d29a965a --- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- src/os_win.c | 3 ++- src/test6.c | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 3738b93a02..f890a8019b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\scomment\sto\sfts3_snippet.c. -D 2012-10-17T20:28:52.286 +C Fix\sharmless\scompiler\swarnings. +D 2012-10-18T09:39:16.781 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -161,7 +161,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 0d3a39dd576c9f384fd7772a2dadc67b144c6ce7 -F src/os_win.c 28bd027791252a4012dffd4d64355a1eb84d761c +F src/os_win.c 43ec1285357e5d5d919cb0492eac775c58ad7d12 F src/pager.c ee59fef31673d5124413c5a801cfd9ef3e6766d3 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -189,7 +189,7 @@ F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 -F src/test6.c e0fc0551afc349acd081a7264627354c682629ca +F src/test6.c b990d3cfa24d589afefb47bb86db3c4a56e5e7be F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 F src/test8.c 8bcce65e5ee027fbfd7da41d28371aabbfd369ff F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -1021,7 +1021,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 514505a84bcc677518d60a42896598f85ed78265 -R 8bd41a2c439b9257ed0c53b5b5e0e2b7 -U dan -Z 16efc8c4916610ff9f4669700be42910 +P b5f5ba3103e6fcf117fb69d5379fa70f691a652d +R 39dbbb084ae6a161ccbba144af20810a +T *branch * warnings +T *sym-warnings * +T -sym-trunk * +U mistachkin +Z 2d0ade0fb9b94740b143c6669e1b62e9 diff --git a/manifest.uuid b/manifest.uuid index 873f29b186..01b958f976 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b5f5ba3103e6fcf117fb69d5379fa70f691a652d \ No newline at end of file +018e09c70347b9e0c76246ae65d57ef5d29a965a \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 2d4c74af9a..3c92b43d4e 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2192,7 +2192,8 @@ static int winWrite( if( retryIoerr(&nRetry, &lastErrno) ) continue; break; } - if( nWrite<=0 ){ + assert( nWrite==0 || nWrite<=(DWORD)nRem ); + if( nWrite==0 || nWrite>(DWORD)nRem ){ lastErrno = osGetLastError(); break; } diff --git a/src/test6.c b/src/test6.c index 02d8624403..828fdc303b 100644 --- a/src/test6.c +++ b/src/test6.c @@ -312,7 +312,7 @@ static int writeListSync(CrashFile *pFile, int isCrash){ assert(pWrite->zBuf); #ifdef TRACE_CRASHTEST - printf("Trashing %d sectors @ %d (sector %d) (%s)\n", + printf("Trashing %d sectors @ %lld (sector %d) (%s)\n", 1+iLast-iFirst, pWrite->iOffset, iFirst, pWrite->pFile->zName ); #endif From 5f070c7bc84cc869e6d6b688b3ef1d7bccfeb4b6 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 18 Oct 2012 10:35:19 +0000 Subject: [PATCH 10/28] More warning fixes. FossilOrigin-Name: 51a6a797e1d61c4361b87cdf3467bfd3ce161cc3 --- manifest | 19 ++++++++----------- manifest.uuid | 2 +- src/btree.c | 2 +- src/hash.c | 2 +- src/test6.c | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index f890a8019b..ad74c6cc34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2012-10-18T09:39:16.781 +C More\swarning\sfixes. +D 2012-10-18T10:35:19.926 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c cab40f2c1fe79d6eb93d3b4086c78c41ad2fa5d0 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 299377f0793038ad3ea322907fbda7fbea615094 +F src/btree.c eccee944cb2221e919d7a855e5928d8643194b14 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 F src/build.c f35dac52924a6e8e6346a90f0c195a84e28b6f21 @@ -135,7 +135,7 @@ F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c c82a04e7a92bb728f9ab972b76590403283be2af F src/func.c cbb90dc84b22eea25caf39528d342279e61b8898 F src/global.c fb44b11e02e06c995e6ed6642509edd23599d584 -F src/hash.c a4031441741932da9e7a65bee2b36b5d0e81c073 +F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c ad0d8943d2a4f0b52ebf75b9e459f2da00117dbd @@ -189,7 +189,7 @@ F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 -F src/test6.c b990d3cfa24d589afefb47bb86db3c4a56e5e7be +F src/test6.c 938794c970ed6810036c8d28450ca28166524bf7 F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 F src/test8.c 8bcce65e5ee027fbfd7da41d28371aabbfd369ff F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -1021,10 +1021,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 b5f5ba3103e6fcf117fb69d5379fa70f691a652d -R 39dbbb084ae6a161ccbba144af20810a -T *branch * warnings -T *sym-warnings * -T -sym-trunk * +P 018e09c70347b9e0c76246ae65d57ef5d29a965a +R 118e249f38e185342e1ec7a1a462b9aa U mistachkin -Z 2d0ade0fb9b94740b143c6669e1b62e9 +Z ad2a76d04895f240393670b919d80b4d diff --git a/manifest.uuid b/manifest.uuid index 01b958f976..c57c558e36 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -018e09c70347b9e0c76246ae65d57ef5d29a965a \ No newline at end of file +51a6a797e1d61c4361b87cdf3467bfd3ce161cc3 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index c0cda1281b..246843b79e 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5744,7 +5744,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){ assert( pPage->nOverflow==1 ); /* This error condition is now caught prior to reaching this function */ - if( pPage->nCell<=0 ) return SQLITE_CORRUPT_BKPT; + if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT; /* Allocate a new page. This page will become the right-sibling of ** pPage. Make the parent page writable, so that the new divider cell diff --git a/src/hash.c b/src/hash.c index d7625d3913..e81dcf95e4 100644 --- a/src/hash.c +++ b/src/hash.c @@ -193,7 +193,7 @@ static void removeElementGivenHash( } sqlite3_free( elem ); pH->count--; - if( pH->count<=0 ){ + if( pH->count==0 ){ assert( pH->first==0 ); assert( pH->count==0 ); sqlite3HashClear(pH); diff --git a/src/test6.c b/src/test6.c index 828fdc303b..f511be9def 100644 --- a/src/test6.c +++ b/src/test6.c @@ -637,7 +637,7 @@ static int cfOpen( memset(pWrapper->zData, 0, pWrapper->nData); for(iOff=0; iOffiSize; iOff += 512){ - int nRead = pWrapper->iSize - iOff; + int nRead = pWrapper->iSize - (int)iOff; if( nRead>512 ) nRead = 512; if( isDb && iOff==PENDING_BYTE ) continue; rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], nRead, iOff); From 2f10fb3f07893495106aefbdab944f82efbabec6 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Oct 2012 20:49:26 +0000 Subject: [PATCH 11/28] Put auxiliary libraries after libsqlite3.a in the testfixture target of the "main.mk" makefile. FossilOrigin-Name: 8fc8548f52ab8fcfb53f88db68422e09c9b98da1 --- main.mk | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/main.mk b/main.mk index 7acae2fe7f..d24ba3a842 100644 --- a/main.mk +++ b/main.mk @@ -546,7 +546,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c $(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \ $(TESTSRC) $(TESTSRC2) $(TOP)/src/tclsqlite.c \ - -o testfixture$(EXE) $(LIBTCL) $(THREADLIB) libsqlite3.a + -o testfixture$(EXE) $(LIBTCL) libsqlite3.a $(THREADLIB) amalgamation-testfixture$(EXE): sqlite3.c $(TESTSRC) $(TOP)/src/tclsqlite.c $(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \ diff --git a/manifest b/manifest index bf575bcd2c..6edbe106ad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sWatcom\scompiler\swarning\sfixes\sinto\strunk. -D 2012-10-18T15:01:27.155 +C Put\sauxiliary\slibraries\safter\slibsqlite3.a\sin\sthe\stestfixture\starget\sof\sthe\n"main.mk"\smakefile. +D 2012-10-18T20:49:26.488 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -103,7 +103,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 7b60c2663388270258f01b59fbf8b9bd78f946bf +F main.mk ed9b74318401c0242fcac7caa95747912b9bd18f F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -1021,7 +1021,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 b5f5ba3103e6fcf117fb69d5379fa70f691a652d 51a6a797e1d61c4361b87cdf3467bfd3ce161cc3 -R 118e249f38e185342e1ec7a1a462b9aa +P 5be96788a142362fa1f218191d2a93fdea46d93d +R 3f8f18e3119674320ee09b7250162066 U drh -Z ac436b000019895766c5be314c79e007 +Z 482461e0a8744c4ec96bca6882c387ab diff --git a/manifest.uuid b/manifest.uuid index 17dc5f1258..70cd8f5723 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5be96788a142362fa1f218191d2a93fdea46d93d \ No newline at end of file +8fc8548f52ab8fcfb53f88db68422e09c9b98da1 \ No newline at end of file From 7c5dbdfd14152396463e629e50441a611968f61f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 19 Oct 2012 00:23:31 +0000 Subject: [PATCH 12/28] Add detailed comments to the build tools used to generate the VSIX package. Also, allow the build configurations and native library directories to be overridden for the multi-platform build tool for MSVC. FossilOrigin-Name: 0482c73bfdf80b0c0ce9abea706554d7ddf36f69 --- manifest | 16 ++++---- manifest.uuid | 2 +- tool/build-all-msvc.bat | 81 +++++++++++++++++++++++++++++++++++++- tool/mkvsix.tcl | 86 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 172 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 6edbe106ad..2605fbeeaf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Put\sauxiliary\slibraries\safter\slibsqlite3.a\sin\sthe\stestfixture\starget\sof\sthe\n"main.mk"\smakefile. -D 2012-10-18T20:49:26.488 +C Add\sdetailed\scomments\sto\sthe\sbuild\stools\sused\sto\sgenerate\sthe\sVSIX\spackage.\s\sAlso,\sallow\sthe\sbuild\sconfigurations\sand\snative\slibrary\sdirectories\sto\sbe\soverridden\sfor\sthe\smulti-platform\sbuild\stool\sfor\sMSVC. +D 2012-10-19T00:23:31.437 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -977,7 +977,7 @@ 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 76b835e0ab91e30f22d8aa48db9dea4d2dc59e9f x +F tool/build-all-msvc.bat c4ff2f18b1a59bb370ce48fdd286b51a82fa0f5c x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -995,7 +995,7 @@ 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 adc17f82e3812787fdb015098d006e31804d6aa5 +F tool/mkvsix.tcl c5e0d52592fb07a17626cd54e5f71295fb4d1b55 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1021,7 +1021,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 5be96788a142362fa1f218191d2a93fdea46d93d -R 3f8f18e3119674320ee09b7250162066 -U drh -Z 482461e0a8744c4ec96bca6882c387ab +P 8fc8548f52ab8fcfb53f88db68422e09c9b98da1 +R ecd8eecc21d562cb6365b84ab6aacfa3 +U mistachkin +Z e537762f3e1c5212ff12ec99c30fc6e2 diff --git a/manifest.uuid b/manifest.uuid index 70cd8f5723..ede7cfe4bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8fc8548f52ab8fcfb53f88db68422e09c9b98da1 \ No newline at end of file +0482c73bfdf80b0c0ce9abea706554d7ddf36f69 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index 989a2af795..c768e2b6e8 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -6,6 +6,49 @@ :: Multi-Platform Build Tool for MSVC :: +REM +REM This batch script is used to build the SQLite DLL for multiple platforms +REM and configurations using MSVC. The built SQLite DLLs, their associated +REM import libraries, and optionally their symbols files, are placed within +REM the directory specified on the command line, in sub-directories named for +REM their respective platforms and configurations. This batch script must be +REM run from inside a Visual Studio Command Prompt for the desired version of +REM Visual Studio ^(the initial platform configured for the command prompt does +REM not really matter^). Exactly one command line argument is required, the +REM name of an existing directory to be used as the final destination directory +REM for the generated output files, which will be placed in sub-directories +REM created therein. Ideally, the directory specified should be empty. +REM +REM Example: +REM +REM CD /D C:\dev\sqlite\core +REM tool\build-all-msvc.bat C:\Temp +REM +REM In the example above, "C:\dev\sqlite\core" represents the root of the +REM source tree for SQLite and "C:\Temp" represents the final destination +REM directory for the generated output files. +REM +REM There are several environment variables that may be set to modify the +REM behavior of this batch script and its associated Makefile. The list of +REM platforms to build may be overriden by using the PLATFORMS environment +REM variable, which should contain a list of platforms ^(e.g. x86 x86_amd64 +REM x86_arm^). All platforms must be supported by the version of Visual Studio +REM being used. The list of configurations to build may be overridden by +REM setting the CONFIGURATIONS environment variable, which should contain a +REM list of configurations to build ^(e.g. Debug Retail^). Neither of these +REM variable values may contain any double quotes, surrounding or embedded. +REM Finally, the NCRTLIBPATH and NSDKLIBPATH environment variables may be set +REM to specify the location of the CRT and SDK, respectively, needed to compile +REM executables native to the architecture of the build machine during any +REM cross-compilation that may be necessary, depending on the platforms to be +REM built. These values in these two variables should be surrounded by double +REM quotes if they contain spaces. +REM +REM Please note that the SQLite build process performed by the Makefile +REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl +REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH +REM environment variable unless a pre-existing amalgamation file is used. +REM SETLOCAL REM SET __ECHO=ECHO @@ -93,6 +136,16 @@ IF NOT DEFINED PLATFORMS ( %_VECHO% Platforms = '%PLATFORMS%' +REM +REM NOTE: If the list of configurations is not already set, use the default +REM list. +REM +IF NOT DEFINED CONFIGURATIONS ( + SET CONFIGURATIONS=Debug Retail +) + +%_VECHO% Configurations = '%CONFIGURATIONS%' + REM REM NOTE: Setup environment variables to translate between the MSVC platform REM names and the names to be used for the platform-specific binary @@ -115,6 +168,24 @@ FOR %%T IN (gawk.exe tclsh85.exe) DO ( SET %%T_PATH=%%~dp$PATH:T ) +REM +REM NOTE: The Gawk executable "gawk.exe" is required during the SQLite build +REM process unless a pre-existing amalgamation file is used. +REM +IF NOT DEFINED gawk.exe_PATH ( + ECHO The Gawk executable "gawk.exe" is required to be in the PATH. + GOTO errors +) + +REM +REM NOTE: The Tcl 8.5 executable "tclsh85.exe" is required during the SQLite +REM build process unless a pre-existing amalgamation file is used. +REM +IF NOT DEFINED tclsh85.exe_PATH ( + ECHO The Tcl 8.5 executable "tclsh85.exe" is required to be in the PATH. + GOTO errors +) + REM REM NOTE: Set the TOOLPATH variable to contain all the directories where the REM external tools were found in the search above. @@ -128,7 +199,13 @@ REM NOTE: Check for MSVC 2012 because the Windows SDK directory handling is REM slightly different for that version. REM IF "%VisualStudioVersion%" == "11.0" ( - SET SET_NSDKLIBPATH=1 + REM + REM NOTE: If the Windows SDK library path has already been set, do not set + REM it to something else later on. + REM + IF NOT DEFINED NSDKLIBPATH ( + SET SET_NSDKLIBPATH=1 + ) ) ELSE ( CALL :fn_UnsetVariable SET_NSDKLIBPATH ) @@ -182,7 +259,7 @@ FOR %%P IN (%PLATFORMS%) DO ( REM SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot% - FOR %%B IN (Debug Retail) DO ( + FOR %%B IN (%CONFIGURATIONS%) DO ( REM REM NOTE: When preparing the debug build, set the DEBUG and MEMDEBUG REM environment variables to be picked up by the MSVC makefile diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 82dae2f691..750453ab94 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -2,7 +2,85 @@ # # This script is used to generate a VSIX (Visual Studio Extension) file for # SQLite usable by Visual Studio. - +# +# PREREQUISITES +# +# 1. Tcl 8.4 and later are supported, earlier versions have not been tested. +# +# 2. The "sqlite3.h" file is assumed to exist in the parent directory of the +# directory containing this script. The [optional] second command line +# argument to this script may be used to specify an alternate location. +# This script also assumes that the "sqlite3.h" file corresponds with the +# version of the binaries to be packaged. This assumption is not verified +# by this script. +# +# 3. The temporary directory specified in the TEMP or TMP environment variables +# must refer to an existing directory writable by the current user. +# +# 4. The "zip" and "unzip" command line tools must be located either in a +# directory contained in the PATH environment variable or specified as the +# exact file names to execute in the "ZipTool" and "UnZipTool" environment +# variables, respectively. +# +# 5. The template VSIX file (which is basically a zip file) must be located in +# a "win" directory inside the directory containing this script. It should +# not contain any executable binaries. It should only contain dynamic +# textual content files to be processed using [subst] and/or static content +# files to be copied verbatim. +# +# 6. The executable and other compiled binary files to be packaged into the +# final VSIX file (e.g. DLLs, LIBs, and PDBs) must be located in a single +# directory tree. The top-level directory of the tree must be specified as +# the first command line argument to this script. The second level +# sub-directory names must match those of the build configuration (e.g. +# "Debug" or "Retail"). The third level sub-directory names must match +# those of the platform (e.g. "x86", "x64", and "ARM"). For example, the +# binary files to be packaged would need to be organized as follows when +# packaging the "Debug" and "Retail" build configurations for the "x86" and +# "x64" platforms (in this example, "C:\temp" is the top-level directory as +# specified in the first command line argument): +# +# C:\Temp\Debug\x86\sqlite3.lib +# C:\Temp\Debug\x86\sqlite3.dll +# C:\Temp\Debug\x86\sqlite3.pdb +# C:\Temp\Debug\x64\sqlite3.lib +# C:\Temp\Debug\x64\sqlite3.dll +# C:\Temp\Debug\x64\sqlite3.pdb +# C:\Temp\Retail\x86\sqlite3.lib +# C:\Temp\Retail\x86\sqlite3.dll +# C:\Temp\Retail\x86\sqlite3.pdb +# C:\Temp\Retail\x64\sqlite3.lib +# C:\Temp\Retail\x64\sqlite3.dll +# C:\Temp\Retail\x64\sqlite3.pdb +# +# The above directory tree organization is performed automatically if the +# "tool\build-all-msvc.bat" batch script is used to build the binary files +# to be packaged. +# +# USAGE +# +# Typically, when on Windows, this script is executed using commands similar to +# the following (from a normal Windows command prompt window): +# +# CD /D C:\dev\sqlite\core +# tclsh85 tool\mkvsix.tcl C:\Temp +# +# In the example above, "C:\dev\sqlite\core" represents the root of the source +# tree for SQLite and "C:\Temp" represents the top-level directory containing +# the executable and other compiled binary files, organized into a directory +# tree as described in item 6 of the PREREQUISITES section, above. +# +# This script should work on non-Windows platforms as well, provided that all +# the requirements listed in the PREREQUISITES section are met. +# +# NOTES +# +# The temporary directory is used as a staging area for the final VSIX file. +# The template VSIX file is extracted, its contents processed, and then the +# resulting files are packaged into the final VSIX file. +# +package require Tcl 8.4 + proc fail { {error ""} {usage false} } { if {[string length $error] > 0} then { puts stdout $error @@ -245,7 +323,11 @@ if {![regexp -line -- $pattern $data dummy version]} then { ############################################################################### # -# NOTE: Setup the master file list data, including the necessary flags. +# NOTE: Setup all the master file list data. This includes the source and +# destination file names, build-neutral boolean flags, platform-neutral +# boolean flags, and the dynamic content (subst) boolean flags. There +# is also one set of boolean flags per build configuration, currently +# "Debug" and "Retail", that control which files are skipped for it. # if {![info exists fileNames(source)]} then { set fileNames(source) [list "" "" "" \ From 8749c1831ae251b2ae5a60277448158f2492634a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 19 Oct 2012 02:10:53 +0000 Subject: [PATCH 13/28] Make sure substructure elements have proper alignment in the ICU tokenizers of FTS2 and FTS3. FossilOrigin-Name: aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 --- ext/fts2/fts2_icu.c | 4 ++-- ext/fts3/fts3_icu.c | 4 ++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/fts2/fts2_icu.c b/ext/fts2/fts2_icu.c index de8e116bb9..2670301f51 100644 --- a/ext/fts2/fts2_icu.c +++ b/ext/fts2/fts2_icu.c @@ -118,7 +118,7 @@ static int icuOpen( nChar = nInput+1; pCsr = (IcuCursor *)sqlite3_malloc( sizeof(IcuCursor) + /* IcuCursor */ - nChar * sizeof(UChar) + /* IcuCursor.aChar[] */ + ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */ (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ ); if( !pCsr ){ @@ -126,7 +126,7 @@ static int icuOpen( } memset(pCsr, 0, sizeof(IcuCursor)); pCsr->aChar = (UChar *)&pCsr[1]; - pCsr->aOffset = (int *)&pCsr->aChar[nChar]; + pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3]; pCsr->aOffset[iOut] = iInput; U8_NEXT(zInput, iInput, nInput, c); diff --git a/ext/fts3/fts3_icu.c b/ext/fts3/fts3_icu.c index 18b7948c32..52df8c7d81 100644 --- a/ext/fts3/fts3_icu.c +++ b/ext/fts3/fts3_icu.c @@ -119,7 +119,7 @@ static int icuOpen( nChar = nInput+1; pCsr = (IcuCursor *)sqlite3_malloc( sizeof(IcuCursor) + /* IcuCursor */ - nChar * sizeof(UChar) + /* IcuCursor.aChar[] */ + ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */ (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */ ); if( !pCsr ){ @@ -127,7 +127,7 @@ static int icuOpen( } memset(pCsr, 0, sizeof(IcuCursor)); pCsr->aChar = (UChar *)&pCsr[1]; - pCsr->aOffset = (int *)&pCsr->aChar[nChar]; + pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3]; pCsr->aOffset[iOut] = iInput; U8_NEXT(zInput, iInput, nInput, c); diff --git a/manifest b/manifest index 2605fbeeaf..4e7f38b9c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sdetailed\scomments\sto\sthe\sbuild\stools\sused\sto\sgenerate\sthe\sVSIX\spackage.\s\sAlso,\sallow\sthe\sbuild\sconfigurations\sand\snative\slibrary\sdirectories\sto\sbe\soverridden\sfor\sthe\smulti-platform\sbuild\stool\sfor\sMSVC. -D 2012-10-19T00:23:31.437 +C Make\ssure\ssubstructure\selements\shave\sproper\salignment\sin\sthe\sICU\stokenizers\nof\sFTS2\sand\sFTS3. +D 2012-10-19T02:10:53.511 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -45,7 +45,7 @@ F ext/fts2/fts2.c 4ef7d7ecf590da0dd416ac54612c53a7d4175790 F ext/fts2/fts2.h da5f76c65163301d1068a971fd32f4119e3c95fa F ext/fts2/fts2_hash.c 2689e42e1107ea67207f725cf69cf8972d00cf93 F ext/fts2/fts2_hash.h 9a5b1be94664139f93217a0770d7144425cffb3a -F ext/fts2/fts2_icu.c 1ea9993a39c9783c2e2d7446d055e9d64411dda0 +F ext/fts2/fts2_icu.c 51c5cd3c04954badd329fa738c95fcdb717b5188 F ext/fts2/fts2_porter.c 747056987951f743e955c8479f1df21a565720fe F ext/fts2/fts2_tokenizer.c 26e993a00b2bd5b6e73c155597361710b12ffe25 F ext/fts2/fts2_tokenizer.h a7e46462d935a314b2682287f12f27530a3ee08e @@ -62,7 +62,7 @@ F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e F ext/fts3/fts3_expr.c ceefcaf91344abbf6ceb3cadf404eef5be6924e6 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec -F ext/fts3/fts3_icu.c b85eca4a52e5ec11b94392de5167974c11906d4a +F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 F ext/fts3/fts3_snippet.c f6ebb3536069ceaa27e9f178f4a59379db44ac10 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 @@ -1021,7 +1021,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 8fc8548f52ab8fcfb53f88db68422e09c9b98da1 -R ecd8eecc21d562cb6365b84ab6aacfa3 -U mistachkin -Z e537762f3e1c5212ff12ec99c30fc6e2 +P 0482c73bfdf80b0c0ce9abea706554d7ddf36f69 +R 359b18ae3c286a09e1c7579425de96fe +U drh +Z 09f8af841cfaabcfb0c92e8b07cb012e diff --git a/manifest.uuid b/manifest.uuid index ede7cfe4bf..9bcbd35ae6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0482c73bfdf80b0c0ce9abea706554d7ddf36f69 \ No newline at end of file +aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 \ No newline at end of file From 0f801707d169f651960e01758d38670c02ea1caf Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 20 Oct 2012 08:40:05 +0000 Subject: [PATCH 14/28] Modify VSIX build tools in support of an additional package flavor. FossilOrigin-Name: 702ebc646b43468e6a89322e4e2f4b1ef7858589 --- manifest | 21 ++-- manifest.uuid | 2 +- tool/build-all-msvc.bat | 45 +++++-- tool/mkvsix.tcl | 268 ++++++++++++++++++++++++++-------------- tool/win/sqlite.vsix | Bin 32802 -> 32754 bytes 5 files changed, 223 insertions(+), 113 deletions(-) diff --git a/manifest b/manifest index 4e7f38b9c7..5a01ae00ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\ssubstructure\selements\shave\sproper\salignment\sin\sthe\sICU\stokenizers\nof\sFTS2\sand\sFTS3. -D 2012-10-19T02:10:53.511 +C Modify\sVSIX\sbuild\stools\sin\ssupport\sof\san\sadditional\spackage\sflavor. +D 2012-10-20T08:40:05.626 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -977,7 +977,7 @@ 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 c4ff2f18b1a59bb370ce48fdd286b51a82fa0f5c x +F tool/build-all-msvc.bat 74fb6e5cca66ebdb6c9bbafb2f8b802f08146d38 x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -995,7 +995,7 @@ 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 c5e0d52592fb07a17626cd54e5f71295fb4d1b55 +F tool/mkvsix.tcl 0c7febb4115fd278ff5764f59bf5111172d78d1b F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1020,8 +1020,11 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 0482c73bfdf80b0c0ce9abea706554d7ddf36f69 -R 359b18ae3c286a09e1c7579425de96fe -U drh -Z 09f8af841cfaabcfb0c92e8b07cb012e +F tool/win/sqlite.vsix afaf61050ca4587a7acf3335fc4cde7c9aa254af +P aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 +R 75ba814e4bd96022706eb169d0651507 +T *branch * vsixFlavor +T *sym-vsixFlavor * +T -sym-trunk * +U mistachkin +Z ef10ccc9c6ae9e2d11f5c86ef842bcab diff --git a/manifest.uuid b/manifest.uuid index 9bcbd35ae6..7e2c236535 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 \ No newline at end of file +702ebc646b43468e6a89322e4e2f4b1ef7858589 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index c768e2b6e8..758036fb75 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -151,13 +151,21 @@ REM NOTE: Setup environment variables to translate between the MSVC platform REM names and the names to be used for the platform-specific binary REM directories. REM +SET amd64_NAME=x64 +SET arm_NAME=ARM +SET x64_NAME=x64 SET x86_NAME=x86 SET x86_amd64_NAME=x64 SET x86_arm_NAME=ARM +SET x86_x64_NAME=x64 +%_VECHO% amd64_Name = '%amd64_NAME%' +%_VECHO% arm_Name = '%arm_NAME%' +%_VECHO% x64_Name = '%x64_NAME%' %_VECHO% x86_Name = '%x86_NAME%' %_VECHO% x86_amd64_Name = '%x86_amd64_NAME%' %_VECHO% x86_arm_Name = '%x86_arm_NAME%' +%_VECHO% x86_x64_Name = '%x86_x64_NAME%' REM REM NOTE: Check for the external tools needed during the build process ^(i.e. @@ -210,6 +218,19 @@ IF "%VisualStudioVersion%" == "11.0" ( CALL :fn_UnsetVariable SET_NSDKLIBPATH ) +REM +REM NOTE: Check if this is the Windows Phone SDK. If so, a different batch +REM file is necessary to setup the build environment. Since the variable +REM values involved here may contain parenthesis, using GOTO instead of +REM an IF block is required. +REM +IF DEFINED WindowsPhoneKitDir GOTO set_vcvarsall_phone +SET VCVARSALL=%VCINSTALLDIR%\vcvarsall.bat +GOTO set_vcvarsall_done +:set_vcvarsall_phone +SET VCVARSALL=%VCINSTALLDIR%\WPSDK\WP80\vcvarsphoneall.bat +:set_vcvarsall_done + REM REM NOTE: This is the outer loop. There should be exactly one iteration per REM platform. @@ -250,6 +271,7 @@ FOR %%P IN (%PLATFORMS%) DO ( CALL :fn_UnsetVariable Platform REM CALL :fn_UnsetVariable VCINSTALLDIR CALL :fn_UnsetVariable VSINSTALLDIR + CALL :fn_UnsetVariable WindowsPhoneKitDir CALL :fn_UnsetVariable WindowsSdkDir CALL :fn_UnsetVariable WindowsSdkDir_35 CALL :fn_UnsetVariable WindowsSdkDir_old @@ -292,10 +314,10 @@ FOR %%P IN (%PLATFORMS%) DO ( REM REM NOTE: Attempt to setup the MSVC environment for this platform. REM - %__ECHO3% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P + %__ECHO3% CALL "%VCVARSALL%" %%P IF ERRORLEVEL 1 ( - ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P. + ECHO Failed to call "%VCVARSALL%" for platform %%P. GOTO errors ) @@ -305,10 +327,12 @@ FOR %%P IN (%PLATFORMS%) DO ( 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 + IF NOT DEFINED __ECHO3 ( + IF NOT DEFINED WindowsPhoneKitDir ( + IF NOT DEFINED WindowsSdkDir ( + ECHO Cannot build, Windows SDK not found for platform %%P. + GOTO errors + ) ) ) @@ -322,8 +346,13 @@ FOR %%P IN (%PLATFORMS%) DO ( 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 + IF DEFINED WindowsPhoneKitDir ( + CALL :fn_CopyVariable WindowsPhoneKitDir NSDKLIBPATH + CALL :fn_AppendVariable NSDKLIBPATH \lib\x86 + ) ELSE IF DEFINED WindowsSdkDir ( + CALL :fn_CopyVariable WindowsSdkDir NSDKLIBPATH + CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86 + ) ) REM diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 750453ab94..dcf195ee0e 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -59,8 +59,18 @@ # # USAGE # -# Typically, when on Windows, this script is executed using commands similar to -# the following (from a normal Windows command prompt window): +# The first argument to this script is required and must be the name of the +# top-level directory containing the directories and files organized into a +# tree as described in item 6 of the PREREQUISITES section, above. The second +# argument is optional and if present must contain the name of the directory +# containing the root of the source tree for SQLite. The third argument is +# optional and if present must contain the flavor the VSIX package to build. +# Currently, the only supported package flavors are "WinRT" and "WP80". The +# fourth argument is optional and if present must be a string containing a list +# of platforms to include in the VSIX package. The format of the platform list +# string is "platform1,platform2,platform3". Typically, when on Windows, this +# script is executed using commands similar to the following from a normal +# Windows command prompt: # # CD /D C:\dev\sqlite\core # tclsh85 tool\mkvsix.tcl C:\Temp @@ -89,11 +99,16 @@ proc fail { {error ""} {usage false} } { puts stdout "usage:\ [file tail [info nameofexecutable]]\ -[file tail [info script]] \[sourceDirectory\]" +[file tail [info script]] \[sourceDirectory\]\ +\[packageFlavor\] \[platformNames\]" exit 1 } +proc appendArgs { args } { + set result ""; eval append result $args +} + proc getEnvironmentVariable { name } { # # NOTE: Returns the value of the specified environment variable or an empty @@ -162,21 +177,24 @@ proc writeFile { fileName data } { proc substFile { fileName } { # # NOTE: Performs all Tcl command, variable, and backslash substitutions in - # the specified file and then re-writes the contents of that same file + # the specified file and then rewrites the contents of that same file # with the substituted data. # return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]] } -proc replaceBuildAndPlatform { fileName buildName platformName } { +proc replaceFileNameTokens { fileName name buildName platformName } { # # NOTE: Returns the specified file name containing the platform name instead # of platform placeholder tokens. # - return [string map [list $buildName $platformName] \ - $fileName] + return [string map [list $buildName $platformName \ + $name] $fileName] } +# +# NOTE: This is the entry point for this script. +# set script [file normalize [info script]] if {[string length $script] == 0} then { @@ -192,7 +210,7 @@ set rootName [file rootname [file tail $script]] # NOTE: Process and verify all the command line arguments. # set argc [llength $argv] -if {$argc != 1 && $argc != 2} then {fail} +if {$argc < 1 || $argc > 4} then {fail} set binaryDirectory [lindex $argv 0] @@ -205,7 +223,7 @@ if {![file exists $binaryDirectory] || \ fail "binary directory does not exist" } -if {$argc == 2} then { +if {$argc >= 2} then { set sourceDirectory [lindex $argv 1] } else { # @@ -224,6 +242,47 @@ if {![file exists $sourceDirectory] || \ fail "source directory does not exist" } +if {$argc >= 3} then { + set packageFlavor [lindex $argv 2] +} else { + # + # NOTE: Assume the package flavor is WinRT. + # + set packageFlavor WinRT +} + +if {[string length $packageFlavor] == 0} then { + fail "invalid package flavor" +} + +if {[string equal -nocase $packageFlavor WinRT]} then { + set shortName SQLite.WinRT + set displayName "SQLite for Windows Runtime" + set targetPlatformIdentifier Windows + set extraSdkPath "" + set extraFileListAttributes [appendArgs \ + "\r\n " {AppliesTo="WindowsAppContainer"} \ + "\r\n " {DependsOn="Microsoft.VCLibs, version=11.0"}] +} elseif {[string equal -nocase $packageFlavor WP80]} then { + set shortName SQLite.WP80 + set displayName "SQLite for Windows Phone" + set targetPlatformIdentifier "Windows Phone" + set extraSdkPath "\\..\\$targetPlatformIdentifier" + set extraFileListAttributes "" +} else { + fail "unsupported package flavor, must be \"WinRT\" or \"WP80\"" +} + +if {$argc >= 4} then { + set platformNames [list] + + foreach platformName [split [lindex $argv 3] ", "] { + if {[string length $platformName] > 0} then { + lappend platformNames $platformName + } + } +} + ############################################################################### # @@ -247,7 +306,7 @@ if {![file exists $templateFile] || \ } set currentDirectory [pwd] -set outputFile [file join $currentDirectory sqlite-output.vsix] +set outputFile [file join $currentDirectory sqlite-$packageFlavor-output.vsix] if {[file exists $outputFile]} then { fail [appendArgs "output file \"" $outputFile "\" already exists"] @@ -323,17 +382,41 @@ if {![regexp -line -- $pattern $data dummy version]} then { ############################################################################### # -# NOTE: Setup all the master file list data. This includes the source and -# destination file names, build-neutral boolean flags, platform-neutral -# boolean flags, and the dynamic content (subst) boolean flags. There -# is also one set of boolean flags per build configuration, currently -# "Debug" and "Retail", that control which files are skipped for it. +# NOTE: Setup all the master file list data. This includes the source file +# names, the destination file names, and the file processing flags. The +# possible file processing flags are: +# +# "buildNeutral" -- This flag indicates the file location and content do +# not depend on the build configuration. +# +# "platformNeutral" -- This flag indicates the file location and content +# do not depend on the build platform. +# +# "subst" -- This flag indicates that the file contains dynamic textual +# content that needs to be processed using [subst] prior to +# packaging the file into the final VSIX package. The primary +# use of this flag is to insert the name of the VSIX package, +# some package flavor-specific value, or the SQLite version +# into a file. +# +# "noDebug" -- This flag indicates that the file should be skipped when +# processing the debug build. +# +# "noRetail" -- This flag indicates that the file should be skipped when +# processing the retail build. +# +# "move" -- This flag indicates that the file should be moved from the +# source to the destination instead of being copied. +# +# This file metadata may be overridden, either in whole or in part, via +# the user-specific customizations file. # 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]] + set fileNames(source) [list "" "" \ + [file join $stagingDirectory DesignTime sqlite3.props] \ + [file join $sourceDirectory sqlite3.h] \ + [file join $binaryDirectory sqlite3.lib] \ + [file join $binaryDirectory sqlite3.dll]] if {![info exists no(symbols)]} then { lappend fileNames(source) \ @@ -343,13 +426,12 @@ if {![info exists fileNames(source)]} then { if {![info exists fileNames(destination)]} then { set fileNames(destination) [list \ - [file join $stagingDirectory extension.vsixmanifest] \ - [file join $stagingDirectory SDKManifest.xml] \ - [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]] + [file join $stagingDirectory extension.vsixmanifest] \ + [file join $stagingDirectory SDKManifest.xml] \ + [file join $stagingDirectory DesignTime .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) \ @@ -357,50 +439,24 @@ if {![info exists fileNames(destination)]} then { } } -if {![info exists fileNames(buildNeutral)]} then { - set fileNames(buildNeutral) [list 1 1 1 1 0 0] +if {![info exists fileNames(flags)]} then { + set fileNames(flags) [list \ + [list buildNeutral platformNeutral subst] \ + [list buildNeutral platformNeutral subst] \ + [list buildNeutral platformNeutral subst move] \ + [list buildNeutral platformNeutral] \ + [list] [list] [list noRetail]] if {![info exists no(symbols)]} then { - 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 - } -} - -if {![info exists fileNames(subst)]} then { - set fileNames(subst) [list 1 1 1 0 0 0] - - if {![info exists no(symbols)]} then { - lappend fileNames(subst) 0 - } -} - -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 + lappend fileNames(flags) [list noRetail] } } ############################################################################### # -# NOTE: Setup the list of builds supported by this script. +# NOTE: Setup the list of builds supported by this script. These may be +# overridden via the user-specific customizations file. # if {![info exists buildNames]} then { set buildNames [list Debug Retail] @@ -409,7 +465,9 @@ if {![info exists buildNames]} then { ############################################################################### # -# NOTE: Setup the list of platforms supported by this script. +# NOTE: Setup the list of platforms supported by this script. These may be +# overridden via the command line or the user-specific customizations +# file. # if {![info exists platformNames]} then { set platformNames [list x86 x64 ARM] @@ -423,54 +481,64 @@ if {![info exists platformNames]} then { file mkdir $stagingDirectory # -# NOTE: Build the Tcl command used to extract the template package to the -# staging directory. +# NOTE: Build the Tcl command used to extract the template VSIX package to +# the staging directory. # set extractCommand [list exec -- $unzip $templateFile -d $stagingDirectory] # -# NOTE: Extract the template package to the staging directory. +# NOTE: Extract the template VSIX package to the staging directory. # eval $extractCommand ############################################################################### # -# NOTE: Process each file in the master file list. There are actually seven +# NOTE: Process each file in the master file list. There are actually three # parallel lists that contain the source file names, the destination file -# names, the build-neutral flags, the platform-neutral flags, the -# use-subst flags, the no-debug flags, and the no-retail flags. If the -# platform-neutral flag is non-zero, the file is not platform-specific. -# If the build-neutral flag is non-zero, the file is not build-specific. -# If the use-subst flag is non-zero, the file is considered to be a text -# file that may contain Tcl variable and/or command replacements, to be -# dynamically replaced during processing. If the no-debug flag is -# non-zero, the file will be skipped when processing for the debug build. -# If the no-retail flag is non-zero, the file will be skipped when -# processing for the retail build. If the source file name is an empty -# string, then the destination file name will be assumed to already exist -# in the staging directory and will not be copied; however, dynamic -# replacements may still be performed on the destination file prior to -# the package being re-zipped. +# names, and the file processing flags. If the "buildNeutral" flag is +# present, the file location and content do not depend on the build +# configuration and "CommonConfiguration" will be used in place of the +# build configuration name. If the "platformNeutral" flag is present, +# the file location and content do not depend on the build platform and +# "neutral" will be used in place of the build platform name. If the +# "subst" flag is present, the file is assumed to be a text file that may +# contain Tcl variable, command, and backslash replacements, to be +# dynamically replaced during processing using the Tcl [subst] command. +# If the "noDebug" flag is present, the file will be skipped when +# processing for the debug build. If the "noRetail" flag is present, the +# file will be skipped when processing for the retail build. If the +# "move" flag is present, the source file will be deleted after it is +# copied to the destination file. If the source file name is an empty +# string, the destination file name will be assumed to already exist in +# the staging directory and will not be copied; however, Tcl variable, +# command, and backslash replacements may still be performed on the +# destination file prior to the final VSIX package being built if the +# "subst" flag is present. # foreach sourceFileName $fileNames(source) \ destinationFileName $fileNames(destination) \ - buildNeutral $fileNames(buildNeutral) \ - platformNeutral $fileNames(platformNeutral) \ - useSubst $fileNames(subst) \ - noDebug $fileNames(noDebug) \ - noRetail $fileNames(noRetail) { + fileFlags $fileNames(flags) { + # + # NOTE: Process the file flags into separate boolean variables that may be + # used within the loop. + # + set isBuildNeutral [expr {[lsearch $fileFlags buildNeutral] != -1}] + set isPlatformNeutral [expr {[lsearch $fileFlags platformNeutral] != -1}] + set isMove [expr {[lsearch $fileFlags move] != -1}] + set useSubst [expr {[lsearch $fileFlags subst] != -1}] + # # 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 buildName \ - [expr {$buildNeutral ? [list CommonConfiguration] : $buildNames}] { + [expr {$isBuildNeutral ? [list CommonConfiguration] : $buildNames}] { # # NOTE: Should the current file be skipped for this build? # - if {[info exists no${buildName}] && [set no${buildName}]} then { + if {[lsearch $fileFlags no${buildName}] != -1} then { continue } @@ -480,12 +548,12 @@ foreach sourceFileName $fileNames(source) \ # supported platform will be processed for it individually. # foreach platformName \ - [expr {$platformNeutral ? [list neutral] : $platformNames}] { + [expr {$isPlatformNeutral ? [list neutral] : $platformNames}] { # # NOTE: Use the actual platform name in the destination file name. # - set newDestinationFileName [replaceBuildAndPlatform \ - $destinationFileName $buildName $platformName] + set newDestinationFileName [replaceFileNameTokens $destinationFileName \ + $shortName $buildName $platformName] # # NOTE: Does the source file need to be copied to the destination file? @@ -499,8 +567,18 @@ foreach sourceFileName $fileNames(source) \ # # NOTE: Then, copy the source file to the destination file verbatim. # - file copy [replaceBuildAndPlatform $sourceFileName $buildName \ - $platformName] $newDestinationFileName + set newSourceFileName [replaceFileNameTokens $sourceFileName \ + $shortName $buildName $platformName] + + file copy $newSourceFileName $newDestinationFileName + + # + # NOTE: If this is a move instead of a copy, delete the source file + # now. + # + if {$isMove} then { + file delete $newSourceFileName + } } # @@ -528,13 +606,13 @@ foreach sourceFileName $fileNames(source) \ cd $stagingDirectory # -# NOTE: Build the Tcl command used to archive the final package in the +# NOTE: Build the Tcl command used to archive the final VSIX package in the # output directory. # set archiveCommand [list exec -- $zip -r $outputFile *] # -# NOTE: Build the final package archive in the output directory. +# NOTE: Build the final VSIX package archive in the output directory. # eval $archiveCommand diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix index 4bdfda5c7df1cbd70227f33bb4b2200a7b77c25e..13f121f2fecba8e02d0e9eec0d31865d941afff7 100644 GIT binary patch delta 1490 zcmZXUX*ARe7{>oIjWyvmNXc$&-Hbv~mYK4|j0dzOE8C1Qvu zS!Qq}gBvo*972S$Mw7B6b#c|F+v(H$9#Lcm+}Qbo>MT{OOO=ZS6Q1$(Tj;%~)nDVmH6YF-|J3&^s$4?0NfEjz2q%;}BWxSkVm1)rLvf-$zzuhP6CdVJ=7r zW$k&>KNlR=M-QZayB3o@j&z$8Q>zJ|s_r9|%C?iibi_-gAn}+}O`7aeolZ@!KRNB~ zrAK#*`4%MWENM?gP^1%8!nN9bFmhatHnpqXHMtgOKQbker*!eXOJoc;ov1ZJX#5~Z zvr#k@E-wxy7yT1Hg7aNwEvCKGXniy6Xd z4iSM4ImcaAS$n)3e^LX_(&jE>l<)Pv8kTiFgWG|S0suf5kg+3R-2=_;gSR>0}_))9^AHoR<7mgT^;ix?_d>OW-;BajMeExZ~{a?4`xS9siJ3zFZa#FjU0I7J^A%(G_OZVyrNYOGbF-H--6C90#||#@s_>=39o=&VBsZ znhOsIYYyv01j>Q4*`p-}hT6z2p;dWM!$M(sOt%3U?-O*ExjUsLssG~~*)OW?rczi$ zfnDgs$t3yi_CNP6@bWR8p!w_zfzht~+Pi59TQ?2!;~zg7FCKMHTq&p>AgV_U*{yi}uC30JHltb0q*a-VmFEWDq&1n;BHZ{R3-r#kcS>AU`&K-Lek zTun+z1@OC`9rU3!Fo#8G!I@V3ZLpWh8W}f^j-A$My*k2s$6$7@>VA6qp}~4%Iq>=% z(&H_+X6iBstKlOifx`NZdQE#%m^&YR!C;@NLNl2WAZvP%GVBV27Qfnkn7|l|3|8|j zhSN*}3#olu{pkXWPHh6U<(t~Q-u<9M=ljF^#vWZ%;WIC~sRVK?2 zdZryxz~LMwqx?P%%8Rm*uHi`0g$8??Xr;cW`po*Rt{m%QHgcK1&PLf;3+IMfR1{A@ zUj$&^s|HnqvNhtNCh%Wz2swrwRs4yEqJYwNMgRZE|I{r~^~ delta 1538 zcmZWpc{J1s9RJN27EQTld986puH=ewtr^OFfn zj>z>WrdEj@N!G}1(80{w{@Q*0@%``fzMuC#*ESbao(QJ2i0Bl2L)JtdBn5&1U>ytq z2DwS9B$tbJK@k`YkDyRzR}BI&j1b;QwRh}A3a4!-anh@p5Ye@AuMF{wGF(QAEG4>d z%l{NZXKGS`mNKsFdRnzII~I zTWTykH7jGrG$=pd6D{ty;ex*f9O&NrAIi6?={-V~`a8=pRe5+Y1k}?i)(pU}!!Svo zZ}Rzaw6U;c52b)(iMPgT?wn2JKaL*e730@*HB&Zl)yC9%xqQ|JlnT)HF>h7iAYGC< zaZ#FoFoaH@gl@r`AP5at@|2X@FQIz^xViRV+@tWaq zOOzqONj~4zuar;FIDDFL$9Vu$l)JPj%-KoRcbmQVo9dlT7hn|C#Q_GA=MMycemaFx%-Y083+yCsIOwey$yw^^#pw4_k03f z#pU$lWVO`ypVLw;HfnfeBl6pp1+uS1v(fX4+RN=)e`!skhDdn!iT0J1MO$aPO2S!eXjsPOY23haVODXzMqu-X z+jMKt7r*wA$S&v95%c!NsjDkK56t`buUZjj4XQS6WM$+A+*YiXZqkQR)|c-EC+3LQRf^nT@T$os_C(eQ*ImulT{;gB7)-$MukXqV@b*ssqz)=RBfEi6@doT7S zTo4!~z8w;tlWaqZwQTiba=PSaS^h-IU}4o)62#g6x^i%OP(FjBzozPMIT+Z9t`-KK!G2sy!(fANI$_s}+Bs66s z|J#XL2}`T_wEJZ>o~m*!2fA(uAf1A!V`4j_rNLoiN_qS_tz8WPSnb1yrpjCwow14}GA7tK<05rtk6>rErOlafBNB}?vvls1Vf>}C#F~r=g(<4%BR#Uj zLsZnNiOW0j#?fG1uK30K`qQPC#rnu~%FH;CD3L+@v;}7-LVQbulQfPE(nB0~|GqnF zkUZapx)Cj-7v4y%;9bwnoHV8E##FyIFqN9&JQ7mqDtu^aL-^CT%g{cbT6}`|pE38j1wxGqMW& Date: Sat, 20 Oct 2012 09:35:57 +0000 Subject: [PATCH 15/28] Modify clean target to handle all VSIX package flavors. FossilOrigin-Name: 023217ea9eea4fea5d3be7707599c6980d4b76f7 --- Makefile.in | 2 +- Makefile.msc | 2 +- main.mk | 2 +- manifest | 19 ++++++++----------- manifest.uuid | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Makefile.in b/Makefile.in index f374aa451c..f078cb68b4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -944,7 +944,7 @@ clean: rm -f sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def rm -f sqlite3.c rm -f sqlite3_analyzer$(TEXE) sqlite3_analyzer.c - rm -f sqlite-output.vsix + rm -f sqlite-*-output.vsix distclean: clean rm -f config.log config.status libtool Makefile sqlite3.pc diff --git a/Makefile.msc b/Makefile.msc index db997fd34b..93d3c0fb25 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1247,7 +1247,7 @@ clean: del /Q sqlite3.c del /Q sqlite3rc.h del /Q sqlite3_analyzer.exe sqlite3_analyzer.exp sqlite3_analyzer.c - del /Q sqlite-output.vsix + del /Q sqlite-*-output.vsix # Dynamic link library section. # diff --git a/main.mk b/main.mk index d24ba3a842..76a9f406a2 100644 --- a/main.mk +++ b/main.mk @@ -619,4 +619,4 @@ clean: rm -f threadtest3 threadtest3.exe rm -f sqlite3.c fts?amal.c tclsqlite3.c rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c - rm -f sqlite-output.vsix + rm -f sqlite-*-output.vsix diff --git a/manifest b/manifest index 5a01ae00ee..4cddf1d481 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Modify\sVSIX\sbuild\stools\sin\ssupport\sof\san\sadditional\spackage\sflavor. -D 2012-10-20T08:40:05.626 +C Modify\sclean\starget\sto\shandle\sall\sVSIX\spackage\sflavors. +D 2012-10-20T09:35:57.904 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb +F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 1d8a5d3cf33b8b8d3247c99367a37af384cc7ebd +F Makefile.msc 911b8188f5d67801035a113e063c3023a617525d F Makefile.vxworks b18ad88e9a8c6a001f5cf4a389116a4f1a7ab45f F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION edab4af5a4623f8198833ea481ce98ab53750a8d @@ -103,7 +103,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk ed9b74318401c0242fcac7caa95747912b9bd18f +F main.mk 615aeaf7474cb2f141547e0c3ac08bcb75dd2b55 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -1021,10 +1021,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix afaf61050ca4587a7acf3335fc4cde7c9aa254af -P aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 -R 75ba814e4bd96022706eb169d0651507 -T *branch * vsixFlavor -T *sym-vsixFlavor * -T -sym-trunk * +P 702ebc646b43468e6a89322e4e2f4b1ef7858589 +R a24f05c2d976ce62cd18d97580a50a82 U mistachkin -Z ef10ccc9c6ae9e2d11f5c86ef842bcab +Z 266a8c9fa37a8bad07b2577c7f95cb0a diff --git a/manifest.uuid b/manifest.uuid index 7e2c236535..350d26526c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -702ebc646b43468e6a89322e4e2f4b1ef7858589 \ No newline at end of file +023217ea9eea4fea5d3be7707599c6980d4b76f7 \ No newline at end of file From 540aaed237575dcbc656367b5353914f34f571d1 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 24 Oct 2012 00:47:59 +0000 Subject: [PATCH 16/28] Translate the Debug/Release project configurations to the Debug/Retail VSIX package configurations. FossilOrigin-Name: 5023a7adcac2022a4a2009183d9d9e0f6b46952b --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/win/sqlite.vsix | Bin 32754 -> 32816 bytes 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 4cddf1d481..de656b8305 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sclean\starget\sto\shandle\sall\sVSIX\spackage\sflavors. -D 2012-10-20T09:35:57.904 +C Translate\sthe\sDebug/Release\sproject\sconfigurations\sto\sthe\sDebug/Retail\sVSIX\spackage\sconfigurations. +D 2012-10-24T00:47:59.405 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1020,8 +1020,8 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -F tool/win/sqlite.vsix afaf61050ca4587a7acf3335fc4cde7c9aa254af -P 702ebc646b43468e6a89322e4e2f4b1ef7858589 -R a24f05c2d976ce62cd18d97580a50a82 +F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac +P 023217ea9eea4fea5d3be7707599c6980d4b76f7 +R df31fe3fba4c339b050d48573a558d63 U mistachkin -Z 266a8c9fa37a8bad07b2577c7f95cb0a +Z d50bfe888efa984ae49286b522083a84 diff --git a/manifest.uuid b/manifest.uuid index 350d26526c..f84fda97f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -023217ea9eea4fea5d3be7707599c6980d4b76f7 \ No newline at end of file +5023a7adcac2022a4a2009183d9d9e0f6b46952b \ No newline at end of file diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix index 13f121f2fecba8e02d0e9eec0d31865d941afff7..93eefac2dbbd9da8a901fc215cc94629002b5723 100644 GIT binary patch delta 547 zcmV+;0^I%b{{gUo0+6*4K!;aB{6X)(uK@r6UjzUEG?9TSk?;VH^S zse+}}o0bbIwo!%K3V{$xIPPU*kL@M~!wU(oILwr^U z?0rqy;AJ`!JV1&~Yu~Vaz(Jve`b_uQLm&e|~o}VzLd)c$$3$e7^Za>Yi*BBdf z_=HG~rLpRo+X^u38W{Wy4Gh_?f!#GMY5>fHYb4)x9@2e3-^tETOkext^}9YpP#Kg$ z_dC@Cy8-GkRUh}+pWZ}Ki4Ia-IBqDW z!&~9wN3(7MvU(0chgU)TLGQn>0RRAB1d}d(R0bc3!#aAglZbsh0j!h7eP;qD1(Pm* lSOH^`hkjfFDHoIFep>yDce)J?gnj2A2$f9q<30NX=7(IZE)fW>`SlynzJLYe5vMK0;MA@ zrB)-YQobwNxdNqn4k2VyK}^0iVsQZg015+>Y<*M)D7s*bFs_rveLMkflLLNd0_X&j nY<^e)C6mQ|TmtJBlOumy0lt%ee_#T~dXwRQNe0b(000000_xtk From 98d312fc3ea45e7836edae65582207a8f75a1451 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 25 Oct 2012 15:23:14 +0000 Subject: [PATCH 17/28] Improvements to the command-line argument parsing in the command-line shell. Command-line options can now occur either before or after the database name and first command and are still accepted and processed. Command-line options are processed even if no database name is given (and :memory: is assumed). FossilOrigin-Name: 317c80cba3688a97ade9cde622cc3bd94cf3436a --- manifest | 14 +++---- manifest.uuid | 2 +- src/shell.c | 101 +++++++++++++++++++++++------------------------ test/shell1.test | 4 +- 4 files changed, 59 insertions(+), 62 deletions(-) diff --git a/manifest b/manifest index 4e7f38b9c7..7a4a586671 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\ssubstructure\selements\shave\sproper\salignment\sin\sthe\sICU\stokenizers\nof\sFTS2\sand\sFTS3. -D 2012-10-19T02:10:53.511 +C Improvements\sto\sthe\scommand-line\sargument\sparsing\sin\sthe\s\ncommand-line\sshell.\s\sCommand-line\soptions\scan\snow\soccur\seither\sbefore\nor\safter\sthe\sdatabase\sname\sand\sfirst\scommand\sand\sare\sstill\saccepted\sand\nprocessed.\s\sCommand-line\soptions\sare\sprocessed\seven\sif\sno\sdatabase\sname\nis\sgiven\s(and\s:memory:\sis\sassumed). +D 2012-10-25T15:23:14.369 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 9b759521f805e25e97baa2dd64037157fe365817 -F src/shell.c 8ee5a3cb502e2d574f97b43972e6c1e275e7bec7 +F src/shell.c d570e6cb3889eb07fdf15808a1b6b136c78e4da5 F src/sqlite.h.in c7be05ad191d2634292fcc77bdb2bcfa4526eb98 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 @@ -706,7 +706,7 @@ F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d F test/shared9.test 614a3ca431adc73c857632deb4eff75bcaee40ec F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf -F test/shell1.test 272384163432c0efd2c6817396beb0d119565d53 +F test/shell1.test 340125225cc96c7f48d59a869aaf82866e481007 F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59 F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 @@ -1021,7 +1021,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 0482c73bfdf80b0c0ce9abea706554d7ddf36f69 -R 359b18ae3c286a09e1c7579425de96fe +P aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 +R 4204a6c0a11b862c569be1046625095c U drh -Z 09f8af841cfaabcfb0c92e8b07cb012e +Z 98d27aa00ef0fe7caf71f35a32885811 diff --git a/manifest.uuid b/manifest.uuid index 9bcbd35ae6..00c77f0975 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 \ No newline at end of file +317c80cba3688a97ade9cde622cc3bd94cf3436a \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 7ad60c505b..d7443b135a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2824,11 +2824,14 @@ static const char zOptions[] = " -bail stop after hitting an error\n" " -batch force batch I/O\n" " -column set output mode to 'column'\n" - " -cmd command run \"command\" before reading stdin\n" + " -cmd COMMIT run \"COMMAND\" before reading stdin\n" " -csv set output mode to 'csv'\n" " -echo print commands before execution\n" " -init filename read/process named file\n" " -[no]header turn headers on or off\n" +#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) + " -heap SIZE Size of heap for memsys3 or memsys5\n" +#endif " -help show this message\n" " -html set output mode to HTML\n" " -interactive force interactive I/O\n" @@ -2837,8 +2840,8 @@ static const char zOptions[] = #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif - " -nullvalue 'text' set text string for NULL values\n" - " -separator 'x' set output field separator (|)\n" + " -nullvalue TEXT set text string for NULL values. Default ''\n" + " -separator SEP set output field separator. Default: '|'\n" " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" @@ -2874,6 +2877,19 @@ static void main_init(struct callback_data *data) { sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); } +/* +** Get the argument to an --option. Throw an error and die if no argument +** is available. +*/ +static char *cmdline_option_value(int argc, char **argv, int i){ + if( i==argc ){ + fprintf(stderr, "%s: Error: missing argument to %s\n", + argv[0], argv[argc-1]); + exit(1); + } + return argv[i]; +} + int main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; @@ -2903,24 +2919,35 @@ int main(int argc, char **argv){ ** the size of the alternative malloc heap, ** and the first command to execute. */ - for(i=1; i=argc){ - fprintf(stderr,"%s: Error: missing argument for option: %s\n", - Argv0, z); - fprintf(stderr,"Use -help for a list of options.\n"); - return 1; - } sqlite3_snprintf(sizeof(data.separator), data.separator, - "%.*s",(int)sizeof(data.separator)-1,argv[i]); + "%s",cmdline_option_value(argc,argv,++i)); }else if( strcmp(z,"-nullvalue")==0 ){ - i++; - if(i>=argc){ - fprintf(stderr,"%s: Error: missing argument for option: %s\n", - Argv0, z); - fprintf(stderr,"Use -help for a list of options.\n"); - return 1; - } sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue, - "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]); + "%s",cmdline_option_value(argc,argv,++i)); }else if( strcmp(z,"-header")==0 ){ data.showHeader = 1; }else if( strcmp(z,"-noheader")==0 ){ @@ -3082,8 +3080,7 @@ int main(int argc, char **argv){ usage(1); }else if( strcmp(z,"-cmd")==0 ){ if( i==argc-1 ) break; - i++; - z = argv[i]; + z = cmdline_option_value(argc,argv,++i); if( z[0]=='.' ){ rc = do_meta_command(z, &data); if( rc && bail_on_error ) return rc; diff --git a/test/shell1.test b/test/shell1.test index 5c49d90532..e826b95e44 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -149,7 +149,7 @@ do_test shell1-1.14.3 { set res [catchcmd "-separator" ""] set rc [lindex $res 0] list $rc \ - [regexp {Error: missing argument for option: -separator} $res] + [regexp {Error: missing argument to -separator} $res] } {1 1} # -stats print memory stats before each finalize @@ -168,7 +168,7 @@ do_test shell1-1.15.3 { set res [catchcmd "-nullvalue" ""] set rc [lindex $res 0] list $rc \ - [regexp {Error: missing argument for option: -nullvalue} $res] + [regexp {Error: missing argument to -nullvalue} $res] } {1 1} # -version show SQLite version From 6d81d75d86c6bd162c30957f4e61233292dd02ec Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 25 Oct 2012 15:43:28 +0000 Subject: [PATCH 18/28] Fix typo in usage text for the command-line shell. Also, in the same usage text, make the file name argument to -init uppercase for consistency. FossilOrigin-Name: a6d906cfeb9b181fd5b88df3650bab7ee1a24c0b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 7a4a586671..0e0b73fd92 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\scommand-line\sargument\sparsing\sin\sthe\s\ncommand-line\sshell.\s\sCommand-line\soptions\scan\snow\soccur\seither\sbefore\nor\safter\sthe\sdatabase\sname\sand\sfirst\scommand\sand\sare\sstill\saccepted\sand\nprocessed.\s\sCommand-line\soptions\sare\sprocessed\seven\sif\sno\sdatabase\sname\nis\sgiven\s(and\s:memory:\sis\sassumed). -D 2012-10-25T15:23:14.369 +C Fix\stypo\sin\susage\stext\sfor\sthe\scommand-line\sshell.\s\sAlso,\sin\sthe\ssame\susage\stext,\smake\sthe\sfile\sname\sargument\sto\s-init\suppercase\sfor\sconsistency. +D 2012-10-25T15:43:28.141 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 9b759521f805e25e97baa2dd64037157fe365817 -F src/shell.c d570e6cb3889eb07fdf15808a1b6b136c78e4da5 +F src/shell.c 24cd0aa74aff73ea08594629faead564c4c2a286 F src/sqlite.h.in c7be05ad191d2634292fcc77bdb2bcfa4526eb98 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 @@ -1021,7 +1021,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 aaa2d9b0db74d8452d9294de17cff786ab4ec7c8 -R 4204a6c0a11b862c569be1046625095c -U drh -Z 98d27aa00ef0fe7caf71f35a32885811 +P 317c80cba3688a97ade9cde622cc3bd94cf3436a +R b4db6e6bb401c9fc38dad15257c4f5e0 +U mistachkin +Z 8698214bd6601b08970e9286ab6d0b5c diff --git a/manifest.uuid b/manifest.uuid index 00c77f0975..7ef634fcdb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -317c80cba3688a97ade9cde622cc3bd94cf3436a \ No newline at end of file +a6d906cfeb9b181fd5b88df3650bab7ee1a24c0b \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index d7443b135a..adb8165434 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2824,10 +2824,10 @@ static const char zOptions[] = " -bail stop after hitting an error\n" " -batch force batch I/O\n" " -column set output mode to 'column'\n" - " -cmd COMMIT run \"COMMAND\" before reading stdin\n" + " -cmd COMMAND run \"COMMAND\" before reading stdin\n" " -csv set output mode to 'csv'\n" " -echo print commands before execution\n" - " -init filename read/process named file\n" + " -init FILENAME read/process named file\n" " -[no]header turn headers on or off\n" #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) " -heap SIZE Size of heap for memsys3 or memsys5\n" From e62c0694deb5d76255b29d40e3c82cd4af629df7 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 25 Oct 2012 19:25:39 +0000 Subject: [PATCH 19/28] Fix a bug in fts3 causing it to return SQLITE_NOMEM when NEAR, OR and some auxiliary functions were used together. Also a segfault in vtab.c that could follow an OOM condition. FossilOrigin-Name: 33f4f9817e8b3cb97ce02a4c49bd586332da37b2 --- ext/fts3/fts3.c | 52 ++++++++++++++++++++++------------------- manifest | 18 +++++++------- manifest.uuid | 2 +- src/vtab.c | 2 -- test/fts3matchinfo.test | 19 +++++++++++++++ 5 files changed, 57 insertions(+), 36 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 58414f65db..7a53ac37a3 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4743,35 +4743,39 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){ nTmp += p->pRight->pPhrase->doclist.nList; } nTmp += p->pPhrase->doclist.nList; - aTmp = sqlite3_malloc(nTmp*2); - if( !aTmp ){ - *pRc = SQLITE_NOMEM; + if( nTmp==0 ){ res = 0; }else{ - char *aPoslist = p->pPhrase->doclist.pList; - int nToken = p->pPhrase->nToken; + aTmp = sqlite3_malloc(nTmp*2); + if( !aTmp ){ + *pRc = SQLITE_NOMEM; + res = 0; + }else{ + char *aPoslist = p->pPhrase->doclist.pList; + int nToken = p->pPhrase->nToken; - for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){ - Fts3Phrase *pPhrase = p->pRight->pPhrase; - int nNear = p->nNear; - res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); - } - - aPoslist = pExpr->pRight->pPhrase->doclist.pList; - nToken = pExpr->pRight->pPhrase->nToken; - for(p=pExpr->pLeft; p && res; p=p->pLeft){ - int nNear; - Fts3Phrase *pPhrase; - assert( p->pParent && p->pParent->pLeft==p ); - nNear = p->pParent->nNear; - pPhrase = ( - p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase - ); - res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); + for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){ + Fts3Phrase *pPhrase = p->pRight->pPhrase; + int nNear = p->nNear; + res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); + } + + aPoslist = pExpr->pRight->pPhrase->doclist.pList; + nToken = pExpr->pRight->pPhrase->nToken; + for(p=pExpr->pLeft; p && res; p=p->pLeft){ + int nNear; + Fts3Phrase *pPhrase; + assert( p->pParent && p->pParent->pLeft==p ); + nNear = p->pParent->nNear; + pPhrase = ( + p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase + ); + res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); + } } + + sqlite3_free(aTmp); } - - sqlite3_free(aTmp); } return res; diff --git a/manifest b/manifest index 0e0b73fd92..f8fd1b8f9e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\susage\stext\sfor\sthe\scommand-line\sshell.\s\sAlso,\sin\sthe\ssame\susage\stext,\smake\sthe\sfile\sname\sargument\sto\s-init\suppercase\sfor\sconsistency. -D 2012-10-25T15:43:28.141 +C Fix\sa\sbug\sin\sfts3\scausing\sit\sto\sreturn\sSQLITE_NOMEM\swhen\sNEAR,\sOR\sand\ssome\sauxiliary\sfunctions\swere\sused\stogether.\sAlso\sa\ssegfault\sin\svtab.c\sthat\scould\sfollow\san\sOOM\scondition. +D 2012-10-25T19:25:39.022 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -55,7 +55,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c ab90126ee0163539d21d0618d22afa2eb645f7e2 +F ext/fts3/fts3.c a867cafae0235324df64c5775cbf352a3f712cb9 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 1e58825246b56259267382d2f9902774c049460a F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e @@ -245,7 +245,7 @@ F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 -F src/vtab.c 9c64ae18af78c740610df841c6f49fc2d240a279 +F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b @@ -486,7 +486,7 @@ F test/fts3fault.test cb72dccb0a3b9f730f16c5240f3fcb9303eb1660 F test/fts3fault2.test 3198eef2804deea7cac8403e771d9cbcb752d887 F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be -F test/fts3matchinfo.test 15edde2c4d373d60449658176af7164d622a62f0 +F test/fts3matchinfo.test ecb08f586d027eb03941bcfcded6cb9d8ccb3a66 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 F test/fts3prefix.test b36d4f00b128a51e7b386cc013a874246d9d7dc1 F test/fts3prefix2.test 477ca96e67f60745b7ac931cfa6e9b080c562da5 @@ -1021,7 +1021,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 317c80cba3688a97ade9cde622cc3bd94cf3436a -R b4db6e6bb401c9fc38dad15257c4f5e0 -U mistachkin -Z 8698214bd6601b08970e9286ab6d0b5c +P a6d906cfeb9b181fd5b88df3650bab7ee1a24c0b +R 674e19925b07366510d1fc7375732e22 +U dan +Z 1032beb5eac48ad97bee39ee66a1a525 diff --git a/manifest.uuid b/manifest.uuid index 7ef634fcdb..6014f84bdb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6d906cfeb9b181fd5b88df3650bab7ee1a24c0b \ No newline at end of file +33f4f9817e8b3cb97ce02a4c49bd586332da37b2 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index 39fbacacbc..958202c31e 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -495,7 +495,6 @@ static int vtabCallConstructor( pVTable->db = db; pVTable->pMod = pMod; - assert( pTab->azModuleArg[1]==0 ); iDb = sqlite3SchemaToIndex(db, pTab->pSchema); pTab->azModuleArg[1] = db->aDb[iDb].zName; @@ -509,7 +508,6 @@ static int vtabCallConstructor( rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr); db->pVtabCtx = pPriorCtx; if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; - pTab->azModuleArg[1] = 0; if( SQLITE_OK!=rc ){ if( zErr==0 ){ diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test index 924db9c8a1..3998c9a40c 100644 --- a/test/fts3matchinfo.test +++ b/test/fts3matchinfo.test @@ -407,5 +407,24 @@ do_catchsql_test 8.5.3.2 { SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +do_execsql_test 8.1 { + CREATE VIRTUAL TABLE t12 USING fts4; + INSERT INTO t12 VALUES('a b c d'); + SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a'; +} {{0 0 0 0 0 0 1 1 1}} +do_execsql_test 8.2 { + INSERT INTO t12 VALUES('a d c d'); + SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a'; +} { + {0 1 1 0 1 1 1 2 2} {1 1 1 1 1 1 1 2 2} +} +do_execsql_test 8.3 { + INSERT INTO t12 VALUES('a d d a'); + SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a'; +} { + {0 3 2 0 3 2 1 4 3} {1 3 2 1 3 2 1 4 3} {2 3 2 2 3 2 2 4 3} +} + finish_test From cb103b9274104dccfc9933344af6ea81d8588c3a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 26 Oct 2012 00:11:23 +0000 Subject: [PATCH 20/28] Make sure all virtual table cursors have been closed on a prepared statement prior to unlinking the perpared statement from its database connection. FossilOrigin-Name: f7c5abe8739090db0738d2c7002a0d71f76c927e --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/status.c | 2 +- src/vdbe.h | 2 +- src/vdbeaux.c | 12 +++++++----- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index f8fd1b8f9e..d8b5eccde7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sfts3\scausing\sit\sto\sreturn\sSQLITE_NOMEM\swhen\sNEAR,\sOR\sand\ssome\sauxiliary\sfunctions\swere\sused\stogether.\sAlso\sa\ssegfault\sin\svtab.c\sthat\scould\sfollow\san\sOOM\scondition. -D 2012-10-25T19:25:39.022 +C Make\ssure\sall\svirtual\stable\scursors\shave\sbeen\sclosed\son\sa\sprepared\sstatement\nprior\sto\sunlinking\sthe\sperpared\sstatement\sfrom\sits\sdatabase\sconnection. +D 2012-10-26T00:11:23.970 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h b49674b1c92173e9796c94fd6f15c1679e3b10cc F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d -F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 +F src/status.c 53463144deb5dfac0a66b3be4dd7844b8f8a4c98 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 515abd8e33e82aa330eeb54675185a7e1e5b6778 F src/test1.c 936afc02766403e5debca49a1817a780e116df7e @@ -237,10 +237,10 @@ F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 F src/vdbe.c 31523df2b986fc6c959dd54ca640ba865884641b -F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb +F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d F src/vdbeInt.h 573a43ab5697b648a1e8f3dfc7d8667d5ca55729 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c -F src/vdbeaux.c 674e969e026d1af1938942eba17071127839fc15 +F src/vdbeaux.c 8c8cfd30063e9b3664e2faa0e3785102bf131a10 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b @@ -1021,7 +1021,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P a6d906cfeb9b181fd5b88df3650bab7ee1a24c0b -R 674e19925b07366510d1fc7375732e22 -U dan -Z 1032beb5eac48ad97bee39ee66a1a525 +P 33f4f9817e8b3cb97ce02a4c49bd586332da37b2 +R bc72b67b42140060c43fae49b44a7daa +T *branch * deferred-close-order +T *sym-deferred-close-order * +T -sym-trunk * +U drh +Z 48246a4a15ab765f01b398ae16f882b2 diff --git a/manifest.uuid b/manifest.uuid index 6014f84bdb..78af04e8ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -33f4f9817e8b3cb97ce02a4c49bd586332da37b2 \ No newline at end of file +f7c5abe8739090db0738d2c7002a0d71f76c927e \ No newline at end of file diff --git a/src/status.c b/src/status.c index 04b7656afe..9b0df8001c 100644 --- a/src/status.c +++ b/src/status.c @@ -208,7 +208,7 @@ int sqlite3_db_status( db->pnBytesFreed = &nByte; for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){ - sqlite3VdbeDeleteObject(db, pVdbe); + sqlite3VdbeClearObject(db, pVdbe); } db->pnBytesFreed = 0; diff --git a/src/vdbe.h b/src/vdbe.h index 90a43ce6ee..fa7b31b727 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -188,7 +188,7 @@ VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); int sqlite3VdbeMakeLabel(Vdbe*); void sqlite3VdbeRunOnlyOnce(Vdbe*); void sqlite3VdbeDelete(Vdbe*); -void sqlite3VdbeDeleteObject(sqlite3*,Vdbe*); +void sqlite3VdbeClearObject(sqlite3*,Vdbe*); void sqlite3VdbeMakeReady(Vdbe*,Parse*); int sqlite3VdbeFinalize(Vdbe*); void sqlite3VdbeResolveLabel(Vdbe*, int); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 405ea48b89..efcc7476c0 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2434,12 +2434,14 @@ void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){ } /* -** Free all memory associated with the Vdbe passed as the second argument. +** Free all memory associated with the Vdbe passed as the second argument, +** except for object itself, which is preserved. +** ** The difference between this function and sqlite3VdbeDelete() is that ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with -** the database connection. +** the database connection and frees the object itself. */ -void sqlite3VdbeDeleteObject(sqlite3 *db, Vdbe *p){ +void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ SubProgram *pSub, *pNext; int i; assert( p->db==0 || p->db==db ); @@ -2460,7 +2462,6 @@ void sqlite3VdbeDeleteObject(sqlite3 *db, Vdbe *p){ sqlite3DbFree(db, p->zExplain); sqlite3DbFree(db, p->pExplain); #endif - sqlite3DbFree(db, p); } /* @@ -2472,6 +2473,7 @@ void sqlite3VdbeDelete(Vdbe *p){ if( NEVER(p==0) ) return; db = p->db; assert( sqlite3_mutex_held(db->mutex) ); + sqlite3VdbeClearObject(db, p); if( p->pPrev ){ p->pPrev->pNext = p->pNext; }else{ @@ -2483,7 +2485,7 @@ void sqlite3VdbeDelete(Vdbe *p){ } p->magic = VDBE_MAGIC_DEAD; p->db = 0; - sqlite3VdbeDeleteObject(db, p); + sqlite3DbFree(db, p); } /* From 537dddf0cd27912091f218d002e5bfdac084d50f Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 26 Oct 2012 13:46:24 +0000 Subject: [PATCH 21/28] Add QNX-specific performance tweaks to the unix VFS. (Cherry-pick merge of [b02849e7bde458].) FossilOrigin-Name: 63a7dd75e61afb3d05a1434f66ad6a5f08352aad --- manifest | 12 +++--- manifest.uuid | 2 +- src/os_unix.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 102 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 76b0c2b169..e83a8c7a14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sall\svirtual\stable\scursors\shave\sbeen\sclosed\son\sa\sprepared\sstatement\nprior\sto\sunlinking\sthe\sperpared\sstatement\sfrom\sits\sdatabase\sconnection.\nThe\stest\scase\sfor\sthis\sis\sin\sTH3,\sin\sthe\smain39.test\smodule. -D 2012-10-26T00:55:07.323 +C Add\sQNX-specific\sperformance\stweaks\sto\sthe\sunix\sVFS.\s(Cherry-pick\smerge\sof\n[b02849e7bde458].) +D 2012-10-26T13:46:24.545 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ 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 0d3a39dd576c9f384fd7772a2dadc67b144c6ce7 +F src/os_unix.c 603d020fe6c58047794cc72c05c7c8f4a82a0579 F src/os_win.c 43ec1285357e5d5d919cb0492eac775c58ad7d12 F src/pager.c ee59fef31673d5124413c5a801cfd9ef3e6766d3 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 @@ -1021,7 +1021,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 33f4f9817e8b3cb97ce02a4c49bd586332da37b2 f7c5abe8739090db0738d2c7002a0d71f76c927e -R bc72b67b42140060c43fae49b44a7daa +P 6d42d806adb833572a324d4141ab3b2c315617b2 +R 9679b392e94d1e56bc54a4f85e939c7e U drh -Z d0356ac18ea49d0169f59bb16fb002ee +Z d2173a314f2a3b1470d7441b9db15fea diff --git a/manifest.uuid b/manifest.uuid index 3163138938..bff2f3a80b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d42d806adb833572a324d4141ab3b2c315617b2 \ No newline at end of file +63a7dd75e61afb3d05a1434f66ad6a5f08352aad \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 5fbac00713..9b6c9401a1 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -218,6 +218,10 @@ struct unixFile { const char *zPath; /* Name of the file */ unixShm *pShm; /* Shared memory segment information */ int szChunk; /* Configured by FCNTL_CHUNK_SIZE */ +#ifdef __QNXNTO__ + int sectorSize; /* Device sector size */ + int deviceCharacteristics; /* Precomputed device characteristics */ +#endif #if SQLITE_ENABLE_LOCKING_STYLE int openFlags; /* The flags specified at open() */ #endif @@ -3638,10 +3642,92 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ ** a database and its journal file) that the sector size will be the ** same for both. */ -static int unixSectorSize(sqlite3_file *pFile){ - (void)pFile; +#ifndef __QNXNTO__ +static int unixSectorSize(sqlite3_file *NotUsed){ + UNUSED_PARAMETER(NotUsed); return SQLITE_DEFAULT_SECTOR_SIZE; } +#endif + +/* +** The following version of unixSectorSize() is optimized for QNX. +*/ +#ifdef __QNXNTO__ +#include +#include +static int unixSectorSize(sqlite3_file *id){ + unixFile *pFile = (unixFile*)id; + if( pFile->sectorSize == 0 ){ + struct statvfs fsInfo; + + /* Set defaults for non-supported filesystems */ + pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; + pFile->deviceCharacteristics = 0; + if( fstatvfs(pFile->h, &fsInfo) == -1 ) { + return pFile->sectorSize; + } + + if( !strcmp(fsInfo.f_basetype, "tmp") ) { + pFile->sectorSize = fsInfo.f_bsize; + pFile->deviceCharacteristics = + SQLITE_IOCAP_ATOMIC4K | /* All ram filesystem writes are atomic */ + SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until + ** the write succeeds */ + SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind + ** so it is ordered */ + 0; + }else if( strstr(fsInfo.f_basetype, "etfs") ){ + pFile->sectorSize = fsInfo.f_bsize; + pFile->deviceCharacteristics = + /* etfs cluster size writes are atomic */ + (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) | + SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until + ** the write succeeds */ + SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind + ** so it is ordered */ + 0; + }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){ + pFile->sectorSize = fsInfo.f_bsize; + pFile->deviceCharacteristics = + SQLITE_IOCAP_ATOMIC | /* All filesystem writes are atomic */ + SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until + ** the write succeeds */ + SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind + ** so it is ordered */ + 0; + }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){ + pFile->sectorSize = fsInfo.f_bsize; + pFile->deviceCharacteristics = + /* full bitset of atomics from max sector size and smaller */ + ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 | + SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind + ** so it is ordered */ + 0; + }else if( strstr(fsInfo.f_basetype, "dos") ){ + pFile->sectorSize = fsInfo.f_bsize; + pFile->deviceCharacteristics = + /* full bitset of atomics from max sector size and smaller */ + ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 | + SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind + ** so it is ordered */ + 0; + }else{ + pFile->deviceCharacteristics = + SQLITE_IOCAP_ATOMIC512 | /* blocks are atomic */ + SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until + ** the write succeeds */ + 0; + } + } + /* Last chance verification. If the sector size isn't a multiple of 512 + ** then it isn't valid.*/ + if( pFile->sectorSize % 512 != 0 ){ + pFile->deviceCharacteristics = 0; + pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; + } + return pFile->sectorSize; +} +#endif /* __QNXNTO__ */ /* ** Return the device characteristics for the file. @@ -3658,11 +3744,15 @@ static int unixSectorSize(sqlite3_file *pFile){ */ static int unixDeviceCharacteristics(sqlite3_file *id){ unixFile *p = (unixFile*)id; + int rc = 0; +#ifdef __QNXNTO__ + if( p->sectorSize==0 ) unixSectorSize(id); + rc = p->deviceCharacteristics; +#endif if( p->ctrlFlags & UNIXFILE_PSOW ){ - return SQLITE_IOCAP_POWERSAFE_OVERWRITE; - }else{ - return 0; + rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; } + return rc; } #ifndef SQLITE_OMIT_WAL From 447b289ec8a49f597b10af0f53400cc7521448b5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 26 Oct 2012 18:40:01 +0000 Subject: [PATCH 22/28] Make sure the automatic index optimization is checked even if the covering index scan optimization was previously selected. FossilOrigin-Name: ac1d5d8a553d8ba76a332eed9d563ce7f04a7a37 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e83a8c7a14..a53f39987a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sQNX-specific\sperformance\stweaks\sto\sthe\sunix\sVFS.\s(Cherry-pick\smerge\sof\n[b02849e7bde458].) -D 2012-10-26T13:46:24.545 +C Make\ssure\sthe\sautomatic\sindex\soptimization\sis\schecked\seven\sif\sthe\s\ncovering\sindex\sscan\soptimization\swas\spreviously\sselected. +D 2012-10-26T18:40:01.620 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -249,7 +249,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b -F src/where.c 3e6c1f9efe4c6a029b0a750e0f6a63964f43bcce +F src/where.c bcd54574cffbfd17a1755d75c29759913f714ac4 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 0be144b453e0622a085fae8665c32f5676708e00 @@ -1021,7 +1021,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 6d42d806adb833572a324d4141ab3b2c315617b2 -R 9679b392e94d1e56bc54a4f85e939c7e +P 63a7dd75e61afb3d05a1434f66ad6a5f08352aad +R 85a59d09377232ed0e481748f0829aa6 U drh -Z d2173a314f2a3b1470d7441b9db15fea +Z 79ad95b1749193530040778d29c308fb diff --git a/manifest.uuid b/manifest.uuid index bff2f3a80b..94fb917d81 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -63a7dd75e61afb3d05a1434f66ad6a5f08352aad \ No newline at end of file +ac1d5d8a553d8ba76a332eed9d563ce7f04a7a37 \ No newline at end of file diff --git a/src/where.c b/src/where.c index b7663386ac..35e7759dee 100644 --- a/src/where.c +++ b/src/where.c @@ -1815,7 +1815,9 @@ static void bestAutomaticIndex(WhereBestIdx *p){ /* Automatic indices are disabled at run-time */ return; } - if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0 ){ + if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0 + && (p->cost.plan.wsFlags & WHERE_COVER_SCAN)==0 + ){ /* We already have some kind of index in use for this query. */ return; } From d4e97e8aad50078ba29b13951f37ec281904d2f6 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 26 Oct 2012 19:22:45 +0000 Subject: [PATCH 23/28] Fix a 32-bit integer overflow problem that could cause an error in a CREATE INDEX statement that writes more than 16GB of data. FossilOrigin-Name: e24ba5bee4424e99d0859ef652164ae1397a2378 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbesort.c | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index a53f39987a..6da9677186 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\sautomatic\sindex\soptimization\sis\schecked\seven\sif\sthe\s\ncovering\sindex\sscan\soptimization\swas\spreviously\sselected. -D 2012-10-26T18:40:01.620 +C Fix\sa\s32-bit\sinteger\soverflow\sproblem\sthat\scould\scause\san\serror\sin\sa\sCREATE\sINDEX\sstatement\sthat\swrites\smore\sthan\s16GB\sof\sdata. +D 2012-10-26T19:22:45.500 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -243,7 +243,7 @@ F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c F src/vdbeaux.c 8c8cfd30063e9b3664e2faa0e3785102bf131a10 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b +F src/vdbesort.c c61ca318681c0e7267da8be3abfca8469652a7e9 F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 @@ -1021,7 +1021,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 63a7dd75e61afb3d05a1434f66ad6a5f08352aad -R 85a59d09377232ed0e481748f0829aa6 -U drh -Z 79ad95b1749193530040778d29c308fb +P ac1d5d8a553d8ba76a332eed9d563ce7f04a7a37 +R 3459aaea2ca2a903a1c6e2fb4e6f5b42 +U dan +Z ba6f72d8caf0a404fc1f08cc5da9f7c5 diff --git a/manifest.uuid b/manifest.uuid index 94fb917d81..124132407c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac1d5d8a553d8ba76a332eed9d563ce7f04a7a37 \ No newline at end of file +e24ba5bee4424e99d0859ef652164ae1397a2378 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index ba1e9f0f23..d51bbf54a3 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -195,8 +195,11 @@ static int vdbeSorterIterRead( int rc; /* sqlite3OsRead() return code */ /* Determine how many bytes of data to read. */ - nRead = (int)(p->iEof - p->iReadOff); - if( nRead>p->nBuffer ) nRead = p->nBuffer; + if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){ + nRead = p->nBuffer; + }else{ + nRead = (int)(p->iEof - p->iReadOff); + } assert( nRead>0 ); /* Read data from the file. Return early if an error occurs. */ From 6e227bf3e0641c6eace29e5b198f82cf9344ed48 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 29 Oct 2012 14:27:26 +0000 Subject: [PATCH 24/28] Make the multiplexor and the IntArray extensions callable from C++. FossilOrigin-Name: cbd8fddf3b4cde840279502e1e9b151bb4bd42f0 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test_intarray.h | 11 +++++++++++ src/test_multiplex.h | 8 ++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 07c8e90ffe..9b374bdad5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sVSIX\stooling\sand\spackaging\senhancements\sto\strunk. -D 2012-10-28T19:35:55.072 +C Make\sthe\smultiplexor\sand\sthe\sIntArray\sextensions\scallable\sfrom\sC++. +D 2012-10-29T14:27:26.624 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -205,12 +205,12 @@ F src/test_fuzzer.c 1d26aa965120420bc14807da29d4d4541bfa6148 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 3cbad7ce525aec925f8fda2192d576d47f0d478a F src/test_intarray.c 07ddcebe4097d400ffca362770f1d883c112387a -F src/test_intarray.h 489edb9068bb926583445cb02589344961054207 +F src/test_intarray.h b999bb18d090b8d9d9c49d36ec37ef8f341fe169 F src/test_journal.c f5c0a05b7b3d5930db769b5ee6c3766dc2221a64 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_malloc.c 01cd65ae7ae93de9fbf8214d1ee6b4eba4850700 F src/test_multiplex.c ac0fbc1748e5b86a41a1d7a84654fae0d53a881d -F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d +F src/test_multiplex.h 9b63b95f07acedee425fdfe49a47197c9bf5f9d8 F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25 F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba @@ -1021,7 +1021,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P e24ba5bee4424e99d0859ef652164ae1397a2378 5023a7adcac2022a4a2009183d9d9e0f6b46952b -R 2f269b564c50576f53b5801166a85a63 -U mistachkin -Z 36e5e06b13ff5e0a8276b5cdb5553525 +P 99f27d642fbaba02264a470977cde38c3a526d13 +R 07bc3a42510a6d7b1ec8ddb3f50b6182 +U drh +Z 118483038e9bfcfd996fdf110e0050f4 diff --git a/manifest.uuid b/manifest.uuid index 11d958431a..4e0c750221 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99f27d642fbaba02264a470977cde38c3a526d13 \ No newline at end of file +cbd8fddf3b4cde840279502e1e9b151bb4bd42f0 \ No newline at end of file diff --git a/src/test_intarray.h b/src/test_intarray.h index e994367c09..691337d1ae 100644 --- a/src/test_intarray.h +++ b/src/test_intarray.h @@ -76,6 +76,13 @@ */ #include "sqlite3.h" +/* +** Make sure we can call this stuff from C++. +*/ +#ifdef __cplusplus +extern "C" { +#endif + /* ** An sqlite3_intarray is an abstract type to stores an instance of ** an integer array. @@ -112,3 +119,7 @@ int sqlite3_intarray_bind( sqlite3_int64 *aElements, /* Content of the intarray */ void (*xFree)(void*) /* How to dispose of the intarray when done */ ); + +#ifdef __cplusplus +} /* End of the 'extern "C"' block */ +#endif diff --git a/src/test_multiplex.h b/src/test_multiplex.h index ec1ba9bb21..b7e1afea5f 100644 --- a/src/test_multiplex.h +++ b/src/test_multiplex.h @@ -46,6 +46,10 @@ #define MULTIPLEX_CTRL_SET_CHUNK_SIZE 214015 #define MULTIPLEX_CTRL_SET_MAX_CHUNKS 214016 +#ifdef __cplusplus +extern "C" { +#endif + /* ** CAPI: Initialize the multiplex VFS shim - sqlite3_multiplex_initialize() ** @@ -88,4 +92,8 @@ extern int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefaul */ extern int sqlite3_multiplex_shutdown(void); +#ifdef __cplusplus +} /* End of the 'extern "C"' block */ +#endif + #endif From 21172c4cc01c6b1fb34a1fa08e3ae8c6dfaae23a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 30 Oct 2012 00:29:07 +0000 Subject: [PATCH 25/28] Add an optimization that attempts to run a subquery as a coroutine rather than manifesting it into a temporary table. FossilOrigin-Name: 7af3acbbd49a2114fcdada9ec907c68ba9b053bd --- manifest | 35 +++++++++++++++++++---------------- manifest.uuid | 2 +- src/delete.c | 1 + src/expr.c | 1 + src/select.c | 38 +++++++++++++++++++++++++++++++++++++- src/sqliteInt.h | 22 ++++++++++++---------- src/vdbe.c | 18 ++++++++++++++---- src/vdbeInt.h | 1 + src/where.c | 12 +++++++++++- test/minmax.test | 2 +- test/minmax2.test | 2 +- test/tkt-31338dca7e.test | 2 +- test/tkt3527.test | 8 ++++---- 13 files changed, 104 insertions(+), 40 deletions(-) diff --git a/manifest b/manifest index 9b374bdad5..1a2cb41f48 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\smultiplexor\sand\sthe\sIntArray\sextensions\scallable\sfrom\sC++. -D 2012-10-29T14:27:26.624 +C Add\san\soptimization\sthat\sattempts\sto\srun\sa\ssubquery\sas\sa\scoroutine\srather\nthan\smanifesting\sit\sinto\sa\stemporary\stable. +D 2012-10-30T00:29:07.224 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -129,8 +129,8 @@ F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 -F src/delete.c e35684ad93c741266b086610d2efd709b7946853 -F src/expr.c 57fb8e7a05d4147e40b9f4c439e37ed2abab9332 +F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d +F src/expr.c 152ba793a8747061c0c332857d0e4d4fd52d4397 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c c82a04e7a92bb728f9ab972b76590403283be2af F src/func.c cbb90dc84b22eea25caf39528d342279e61b8898 @@ -174,12 +174,12 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 9b759521f805e25e97baa2dd64037157fe365817 +F src/select.c d441b50c389dc0ffc50f0b6f469ff5117196dc86 F src/shell.c 24cd0aa74aff73ea08594629faead564c4c2a286 F src/sqlite.h.in c7be05ad191d2634292fcc77bdb2bcfa4526eb98 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h b49674b1c92173e9796c94fd6f15c1679e3b10cc +F src/sqliteInt.h c1927e2b0d596480445bcf3b7d679aae1069a8e0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 53463144deb5dfac0a66b3be4dd7844b8f8a4c98 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -236,9 +236,9 @@ F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 -F src/vdbe.c 31523df2b986fc6c959dd54ca640ba865884641b +F src/vdbe.c f3310ec731dc43e58bbf871da0054a297ecada4b F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d -F src/vdbeInt.h 573a43ab5697b648a1e8f3dfc7d8667d5ca55729 +F src/vdbeInt.h 79abf9b31be406d35ca77d6999cb2d42aaf91e78 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c F src/vdbeaux.c 8c8cfd30063e9b3664e2faa0e3785102bf131a10 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb @@ -249,7 +249,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b -F src/where.c bcd54574cffbfd17a1755d75c29759913f714ac4 +F src/where.c 73eb4c41f3e745bbaa7ecc49d3aa2688e4f298ba F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 0be144b453e0622a085fae8665c32f5676708e00 @@ -611,8 +611,8 @@ F test/memdb.test 708a028d6d373e5b3842e4bdc8ba80998c9a4da6 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 F test/memsubsys1.test a8f9e37567453a5d1d9d37ec102d4d88ab6be33f F test/memsubsys2.test 3a1c1a9de48e5726faa85108b02459fae8cb9ee9 -F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d -F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0 +F test/minmax.test c61518429e66e228efc79661fbd2dc3e4924ec44 +F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 536a3360470633a177e42fbc19660d146b51daef F test/misc1.test 889b40722442380a2f6575f30831b32b2372d70e @@ -760,7 +760,7 @@ F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 F test/tkt-2a5629202f.test 1ab32e084e9fc3d36be6dee2617530846a0eb0b6 F test/tkt-2d1a5c67d.test b028a811049eb472cb2d3a43fc8ce4f6894eebda F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28 -F test/tkt-31338dca7e.test 1f714c14b6682c5db715e0bda347926a3456f7a9 +F test/tkt-31338dca7e.test 6fb8807851964da0d24e942f2e19c7c705b9fb58 F test/tkt-313723c356.test c47f8a9330523e6f35698bf4489bcb29609b53ac F test/tkt-385a5b56b9.test 7782a382912a51f09f1d1a1442bca1e75f9c549b F test/tkt-38cb5df375.test f3cc8671f1eb604d4ae9cf886ed4366bec656678 @@ -851,7 +851,7 @@ F test/tkt3461.test 228ea328a5a21e8663f80ee3d212a6ad92549a19 F test/tkt3493.test 1686cbde85f8721fc1bdc0ee72f2ef2f63139218 F test/tkt3508.test d75704db9501625c7f7deec119fcaf1696aefb7d F test/tkt3522.test 22ce2ebbcb04a6be56c0977d405c207967318fd6 -F test/tkt3527.test 9e8f28a706c772d5a7cd1020c946fab6c74e3ae0 +F test/tkt3527.test 1a6a48441b560bdc53aec581a868eb576234874d F test/tkt3541.test 5dc257bde9bc833ab9cc6844bf170b998dbb950a F test/tkt3554.test f599967f279077bace39220cbe76085c7b423725 F test/tkt3581.test 1966b7193f1e3f14951cce8c66907ae69454e9a3 @@ -1021,7 +1021,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 99f27d642fbaba02264a470977cde38c3a526d13 -R 07bc3a42510a6d7b1ec8ddb3f50b6182 +P cbd8fddf3b4cde840279502e1e9b151bb4bd42f0 +R e804ca235c11687c1af8c5ce37532c75 +T *branch * subquery-as-coroutine +T *sym-subquery-as-coroutine * +T -sym-trunk * U drh -Z 118483038e9bfcfd996fdf110e0050f4 +Z e25ab88b15575239ebd4117d30628530 diff --git a/manifest.uuid b/manifest.uuid index 4e0c750221..ab0810df47 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbd8fddf3b4cde840279502e1e9b151bb4bd42f0 \ No newline at end of file +7af3acbbd49a2114fcdada9ec907c68ba9b053bd \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index c83ea98970..01a130d65b 100644 --- a/src/delete.c +++ b/src/delete.c @@ -112,6 +112,7 @@ void sqlite3MaterializeView( sqlite3SelectDelete(db, pDup); } pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0); + if( pDup ) pDup->selFlags |= SF_Materialize; } sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); sqlite3Select(pParse, pDup, &dest); diff --git a/src/expr.c b/src/expr.c index 04216b1711..3eee3c6d69 100644 --- a/src/expr.c +++ b/src/expr.c @@ -939,6 +939,7 @@ SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ pNewItem->addrFillSub = pOldItem->addrFillSub; pNewItem->regReturn = pOldItem->regReturn; pNewItem->isCorrelated = pOldItem->isCorrelated; + pNewItem->viaCoroutine = pOldItem->viaCoroutine; pNewItem->zIndex = sqlite3DbStrDup(db, pOldItem->zIndex); pNewItem->notIndexed = pOldItem->notIndexed; pNewItem->pIndex = pOldItem->pIndex; diff --git a/src/select.c b/src/select.c index ea85d1d71d..abcbb5ba1c 100644 --- a/src/select.c +++ b/src/select.c @@ -3909,8 +3909,17 @@ int sqlite3Select( int isAggSub; if( pSub==0 ) continue; + + /* Sometimes the code for a subquery will be generated more than + ** once, if the subquery is part of the WHERE clause in a LEFT JOIN, + ** for example. In that case, do not regenerate the code to manifest + ** a view or the co-routine to implement a view. The first instance + ** is sufficient, though the subroutine to manifest the view does need + ** to be invoked again. */ if( pItem->addrFillSub ){ - sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub); + if( pItem->viaCoroutine==0 ){ + sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub); + } continue; } @@ -3931,6 +3940,33 @@ int sqlite3Select( p->selFlags |= SF_Aggregate; } i = -1; + }else if( pTabList->nSrc==1 && (p->selFlags & SF_Materialize)==0 ){ + /* Implement a co-routine that will return a single row of the result + ** set on each invocation. + */ + int addrTop; + int addrEof; + pItem->regReturn = ++pParse->nMem; + addrEof = ++pParse->nMem; + sqlite3VdbeAddOp0(v, OP_Goto); + addrTop = sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor); + sqlite3VdbeChangeP5(v, 1); + VdbeComment((v, "coroutine for %s", pItem->pTab->zName)); + pItem->addrFillSub = addrTop; + sqlite3VdbeAddOp2(v, OP_Integer, 0, addrEof); + sqlite3VdbeChangeP5(v, 1); + sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn); + explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); + sqlite3Select(pParse, pSub, &dest); + pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow; + pItem->viaCoroutine = 1; + sqlite3VdbeChangeP2(v, addrTop, dest.iSdst); + sqlite3VdbeChangeP3(v, addrTop, dest.nSdst); + sqlite3VdbeAddOp2(v, OP_Integer, 1, addrEof); + sqlite3VdbeAddOp1(v, OP_Yield, pItem->regReturn); + VdbeComment((v, "end %s", pItem->pTab->zName)); + sqlite3VdbeJumpHere(v, addrTop-1); + sqlite3ClearTempRegCache(pParse); }else{ /* Generate a subroutine that will fill an ephemeral table with ** the content of this subquery. pItem->addrFillSub will point diff --git a/src/sqliteInt.h b/src/sqliteInt.h index dbefb4c585..20b2e71660 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1878,8 +1878,9 @@ struct SrcList { int addrFillSub; /* Address of subroutine to manifest a subquery */ int regReturn; /* Register holding return address of addrFillSub */ u8 jointype; /* Type of join between this able and the previous */ - u8 notIndexed; /* True if there is a NOT INDEXED clause */ - u8 isCorrelated; /* True if sub-query is correlated */ + unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ + unsigned isCorrelated :1; /* True if sub-query is correlated */ + unsigned viaCoroutine :1; /* Implemented as a co-routine */ #ifndef SQLITE_OMIT_EXPLAIN u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ #endif @@ -2103,14 +2104,15 @@ struct Select { ** Allowed values for Select.selFlags. The "SF" prefix stands for ** "Select Flag". */ -#define SF_Distinct 0x01 /* Output should be DISTINCT */ -#define SF_Resolved 0x02 /* Identifiers have been resolved */ -#define SF_Aggregate 0x04 /* Contains aggregate functions */ -#define SF_UsesEphemeral 0x08 /* Uses the OpenEphemeral opcode */ -#define SF_Expanded 0x10 /* sqlite3SelectExpand() called on this */ -#define SF_HasTypeInfo 0x20 /* FROM subqueries have Table metadata */ -#define SF_UseSorter 0x40 /* Sort using a sorter */ -#define SF_Values 0x80 /* Synthesized from VALUES clause */ +#define SF_Distinct 0x0001 /* Output should be DISTINCT */ +#define SF_Resolved 0x0002 /* Identifiers have been resolved */ +#define SF_Aggregate 0x0004 /* Contains aggregate functions */ +#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ +#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ +#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ +#define SF_UseSorter 0x0040 /* Sort using a sorter */ +#define SF_Values 0x0080 /* Synthesized from VALUES clause */ +#define SF_Materialize 0x0100 /* Force materialization of views */ /* diff --git a/src/vdbe.c b/src/vdbe.c index c8066d63c0..d52c0f4696 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2207,7 +2207,10 @@ case OP_Column: { ** the number of columns is stored in the VdbeCursor.nField element. */ pC = p->apCsr[p1]; - assert( pC!=0 ); + if( pC==0 ){ + sqlite3VdbeMemSetNull(pDest); + goto op_column_out; + } #ifndef SQLITE_OMIT_VIRTUALTABLE assert( pC->pVtabCursor==0 ); #endif @@ -2237,6 +2240,11 @@ case OP_Column: { } }else if( ALWAYS(pC->pseudoTableReg>0) ){ pReg = &aMem[pC->pseudoTableReg]; + if( pC->multiPseudo ){ + sqlite3VdbeMemShallowCopy(pDest, pReg+p2, MEM_Ephem); + Deephemeralize(pDest); + goto op_column_out; + } assert( pReg->flags & MEM_Blob ); assert( memIsValid(pReg) ); payloadSize = pReg->n; @@ -3322,8 +3330,9 @@ case OP_SorterOpen: { ** ** Open a new cursor that points to a fake table that contains a single ** row of data. The content of that one row in the content of memory -** register P2. In other words, cursor P1 becomes an alias for the -** MEM_Blob content contained in register P2. +** register P2 when P5==0. In other words, cursor P1 becomes an alias for the +** MEM_Blob content contained in register P2. When P5==1, then the +** row is represented by P3 consecutive registers beginning with P2. ** ** A pseudo-table created by this opcode is used to hold a single ** row output from the sorter so that the row can be decomposed into @@ -3343,6 +3352,7 @@ case OP_OpenPseudo: { pCx->pseudoTableReg = pOp->p2; pCx->isTable = 1; pCx->isIndex = 0; + pCx->multiPseudo = pOp->p5; break; } @@ -4307,7 +4317,7 @@ case OP_Rowid: { /* out2-prerelease */ assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); - assert( pC->pseudoTableReg==0 ); + assert( pC->pseudoTableReg==0 || pC->nullRow ); if( pC->nullRow ){ pOut->flags = MEM_Null; break; diff --git a/src/vdbeInt.h b/src/vdbeInt.h index aecada6038..fac0b2f6ed 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -63,6 +63,7 @@ struct VdbeCursor { Bool isIndex; /* True if an index containing keys only - no data */ Bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ Bool isSorter; /* True if a new-style sorter */ + Bool multiPseudo; /* Multi-register pseudo-cursor */ sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */ const sqlite3_module *pModule; /* Module for cursor pVtabCursor */ i64 seqCount; /* Sequence counter */ diff --git a/src/where.c b/src/where.c index 35e7759dee..9dfc8dc178 100644 --- a/src/where.c +++ b/src/where.c @@ -2998,7 +2998,7 @@ static int isSortingIndex( ** SQLITE_BIG_DBL. If a plan is found that uses the named index, ** then the cost is calculated in the usual way. ** -** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table +** If a NOT INDEXED clause was attached to the table ** in the SELECT statement, then no indexes are considered. However, the ** selected plan may still take advantage of the built-in rowid primary key ** index. @@ -4026,6 +4026,16 @@ static Bitmask codeOneLoopStart( VdbeComment((v, "init LEFT JOIN no-match flag")); } + /* Special case of a FROM clause subquery implemented as a co-routine */ + if( pTabItem->viaCoroutine ){ + int regYield = pTabItem->regReturn; + sqlite3VdbeAddOp2(v, OP_Integer, pTabItem->addrFillSub-1, regYield); + pLevel->p2 = sqlite3VdbeAddOp1(v, OP_Yield, regYield); + VdbeComment((v, "next row of co-routine %s", pTabItem->pTab->zName)); + sqlite3VdbeAddOp2(v, OP_If, regYield+1, addrBrk); + pLevel->op = OP_Goto; + }else + #ifndef SQLITE_OMIT_VIRTUALTABLE if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){ /* Case 0: The table is a virtual-table. Use the VFilter and VNext diff --git a/test/minmax.test b/test/minmax.test index 599024508c..3621375ee7 100644 --- a/test/minmax.test +++ b/test/minmax.test @@ -299,7 +299,7 @@ ifcapable {compound && subquery} { SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5 ) } - } {1} + } {{}} do_test minmax-9.2 { execsql { SELECT max(rowid) FROM ( diff --git a/test/minmax2.test b/test/minmax2.test index 2f504d4999..da8fec30ce 100644 --- a/test/minmax2.test +++ b/test/minmax2.test @@ -289,7 +289,7 @@ ifcapable {compound && subquery} { SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5 ) } - } {1} + } {{}} do_test minmax2-9.2 { execsql { SELECT max(rowid) FROM ( diff --git a/test/tkt-31338dca7e.test b/test/tkt-31338dca7e.test index 9423c684e9..41dd9d3bf8 100644 --- a/test/tkt-31338dca7e.test +++ b/test/tkt-31338dca7e.test @@ -91,7 +91,7 @@ do_test tkt-31338-3.1 { INSERT INTO t3 VALUES(4); CREATE TABLE t4(h); INSERT INTO t4 VALUES(5); - + SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h WHERE (a=1 AND h=4) OR (b IN ( diff --git a/test/tkt3527.test b/test/tkt3527.test index d9b1dadfdc..da3d05ac46 100644 --- a/test/tkt3527.test +++ b/test/tkt3527.test @@ -52,8 +52,8 @@ do_test tkt3527-1.1 { INSERT INTO Element VALUES(5,'Elem5'); INSERT INTO ElemOr Values(3,4); INSERT INTO ElemOr Values(3,5); - INSERT INTO ElemAnd VALUES(1,3,1,1,1); - INSERT INTO ElemAnd VALUES(1,2,1,1,1); + INSERT INTO ElemAnd VALUES(1,3,'a','b','c'); + INSERT INTO ElemAnd VALUES(1,2,'x','y','z'); CREATE VIEW ElemView1 AS SELECT @@ -112,12 +112,12 @@ do_test tkt3527-1.1 { SELECT * FROM ElemView1; } -} {1 1 Elem1 2 1 1 1 0 0 1 1 Elem1 3 1 1 1 0 0 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1} +} {1 1 Elem1 2 x y z 0 0 1 1 Elem1 3 a b c 0 0 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1} do_test tkt3527-1.2 { db eval { SELECT * FROM ElemView2; } -} {1 1 Elem1 2 1 1 1 0 0 1 1 Elem1 3 1 1 1 0 0 1.3 3 Elem3 4 {} {} {} 1 1 1.3 3 Elem3 5 {} {} {} 1 1 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1} +} {1 1 Elem1 2 x y z 0 0 1 1 Elem1 3 a b c 0 0 1.3 3 Elem3 4 {} {} {} 1 1 1.3 3 Elem3 5 {} {} {} 1 1 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1} finish_test From a5759677934302a7eb99e2713855258b88f0a66d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 30 Oct 2012 14:39:12 +0000 Subject: [PATCH 26/28] Make it possible to disable the subquery-by-coroutine optimization using sqlite3_test_control(). Remove an always-false conditional. FossilOrigin-Name: 564631f3e45f8f8a8db69f1e0df0d1dadbad8a2c --- manifest | 21 +++++++++------------ manifest.uuid | 2 +- src/main.c | 2 +- src/select.c | 4 +++- src/sqliteInt.h | 5 +++-- src/vdbe.c | 5 +---- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 1a2cb41f48..08634c4656 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\soptimization\sthat\sattempts\sto\srun\sa\ssubquery\sas\sa\scoroutine\srather\nthan\smanifesting\sit\sinto\sa\stemporary\stable. -D 2012-10-30T00:29:07.224 +C Make\sit\spossible\sto\sdisable\sthe\ssubquery-by-coroutine\soptimization\susing\nsqlite3_test_control().\s\sRemove\san\salways-false\sconditional. +D 2012-10-30T14:39:12.994 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c ca6784455f3207524b82d24141676d641d44f137 +F src/main.c 5249486037f88e765cce7c4870846dc5a2cd2ed1 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa @@ -174,12 +174,12 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c d441b50c389dc0ffc50f0b6f469ff5117196dc86 +F src/select.c 3a8baf4719f9723b4e0b43f2baa60692d0d921f8 F src/shell.c 24cd0aa74aff73ea08594629faead564c4c2a286 F src/sqlite.h.in c7be05ad191d2634292fcc77bdb2bcfa4526eb98 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h c1927e2b0d596480445bcf3b7d679aae1069a8e0 +F src/sqliteInt.h f29ed6fbbf80a6d9ac8aae9998ecae2b8d72e0ae F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 53463144deb5dfac0a66b3be4dd7844b8f8a4c98 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -236,7 +236,7 @@ F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 -F src/vdbe.c f3310ec731dc43e58bbf871da0054a297ecada4b +F src/vdbe.c fbb695e32d00dfb35f6a34947b88ea3ef9f10430 F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d F src/vdbeInt.h 79abf9b31be406d35ca77d6999cb2d42aaf91e78 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c @@ -1021,10 +1021,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P cbd8fddf3b4cde840279502e1e9b151bb4bd42f0 -R e804ca235c11687c1af8c5ce37532c75 -T *branch * subquery-as-coroutine -T *sym-subquery-as-coroutine * -T -sym-trunk * +P 7af3acbbd49a2114fcdada9ec907c68ba9b053bd +R 76b1d0ca402c9a816ba12f1054e42e79 U drh -Z e25ab88b15575239ebd4117d30628530 +Z 70485ac41c9ad9e9086d4cf7e24e57e2 diff --git a/manifest.uuid b/manifest.uuid index ab0810df47..1e5a4a046a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7af3acbbd49a2114fcdada9ec907c68ba9b053bd \ No newline at end of file +564631f3e45f8f8a8db69f1e0df0d1dadbad8a2c \ No newline at end of file diff --git a/src/main.c b/src/main.c index 8f3d25dd22..b2826c0c7b 100644 --- a/src/main.c +++ b/src/main.c @@ -3019,7 +3019,7 @@ int sqlite3_test_control(int op, ...){ */ case SQLITE_TESTCTRL_OPTIMIZATIONS: { sqlite3 *db = va_arg(ap, sqlite3*); - db->dbOptFlags = (u8)(va_arg(ap, int) & 0xff); + db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff); break; } diff --git a/src/select.c b/src/select.c index abcbb5ba1c..cba766f99d 100644 --- a/src/select.c +++ b/src/select.c @@ -3940,7 +3940,9 @@ int sqlite3Select( p->selFlags |= SF_Aggregate; } i = -1; - }else if( pTabList->nSrc==1 && (p->selFlags & SF_Materialize)==0 ){ + }else if( pTabList->nSrc==1 && (p->selFlags & SF_Materialize)==0 + && OptimizationEnabled(db, SQLITE_SubqCoroutine) + ){ /* Implement a co-routine that will return a single row of the result ** set on each invocation. */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 20b2e71660..e44ce7b7e8 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -827,7 +827,7 @@ struct sqlite3 { unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ int errCode; /* Most recent error code (SQLITE_*) */ int errMask; /* & result codes with this before returning */ - u8 dbOptFlags; /* Flags to enable/disable optimizations */ + u16 dbOptFlags; /* Flags to enable/disable optimizations */ u8 autoCommit; /* The auto-commit flag. */ u8 temp_store; /* 1: file 2: memory 0: default */ u8 mallocFailed; /* True if we have seen a malloc failure */ @@ -972,7 +972,8 @@ struct sqlite3 { #define SQLITE_DistinctOpt 0x0020 /* DISTINCT using indexes */ #define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */ #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */ -#define SQLITE_AllOpts 0x00ff /* All optimizations */ +#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */ +#define SQLITE_AllOpts 0xffff /* All optimizations */ /* ** Macros for testing whether or not optimizations are enabled or disabled. diff --git a/src/vdbe.c b/src/vdbe.c index d52c0f4696..fee287711c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2207,10 +2207,7 @@ case OP_Column: { ** the number of columns is stored in the VdbeCursor.nField element. */ pC = p->apCsr[p1]; - if( pC==0 ){ - sqlite3VdbeMemSetNull(pDest); - goto op_column_out; - } + assert( pC!=0 ); #ifndef SQLITE_OMIT_VIRTUALTABLE assert( pC->pVtabCursor==0 ); #endif From 980db4b67cb93a17ef9864d32b3e14523730762c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 30 Oct 2012 14:44:14 +0000 Subject: [PATCH 27/28] Fix a typo in the header comment for the OpenPseudo opcode. FossilOrigin-Name: 4f1061230e0e5a66038a4db99f1ee6203e4d2b9f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 08634c4656..81f366ccb7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sit\spossible\sto\sdisable\sthe\ssubquery-by-coroutine\soptimization\susing\nsqlite3_test_control().\s\sRemove\san\salways-false\sconditional. -D 2012-10-30T14:39:12.994 +C Fix\sa\stypo\sin\sthe\sheader\scomment\sfor\sthe\sOpenPseudo\sopcode. +D 2012-10-30T14:44:14.439 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -236,7 +236,7 @@ F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 -F src/vdbe.c fbb695e32d00dfb35f6a34947b88ea3ef9f10430 +F src/vdbe.c e1b2f881f85598b8e5d3366a3cdba60526d40144 F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d F src/vdbeInt.h 79abf9b31be406d35ca77d6999cb2d42aaf91e78 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c @@ -1021,7 +1021,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 7af3acbbd49a2114fcdada9ec907c68ba9b053bd -R 76b1d0ca402c9a816ba12f1054e42e79 +P 564631f3e45f8f8a8db69f1e0df0d1dadbad8a2c +R 918a33fddb4e577c100ae5ae2579f54e U drh -Z 70485ac41c9ad9e9086d4cf7e24e57e2 +Z b3c2f4b19e56c38b641de4231414b78d diff --git a/manifest.uuid b/manifest.uuid index 1e5a4a046a..530655516a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -564631f3e45f8f8a8db69f1e0df0d1dadbad8a2c \ No newline at end of file +4f1061230e0e5a66038a4db99f1ee6203e4d2b9f \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index fee287711c..df11b71ea4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3323,7 +3323,7 @@ case OP_SorterOpen: { break; } -/* Opcode: OpenPseudo P1 P2 P3 * * +/* Opcode: OpenPseudo P1 P2 P3 * P5 ** ** Open a new cursor that points to a fake table that contains a single ** row of data. The content of that one row in the content of memory From da998c8ec01fd838faf413c7c9177361b0e16136 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 30 Oct 2012 15:31:31 +0000 Subject: [PATCH 28/28] Make sure that the optimizer never tries to create an automatic index on a coroutine subquery. FossilOrigin-Name: f83aa0de8470748b3cd0bff232aeea3baf8dae53 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 81f366ccb7..07ba08517f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sthe\sheader\scomment\sfor\sthe\sOpenPseudo\sopcode. -D 2012-10-30T14:44:14.439 +C Make\ssure\sthat\sthe\soptimizer\snever\stries\sto\screate\san\sautomatic\nindex\son\sa\scoroutine\ssubquery. +D 2012-10-30T15:31:31.124 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -249,7 +249,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b -F src/where.c 73eb4c41f3e745bbaa7ecc49d3aa2688e4f298ba +F src/where.c 6a753aa008de6494e64dd265a27afbb0ad80ccf5 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 0be144b453e0622a085fae8665c32f5676708e00 @@ -1021,7 +1021,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 564631f3e45f8f8a8db69f1e0df0d1dadbad8a2c -R 918a33fddb4e577c100ae5ae2579f54e +P 4f1061230e0e5a66038a4db99f1ee6203e4d2b9f +R 4d92f802c3d1be35ade1de0afef59aa0 U drh -Z b3c2f4b19e56c38b641de4231414b78d +Z a71a8eb0758da05cfd0416f53ad3bce7 diff --git a/manifest.uuid b/manifest.uuid index 530655516a..923c49cce3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f1061230e0e5a66038a4db99f1ee6203e4d2b9f \ No newline at end of file +f83aa0de8470748b3cd0bff232aeea3baf8dae53 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 9dfc8dc178..38f6f1436f 100644 --- a/src/where.c +++ b/src/where.c @@ -1821,6 +1821,10 @@ static void bestAutomaticIndex(WhereBestIdx *p){ /* We already have some kind of index in use for this query. */ return; } + if( pSrc->viaCoroutine ){ + /* Cannot index a co-routine */ + return; + } if( pSrc->notIndexed ){ /* The NOT INDEXED clause appears in the SQL. */ return;