From c5c07079702e681e415a4361edbf31e1b9869db7 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 29 Nov 2012 14:26:11 +0000 Subject: [PATCH 01/43] Mark the "async" module as deprecated as its functionality has been superceded by WAL mode. This closes ticket [f46ca03b55ae0e] FossilOrigin-Name: 3d548db7eb14a4133afa6a94530f61fb3ef4a052 --- ext/async/README.txt | 8 +++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ext/async/README.txt b/ext/async/README.txt index 05acffe0df..14041e5025 100644 --- a/ext/async/README.txt +++ b/ext/async/README.txt @@ -1,3 +1,10 @@ +NOTE (2012-11-29): + +The functionality implemented by this extension has been superceded +by WAL-mode. This module is no longer supported or maintained. The +code is retained for historical reference only. + +------------------------------------------------------------------------------ Normally, when SQLite writes to a database file, it waits until the write operation is finished before returning control to the calling application. @@ -161,4 +168,3 @@ the database, eliminating the bottleneck. The functionality required of each of the above functions is described in comments in sqlite3async.c. - diff --git a/manifest b/manifest index 55cc2f4544..c64849463c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLLOG\scapability\sto\strunk. -D 2012-11-27T21:22:54.195 +C Mark\sthe\s"async"\smodule\sas\sdeprecated\sas\sits\sfunctionality\shas\sbeen\nsuperceded\sby\sWAL\smode.\s\sThis\scloses\sticket\s[f46ca03b55ae0e] +D 2012-11-29T14:26:11.774 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -22,7 +22,7 @@ F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 F doc/vfs-shm.txt e101f27ea02a8387ce46a05be2b1a902a021d37a F ext/README.txt 913a7bd3f4837ab14d7e063304181787658b14e1 -F ext/async/README.txt 0c541f418b14b415212264cbaaf51c924ec62e5b +F ext/async/README.txt 048f24b1b8f28eb31fb84aac28e70a6ce3de6973 F ext/async/sqlite3async.c 733a9f21b1066f44ff07b9c0da973b1e483d1e0c F ext/async/sqlite3async.h a21e1252deb14a2c211f0e165c4b9122a8f1f344 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e @@ -1025,7 +1025,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 92e9b5bc05887c47bc964828447a76ce29aa255c b3809c937b230b34e5bc6ce4909c04ceef72fb85 -R 7b1c6922767981286ed7cd5ff2185445 +P f0843f885ab3337f83fe3b304aab80bb7b5dd0a3 +R 1bc9994dc1983e832fe7d5970ec76e1b U drh -Z 56c73f084832549f0811a2beca2c3d86 +Z d2606d0f5b2b21bd75d458ededc57a06 diff --git a/manifest.uuid b/manifest.uuid index efda54efe5..fc0e10e5b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0843f885ab3337f83fe3b304aab80bb7b5dd0a3 \ No newline at end of file +3d548db7eb14a4133afa6a94530f61fb3ef4a052 \ No newline at end of file From 4d15a0d6d5b9ddacaa3bc10db1a46e1b5c91b648 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 1 Dec 2012 20:21:22 +0000 Subject: [PATCH 02/43] Do not exist the command-line shell if a ".read" command invokes a script that contains two errors. But reported on the mailing list. FossilOrigin-Name: 2e5e65152758bc37439584ccba4c1b1c5ceb24f8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c64849463c..691899f856 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Mark\sthe\s"async"\smodule\sas\sdeprecated\sas\sits\sfunctionality\shas\sbeen\nsuperceded\sby\sWAL\smode.\s\sThis\scloses\sticket\s[f46ca03b55ae0e] -D 2012-11-29T14:26:11.774 +C Do\snot\sexist\sthe\scommand-line\sshell\sif\sa\s".read"\scommand\sinvokes\sa\sscript\sthat\ncontains\stwo\serrors.\s\sBut\sreported\son\sthe\smailing\slist. +D 2012-12-01T20:21:22.105 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 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 3a8baf4719f9723b4e0b43f2baa60692d0d921f8 -F src/shell.c 24cd0aa74aff73ea08594629faead564c4c2a286 +F src/shell.c 99091f9dcf2bca1e1ff342f3361388b57f804135 F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 @@ -1025,7 +1025,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 f0843f885ab3337f83fe3b304aab80bb7b5dd0a3 -R 1bc9994dc1983e832fe7d5970ec76e1b +P 3d548db7eb14a4133afa6a94530f61fb3ef4a052 +R a8f759d368c1676ca502f98eec1f6be2 U drh -Z d2606d0f5b2b21bd75d458ededc57a06 +Z 02e70790acf1c68859534e04f6be9da6 diff --git a/manifest.uuid b/manifest.uuid index fc0e10e5b0..1b7b4f64a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d548db7eb14a4133afa6a94530f61fb3ef4a052 \ No newline at end of file +2e5e65152758bc37439584ccba4c1b1c5ceb24f8 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index adb8165434..0283c9e136 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2711,7 +2711,7 @@ static int process_input(struct callback_data *p, FILE *in){ free(zSql); } free(zLine); - return errCnt; + return errCnt>0; } /* From fc5e54664192cde9c89ee14905a91a9e12ec54ef Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 3 Dec 2012 17:04:40 +0000 Subject: [PATCH 03/43] Make sure that the optimization that set the maximum column that will be used on a particular query does not mistakenly change an opcode other than OP_OpenRead or OP_OpenWrite. In particular, make sure it does not overwrite the P4 field of an OP_SorterOpen. FossilOrigin-Name: b0c1ba655d69c0c46c16ea2aef4e6c9a3e6ce3fb --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbe.c | 2 +- src/vdbeaux.c | 1 + src/where.c | 2 ++ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 691899f856..ec3b113d34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sexist\sthe\scommand-line\sshell\sif\sa\s".read"\scommand\sinvokes\sa\sscript\sthat\ncontains\stwo\serrors.\s\sBut\sreported\son\sthe\smailing\slist. -D 2012-12-01T20:21:22.105 +C Make\ssure\sthat\sthe\soptimization\sthat\sset\sthe\smaximum\scolumn\sthat\swill\sbe\sused\non\sa\sparticular\squery\sdoes\snot\smistakenly\schange\san\sopcode\sother\sthan\nOP_OpenRead\sor\sOP_OpenWrite.\s\sIn\sparticular,\smake\ssure\sit\sdoes\snot\soverwrite\nthe\sP4\sfield\sof\san\sOP_SorterOpen. +D 2012-12-03T17:04:40.994 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -237,11 +237,11 @@ F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3 -F src/vdbe.c e1b2f881f85598b8e5d3366a3cdba60526d40144 +F src/vdbe.c 5b49cb1f852e4604a4fb6c47e087ddab28af193f F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d F src/vdbeInt.h 79abf9b31be406d35ca77d6999cb2d42aaf91e78 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c -F src/vdbeaux.c 552a878f5d9d3484ff6fd09acc3d566403f5db4b +F src/vdbeaux.c 2d1b3ee65860b1ea97ad9f20a02338b26caf2367 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c c61ca318681c0e7267da8be3abfca8469652a7e9 @@ -250,7 +250,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 832e33fefbe5ba751c1f5a06e63de98be95e56f2 +F src/where.c b5325975cbdd9b64f680fb88d7e727fc9368db68 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -1025,7 +1025,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 3d548db7eb14a4133afa6a94530f61fb3ef4a052 -R a8f759d368c1676ca502f98eec1f6be2 +P 2e5e65152758bc37439584ccba4c1b1c5ceb24f8 +R a8b889710169aeb4c03f1d5fd7d8d5f6 U drh -Z 02e70790acf1c68859534e04f6be9da6 +Z 49f89035377b6df810239244d05c5340 diff --git a/manifest.uuid b/manifest.uuid index 1b7b4f64a2..ad9fa804ec 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2e5e65152758bc37439584ccba4c1b1c5ceb24f8 \ No newline at end of file +b0c1ba655d69c0c46c16ea2aef4e6c9a3e6ce3fb \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index df11b71ea4..bbccac8a90 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3300,7 +3300,7 @@ case OP_OpenEphemeral: { break; } -/* Opcode: OpenSorter P1 P2 * P4 * +/* Opcode: SorterOpen P1 P2 * P4 * ** ** This opcode works like OP_OpenEphemeral except that it opens ** a transient index that is specifically designed to sort large diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 286c733592..f5bf3f3242 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -723,6 +723,7 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ addr = p->nOp - 1; } pOp = &p->aOp[addr]; + assert( pOp->p4type==P4_NOTUSED || pOp->p4type==P4_INT32 ); freeP4(db, pOp->p4type, pOp->p4.p); pOp->p4.p = 0; if( n==P4_INT32 ){ diff --git a/src/where.c b/src/where.c index 20bd90979e..196d8f5af7 100644 --- a/src/where.c +++ b/src/where.c @@ -5257,6 +5257,8 @@ WhereInfo *sqlite3WhereBegin( const char *pVTab = (const char *)sqlite3GetVTable(db, pTab); int iCur = pTabItem->iCursor; sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB); + }else if( IsVirtual(pTab) ){ + /* noop */ }else #endif if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 From 5f53aac2e7364bef102c4bbf43a9f9602a3573ca Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 3 Dec 2012 19:42:39 +0000 Subject: [PATCH 04/43] Remove an unreachable condition. Replace it with an assert(). FossilOrigin-Name: 7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ec3b113d34..60900d200c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthat\sthe\soptimization\sthat\sset\sthe\smaximum\scolumn\sthat\swill\sbe\sused\non\sa\sparticular\squery\sdoes\snot\smistakenly\schange\san\sopcode\sother\sthan\nOP_OpenRead\sor\sOP_OpenWrite.\s\sIn\sparticular,\smake\ssure\sit\sdoes\snot\soverwrite\nthe\sP4\sfield\sof\san\sOP_SorterOpen. -D 2012-12-03T17:04:40.994 +C Remove\san\sunreachable\scondition.\s\sReplace\sit\swith\san\sassert(). +D 2012-12-03T19:42:39.167 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -138,7 +138,7 @@ F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c ad0d8943d2a4f0b52ebf75b9e459f2da00117dbd +F src/insert.c d7ed04b1fab887d6d26cf5e36753f5d6d1246290 F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b @@ -1025,7 +1025,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 2e5e65152758bc37439584ccba4c1b1c5ceb24f8 -R a8b889710169aeb4c03f1d5fd7d8d5f6 +P b0c1ba655d69c0c46c16ea2aef4e6c9a3e6ce3fb +R b849c716d2b2c058f619a22bc4f40fe8 U drh -Z 49f89035377b6df810239244d05c5340 +Z 0f893cca86d4c59ca9756d8f8e113fff diff --git a/manifest.uuid b/manifest.uuid index ad9fa804ec..fd0b82143f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0c1ba655d69c0c46c16ea2aef4e6c9a3e6ce3fb \ No newline at end of file +7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 47a2b104ed..d7425d4fe8 100644 --- a/src/insert.c +++ b/src/insert.c @@ -25,7 +25,7 @@ void sqlite3OpenTable( int opcode /* OP_OpenRead or OP_OpenWrite */ ){ Vdbe *v; - if( IsVirtual(pTab) ) return; + assert( !IsVirtual(pTab) ); v = sqlite3GetVdbe(p); assert( opcode==OP_OpenWrite || opcode==OP_OpenRead ); sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName); From 585dcb251bf297566d57aa4894f124045dea31d4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 4 Dec 2012 00:23:43 +0000 Subject: [PATCH 05/43] Improvements to the 'tcl' shell output mode. Escape double quotes, set separator to space when mode is set, and skip separator after final column. FossilOrigin-Name: 41fd9dd29034b2269e4b7f2626350124d37b5303 --- manifest | 19 ++++++++++-------- manifest.uuid | 2 +- src/shell.c | 8 ++++++-- test/shell1.test | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 60900d200c..f459268d41 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\scondition.\s\sReplace\sit\swith\san\sassert(). -D 2012-12-03T19:42:39.167 +C Improvements\sto\sthe\s'tcl'\sshell\soutput\smode.\s\sEscape\sdouble\squotes,\sset\sseparator\sto\sspace\swhen\smode\sis\sset,\sand\sskip\sseparator\safter\sfinal\scolumn. +D 2012-12-04T00:23:43.067 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 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 3a8baf4719f9723b4e0b43f2baa60692d0d921f8 -F src/shell.c 99091f9dcf2bca1e1ff342f3361388b57f804135 +F src/shell.c e392dd1ccbb77cc1d75a8367a89b473c24bea019 F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 @@ -708,7 +708,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 340125225cc96c7f48d59a869aaf82866e481007 +F test/shell1.test b7896eb84028f3bc8300caf1fc796a73728aad0b F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59 F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 @@ -1025,7 +1025,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 b0c1ba655d69c0c46c16ea2aef4e6c9a3e6ce3fb -R b849c716d2b2c058f619a22bc4f40fe8 -U drh -Z 0f893cca86d4c59ca9756d8f8e113fff +P 7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 +R 38c0a4b163ba004b3c0d2e19a002293a +T *branch * tclMode +T *sym-tclMode * +T -sym-trunk * +U mistachkin +Z 962a729a6a99e4b42add9e81143f97fc diff --git a/manifest.uuid b/manifest.uuid index fd0b82143f..ce8ea06e1c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 \ No newline at end of file +41fd9dd29034b2269e4b7f2626350124d37b5303 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 0283c9e136..7dd741b2d7 100644 --- a/src/shell.c +++ b/src/shell.c @@ -541,6 +541,9 @@ static void output_c_string(FILE *out, const char *z){ if( c=='\\' ){ fputc(c, out); fputc(c, out); + }else if( c=='"' ){ + fputc('\\', out); + fputc('"', out); }else if( c=='\t' ){ fputc('\\', out); fputc('t', out); @@ -796,14 +799,14 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int if( p->cnt++==0 && p->showHeader ){ for(i=0; iout,azCol[i] ? azCol[i] : ""); - fprintf(p->out, "%s", p->separator); + if(iout, "%s", p->separator); } fprintf(p->out,"\n"); } if( azArg==0 ) break; for(i=0; iout, azArg[i] ? azArg[i] : p->nullvalue); - fprintf(p->out, "%s", p->separator); + if(iout, "%s", p->separator); } fprintf(p->out,"\n"); break; @@ -2018,6 +2021,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ p->mode = MODE_Html; }else if( n2==3 && strncmp(azArg[1],"tcl",n2)==0 ){ p->mode = MODE_Tcl; + sqlite3_snprintf(sizeof(p->separator), p->separator, " "); }else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){ p->mode = MODE_Csv; sqlite3_snprintf(sizeof(p->separator), p->separator, ","); diff --git a/test/shell1.test b/test/shell1.test index e826b95e44..50e6c7125c 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -719,13 +719,14 @@ do_test shell1-3-29.1 { do_test shell1-4.1 { db eval { CREATE TABLE t1(x); - INSERT INTO t1 VALUES(null), (1), (2.25), ('hello'), (x'807f'); + INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f'); } catchcmd test.db {.dump} } {0 {PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE t1(x); INSERT INTO "t1" VALUES(NULL); +INSERT INTO "t1" VALUES(''); INSERT INTO "t1" VALUES(1); INSERT INTO "t1" VALUES(2.25); INSERT INTO "t1" VALUES('hello'); @@ -737,10 +738,58 @@ COMMIT;}} do_test shell1-4.2 { catchcmd test.db ".mode insert t1\nselect * from t1;" } {0 {INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(''); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2.25); INSERT INTO t1 VALUES('hello'); INSERT INTO t1 VALUES(X'807f');}} +# Test the output of ".mode tcl" +# +do_test shell1-4.3 { + catchcmd test.db ".mode tcl\nselect * from t1;" +} {0 {"" +"" +"1" +"2.25" +"hello" +"\200\177"}} + +# Test the output of ".mode tcl" with multiple columns +# +do_test shell1-4.4 { + db eval { + CREATE TABLE t2(x,y); + INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f'); + } + catchcmd test.db ".mode tcl\nselect * from t2;" +} {0 {"" "" +"1" "2.25" +"hello" "\200\177"}} + +# Test the output of ".mode tcl" with ".nullvalue" +# +do_test shell1-4.5 { + catchcmd test.db ".mode tcl\n.nullvalue NULL\nselect * from t2;" +} {0 {"NULL" "" +"1" "2.25" +"hello" "\200\177"}} + +# Test the output of ".mode tcl" with Tcl reserved characters +# +do_test shell1-4.6 { + db eval { + CREATE TABLE tcl1(x); + INSERT INTO tcl1 VALUES('"'), ('['), (']'), ('\{'), ('\}'), (';'), ('$'); + } + foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break + list $x $y [llength $y] +} {0 {"\"" +"[" +"]" +"\\{" +"\\}" +";" +"$"} 7} finish_test From a359b5eea45790fb412dcab933223ceac8329d1f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 4 Dec 2012 00:37:58 +0000 Subject: [PATCH 06/43] Fix an out-of-order function declaration when compiled with MEMDEBUG. FossilOrigin-Name: 6d31557837fef2c8fad6f009ac6dd97dd4af0a54 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test_malloc.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 60900d200c..982371eb75 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\scondition.\s\sReplace\sit\swith\san\sassert(). -D 2012-12-03T19:42:39.167 +C Fix\san\sout-of-order\sfunction\sdeclaration\swhen\scompiled\swith\sMEMDEBUG. +D 2012-12-04T00:37:58.757 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -208,7 +208,7 @@ F src/test_intarray.c 07ddcebe4097d400ffca362770f1d883c112387a 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_malloc.c 6982a357a6a6c24f281b91c89303a5c31075c392 F src/test_multiplex.c ac0fbc1748e5b86a41a1d7a84654fae0d53a881d F src/test_multiplex.h 9b63b95f07acedee425fdfe49a47197c9bf5f9d8 F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e @@ -1025,7 +1025,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 b0c1ba655d69c0c46c16ea2aef4e6c9a3e6ce3fb -R b849c716d2b2c058f619a22bc4f40fe8 -U drh -Z 0f893cca86d4c59ca9756d8f8e113fff +P 7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 +R 51b08a3d6b6d9647118accff35071b4d +U mistachkin +Z e9663e5c6dfd0808fc144666962de0b7 diff --git a/manifest.uuid b/manifest.uuid index fd0b82143f..a5c0c5c571 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 \ No newline at end of file +6d31557837fef2c8fad6f009ac6dd97dd4af0a54 \ No newline at end of file diff --git a/src/test_malloc.c b/src/test_malloc.c index e1420de648..33de859d27 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -720,8 +720,8 @@ static int test_memdebug_settitle( #ifdef SQLITE_MEMDEBUG { const char *zTitle; - zTitle = Tcl_GetString(objv[1]); extern int sqlite3MemdebugSettitle(const char*); + zTitle = Tcl_GetString(objv[1]); sqlite3MemdebugSettitle(zTitle); } #endif From 7b6be6f7bf82cd947ace21ef2f1a1a94fa8e998f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 4 Dec 2012 00:53:08 +0000 Subject: [PATCH 07/43] Fix an uninitialized variable detected by valgrind. FossilOrigin-Name: ffd1e51490286abfaea68fd4b4b4cb967d87b04b --- ext/fts3/fts3_write.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 2cfdd2a66c..bda7fbbe1a 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -5253,7 +5253,7 @@ int sqlite3Fts3UpdateMethod( int rc = SQLITE_OK; /* Return Code */ int isRemove = 0; /* True for an UPDATE or DELETE */ u32 *aSzIns = 0; /* Sizes of inserted documents */ - u32 *aSzDel; /* Sizes of deleted documents */ + u32 *aSzDel = 0; /* Sizes of deleted documents */ int nChng = 0; /* Net change in number of documents */ int bInsertDone = 0; diff --git a/manifest b/manifest index 982371eb75..8535e45d66 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sout-of-order\sfunction\sdeclaration\swhen\scompiled\swith\sMEMDEBUG. -D 2012-12-04T00:37:58.757 +C Fix\san\suninitialized\svariable\sdetected\sby\svalgrind. +D 2012-12-04T00:53:08.237 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -72,7 +72,7 @@ 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 a432433a706bd065e8bb0f8b3b33ce7cf9d7f21d +F ext/fts3/fts3_write.c c2166f7148a4ad8bcdad99a99d647b1091744e6b F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/tool/fts3view.c 6cfc5b67a5f0e09c0d698f9fd012c784bfaa9197 @@ -1025,7 +1025,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 7d5fc1a339cf4f3597ab6a5f3e7101884d2d7673 -R 51b08a3d6b6d9647118accff35071b4d -U mistachkin -Z e9663e5c6dfd0808fc144666962de0b7 +P 6d31557837fef2c8fad6f009ac6dd97dd4af0a54 +R ffba2844807fcdd5e34e884677457f21 +U drh +Z f9efa9b0c08091e08c6d5b44e8bed86a diff --git a/manifest.uuid b/manifest.uuid index a5c0c5c571..31bc8f7818 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d31557837fef2c8fad6f009ac6dd97dd4af0a54 \ No newline at end of file +ffd1e51490286abfaea68fd4b4b4cb967d87b04b \ No newline at end of file From ec6b07b27b642b423999a7a7b01db99bb9fa0315 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 4 Dec 2012 05:24:21 +0000 Subject: [PATCH 08/43] Add a test to ensure that the fix in [b0c1ba655d] has worked. FossilOrigin-Name: 41806de5c88e924e306ca737192755c011517426 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/vtab1.test | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ad17a0fd1e..f3e2ecf3d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\s'tcl'\sshell\soutput\smode.\sEscape\sdoublequotes,\s\nset\sseparator\sto\sspace\swhen\smode\sis\sset,\sand\sskip\sseparator\safter\sfinal\s\ncolumn. -D 2012-12-04T00:59:05.343 +C Add\sa\stest\sto\sensure\sthat\sthe\sfix\sin\s[b0c1ba655d]\shas\sworked. +D 2012-12-04T05:24:21.277 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -918,7 +918,7 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 7701bb609fe8bf6535514e8b849a309e8f00573b F test/view.test b182a67ec43f490b156b5a710827a341be83dd17 -F test/vtab1.test 10fb9e656fe4b318cd82ff1616a340acc01aac4b +F test/vtab1.test 36c9935e4be3b6350b31b6b697561b6fc3ab349a F test/vtab2.test 7bcffc050da5c68f4f312e49e443063e2d391c0d F test/vtab3.test baad99fd27217f5d6db10660522e0b7192446de1 F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 @@ -1025,7 +1025,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 ffd1e51490286abfaea68fd4b4b4cb967d87b04b 41fd9dd29034b2269e4b7f2626350124d37b5303 -R 73681e387dffe475fd9637264683a4fd -U drh -Z 4616a9e41f5cc64f88cf72ef7a9185dc +P 487ba753139c256b911f16aee9586144faea846f +R 3d588766f0b20ddf6011174c0e1b67ff +U dan +Z 0f97fb82e8b32b135392c5a33d9875bf diff --git a/manifest.uuid b/manifest.uuid index ecd8057d8e..32490a52ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -487ba753139c256b911f16aee9586144faea846f \ No newline at end of file +41806de5c88e924e306ca737192755c011517426 \ No newline at end of file diff --git a/test/vtab1.test b/test/vtab1.test index 340994304c..95811d746e 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -1293,4 +1293,44 @@ do_test 19.3 { db2 close } {} +#------------------------------------------------------------------------- +# Test that the bug fixed by [b0c1ba655d69] really is fixed. +# +do_execsql_test 20.1 { + CREATE TABLE t7 (a, b); + CREATE TABLE t8 (c, d); + CREATE INDEX i2 ON t7(a); + CREATE INDEX i3 ON t7(b); + CREATE INDEX i4 ON t8(c); + CREATE INDEX i5 ON t8(d); + + CREATE VIRTUAL TABLE t7v USING echo(t7); + CREATE VIRTUAL TABLE t8v USING echo(t8); +} + +do_test 20.2 { + for {set i 0} {$i < 1000} {incr i} { + db eval {INSERT INTO t7 VALUES($i, $i)} + db eval {INSERT INTO t8 VALUES($i, $i)} + } +} {} + +do_execsql_test 20.3 { + SELECT a, b FROM ( + SELECT a, b FROM t7 WHERE a=11 OR b=12 + UNION ALL + SELECT c, d FROM t8 WHERE c=5 OR d=6 + ) + ORDER BY 1, 2; +} {5 5 6 6 11 11 12 12} + +do_execsql_test 20.4 { + SELECT a, b FROM ( + SELECT a, b FROM t7v WHERE a=11 OR b=12 + UNION ALL + SELECT c, d FROM t8v WHERE c=5 OR d=6 + ) + ORDER BY 1, 2; +} {5 5 6 6 11 11 12 12} + finish_test From 68c804b9ab01170679a9fc7f7887146443e9ce14 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 4 Dec 2012 11:03:11 +0000 Subject: [PATCH 09/43] Fix a harmless compiler warning. FossilOrigin-Name: 12693deba9b8a47ad02ca4e32d5fba6006b0401c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f3e2ecf3d8..da362bc349 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sto\sensure\sthat\sthe\sfix\sin\s[b0c1ba655d]\shas\sworked. -D 2012-12-04T05:24:21.277 +C Fix\sa\sharmless\scompiler\swarning. +D 2012-12-04T11:03:11.336 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d F src/expr.c 3b25a95f3d309403940ba4a3212f197b8b6251d5 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c c82a04e7a92bb728f9ab972b76590403283be2af -F src/func.c 1755cafdb8f2a291681f1ea55e0215518ebd6e52 +F src/func.c 8147799b048065a1590805be464d05b4913e652c F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -1025,7 +1025,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 487ba753139c256b911f16aee9586144faea846f -R 3d588766f0b20ddf6011174c0e1b67ff -U dan -Z 0f97fb82e8b32b135392c5a33d9875bf +P 41806de5c88e924e306ca737192755c011517426 +R d1dfe038d18ec2a0011faa499e6f0db7 +U drh +Z 4b51d21c427563be96796ad15017cf65 diff --git a/manifest.uuid b/manifest.uuid index 32490a52ef..b38dc16e51 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -41806de5c88e924e306ca737192755c011517426 \ No newline at end of file +12693deba9b8a47ad02ca4e32d5fba6006b0401c \ No newline at end of file diff --git a/src/func.c b/src/func.c index c7af7d679c..d4655ad7e9 100644 --- a/src/func.c +++ b/src/func.c @@ -192,6 +192,7 @@ static void instrFunc( int N = 1; int isText; + UNUSED_PARAMETER(argc); typeHaystack = sqlite3_value_type(argv[0]); typeNeedle = sqlite3_value_type(argv[1]); if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return; From 8411b25c595dd6e4116b0b206250c93bdc99158e Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Dec 2012 09:12:58 +0000 Subject: [PATCH 10/43] Update a couple of test scripts so that they work in auto-vacuum mode. FossilOrigin-Name: 04ab2dc6914e4d6fe2682eba08fc1cd1148a44a1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/backup4.test | 6 ++---- test/wal9.test | 13 +++++++++---- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index da362bc349..466300ab02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning. -D 2012-12-04T11:03:11.336 +C Update\sa\scouple\sof\stest\sscripts\sso\sthat\sthey\swork\sin\sauto-vacuum\smode. +D 2012-12-05T09:12:58.803 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -290,7 +290,7 @@ F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 F test/backcompat.test ecd841f3a3bfb81518721879cc56a760670e3198 F test/backup.test c9cdd23a495864b9edf75a9fa66f5cb7e10fcf62 F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf -F test/backup4.test 3c3639d28f3cdb4a123694a0a7c5fa7bfe304e2a +F test/backup4.test 4d90389daeb781fe718816a4fc836ad1b06791d8 F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0 F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450 F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f @@ -944,7 +944,7 @@ F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437 F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd F test/wal8.test b3ee739fe8f7586aaebdc2367f477ebcf3e3b034 -F test/wal9.test 48c40803faf6849515c81213697e9f3376835981 +F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750 F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877 F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434 @@ -1025,7 +1025,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 41806de5c88e924e306ca737192755c011517426 -R d1dfe038d18ec2a0011faa499e6f0db7 -U drh -Z 4b51d21c427563be96796ad15017cf65 +P 12693deba9b8a47ad02ca4e32d5fba6006b0401c +R c40e9ea83d74454bcc63d7bebd03fb54 +U dan +Z 803d14ed6f4f5e70c7f9aeded4a72924 diff --git a/manifest.uuid b/manifest.uuid index b38dc16e51..c0dc4ead0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -12693deba9b8a47ad02ca4e32d5fba6006b0401c \ No newline at end of file +04ab2dc6914e4d6fe2682eba08fc1cd1148a44a1 \ No newline at end of file diff --git a/test/backup4.test b/test/backup4.test index 629718a750..a1a7735528 100644 --- a/test/backup4.test +++ b/test/backup4.test @@ -63,8 +63,7 @@ do_execsql_test 2.1 { CREATE TABLE t1(a, b); CREATE INDEX i1 ON t1(a, b); } - -do_test 2.2 { file size test.db } 3072 +do_test 2.2 { file size test.db } [expr $AUTOVACUUM ? 4096 : 3072] do_test 2.3 { sqlite3 db1 test.db2 @@ -90,8 +89,7 @@ do_execsql_test 3.1 { CREATE TABLE t1(a, b); CREATE INDEX i1 ON t1(a, b); } - -do_test 3.2 { file size test.db } 12288 +do_test 3.2 { file size test.db } [expr $AUTOVACUUM ? 16384 : 12288] do_test 3.3 { sqlite3 db1 test.db2 diff --git a/test/wal9.test b/test/wal9.test index f483eb615c..ae2a52bb02 100644 --- a/test/wal9.test +++ b/test/wal9.test @@ -60,11 +60,16 @@ do_execsql_test 1.2 { # Check file sizes are as expected. The real requirement here is that # the *shm file is now more than one chunk (>32KiB). +# +# The sizes of various files are slightly different in normal and +# auto-vacuum mode. do_test 1.3 { file size test.db } {1024} -do_test 1.4 { file size test.db-wal } {15421352} -do_test 1.5 { expr {[file size test.db-shm]>32768} } {1} - -do_execsql_test 1.6 { PRAGMA wal_checkpoint } {0 14715 14715} +do_test 1.4 { expr {[file size test.db-wal]>(1500*1024)} } {1} +do_test 1.5 { expr {[file size test.db-shm]>32768} } {1} +do_test 1.6 { + foreach {a b c} [db eval {PRAGMA wal_checkpoint}] break + list [expr {$a==0}] [expr {$b>14500}] [expr {$c>14500}] [expr {$b==$c}] +} {1 1 1 1} # At this point connection [db2] has mapped the first 32KB of the *shm file # only. Because the entire WAL file has been checkpointed, it is not From 3de0f18476924deaee48891b41b45f3c9cc8dcfb Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Dec 2012 10:01:35 +0000 Subject: [PATCH 11/43] If the atomic-write property is enabled, a transaction may be committed in journal_mode=DELETE mode without ever actually creating a journal file on disk. In this case, do not attempt to unlink() the journal file when committing the transaction. FossilOrigin-Name: 11aa47b0a837858b644c304638e1cbbf482de2f0 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/journal.c | 10 ++++++++++ src/pager.c | 3 ++- src/sqliteInt.h | 2 ++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 466300ab02..1f2a41d127 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\scouple\sof\stest\sscripts\sso\sthat\sthey\swork\sin\sauto-vacuum\smode. -D 2012-12-05T09:12:58.803 +C If\sthe\satomic-write\sproperty\sis\senabled,\sa\stransaction\smay\sbe\scommitted\sin\sjournal_mode=DELETE\smode\swithout\sever\sactually\screating\sa\sjournal\sfile\son\sdisk.\sIn\sthis\scase,\sdo\snot\sattempt\sto\sunlink()\sthe\sjournal\sfile\swhen\scommitting\sthe\stransaction. +D 2012-12-05T10:01:35.014 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -139,7 +139,7 @@ F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c d7ed04b1fab887d6d26cf5e36753f5d6d1246290 -F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e +F src/journal.c eb7b9f5e783266521bcd9b2b93d419a219411f71 F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d @@ -162,7 +162,7 @@ F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c b75d9b0876ad3fde151843ad389b4c3dd727c662 F src/os_win.c 6e55b48f793d0c0d0e086d3f1482a0882530eeeb -F src/pager.c ed53fe75a269c1d67645fe079ea0f3f0ce6492d5 +F src/pager.c 521251dd7855cb4d917815f742dd679baf3f148e F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -179,7 +179,7 @@ F src/shell.c e392dd1ccbb77cc1d75a8367a89b473c24bea019 F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 68f23dcfc3fb6559c07b327ab6d8d2e63e4bb69e +F src/sqliteInt.h 72ab83e698a42d509a0d1cf16a66ec2dae51a756 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1025,7 +1025,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 12693deba9b8a47ad02ca4e32d5fba6006b0401c -R c40e9ea83d74454bcc63d7bebd03fb54 +P 04ab2dc6914e4d6fe2682eba08fc1cd1148a44a1 +R 8c3b33c5b9f09a2ab875a23939115f6f U dan -Z 803d14ed6f4f5e70c7f9aeded4a72924 +Z 626b4f7906fb9116d17f012a395a239f diff --git a/manifest.uuid b/manifest.uuid index c0dc4ead0e..77aefdee21 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -04ab2dc6914e4d6fe2682eba08fc1cd1148a44a1 \ No newline at end of file +11aa47b0a837858b644c304638e1cbbf482de2f0 \ No newline at end of file diff --git a/src/journal.c b/src/journal.c index 2f9e222089..06605cc956 100644 --- a/src/journal.c +++ b/src/journal.c @@ -228,6 +228,16 @@ int sqlite3JournalCreate(sqlite3_file *p){ return createFile((JournalFile *)p); } +/* +** The file-handle passed as the only argument is guaranteed to be an open +** file. It may or may not be of class JournalFile. If the file is a +** JournalFile, and the underlying file on disk has not yet been opened, +** return 0. Otherwise, return 1. +*/ +int sqlite3JournalExists(sqlite3_file *p){ + return (p->pMethods!=&JournalFileMethods || ((JournalFile *)p)->pReal!=0); +} + /* ** Return the number of bytes required to store a JournalFile that uses vfs ** pVfs to create the underlying on-disk files. diff --git a/src/pager.c b/src/pager.c index 7c039e7a76..354b5c27b5 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1941,12 +1941,13 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){ ** file should be closed and deleted. If this connection writes to ** the database file, it will do so using an in-memory journal. */ + int bDelete = (!pPager->tempFile && sqlite3JournalExists(pPager->jfd)); assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE || pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->journalMode==PAGER_JOURNALMODE_WAL ); sqlite3OsClose(pPager->jfd); - if( !pPager->tempFile ){ + if( bDelete ){ rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0); } } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 14dce8ed7c..72fa5fa950 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3253,8 +3253,10 @@ int sqlite3FindInIndex(Parse *, Expr *, int*); int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int); int sqlite3JournalSize(sqlite3_vfs *); int sqlite3JournalCreate(sqlite3_file *); + int sqlite3JournalExists(sqlite3_file *p); #else #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile) + #define sqlite3JournalExists(p) 1 #endif void sqlite3MemJournalOpen(sqlite3_file *); From 44c4fcb9d879a4fea37f794e28435bcf2d19083c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Dec 2012 11:30:28 +0000 Subject: [PATCH 12/43] Since errors are ignored anyway, use sqlite3OsFileControlHint() instead of OsFileControl() to invoke the SQLITE_FCNTL_BUSY_HANDLER file-control. FossilOrigin-Name: bdceca2738eb3e8acc44d0384cf2a3a969ee8170 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1f2a41d127..6011b633bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sthe\satomic-write\sproperty\sis\senabled,\sa\stransaction\smay\sbe\scommitted\sin\sjournal_mode=DELETE\smode\swithout\sever\sactually\screating\sa\sjournal\sfile\son\sdisk.\sIn\sthis\scase,\sdo\snot\sattempt\sto\sunlink()\sthe\sjournal\sfile\swhen\scommitting\sthe\stransaction. -D 2012-12-05T10:01:35.014 +C Since\serrors\sare\signored\sanyway,\suse\ssqlite3OsFileControlHint()\sinstead\sof\sOsFileControl()\sto\sinvoke\sthe\sSQLITE_FCNTL_BUSY_HANDLER\sfile-control. +D 2012-12-05T11:30:28.616 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 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 b75d9b0876ad3fde151843ad389b4c3dd727c662 F src/os_win.c 6e55b48f793d0c0d0e086d3f1482a0882530eeeb -F src/pager.c 521251dd7855cb4d917815f742dd679baf3f148e +F src/pager.c 4092c907222cfd451c74fe6bd2fd64b342f7190f F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 @@ -1025,7 +1025,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 04ab2dc6914e4d6fe2682eba08fc1cd1148a44a1 -R 8c3b33c5b9f09a2ab875a23939115f6f +P 11aa47b0a837858b644c304638e1cbbf482de2f0 +R 2c5b6d51e26c07bb7aa01494f26aa504 U dan -Z 626b4f7906fb9116d17f012a395a239f +Z 491f382600c3145f948c8c8459b2421a diff --git a/manifest.uuid b/manifest.uuid index 77aefdee21..2cd9b15b65 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11aa47b0a837858b644c304638e1cbbf482de2f0 \ No newline at end of file +bdceca2738eb3e8acc44d0384cf2a3a969ee8170 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 354b5c27b5..5879cf760a 100644 --- a/src/pager.c +++ b/src/pager.c @@ -3486,7 +3486,7 @@ void sqlite3PagerSetBusyhandler( void **ap = (void **)&pPager->xBusyHandler; assert( ((int(*)(void *))(ap[0]))==xBusyHandler ); assert( ap[1]==pBusyHandlerArg ); - sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap); + sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap); } } From 7f5febc7290dcd5080073590c5f15857768ac336 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 5 Dec 2012 14:31:13 +0000 Subject: [PATCH 13/43] Make sure memory is freed using a routine that is compatible with the routine used to allocate the memory. The SQLITE_MEMDEBUG compile-time option enforces this. FossilOrigin-Name: 9f6c68856b694373b7ffb124abd996e519ba5921 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/attach.c | 2 +- src/vdbeaux.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 6011b633bf..cba51a4ca4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Since\serrors\sare\signored\sanyway,\suse\ssqlite3OsFileControlHint()\sinstead\sof\sOsFileControl()\sto\sinvoke\sthe\sSQLITE_FCNTL_BUSY_HANDLER\sfile-control. -D 2012-12-05T11:30:28.616 +C Make\ssure\smemory\sis\sfreed\susing\sa\sroutine\sthat\sis\scompatible\swith\sthe\nroutine\sused\sto\sallocate\sthe\smemory.\s\sThe\sSQLITE_MEMDEBUG\scompile-time\noption\senforces\sthis. +D 2012-12-05T14:31:13.890 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -116,7 +116,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168 F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410 -F src/attach.c 34c15ecd686e58f08e5bb1389e28a0b65c2c83db +F src/attach.c ea5247f240e2c08afd608e9beb380814b86655e1 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c cab40f2c1fe79d6eb93d3b4086c78c41ad2fa5d0 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 @@ -241,7 +241,7 @@ F src/vdbe.c 5b49cb1f852e4604a4fb6c47e087ddab28af193f F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d F src/vdbeInt.h 79abf9b31be406d35ca77d6999cb2d42aaf91e78 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c -F src/vdbeaux.c 2d1b3ee65860b1ea97ad9f20a02338b26caf2367 +F src/vdbeaux.c f68a124380954985d797fa7d91fe483e2e894aca F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c c61ca318681c0e7267da8be3abfca8469652a7e9 @@ -1025,7 +1025,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 11aa47b0a837858b644c304638e1cbbf482de2f0 -R 2c5b6d51e26c07bb7aa01494f26aa504 -U dan -Z 491f382600c3145f948c8c8459b2421a +P bdceca2738eb3e8acc44d0384cf2a3a969ee8170 +R 80503ae4ab80fdd798bfbc400d2c3f61 +U drh +Z 4593af5fed4b145d5a6fe4d8f35510ce diff --git a/manifest.uuid b/manifest.uuid index 2cd9b15b65..586da86417 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bdceca2738eb3e8acc44d0384cf2a3a969ee8170 \ No newline at end of file +9f6c68856b694373b7ffb124abd996e519ba5921 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 3e045aa366..6682c91475 100644 --- a/src/attach.c +++ b/src/attach.c @@ -471,7 +471,7 @@ int sqlite3FixSrcList( pFix->zType, pFix->pName, pItem->zDatabase); return 1; } - sqlite3_free(pItem->zDatabase); + sqlite3DbFree(pFix->pParse->db, pItem->zDatabase); pItem->zDatabase = 0; pItem->pSchema = pFix->pSchema; #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) diff --git a/src/vdbeaux.c b/src/vdbeaux.c index f5bf3f3242..7f419ecdaa 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2482,7 +2482,7 @@ void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ sqlite3DbFree(db, p->zSql); sqlite3DbFree(db, p->pFree); #if defined(SQLITE_ENABLE_TREE_EXPLAIN) - sqlite3DbFree(db, p->zExplain); + sqlite3_free(p->zExplain); sqlite3DbFree(db, p->pExplain); #endif } From 9ccaefb172900780bf2449aa26b3c61b12e9550f Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Dec 2012 14:37:55 +0000 Subject: [PATCH 14/43] Fixes to a test case in shared_err.test. The fix is to prevent sqlite3_prepare() from being called when the test intends to test the response of sqlite3_step() to an OOM condition. FossilOrigin-Name: 40c143955ebe75f8e73119f9103f36a3c8ac4514 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/shared_err.test | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index cba51a4ca4..431fbf1d25 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\smemory\sis\sfreed\susing\sa\sroutine\sthat\sis\scompatible\swith\sthe\nroutine\sused\sto\sallocate\sthe\smemory.\s\sThe\sSQLITE_MEMDEBUG\scompile-time\noption\senforces\sthis. -D 2012-12-05T14:31:13.890 +C Fixes\sto\sa\stest\scase\sin\sshared_err.test.\sThe\sfix\sis\sto\sprevent\ssqlite3_prepare()\sfrom\sbeing\scalled\swhen\sthe\stest\sintends\sto\stest\sthe\sresponse\sof\ssqlite3_step()\sto\san\sOOM\scondition. +D 2012-12-05T14:37:55.972 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -706,7 +706,7 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d F test/shared9.test 614a3ca431adc73c857632deb4eff75bcaee40ec -F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de +F test/shared_err.test 0079c05c97d88cfa03989b7c20a8b266983087aa F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/shell1.test b7896eb84028f3bc8300caf1fc796a73728aad0b F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a @@ -1025,7 +1025,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 bdceca2738eb3e8acc44d0384cf2a3a969ee8170 -R 80503ae4ab80fdd798bfbc400d2c3f61 -U drh -Z 4593af5fed4b145d5a6fe4d8f35510ce +P 9f6c68856b694373b7ffb124abd996e519ba5921 +R 0d9643e028363737d4ff9c9748568eab +U dan +Z bbb987d6c204716231a7c44af62004e5 diff --git a/manifest.uuid b/manifest.uuid index 586da86417..97719f291b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f6c68856b694373b7ffb124abd996e519ba5921 \ No newline at end of file +40c143955ebe75f8e73119f9103f36a3c8ac4514 \ No newline at end of file diff --git a/test/shared_err.test b/test/shared_err.test index f501fc70d9..17add94bb7 100644 --- a/test/shared_err.test +++ b/test/shared_err.test @@ -401,6 +401,8 @@ do_malloc_test shared_err-8 -tclprep { execsql {INSERT INTO t1 VALUES($a, $b)} db2 } execsql {COMMIT} db2 + execsql BEGIN + execsql ROLLBACK set ::DB2 [sqlite3_connection_pointer db2] set ::STMT [sqlite3_prepare $::DB2 "SELECT a FROM t1 ORDER BY a" -1 DUMMY] sqlite3_step $::STMT ;# Cursor points at 0000000000 @@ -409,8 +411,7 @@ do_malloc_test shared_err-8 -tclprep { execsql { BEGIN; INSERT INTO t1 VALUES(6, NULL); - ROLLBACK; - } + ROLLBACK} } -cleanup { # UPDATE: As of [5668], if the rollback fails SQLITE_CORRUPT is returned. # So these tests have been updated to expect SQLITE_CORRUPT and its From 97305a7ccb17c4fccf375625206cba25c42ffed7 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Dec 2012 16:44:13 +0000 Subject: [PATCH 15/43] Modify a query in test/thread001.test to ensure that results are returned in the order expected by the test. FossilOrigin-Name: 51cbddd51d02bcd954be411ecc83556c049a2680 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/thread001.test | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 431fbf1d25..37bee138b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\sa\stest\scase\sin\sshared_err.test.\sThe\sfix\sis\sto\sprevent\ssqlite3_prepare()\sfrom\sbeing\scalled\swhen\sthe\stest\sintends\sto\stest\sthe\sresponse\sof\ssqlite3_step()\sto\san\sOOM\scondition. -D 2012-12-05T14:37:55.972 +C Modify\sa\squery\sin\stest/thread001.test\sto\sensure\sthat\sresults\sare\sreturned\sin\sthe\sorder\sexpected\sby\sthe\stest. +D 2012-12-05T16:44:13.337 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -746,7 +746,7 @@ F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d F test/tester.tcl 2f383e811010b05a83c0f00fc168cae1dd63a6d9 -F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91 +F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 F test/thread004.test f51dfc3936184aaf73ee85f315224baad272a87f @@ -1025,7 +1025,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 9f6c68856b694373b7ffb124abd996e519ba5921 -R 0d9643e028363737d4ff9c9748568eab +P 40c143955ebe75f8e73119f9103f36a3c8ac4514 +R f84e4b8cfc7fea3471a813d76f6cf616 U dan -Z bbb987d6c204716231a7c44af62004e5 +Z cfac0ef537a462cb80cbccc9f0909b0c diff --git a/manifest.uuid b/manifest.uuid index 97719f291b..bc1844d346 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40c143955ebe75f8e73119f9103f36a3c8ac4514 \ No newline at end of file +51cbddd51d02bcd954be411ecc83556c049a2680 \ No newline at end of file diff --git a/test/thread001.test b/test/thread001.test index 7e0893f29d..a796c57b4a 100644 --- a/test/thread001.test +++ b/test/thread001.test @@ -87,7 +87,7 @@ foreach {tn same_db shared_cache} [list \ do_test t1 { execsql { SELECT - (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) == + (SELECT md5sum(a, b) FROM ab WHERE +a < (SELECT max(a) FROM ab)) == (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab)) } } {1} @@ -131,7 +131,7 @@ foreach {tn same_db shared_cache} [list \ do_test thread001.$tn.6 { execsql { SELECT - (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) == + (SELECT md5sum(a, b) FROM ab WHERE +a < (SELECT max(a) FROM ab)) == (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab)) } } {1} From e825831ee448e63a4664bb8ef9e28fe6b03c77b1 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Dec 2012 19:04:32 +0000 Subject: [PATCH 16/43] Disable a couple of tests in where.test when running the "no_optimization" permutation. FossilOrigin-Name: 5e961e37c5357776bcb44c473cb5ee4b59561f07 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/where.test | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 37bee138b0..8fb7fa65fa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sa\squery\sin\stest/thread001.test\sto\sensure\sthat\sresults\sare\sreturned\sin\sthe\sorder\sexpected\sby\sthe\stest. -D 2012-12-05T16:44:13.337 +C Disable\sa\scouple\sof\stests\sin\swhere.test\swhen\srunning\sthe\s"no_optimization"\spermutation. +D 2012-12-05T19:04:32.951 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -961,7 +961,7 @@ F test/walro.test a31deb621033442a76c3a61e44929250d06f81b1 F test/walshared.test 6dda2293880c300baf5d791c307f653094585761 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e -F test/where.test 41b65069a227a61238c1387b050f029480ca5677 +F test/where.test 9714e6f292d70c22e78e1cecb3d896457186b9b7 F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554 F test/where3.test 667e75642102c97a00bf9b23d3cb267db321d006 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2 @@ -1025,7 +1025,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 40c143955ebe75f8e73119f9103f36a3c8ac4514 -R f84e4b8cfc7fea3471a813d76f6cf616 +P 51cbddd51d02bcd954be411ecc83556c049a2680 +R 004544aa2f154dd2f5140bcbbf89a0db U dan -Z cfac0ef537a462cb80cbccc9f0909b0c +Z 47907e9189566266b1668203df85c209 diff --git a/manifest.uuid b/manifest.uuid index bc1844d346..cd4d199854 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -51cbddd51d02bcd954be411ecc83556c049a2680 \ No newline at end of file +5e961e37c5357776bcb44c473cb5ee4b59561f07 \ No newline at end of file diff --git a/test/where.test b/test/where.test index 461ab87277..05c7b2f04f 100644 --- a/test/where.test +++ b/test/where.test @@ -1079,6 +1079,7 @@ do_test where-13.12 { # When optimizing out ORDER BY clauses, make sure that trailing terms # of the ORDER BY clause do not reference other tables in a join. # +if {[permutation] != "no_optimization"} { do_test where-14.1 { execsql { CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE); @@ -1156,6 +1157,7 @@ do_test where-14.12 { SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b DESC } } {4/4 4/1 1/4 1/1 sort} +} ;# {permutation != "no_optimization"} # Ticket #2445. # From f344a5e70e6afbf6bc86ed4174392d2999ab893c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 6 Dec 2012 00:16:51 +0000 Subject: [PATCH 17/43] Stop using the TCL_LIBS configuration variable when linking with Tcl. Remove superfluous 'rm' command. FossilOrigin-Name: e1feab9834fe829d43ae895cc575ad269a36668c --- Makefile.in | 3 +-- configure | 1 - configure.ac | 1 - manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile.in b/Makefile.in index f078cb68b4..8d9d3c9694 100644 --- a/Makefile.in +++ b/Makefile.in @@ -45,7 +45,7 @@ TCC += @TCL_INCLUDE_SPEC@ # The library that programs using TCL must link against. # -LIBTCL = @TCL_LIB_SPEC@ @TCL_LIBS@ +LIBTCL = @TCL_LIB_SPEC@ # Compiler options needed for programs that use the readline() library. # @@ -935,7 +935,6 @@ clean: rm -rf .libs .deps rm -f lemon$(BEXE) lempar.c parse.* sqlite*.tar.gz rm -f mkkeywordhash$(BEXE) keywordhash.h - rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out rm -rf quota2a quota2b quota2c rm -rf tsrc .target_source diff --git a/configure b/configure index 0986b63667..badc9da34e 100755 --- a/configure +++ b/configure @@ -879,7 +879,6 @@ TARGET_EXEEXT TCL_VERSION TCL_BIN_DIR TCL_SRC_DIR -TCL_LIBS TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIB_FLAG diff --git a/configure.ac b/configure.ac index 882c3ccf92..4a7043ede1 100644 --- a/configure.ac +++ b/configure.ac @@ -501,7 +501,6 @@ if test "${use_tcl}" = "yes" ; then AC_SUBST(TCL_VERSION) AC_SUBST(TCL_BIN_DIR) AC_SUBST(TCL_SRC_DIR) - AC_SUBST(TCL_LIBS) AC_SUBST(TCL_INCLUDE_SPEC) AC_SUBST(TCL_LIB_FILE) diff --git a/manifest b/manifest index 8fb7fa65fa..ef40548d0c 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Disable\sa\scouple\sof\stests\sin\swhere.test\swhen\srunning\sthe\s"no_optimization"\spermutation. -D 2012-12-05T19:04:32.951 +C Stop\susing\sthe\sTCL_LIBS\sconfiguration\svariable\swhen\slinking\swith\sTcl.\s\sRemove\ssuperfluous\s'rm'\scommand. +D 2012-12-06T00:16:51.996 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 +F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc 911b8188f5d67801035a113e063c3023a617525d F Makefile.vxworks b18ad88e9a8c6a001f5cf4a389116a4f1a7ab45f @@ -15,8 +15,8 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 4907207e1627a394e8892cce8dcc8068fbe5f7cd x -F configure.ac 6e909664785b8184db2179013cd9d574f96ca3a3 +F configure 252992f6588107ebd5d17c956d90cf7484580c6f x +F configure.ac 81c43d151d0b0e406be056394cc9ff4cb3fd0444 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1025,7 +1025,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 51cbddd51d02bcd954be411ecc83556c049a2680 -R 004544aa2f154dd2f5140bcbbf89a0db -U dan -Z 47907e9189566266b1668203df85c209 +P 5e961e37c5357776bcb44c473cb5ee4b59561f07 +R c93349168a8ba9f9a5a912129488c71b +T *branch * noTclLibs +T *sym-noTclLibs * +T -sym-trunk * +U mistachkin +Z c1e70093e440f3f1851be714ee963068 diff --git a/manifest.uuid b/manifest.uuid index cd4d199854..1a5fc2a86a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e961e37c5357776bcb44c473cb5ee4b59561f07 \ No newline at end of file +e1feab9834fe829d43ae895cc575ad269a36668c \ No newline at end of file From e6f1e760d563afbbb72e53fdba924776913105ca Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Dec 2012 01:03:15 +0000 Subject: [PATCH 18/43] Remove obsolete comments from the definition of the CollSeq object. FossilOrigin-Name: 7b6951016f5bf4c21f843f09769ba176c709e785 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 14 +------------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 8fb7fa65fa..3d00feff97 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sa\scouple\sof\stests\sin\swhere.test\swhen\srunning\sthe\s"no_optimization"\spermutation. -D 2012-12-05T19:04:32.951 +C Remove\sobsolete\scomments\sfrom\sthe\sdefinition\sof\sthe\sCollSeq\sobject. +D 2012-12-06T01:03:15.144 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 82c41c0ed4cc94dd3cc7d498575b84c57c2c2384 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/shell.c e392dd1ccbb77cc1d75a8367a89b473c24bea019 F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 72ab83e698a42d509a0d1cf16a66ec2dae51a756 +F src/sqliteInt.h 666935d603a7354d90e7ddfe040e3afdd1d8ee16 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1025,7 +1025,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 51cbddd51d02bcd954be411ecc83556c049a2680 -R 004544aa2f154dd2f5140bcbbf89a0db -U dan -Z 47907e9189566266b1668203df85c209 +P 5e961e37c5357776bcb44c473cb5ee4b59561f07 +R fb935adb35724a8c37f202a5f108afb7 +U drh +Z be388c11b29af9fbbbff8cde4f1db193 diff --git a/manifest.uuid b/manifest.uuid index cd4d199854..7934773965 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e961e37c5357776bcb44c473cb5ee4b59561f07 \ No newline at end of file +7b6951016f5bf4c21f843f09769ba176c709e785 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 72fa5fa950..b9b9e6c417 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1150,19 +1150,7 @@ struct Column { ** structure. Conceptually, a collating sequence consists of a name and ** a comparison routine that defines the order of that sequence. ** -** There may two separate implementations of the collation function, one -** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that -** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine -** native byte order. When a collation sequence is invoked, SQLite selects -** the version that will require the least expensive encoding -** translations, if any. -** -** The CollSeq.pUser member variable is an extra parameter that passed in -** as the first argument to the UTF-8 comparison function, xCmp. -** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, -** xCmp16. -** -** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the +** If CollSeq.xCmp is NULL, it means that the ** collating sequence is undefined. Indices built on an undefined ** collating sequence may not be read or written. */ From f44d4b41bd0ea58fd83bfbefc3c4a70928c93f2d Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 6 Dec 2012 04:19:24 +0000 Subject: [PATCH 19/43] Bring the ancient malloc3.test file closer into relevance with the latest core code. FossilOrigin-Name: 9793a21c13a1188383b4be64df86629f196ca330 --- manifest | 14 +++++------ manifest.uuid | 2 +- test/malloc3.test | 60 +++++++++++++++++++++++++++-------------------- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 9ecf488892..a79aea4367 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Stop\susing\sthe\sTCL_LIBS\sconfiguration\svariable\swhen\slinking\swith\sTcl.\nRemove\ssuperfluous\s'rm'\scommand\sfrom\sthe\s"clean"\starget. -D 2012-12-06T02:56:05.083 +C Bring\sthe\sancient\smalloc3.test\sfile\scloser\sinto\srelevance\swith\sthe\slatest\score\scode. +D 2012-12-06T04:19:24.854 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -587,7 +587,7 @@ F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2 F test/main.test 39c4bb8a157f57298ed1659d6df89d9f35aaf2c8 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 F test/malloc.test bc745155ff4252d4f35ec8316625b0dfe2abc659 -F test/malloc3.test de8eca0c3e748878845fdca3663ec4b642073caf +F test/malloc3.test c4f172a3007d90750f2cf0232f24a3e8d80197bd F test/malloc4.test 957337613002b7058a85116493a262f679f3a261 F test/malloc5.test a577cbbcc1594c7763b9b3515b3633555751c7f0 F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151 @@ -1025,7 +1025,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 7b6951016f5bf4c21f843f09769ba176c709e785 e1feab9834fe829d43ae895cc575ad269a36668c -R f01b3a94b8eaef4b696e4f8ea4977242 -U drh -Z 32493e27d940243c2fe11a6697bb936e +P 1551277208048cb24887928f2f971e47a942c849 +R 2cd100741db07187aa3e11b20913cc45 +U mistachkin +Z 3201c1cb9479ff298b2a89dab4136397 diff --git a/manifest.uuid b/manifest.uuid index f4c64a7549..57be4707f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1551277208048cb24887928f2f971e47a942c849 \ No newline at end of file +9793a21c13a1188383b4be64df86629f196ca330 \ No newline at end of file diff --git a/test/malloc3.test b/test/malloc3.test index 2dfde466a0..46d5c0b6c9 100644 --- a/test/malloc3.test +++ b/test/malloc3.test @@ -147,6 +147,7 @@ if {!$MEMDEBUG} { # ::run_test_script. At the end of this file, the proc [run_test] is used # to execute the program (and all test cases contained therein). # +set ::run_test_sql_id 0 set ::run_test_script [list] proc TEST {id t} {lappend ::run_test_script -test [list $id $t]} proc PREP {p} {lappend ::run_test_script -prep [string trim $p]} @@ -162,13 +163,14 @@ proc DEBUG {s} {lappend ::run_test_script -debug $s} # transaction only. # proc SQL {a1 {a2 ""}} { - # An SQL primitive parameter is a list of two elements, a boolean value - # indicating if the statement may cause transaction rollback when malloc() - # fails, and the sql statement itself. + # An SQL primitive parameter is a list of three elements, an id, a boolean + # value indicating if the statement may cause transaction rollback when + # malloc() fails, and the sql statement itself. + set id [incr ::run_test_sql_id] if {$a2 == ""} { - lappend ::run_test_script -sql [list true [string trim $a1]] + lappend ::run_test_script -sql [list $id true [string trim $a1]] } else { - lappend ::run_test_script -sql [list false [string trim $a2]] + lappend ::run_test_script -sql [list $id false [string trim $a2]] } } @@ -258,7 +260,7 @@ TEST 5 { set sql { BEGIN;DELETE FROM abc; } -for {set i 1} {$i < 15} {incr i} { +for {set i 1} {$i < 100} {incr i} { set a $i set b "String value $i" set c [string repeat X $i] @@ -529,12 +531,13 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { } for {set i 0} {$i < $pcstart} {incr i} { - set k2 [lindex $arglist [expr 2 * $i]] - set v2 [lindex $arglist [expr 2 * $i + 1]] + set k2 [lindex $arglist [expr {2 * $i}]] + set v2 [lindex $arglist [expr {2 * $i + 1}]] set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit switch -- $k2 { - -sql {db eval [lindex $v2 1]} + -sql {db eval [lindex $v2 2]} -prep {db eval $v2} + -debug {eval $v2} } set nac [sqlite3_get_autocommit $::DB] ;# New Auto-Commit if {$ac && !$nac} {set begin_pc $i} @@ -545,25 +548,31 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { set iFail $iFailStart set pc $pcstart while {$pc*2 < [llength $arglist]} { + # Fetch the current instruction type and payload. + set k [lindex $arglist [expr {2 * $pc}]] + set v [lindex $arglist [expr {2 * $pc + 1}]] # Id of this iteration: - set k [lindex $arglist [expr 2 * $pc]] set iterid "pc=$pc.iFail=$iFail$k" - set v [lindex $arglist [expr 2 * $pc + 1]] switch -- $k { -test { foreach {id script} $v {} + set testid "malloc3-(test $id).$iterid" + eval $script incr pc } -sql { set ::rollback_hook_count 0 + set id [lindex $v 0] + set testid "malloc3-(integrity $id).$iterid" + set ac [sqlite3_get_autocommit $::DB] ;# Auto-Commit sqlite3_memdebug_fail $iFail -repeat 0 - set rc [catch {db eval [lindex $v 1]} msg] ;# True error occurs + set rc [catch {db eval [lindex $v 2]} msg] ;# True error occurs set nac [sqlite3_get_autocommit $::DB] ;# New Auto-Commit if {$rc != 0 && $nac && !$ac} { @@ -571,7 +580,7 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { # is set. Since an error occured we assume this was not a # commit - therefore a rollback occured. Check that the # rollback-hook was invoked. - do_test malloc3-rollback_hook.$iterid { + do_test malloc3-rollback_hook_count.$iterid { set ::rollback_hook_count } {1} } @@ -582,8 +591,9 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { # calls should be equal to the number of benign failures. # Otherwise a malloc() failed and the error was not reported. # - if {$nFail!=$nBenign} { - error "Unreported malloc() failure" + set expr {$nFail!=$nBenign} + if {[expr $expr]} { + error "Unreported malloc() failure, test \"$testid\", $expr" } if {$ac && !$nac} { @@ -595,24 +605,23 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { incr pc set iFail 1 - integrity_check "malloc3-(integrity).$iterid" + integrity_check $testid } elseif {[regexp {.*out of memory} $msg] || [db errorcode] == 3082} { # Out of memory error, as expected. # - integrity_check "malloc3-(integrity).$iterid" + integrity_check $testid incr iFail if {$nac && !$ac} { - - if {![lindex $v 0] && [db errorcode] != 3082} { - # error "Statement \"[lindex $v 1]\" caused a rollback" + if {![lindex $v 1] && [db errorcode] != 3082} { + # error "Statement \"[lindex $v 2]\" caused a rollback" } for {set i $begin_pc} {$i < $pc} {incr i} { - set k2 [lindex $arglist [expr 2 * $i]] - set v2 [lindex $arglist [expr 2 * $i + 1]] + set k2 [lindex $arglist [expr {2 * $i}]] + set v2 [lindex $arglist [expr {2 * $i + 1}]] set catchupsql "" switch -- $k2 { - -sql {set catchupsql [lindex $v2 1]} + -sql {set catchupsql [lindex $v2 2]} -prep {set catchupsql $v2} } db eval $catchupsql @@ -622,7 +631,8 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { error $msg } - while {[lindex $arglist [expr 2 * ($pc -1)]] == "-test"} { + # back up to the previous "-test" block. + while {[lindex $arglist [expr {2 * ($pc - 1)}]] == "-test"} { incr pc -1 } } @@ -642,7 +652,7 @@ proc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} { } } -# Turn of the Tcl interface's prepared statement caching facility. Then +# Turn off the Tcl interface's prepared statement caching facility. Then # run the tests with "persistent" malloc failures. sqlite3_extended_result_codes db 1 db cache size 0 From 48dd9deffe0a56081af7055013050b07186b8278 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 6 Dec 2012 04:33:13 +0000 Subject: [PATCH 20/43] For the sqlite3-all.c target, use backslashes when calling the splitter script via the MSVC makefile. FossilOrigin-Name: d507648d820cfea70e17f3d21c35c932a2d20367 --- Makefile.msc | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 93d3c0fb25..d12e5d0ec1 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -829,8 +829,8 @@ sqlite3.exe: $(TOP)\src\shell.c libsqlite3.lib $(LIBRESOBJS) sqlite3.h sqlite3.c: .target_source $(TOP)\tool\mksqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl -sqlite3-all.c: sqlite3.c $(TOP)/tool/split-sqlite3c.tcl - $(TCLSH_CMD) $(TOP)/tool/split-sqlite3c.tcl +sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl + $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl # Rule to build the amalgamation # diff --git a/manifest b/manifest index a79aea4367..69db5c635e 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Bring\sthe\sancient\smalloc3.test\sfile\scloser\sinto\srelevance\swith\sthe\slatest\score\scode. -D 2012-12-06T04:19:24.854 +C For\sthe\ssqlite3-all.c\starget,\suse\sbackslashes\swhen\scalling\sthe\ssplitter\sscript\svia\sthe\sMSVC\smakefile. +D 2012-12-06T04:33:13.120 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 911b8188f5d67801035a113e063c3023a617525d +F Makefile.msc 5a3b6f34d263b01f8b798c291fac1529fd650308 F Makefile.vxworks b18ad88e9a8c6a001f5cf4a389116a4f1a7ab45f F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION edab4af5a4623f8198833ea481ce98ab53750a8d @@ -1025,7 +1025,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 1551277208048cb24887928f2f971e47a942c849 -R 2cd100741db07187aa3e11b20913cc45 +P 9793a21c13a1188383b4be64df86629f196ca330 +R b1ae0671b34d9888ba979c90eefe9883 U mistachkin -Z 3201c1cb9479ff298b2a89dab4136397 +Z 488057b91d078ba82beb69ea442d1563 diff --git a/manifest.uuid b/manifest.uuid index 57be4707f7..01dc80574a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9793a21c13a1188383b4be64df86629f196ca330 \ No newline at end of file +d507648d820cfea70e17f3d21c35c932a2d20367 \ No newline at end of file From 74358f0c77665c34db821fff16bcce51004d8185 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Dec 2012 15:15:15 +0000 Subject: [PATCH 21/43] Add a test case that demonstrates ticket [71e333e7d2e642]. FossilOrigin-Name: cc6e0785df3c2342376351e19ba7dba7b8d2f6a3 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- test/shared9.test | 25 ++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 69db5c635e..36a1e81ed7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sthe\ssqlite3-all.c\starget,\suse\sbackslashes\swhen\scalling\sthe\ssplitter\sscript\svia\sthe\sMSVC\smakefile. -D 2012-12-06T04:33:13.120 +C Add\sa\stest\scase\sthat\sdemonstrates\sticket\s[71e333e7d2e642]. +D 2012-12-06T15:15:15.819 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -705,7 +705,7 @@ F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d -F test/shared9.test 614a3ca431adc73c857632deb4eff75bcaee40ec +F test/shared9.test 5f2a8f79b4d6c7d107a01ffa1ed05ae7e6333e21 F test/shared_err.test 0079c05c97d88cfa03989b7c20a8b266983087aa F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/shell1.test b7896eb84028f3bc8300caf1fc796a73728aad0b @@ -1025,7 +1025,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 9793a21c13a1188383b4be64df86629f196ca330 -R b1ae0671b34d9888ba979c90eefe9883 -U mistachkin -Z 488057b91d078ba82beb69ea442d1563 +P d507648d820cfea70e17f3d21c35c932a2d20367 +R c8862607377e39d862ea6493db661aac +T *branch * ticket-71e333e7 +T *sym-ticket-71e333e7 * +T -sym-trunk * +U drh +Z b40bafefd4b37344c158547788b014ab diff --git a/manifest.uuid b/manifest.uuid index 01dc80574a..317159043e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d507648d820cfea70e17f3d21c35c932a2d20367 \ No newline at end of file +cc6e0785df3c2342376351e19ba7dba7b8d2f6a3 \ No newline at end of file diff --git a/test/shared9.test b/test/shared9.test index 4ebdc1743d..1982a593e3 100644 --- a/test/shared9.test +++ b/test/shared9.test @@ -136,6 +136,30 @@ do_test 2.4 { set ::invoked_mycollate_db1 } {0} +forcedelete test.db test.db2 +sqlite3 db1 test.db +sqlite3 db2 test.db +db1 collate mycollate mycollate_db1 +db2 collate mycollate mycollate_db2 + +do_test 2.13 { + set ::invoked_mycollate_db1 0 + db1 eval { + CREATE TABLE t1(a, CHECK (a COLLATE mycollate IN ('one', 'two', 'three'))); + INSERT INTO t1 VALUES('one'); + } + db1 close + set ::invoked_mycollate_db1 +} {1} +do_test 2.14 { + set ::invoked_mycollate_db1 0 + db2 eval { + INSERT INTO t1 VALUES('two'); + } + db2 close + set ::invoked_mycollate_db1 +} {0} + #------------------------------------------------------------------------- # This test verifies that a bug causing a busy-handler belonging to one # shared-cache connection to be executed as a result of an sqlite3_step() @@ -204,4 +228,3 @@ db2 close sqlite3_enable_shared_cache $::enable_shared_cache finish_test - From 696b33e622f4f139be012f12671f860c17d0bb67 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Dec 2012 19:01:42 +0000 Subject: [PATCH 22/43] Add the SQLITE_FCNTL_TEMPFILENAME file control that asks the underlying VFS to return a new temporary filename. Per request from NSS team at Mozilla. FossilOrigin-Name: 1a63b1d5fa5d79f96eddbda6d94bc10248863710 --- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/os_unix.c | 11 +++++++++++ src/os_win.c | 11 +++++++++++ src/sqlite.h.in | 12 +++++++++++- src/test1.c | 33 +++++++++++++++++++++++++++++++++ src/test_sqllog.c | 2 +- src/test_vfstrace.c | 4 +++- test/filectrl.test | 6 ++++++ 9 files changed, 90 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 69db5c635e..8b6632de60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sthe\ssqlite3-all.c\starget,\suse\sbackslashes\swhen\scalling\sthe\ssplitter\sscript\svia\sthe\sMSVC\smakefile. -D 2012-12-06T04:33:13.120 +C Add\sthe\sSQLITE_FCNTL_TEMPFILENAME\sfile\scontrol\sthat\sasks\sthe\sunderlying\sVFS\nto\sreturn\sa\snew\stemporary\sfilename.\s\sPer\srequest\sfrom\sNSS\steam\sat\sMozilla. +D 2012-12-06T19:01:42.467 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,8 +160,8 @@ 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 b75d9b0876ad3fde151843ad389b4c3dd727c662 -F src/os_win.c 6e55b48f793d0c0d0e086d3f1482a0882530eeeb +F src/os_unix.c ad459bb62eb6f3f6aae26d97b1a28fbac7bf0260 +F src/os_win.c ce1f5db8a7bb4d6f2092b1b2cb9631bec54a6320 F src/pager.c 4092c907222cfd451c74fe6bd2fd64b342f7190f F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -176,7 +176,7 @@ F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 3a8baf4719f9723b4e0b43f2baa60692d0d921f8 F src/shell.c e392dd1ccbb77cc1d75a8367a89b473c24bea019 -F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3 +F src/sqlite.h.in e5552743b5b74dc675ebbdedd849ba8283424fa9 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 666935d603a7354d90e7ddfe040e3afdd1d8ee16 @@ -184,7 +184,7 @@ F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 515abd8e33e82aa330eeb54675185a7e1e5b6778 -F src/test1.c 936afc02766403e5debca49a1817a780e116df7e +F src/test1.c f62769c989146149590662ab02de4a813813a9c5 F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa @@ -221,14 +221,14 @@ F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f F src/test_spellfix.c 76dd8d3111d2f5354c374f71fa23b752bd0b029c -F src/test_sqllog.c 7813b47021a6d4e39bb7b1b328a8893dc59885cb +F src/test_sqllog.c 8acb843ddb9928dea8962e31bb09f421a72ffccb F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4 F src/test_vfs.c c6260ef238c1142c8f8bd402db02216afd182ae3 -F src/test_vfstrace.c f60e12754e65c05386aab59db8d2ae086314138d +F src/test_vfstrace.c 34b544e80ba7fb77be15395a609c669df2e660a2 F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 1e86210d3976717a19238ea7b047fac481fe8c12 @@ -406,7 +406,7 @@ F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30 F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d F test/fallocate.test b5d34437bd7ab01d41b1464b8117aefd4d32160e -F test/filectrl.test f0327bd804d9c7bd048fa7a151c5eab8e27df42b +F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a F test/filefmt.test ffa17b5aebc3eb4b1e3be1ccb5ee906ffbd97f6e F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da F test/fkey2.test 080969fe219b3b082b0e097ac18c6af2e5b0631f @@ -1025,7 +1025,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 9793a21c13a1188383b4be64df86629f196ca330 -R b1ae0671b34d9888ba979c90eefe9883 -U mistachkin -Z 488057b91d078ba82beb69ea442d1563 +P d507648d820cfea70e17f3d21c35c932a2d20367 +R eb2cb26563b5f98893b41a686dd89dac +U drh +Z a78031be2e88797bf9b27c616571dbb4 diff --git a/manifest.uuid b/manifest.uuid index 01dc80574a..3e42a7d077 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d507648d820cfea70e17f3d21c35c932a2d20367 \ No newline at end of file +1a63b1d5fa5d79f96eddbda6d94bc10248863710 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index a3a012126b..315f150188 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3581,6 +3581,9 @@ static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){ } } +/* Forward declaration */ +static int unixGetTempname(int nBuf, char *zBuf); + /* ** Information and control of an open file handle. */ @@ -3618,6 +3621,14 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName); return SQLITE_OK; } + case SQLITE_FCNTL_TEMPFILENAME: { + char *zTFile = sqlite3_malloc( pFile->pVfs->mxPathname ); + if( zTFile ){ + unixGetTempname(pFile->pVfs->mxPathname, zTFile); + *(char**)pArg = zTFile; + } + return SQLITE_OK; + } #ifdef SQLITE_DEBUG /* The pager calls this method to signal that it has done ** a rollback and that the database is therefore unchanged and diff --git a/src/os_win.c b/src/os_win.c index 6f49257705..107370c41b 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2691,6 +2691,9 @@ static void winModeBit(winFile *pFile, unsigned char mask, int *pArg){ } } +/* Forward declaration */ +static int getTempname(int nBuf, char *zBuf); + /* ** Control and query of the open file handle. */ @@ -2751,6 +2754,14 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ } return SQLITE_OK; } + case SQLITE_FCNTL_TEMPFILENAME: { + char *zTFile = sqlite3_malloc( pFile->pVfs->mxPathname ); + if( zTFile ){ + getTempname(pFile->pVfs->mxPathname, zTFile); + *(char**)pArg = zTFile; + } + return SQLITE_OK; + } } return SQLITE_NOTFOUND; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ba97cd7d4e..0bf0be5fcf 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -852,7 +852,6 @@ struct sqlite3_io_methods { ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] ** file control occurs at the beginning of pragma statement analysis and so ** it is able to override built-in [PRAGMA] statements. -** ** **
  • [[SQLITE_FCNTL_BUSYHANDLER]] ** ^This file-control may be invoked by SQLite on the database file handle @@ -864,6 +863,16 @@ struct sqlite3_io_methods { ** the array as the only argument. If it returns non-zero, then the operation ** should be retried. If it returns zero, the custom VFS should abandon the ** current operation. +** +**
  • [[SQLITE_FCNTL_TEMPFILENAME]] +** ^Application can invoke this file-control to have SQLite generate a +** temporary filename using the same algorithm that is followed to generate +** temporary filenames for TEMP tables and other internal uses. The +** argument should be a char** which will be filled with the filename +** written into memory obtained from [sqlite3_malloc()]. The caller should +** invoke [sqlite3_free()] on the result to avoid a memory leak. +** +** */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_GET_LOCKPROXYFILE 2 @@ -880,6 +889,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 #define SQLITE_FCNTL_PRAGMA 14 #define SQLITE_FCNTL_BUSYHANDLER 15 +#define SQLITE_FCNTL_TEMPFILENAME 16 /* ** CAPI3REF: Mutex Handle diff --git a/src/test1.c b/src/test1.c index e7a2242210..bb8d186c12 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5321,6 +5321,38 @@ static int file_control_vfsname( return TCL_OK; } +/* +** tclcmd: file_control_tempfilename DB ?AUXDB? +** +** Return a string that is a temporary filename +*/ +static int file_control_tempfilename( + ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int objc, /* Number of arguments */ + Tcl_Obj *CONST objv[] /* Command arguments */ +){ + sqlite3 *db; + const char *zDbName = "main"; + char *zTName = 0; + + if( objc!=2 && objc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " DB ?AUXDB?", 0); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ + return TCL_ERROR; + } + if( objc==3 ){ + zDbName = Tcl_GetString(objv[2]); + } + sqlite3_file_control(db, zDbName, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTName); + Tcl_AppendResult(interp, zTName, (char*)0); + sqlite3_free(zTName); + return TCL_OK; +} + /* ** tclcmd: sqlite3_vfs_list @@ -6150,6 +6182,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "file_control_persist_wal", file_control_persist_wal, 0 }, { "file_control_powersafe_overwrite",file_control_powersafe_overwrite,0}, { "file_control_vfsname", file_control_vfsname, 0 }, + { "file_control_tempfilename", file_control_tempfilename, 0 }, { "sqlite3_vfs_list", vfs_list, 0 }, { "sqlite3_create_function_v2", test_create_function_v2, 0 }, diff --git a/src/test_sqllog.c b/src/test_sqllog.c index 49569a39fb..7cb570bcf2 100644 --- a/src/test_sqllog.c +++ b/src/test_sqllog.c @@ -390,7 +390,7 @@ static void testSqllogStmt(struct SLConn *p, const char *zSql){ ** The SQLITE_CONFIG_SQLLOG callback registered by sqlite3_init_sqllog(). */ static void testSqllog(void *pCtx, sqlite3 *db, const char *zSql, int eType){ - struct SLConn *p; + struct SLConn *p = 0; sqlite3_mutex *master = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); assert( eType==0 || eType==1 || eType==2 ); diff --git a/src/test_vfstrace.c b/src/test_vfstrace.c index d2f7455e3d..0aacc01fe4 100644 --- a/src/test_vfstrace.c +++ b/src/test_vfstrace.c @@ -475,6 +475,7 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){ case SQLITE_FCNTL_PERSIST_WAL: zOp = "PERSIST_WAL"; break; case SQLITE_FCNTL_OVERWRITE: zOp = "OVERWRITE"; break; case SQLITE_FCNTL_VFSNAME: zOp = "VFSNAME"; break; + case SQLITE_FCNTL_TEMPFILENAME: zOp = "TEMPFILENAME"; break; case 0xca093fa0: zOp = "DB_UNCHANGED"; break; case SQLITE_FCNTL_PRAGMA: { const char *const* a = (const char*const*)pArg; @@ -496,7 +497,8 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){ *(char**)pArg = sqlite3_mprintf("vfstrace.%s/%z", pInfo->zVfsName, *(char**)pArg); } - if( op==SQLITE_FCNTL_PRAGMA && rc==SQLITE_OK && *(char**)pArg ){ + if( (op==SQLITE_FCNTL_PRAGMA || op==SQLITE_FCNTL_TEMPFILENAME) + && rc==SQLITE_OK && *(char**)pArg ){ vfstrace_printf(pInfo, "%s.xFileControl(%s,%s) returns %s", pInfo->zVfsName, p->zFName, zOp, *(char**)pArg); } diff --git a/test/filectrl.test b/test/filectrl.test index 1e4ec59853..1d878bf968 100644 --- a/test/filectrl.test +++ b/test/filectrl.test @@ -36,6 +36,12 @@ do_test filectrl-1.5 { sqlite3 db test_control_lockproxy.db file_control_lockproxy_test db [get_pwd] } {} +do_test filectrl-1.6 { + sqlite3 db test.db + set fn [file_control_tempfilename db] + puts -nonewline \[$fn\] + set fn +} {/etilqs_/} db close forcedelete .test_control_lockproxy.db-conch test.proxy finish_test From f78baafe41c23563d47799a5496692533abc53f1 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 6 Dec 2012 19:37:22 +0000 Subject: [PATCH 23/43] Apply the same restrictions on constant refactoring to statements within a trigger program as top-level statements. Candidate fix for [ae3c5670b6]. FossilOrigin-Name: 0c31a46801746191d1a53332d75beda880fe1fd7 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/build.c | 10 ++++++++++ src/trigger.c | 9 +++++++++ test/triggerC.test | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8b6632de60..6a5a27c92a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_FCNTL_TEMPFILENAME\sfile\scontrol\sthat\sasks\sthe\sunderlying\sVFS\nto\sreturn\sa\snew\stemporary\sfilename.\s\sPer\srequest\sfrom\sNSS\steam\sat\sMozilla. -D 2012-12-06T19:01:42.467 +C Apply\sthe\ssame\srestrictions\son\sconstant\srefactoring\sto\sstatements\swithin\sa\strigger\sprogram\sas\stop-level\sstatements.\sCandidate\sfix\sfor\s[ae3c5670b6]. +D 2012-12-06T19:37:22.521 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c eccee944cb2221e919d7a855e5928d8643194b14 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 -F src/build.c f35dac52924a6e8e6346a90f0c195a84e28b6f21 +F src/build.c fd68fb1bee609b88f4f7c8ebe4dc9560c583c39d F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e @@ -232,7 +232,7 @@ F src/test_vfstrace.c 34b544e80ba7fb77be15395a609c669df2e660a2 F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 1e86210d3976717a19238ea7b047fac481fe8c12 -F src/trigger.c 3f258307040173aff383eb23fb74c44fe829078c +F src/trigger.c cd95ac64efa60e39faf9b5597443192ff27a22fa F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 @@ -899,7 +899,7 @@ F test/trigger8.test 30cb0530bd7c4728055420e3f739aa00412eafa4 F test/trigger9.test 5b0789f1c5c4600961f8e68511b825b87be53e31 F test/triggerA.test e0aaba16d3547193d36bbd82a1b0ed75e9c88d40 F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe -F test/triggerC.test 29173df06f8e91bec2b95ea7048b30d1e1c7b9db +F test/triggerC.test a7b4367392c755bc5fd5fff88011753e6b6afe90 F test/triggerD.test 8e7f3921a92a5797d472732108109e44575fa650 F test/tt3_checkpoint.c 415eccce672d681b297485fc20f44cdf0eac93af F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff @@ -1025,7 +1025,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 d507648d820cfea70e17f3d21c35c932a2d20367 -R eb2cb26563b5f98893b41a686dd89dac -U drh -Z a78031be2e88797bf9b27c616571dbb4 +P 1a63b1d5fa5d79f96eddbda6d94bc10248863710 +R 919f27f45c7dc1e6e97e702080115442 +T *branch * constant-refactoring-in-triggers +T *sym-constant-refactoring-in-triggers * +T -sym-trunk * +U dan +Z 10c6ff069df8e2b9b146f1c13827ef9e diff --git a/manifest.uuid b/manifest.uuid index 3e42a7d077..515161250d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a63b1d5fa5d79f96eddbda6d94bc10248863710 \ No newline at end of file +0c31a46801746191d1a53332d75beda880fe1fd7 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 4c45a92727..382b6cb33a 100644 --- a/src/build.c +++ b/src/build.c @@ -127,6 +127,7 @@ void sqlite3FinishCoding(Parse *pParse){ sqlite3 *db; Vdbe *v; + assert( pParse->pToplevel==0 ); db = pParse->db; if( db->mallocFailed ) return; if( pParse->nested ) return; @@ -3589,6 +3590,15 @@ int sqlite3OpenTempDatabase(Parse *pParse){ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ Parse *pToplevel = sqlite3ParseToplevel(pParse); +#ifndef SQLITE_OMIT_TRIGGER + if( pToplevel!=pParse ){ + /* This branch is taken if a trigger is currently being coded. In this + ** case, set cookieGoto to a non-zero value to show that this function + ** has been called. This is used by the sqlite3ExprCodeConstants() + ** function. */ + pParse->cookieGoto = -1; + } +#endif if( pToplevel->cookieGoto==0 ){ Vdbe *v = sqlite3GetVdbe(pToplevel); if( v==0 ) return; /* This only happens if there was a prior error */ diff --git a/src/trigger.c b/src/trigger.c index 8985ec6eb8..f1ff766e20 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -729,6 +729,15 @@ static int codeTriggerProgram( */ pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf; + /* Clear the cookieGoto flag. When coding triggers, the cookieGoto + ** variable is used as a flag to indicate to sqlite3ExprCodeConstants() + ** that it is not safe to refactor constants (this happens after the + ** start of the first loop in the SQL statement is coded - at that + ** point code may be conditionally executed, so it is no longer safe to + ** initialize constant register values). */ + assert( pParse->cookieGoto==0 || pParse->cookieGoto==-1 ); + pParse->cookieGoto = 0; + switch( pStep->op ){ case TK_UPDATE: { sqlite3Update(pParse, diff --git a/test/triggerC.test b/test/triggerC.test index db37ab3b66..8d9848794a 100644 --- a/test/triggerC.test +++ b/test/triggerC.test @@ -949,6 +949,48 @@ do_catchsql_test triggerC-13.2 { UPDATE t12 SET a=a+1, b=b+1; } {1 {too many levels of trigger recursion}} +#------------------------------------------------------------------------- +# The following tests seek to verify that constant values (i.e. literals) +# are not factored out of loops within trigger programs. SQLite does +# not factor constants out of loops within trigger programs as it may only +# do so in code generated before the first table or index is opened. And +# by the time a trigger program is coded, at least one table or index has +# always been opened. +# +# At one point, due to a bug allowing constant factoring within triggers, +# the following SQL would produce the wrong result. +# +set SQL { + CREATE TABLE t1(a, b, c); + CREATE INDEX i1 ON t1(a, c); + CREATE INDEX i2 ON t1(b, c); + INSERT INTO t1 VALUES(1, 2, 3); + CREATE TABLE t2(e, f); + CREATE INDEX i3 ON t2(e); + INSERT INTO t2 VALUES(1234567, 3); + + CREATE TABLE empty(x); + CREATE TABLE not_empty(x); + INSERT INTO not_empty VALUES(2); + + CREATE TABLE t4(x); + CREATE TABLE t5(g, h, i); + + CREATE TRIGGER trig BEFORE INSERT ON t4 BEGIN + INSERT INTO t5 SELECT * FROM t1 WHERE + (a IN (SELECT x FROM empty) OR b IN (SELECT x FROM not_empty)) + AND c IN (SELECT f FROM t2 WHERE e=1234567); + END; + + INSERT INTO t4 VALUES(0); + SELECT * FROM t5; +} + +reset_db +do_execsql_test triggerC-14.1 $SQL {1 2 3} +reset_db +optimization_control db factor-constants 0 +do_execsql_test triggerC-14.2 $SQL {1 2 3} finish_test From ae80ddea9f4cf8505b5a27aeec3fa8b959218064 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Dec 2012 21:16:43 +0000 Subject: [PATCH 24/43] Remove the Expr.pColl field and compute the collating sequence as it is needed. This fixes the test script "shared9.test", though there is still a memory leak. And there are other problems. Consider this a work-in-progress. FossilOrigin-Name: fd011cb22f2d899d94ec7ce22641d7a8f5e19972 --- manifest | 27 +++++------ manifest.uuid | 2 +- src/build.c | 18 +++---- src/expr.c | 123 +++++++++++++++++++++++++----------------------- src/fkey.c | 2 +- src/resolve.c | 9 +--- src/select.c | 9 +--- src/sqliteInt.h | 4 +- src/where.c | 44 ++++++++++------- 9 files changed, 117 insertions(+), 121 deletions(-) diff --git a/manifest b/manifest index 36a1e81ed7..982c3dfca5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sthat\sdemonstrates\sticket\s[71e333e7d2e642]. -D 2012-12-06T15:15:15.819 +C Remove\sthe\sExpr.pColl\sfield\sand\scompute\sthe\scollating\ssequence\sas\sit\sis\sneeded.\nThis\sfixes\sthe\stest\sscript\s"shared9.test",\sthough\sthere\sis\sstill\sa\smemory\sleak.\nAnd\sthere\sare\sother\sproblems.\s\sConsider\sthis\sa\swork-in-progress. +D 2012-12-06T21:16:43.401 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,15 +124,15 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c eccee944cb2221e919d7a855e5928d8643194b14 F src/btree.h 3ad7964d6c5b1c7bff569aab6adfa075f8bf06cd F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 -F src/build.c f35dac52924a6e8e6346a90f0c195a84e28b6f21 +F src/build.c 9721f654f5dc84b3c85559d181346b701f8ea9a4 F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d -F src/expr.c 3b25a95f3d309403940ba4a3212f197b8b6251d5 +F src/expr.c 696c9e664a3d0405fb83ed206500809519f9c1a7 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c c82a04e7a92bb728f9ab972b76590403283be2af +F src/fkey.c ca70996e72b307d58718e4d1f11668ff76d5f2d4 F src/func.c 8147799b048065a1590805be464d05b4913e652c F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 @@ -172,14 +172,14 @@ F src/pragma.c 015723c48072781d2740e310ab04dc92956b76d1 F src/prepare.c 931ad0d852a0df48f79adcba6ce79ca5f475625c F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 -F src/resolve.c 7b986a715ac281643309c29257bb58cfae7aa810 +F src/resolve.c 6faf0f337ef89f7f9f6142d766793a87074612dc F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 3a8baf4719f9723b4e0b43f2baa60692d0d921f8 +F src/select.c da1af4c2f1ff4d280aa68eb58b714e9b7d0fc1c3 F src/shell.c e392dd1ccbb77cc1d75a8367a89b473c24bea019 F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 666935d603a7354d90e7ddfe040e3afdd1d8ee16 +F src/sqliteInt.h 9cec95011e6e6f14f74f855275e21bea79daee2e F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -250,7 +250,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 b5325975cbdd9b64f680fb88d7e727fc9368db68 +F src/where.c 1c7ff5ad06fe23d9d46008a23f9118926bb4fcb7 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -1025,10 +1025,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 d507648d820cfea70e17f3d21c35c932a2d20367 -R c8862607377e39d862ea6493db661aac -T *branch * ticket-71e333e7 -T *sym-ticket-71e333e7 * -T -sym-trunk * +P cc6e0785df3c2342376351e19ba7dba7b8d2f6a3 +R a2a449d5f80e428bd0ee765a55dfac68 U drh -Z b40bafefd4b37344c158547788b014ab +Z 434d5050577e1426f5ec867bc43f759c diff --git a/manifest.uuid b/manifest.uuid index 317159043e..e5f7e5fe65 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc6e0785df3c2342376351e19ba7dba7b8d2f6a3 \ No newline at end of file +fd011cb22f2d899d94ec7ce22641d7a8f5e19972 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 4c45a92727..c03e50295d 100644 --- a/src/build.c +++ b/src/build.c @@ -2690,10 +2690,8 @@ Index *sqlite3CreateIndex( for(i=0; inExpr; i++){ Expr *pExpr = pList->a[i].pExpr; if( pExpr ){ - CollSeq *pColl = pExpr->pColl; - /* Either pColl!=0 or there was an OOM failure. But if an OOM - ** failure we have quit before reaching this point. */ - if( ALWAYS(pColl) ){ + CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr); + if( pColl ){ nExtra += (1 + sqlite3Strlen30(pColl->zName)); } } @@ -2756,6 +2754,7 @@ Index *sqlite3CreateIndex( const char *zColName = pListItem->zName; Column *pTabCol; int requestedSortOrder; + CollSeq *pColl; /* Collating sequence */ char *zColl; /* Collation sequence name */ for(j=0, pTabCol=pTab->aCol; jnCol; j++, pTabCol++){ @@ -2768,14 +2767,11 @@ Index *sqlite3CreateIndex( goto exit_create_index; } pIndex->aiColumn[i] = j; - /* Justification of the ALWAYS(pListItem->pExpr->pColl): Because of - ** the way the "idxlist" non-terminal is constructed by the parser, - ** if pListItem->pExpr is not null then either pListItem->pExpr->pColl - ** must exist or else there must have been an OOM error. But if there - ** was an OOM error, we would never reach this point. */ - if( pListItem->pExpr && ALWAYS(pListItem->pExpr->pColl) ){ + if( pListItem->pExpr + && (pColl = sqlite3ExprCollSeq(pParse, pListItem->pExpr))!=0 + ){ int nColl; - zColl = pListItem->pExpr->pColl->zName; + zColl = pColl->zName; nColl = sqlite3Strlen30(zColl) + 1; assert( nExtra>=nColl ); memcpy(zExtra, zColl, nColl); diff --git a/src/expr.c b/src/expr.c index ae828489a6..11feaa216a 100644 --- a/src/expr.c +++ b/src/expr.c @@ -55,67 +55,73 @@ char sqlite3ExprAffinity(Expr *pExpr){ return pExpr->affinity; } -/* -** Set the explicit collating sequence for an expression to the -** collating sequence supplied in the second argument. -*/ -Expr *sqlite3ExprSetColl(Expr *pExpr, CollSeq *pColl){ - if( pExpr && pColl ){ - pExpr->pColl = pColl; - pExpr->flags |= EP_ExpCollate; - } - return pExpr; -} - /* ** Set the collating sequence for expression pExpr to be the collating -** sequence named by pToken. Return a pointer to the revised expression. -** The collating sequence is marked as "explicit" using the EP_ExpCollate -** flag. An explicit collating sequence will override implicit -** collating sequences. +** sequence named by pToken. Return a pointer to a new Expr node that +** implements the COLLATE operator. */ Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr *pExpr, Token *pCollName){ - char *zColl = 0; /* Dequoted name of collation sequence */ - CollSeq *pColl; - sqlite3 *db = pParse->db; - zColl = sqlite3NameFromToken(db, pCollName); - pColl = sqlite3LocateCollSeq(pParse, zColl); - sqlite3ExprSetColl(pExpr, pColl); - sqlite3DbFree(db, zColl); - return pExpr; + Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1); + if( pNew ){ + pNew->pLeft = pExpr; + pNew->flags |= EP_Collate; + } + return pNew; } /* -** Return the default collation sequence for the expression pExpr. If -** there is no default collation type, return 0. +** Return the collation sequence for the expression pExpr. If +** there is no defined collating sequence, return NULL. +** +** The collating sequence might be determined by a COLLATE operator +** or by the presence of a column with a defined collating sequence. +** COLLATE operators take first precedence. Left operands take +** precedence over right operands. */ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ + sqlite3 *db = pParse->db; CollSeq *pColl = 0; Expr *p = pExpr; - while( p ){ - int op; - pColl = p->pColl; - if( pColl ) break; - op = p->op; - if( p->pTab!=0 && ( - op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_REGISTER || op==TK_TRIGGER - )){ + while( p && pColl==0 ){ + int op = p->op; + if( op==TK_CAST || op==TK_UPLUS ){ + p = p->pLeft; + continue; + } + if( op==TK_COLLATE ){ + pColl = sqlite3FindCollSeq(db, ENC(db), p->u.zToken, 0); + break; + } + if( p->pTab!=0 + && (op==TK_AGG_COLUMN || op==TK_COLUMN + || op==TK_REGISTER || op==TK_TRIGGER) + ){ /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally ** a TK_COLUMN but was previously evaluated and cached in a register */ - const char *zColl; int j = p->iColumn; if( j>=0 ){ - sqlite3 *db = pParse->db; - zColl = p->pTab->aCol[j].zColl; + const char *zColl = p->pTab->aCol[j].zColl; pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); - pExpr->pColl = pColl; } break; } - if( op!=TK_CAST && op!=TK_UPLUS ){ + if( p->flags & EP_Collate ){ + if( p->pLeft->flags & EP_Collate ){ + p = p->pLeft; + }else{ + p = p->pRight; + } + }else{ break; } - p = p->pLeft; +#if 0 + else if( p->flags & EP_TokenOnly ){ + break; + }else{ + pColl = sqlite3ExprCollSeq(pParse, p->pLeft); + p = p->pRight; + } +#endif } if( sqlite3CheckCollSeq(pParse, pColl) ){ pColl = 0; @@ -219,12 +225,10 @@ CollSeq *sqlite3BinaryCompareCollSeq( ){ CollSeq *pColl; assert( pLeft ); - if( pLeft->flags & EP_ExpCollate ){ - assert( pLeft->pColl ); - pColl = pLeft->pColl; - }else if( pRight && pRight->flags & EP_ExpCollate ){ - assert( pRight->pColl ); - pColl = pRight->pColl; + if( pLeft->flags & EP_Collate ){ + pColl = sqlite3ExprCollSeq(pParse, pLeft); + }else if( pRight && (pRight->flags & EP_Collate)!=0 ){ + pColl = sqlite3ExprCollSeq(pParse, pRight); }else{ pColl = sqlite3ExprCollSeq(pParse, pLeft); if( !pColl ){ @@ -454,17 +458,11 @@ void sqlite3ExprAttachSubtrees( }else{ if( pRight ){ pRoot->pRight = pRight; - if( pRight->flags & EP_ExpCollate ){ - pRoot->flags |= EP_ExpCollate; - pRoot->pColl = pRight->pColl; - } + pRoot->flags |= EP_Collate & pRight->flags; } if( pLeft ){ pRoot->pLeft = pLeft; - if( pLeft->flags & EP_ExpCollate ){ - pRoot->flags |= EP_ExpCollate; - pRoot->pColl = pLeft->pColl; - } + pRoot->flags |= EP_Collate & pLeft->flags; } exprSetHeight(pRoot); } @@ -722,7 +720,7 @@ static int dupedExprStructSize(Expr *p, int flags){ assert( !ExprHasProperty(p, EP_FromJoin) ); assert( (p->flags2 & EP2_MallocedToken)==0 ); assert( (p->flags2 & EP2_Irreducible)==0 ); - if( p->pLeft || p->pRight || p->pColl || p->x.pList ){ + if( p->pLeft || p->pRight || p->x.pList ){ nSize = EXPR_REDUCEDSIZE | EP_Reduced; }else{ nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly; @@ -2746,6 +2744,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ sqlite3ReleaseTempReg(pParse, r4); break; } + case TK_COLLATE: case TK_UPLUS: { inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); break; @@ -3773,7 +3772,15 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB){ return 2; } if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2; - if( pA->op!=pB->op ) return 2; + if( pA->op!=pB->op ){ + if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){ + return 1; + } + if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){ + return 1; + } + return 2; + } if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2; if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2; if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2; @@ -3785,11 +3792,9 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB){ }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){ if( ExprHasProperty(pB, EP_IntValue) || NEVER(pB->u.zToken==0) ) return 2; if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ - return 2; + return pA->op==TK_COLLATE ? 1 : 2; } } - if( (pA->flags & EP_ExpCollate)!=(pB->flags & EP_ExpCollate) ) return 1; - if( (pA->flags & EP_ExpCollate)!=0 && pA->pColl!=pB->pColl ) return 2; return 0; } diff --git a/src/fkey.c b/src/fkey.c index a3214a94da..a120b7b2b3 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -516,7 +516,7 @@ static void fkScanChildren( if( pTab->iPKey==iCol ) iCol = -1; pLeft->iTable = regData+iCol+1; pLeft->affinity = pCol->affinity; - pLeft->pColl = sqlite3LocateCollSeq(pParse, pCol->zColl); + // fix me. pLeft->pColl = sqlite3LocateCollSeq(pParse, pCol->zColl); }else{ pLeft->iTable = regData; pLeft->affinity = SQLITE_AFF_INTEGER; diff --git a/src/resolve.c b/src/resolve.c index 0ffc633558..c2b0523f08 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -114,10 +114,6 @@ static void resolveAlias( pDup->flags2 |= EP2_MallocedToken; pDup->u.zToken = sqlite3DbStrDup(db, zToken); } - if( pExpr->flags & EP_ExpCollate ){ - pDup->pColl = pExpr->pColl; - pDup->flags |= EP_ExpCollate; - } /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This ** prevents ExprDelete() from deleting the Expr structure itself, @@ -830,13 +826,10 @@ static int resolveCompoundOrderBy( } } if( iCol>0 ){ - CollSeq *pColl = pE->pColl; - int flags = pE->flags & EP_ExpCollate; sqlite3ExprDelete(db, pE); pItem->pExpr = pE = sqlite3Expr(db, TK_INTEGER, 0); if( pE==0 ) return 1; - pE->pColl = pColl; - pE->flags |= EP_IntValue | flags; + pE->flags |= EP_IntValue; pE->u.iValue = iCol; pItem->iOrderByCol = (u16)iCol; pItem->done = 1; diff --git a/src/select.c b/src/select.c index cba766f99d..ee1755dbd8 100644 --- a/src/select.c +++ b/src/select.c @@ -2333,12 +2333,10 @@ static int multiSelectOrderBy( for(i=0; ia[i].pExpr; - if( pTerm->flags & EP_ExpCollate ){ - pColl = pTerm->pColl; + if( pTerm->flags & EP_Collate ){ + pColl = sqlite3ExprCollSeq(pParse, pTerm); }else{ pColl = multiSelectCollSeq(pParse, p, aPermute[i]); - pTerm->flags |= EP_ExpCollate; - pTerm->pColl = pColl; } pKeyMerge->aColl[i] = pColl; pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; @@ -2608,9 +2606,6 @@ static Expr *substExpr( assert( pEList!=0 && pExpr->iColumnnExpr ); assert( pExpr->pLeft==0 && pExpr->pRight==0 ); pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0); - if( pNew && pExpr->pColl ){ - pNew->pColl = pExpr->pColl; - } sqlite3ExprDelete(db, pExpr); pExpr = pNew; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b9b9e6c417..fc975bd3c3 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1678,7 +1678,6 @@ struct Expr { ExprList *pList; /* Function arguments or in " IN ( IN (