From 2aab11fa5a7eea97a0a7f2fcbbf2432b883c071a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 29 Apr 2016 20:30:56 +0000 Subject: [PATCH 001/302] Fix the temporary directory search algorithm for unix so that it fails gracefully even if all candidate directories are inaccessible. This fixes a bug that was introduced by check-in [9b8fec60d8e]. FossilOrigin-Name: 614bb709d34e11488da88861243023cc5de4b409 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/os_unix.c | 18 +++++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 79ea0c73d4..1bc788b248 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Postpone\sI/O\sassociated\swith\sTEMP\sfiles\sfor\sas\slong\sas\spossible,\swith\sthe\nhope\sthat\sthe\sI/O\scan\sultimately\sbe\savoided\scompletely. -D 2016-04-29T15:39:48.423 +C Fix\sthe\stemporary\sdirectory\ssearch\salgorithm\sfor\sunix\sso\sthat\sit\sfails\ngracefully\seven\sif\sall\scandidate\sdirectories\sare\sinaccessible.\s\sThis\sfixes\na\sbug\sthat\swas\sintroduced\sby\scheck-in\s[9b8fec60d8e]. +D 2016-04-29T20:30:56.115 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -361,7 +361,7 @@ F src/os.c 4d83917f072ad958fba9235136fa2ed43df47905 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 8422fba2eb592fbbb2d4006b6f2a67cad8951495 +F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c a8d30c49c231e9a20d05257613db922532588963 @@ -1486,8 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4cbd50245440e714935399a5c285cf32d8bfc424 b7bec7f2d3d08d0c14f77654be2c5cedf1619e58 -R f9ef4e1af8653e902d9192ffb04cabc2 -T +closed b7bec7f2d3d08d0c14f77654be2c5cedf1619e58 +P 9d0a5ae00273686ea35b43bc2ffaa8775c176363 +R a933a7d712b512086a1e3835745ceb3a U drh -Z 20681342134be4241c18925dab8e4f41 +Z 98ad5e2467f45a0f2dba904fa48c29d6 diff --git a/manifest.uuid b/manifest.uuid index fc6b7bfe05..d973fd4f41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d0a5ae00273686ea35b43bc2ffaa8775c176363 \ No newline at end of file +614bb709d34e11488da88861243023cc5de4b409 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 01de00e0dd..f5b01e9958 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5412,18 +5412,22 @@ static const char *unixTempFileDir(void){ "/tmp", "." }; - unsigned int i; + unsigned int i = 0; struct stat buf; const char *zDir = sqlite3_temp_directory; if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR"); if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); - for(i=0; i<=sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){ - if( zDir==0 ) continue; - if( osStat(zDir, &buf) ) continue; - if( !S_ISDIR(buf.st_mode) ) continue; - if( osAccess(zDir, 03) ) continue; - return zDir; + while(1){ + if( zDir!=0 + && osStat(zDir, &buf)==0 + && S_ISDIR(buf.st_mode) + && osAccess(zDir, 03)==0 + ){ + return zDir; + } + if( i>=sizeof(azDirs)/sizeof(azDirs[0]) ) break; + zDir = azDirs[i++]; } return 0; } From 99f5de771faee5c3bcf2ab8758e821220edf4867 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 30 Apr 2016 02:59:15 +0000 Subject: [PATCH 002/302] Simplifications to the OP_Halt opcode implementation. FossilOrigin-Name: daf4630f96f13133664908045e279da9d5a40bb5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 22 +++++++--------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 1bc788b248..c3be714871 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\stemporary\sdirectory\ssearch\salgorithm\sfor\sunix\sso\sthat\sit\sfails\ngracefully\seven\sif\sall\scandidate\sdirectories\sare\sinaccessible.\s\sThis\sfixes\na\sbug\sthat\swas\sintroduced\sby\scheck-in\s[9b8fec60d8e]. -D 2016-04-29T20:30:56.115 +C Simplifications\sto\sthe\sOP_Halt\sopcode\simplementation. +D 2016-04-30T02:59:15.737 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -443,7 +443,7 @@ F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 08fbea00a7f7f723973093c5f5bf7c40c025e2b3 +F src/vdbe.c b2067cd06a0f30a6dea865f93c690df15e0314a8 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9d0a5ae00273686ea35b43bc2ffaa8775c176363 -R a933a7d712b512086a1e3835745ceb3a +P 614bb709d34e11488da88861243023cc5de4b409 +R b15a9da5ab52f0ada1f3249ae1287c3e U drh -Z 98ad5e2467f45a0f2dba904fa48c29d6 +Z 574106fd28e4252d413254df9dee5be2 diff --git a/manifest.uuid b/manifest.uuid index d973fd4f41..5bb7f4d874 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -614bb709d34e11488da88861243023cc5de4b409 \ No newline at end of file +daf4630f96f13133664908045e279da9d5a40bb5 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 5fba14a5c3..cb977e0854 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -949,8 +949,6 @@ case OP_HaltIfNull: { /* in3 */ ** is the same as executing Halt. */ case OP_Halt: { - const char *zType; - const char *zLogFmt; VdbeFrame *pFrame; int pcx; @@ -979,34 +977,28 @@ case OP_Halt: { p->rc = pOp->p1; p->errorAction = (u8)pOp->p2; p->pc = pcx; + assert( pOp->p5>=0 && pOp->p5<=4 ); if( p->rc ){ if( pOp->p5 ){ static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", "FOREIGN KEY" }; - assert( pOp->p5>=1 && pOp->p5<=4 ); testcase( pOp->p5==1 ); testcase( pOp->p5==2 ); testcase( pOp->p5==3 ); testcase( pOp->p5==4 ); - zType = azType[pOp->p5-1]; + sqlite3VdbeError(p, "%s constraint failed", azType[pOp->p5-1]); + if( pOp->p4.z ){ + p->zErrMsg = sqlite3MPrintf(db, "%z: %s", p->zErrMsg, pOp->p4.z); + } }else{ - zType = 0; - } - assert( zType!=0 || pOp->p4.z!=0 ); - zLogFmt = "abort at %d in [%s]: %s"; - if( zType && pOp->p4.z ){ - sqlite3VdbeError(p, "%s constraint failed: %s", zType, pOp->p4.z); - }else if( pOp->p4.z ){ sqlite3VdbeError(p, "%s", pOp->p4.z); - }else{ - sqlite3VdbeError(p, "%s constraint failed", zType); } - sqlite3_log(pOp->p1, zLogFmt, pcx, p->zSql, p->zErrMsg); + sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pcx, p->zSql, p->zErrMsg); } rc = sqlite3VdbeHalt(p); assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); if( rc==SQLITE_BUSY ){ - p->rc = rc = SQLITE_BUSY; + p->rc = SQLITE_BUSY; }else{ assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT ); assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 ); From 2e55b04da45c2fb17a0464f0480af33082c23810 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 30 Apr 2016 17:19:30 +0000 Subject: [PATCH 003/302] More bug fixes to Lemon identified by Kelvin Sherlock. None of these have any impact on SQLite. FossilOrigin-Name: 762bdc55f8878ee2ef65af2165a8e7fdbddf0160 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 23 ++++++++++++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index c3be714871..c82cd48e76 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\sOP_Halt\sopcode\simplementation. -D 2016-04-30T02:59:15.737 +C More\sbug\sfixes\sto\sLemon\sidentified\sby\sKelvin\sSherlock.\s\sNone\sof\sthese\nhave\sany\simpact\son\sSQLite. +D 2016-04-30T17:19:30.162 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1416,7 +1416,7 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 83318dff3911e47f2b85e136e56aa1c4674a2d2b +F tool/lemon.c f38a55106d79b7a4c063abb958517d6c47dc6ac7 F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 614bb709d34e11488da88861243023cc5de4b409 -R b15a9da5ab52f0ada1f3249ae1287c3e +P daf4630f96f13133664908045e279da9d5a40bb5 +R abf1ac3c7e03f177ba74945ccc38d922 U drh -Z 574106fd28e4252d413254df9dee5be2 +Z cfd7bc89828187e9540e8e1e6f984687 diff --git a/manifest.uuid b/manifest.uuid index 5bb7f4d874..03d710e202 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -daf4630f96f13133664908045e279da9d5a40bb5 \ No newline at end of file +762bdc55f8878ee2ef65af2165a8e7fdbddf0160 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 2f76465d89..01c8a1da96 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -3556,14 +3556,11 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ } - if( rp->lhsalias==0 ){ - /* There is no LHS value symbol. */ - lhsdirect = 1; - }else if( rp->nrhs==0 ){ + if( rp->nrhs==0 ){ /* If there are no RHS symbols, then writing directly to the LHS is ok */ lhsdirect = 1; }else if( rp->rhsalias[0]==0 ){ - /* The left-most RHS symbol has not value. LHS direct is ok. But + /* The left-most RHS symbol has no value. LHS direct is ok. But ** we have to call the distructor on the RHS symbol first. */ lhsdirect = 1; if( has_destructor(rp->rhs[0],lemp) ){ @@ -3572,6 +3569,9 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ rp->rhs[0]->index,1-rp->nrhs); rp->codePrefix = Strsafe(append_str(0,0,0,0)); } + }else if( rp->lhsalias==0 ){ + /* There is no LHS value symbol. */ + lhsdirect = 1; }else if( strcmp(rp->lhsalias,rp->rhsalias[0])==0 ){ /* The LHS symbol and the left-most RHS symbol are the same, so ** direct writing is allowed */ @@ -3715,7 +3715,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ /* Suffix code generation complete */ cp = append_str(0,0,0,0); - if( cp ) rp->codeSuffix = Strsafe(cp); + if( cp && cp[0] ) rp->codeSuffix = Strsafe(cp); return rc; } @@ -4397,7 +4397,14 @@ void ReportTable( for(rp=lemp->rule; rp; rp=rp->next){ struct rule *rp2; /* Other rules with the same action */ if( rp->code==0 ) continue; - if( rp->code[0]=='\n' && rp->code[1]==0 ) continue; /* Will be default: */ + if( rp->code[0]=='\n' + && rp->code[1]==0 + && rp->codePrefix==0 + && rp->codeSuffix==0 + ){ + /* No actions, so this will be part of the "default:" rule */ + continue; + } fprintf(out," case %d: /* ", rp->iRule); writeRuleText(out, rp); fprintf(out, " */\n"); lineno++; @@ -4420,6 +4427,8 @@ void ReportTable( for(rp=lemp->rule; rp; rp=rp->next){ if( rp->code==0 ) continue; assert( rp->code[0]=='\n' && rp->code[1]==0 ); + assert( rp->codePrefix==0 ); + assert( rp->codeSuffix==0 ); fprintf(out," /* (%d) ", rp->iRule); writeRuleText(out, rp); fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++; From 2f55511dfa0ff9ad1c82a918ea62a7be236420cb Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 30 Apr 2016 18:10:34 +0000 Subject: [PATCH 004/302] Remove an unnecessary branch from the OP_String8 opcode. FossilOrigin-Name: 459a0b456da69112605b37adc9af27d79e35a4d7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 7 +++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index c82cd48e76..fe30409fc4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\sbug\sfixes\sto\sLemon\sidentified\sby\sKelvin\sSherlock.\s\sNone\sof\sthese\nhave\sany\simpact\son\sSQLite. -D 2016-04-30T17:19:30.162 +C Remove\san\sunnecessary\sbranch\sfrom\sthe\sOP_String8\sopcode. +D 2016-04-30T18:10:34.585 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -443,7 +443,7 @@ F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c b2067cd06a0f30a6dea865f93c690df15e0314a8 +F src/vdbe.c 465bb820f9760602959ba8d279cdae621206d696 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P daf4630f96f13133664908045e279da9d5a40bb5 -R abf1ac3c7e03f177ba74945ccc38d922 +P 762bdc55f8878ee2ef65af2165a8e7fdbddf0160 +R c6bd6d9832f41be3a84777fb9beacd97 U drh -Z cfd7bc89828187e9540e8e1e6f984687 +Z beaad3433e5488a905014b307adfe5b7 diff --git a/manifest.uuid b/manifest.uuid index 03d710e202..c3f171f13c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -762bdc55f8878ee2ef65af2165a8e7fdbddf0160 \ No newline at end of file +459a0b456da69112605b37adc9af27d79e35a4d7 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index cb977e0854..469ab86e42 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1064,10 +1064,7 @@ case OP_String8: { /* same as TK_STRING, out2 */ #ifndef SQLITE_OMIT_UTF16 if( encoding!=SQLITE_UTF8 ){ rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC); - if( rc ){ - assert( rc==SQLITE_TOOBIG ); /* This is the only possible error here */ - goto too_big; - } + assert( rc==SQLITE_OK || rc==SQLITE_TOOBIG ); if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem; assert( pOut->szMalloc>0 && pOut->zMalloc==pOut->z ); assert( VdbeMemDynamic(pOut)==0 ); @@ -1080,10 +1077,12 @@ case OP_String8: { /* same as TK_STRING, out2 */ pOp->p4.z = pOut->z; pOp->p1 = pOut->n; } + testcase( rc==SQLITE_TOOBIG ); #endif if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){ goto too_big; } + assert( rc==SQLITE_OK ); /* Fall through to the next case, OP_String */ } From 40cf36ff1756a3c65f9569afeae4066bbb5aed41 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 30 Apr 2016 19:23:10 +0000 Subject: [PATCH 005/302] Change the way tester.tcl handes $argv so that in "permutations.test " may be the name of any file in the test/ directory. FossilOrigin-Name: 820c57bb24ad3d8663ca512e4022268b940bb2ee --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/tester.tcl | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index fe30409fc4..ec489b353d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\sbranch\sfrom\sthe\sOP_String8\sopcode. -D 2016-04-30T18:10:34.585 +C Change\sthe\sway\stester.tcl\shandes\s$argv\sso\sthat\sin\s"permutations.test\s\s"\s\smay\sbe\sthe\sname\sof\sany\sfile\sin\sthe\stest/\sdirectory. +D 2016-04-30T19:23:10.056 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1115,7 +1115,7 @@ F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test c3d8c138f493207612960bbd6a8c50e84975e2ee F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl 30c7a9be8601d1c1c9c93d013545ebcb28d64254 +F test/tester.tcl 3ace46dee55f07e28a1e3ab03258b929fefcee5b F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 762bdc55f8878ee2ef65af2165a8e7fdbddf0160 -R c6bd6d9832f41be3a84777fb9beacd97 -U drh -Z beaad3433e5488a905014b307adfe5b7 +P 459a0b456da69112605b37adc9af27d79e35a4d7 +R 23212a22e435d3100aef78ab9c45b327 +U dan +Z 034fcb062ad20342a7b230d87b3ffc20 diff --git a/manifest.uuid b/manifest.uuid index c3f171f13c..6ff03c7829 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -459a0b456da69112605b37adc9af27d79e35a4d7 \ No newline at end of file +820c57bb24ad3d8663ca512e4022268b940bb2ee \ No newline at end of file diff --git a/test/tester.tcl b/test/tester.tcl index 23810d09ee..9fbc7b2569 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -521,7 +521,11 @@ if {[info exists cmdlinearg]==0} { } default { - lappend leftover [file normalize $a] + if {[file tail $a]==$a} { + lappend leftover $a + } else { + lappend leftover [file normalize $a] + } } } } From 44aebff24623d6adc3e2977d1e95ad1a2353ea6d Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 May 2016 10:25:42 +0000 Subject: [PATCH 006/302] Improvements to the way the LIKE optimization is implemented, resulting in slightly smaller and faster code that is easier to test. FossilOrigin-Name: 54c63b329288729031f45b7778752552cd90e226 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/vdbe.c | 26 ++++++-------------------- src/where.c | 9 ++------- src/whereInt.h | 2 +- src/wherecode.c | 36 +++++++++++++++++++++++------------- 6 files changed, 43 insertions(+), 52 deletions(-) diff --git a/manifest b/manifest index ec489b353d..4b7ff45c68 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sway\stester.tcl\shandes\s$argv\sso\sthat\sin\s"permutations.test\s\s"\s\smay\sbe\sthe\sname\sof\sany\sfile\sin\sthe\stest/\sdirectory. -D 2016-04-30T19:23:10.056 +C Improvements\sto\sthe\sway\sthe\sLIKE\soptimization\sis\simplemented,\sresulting\sin\nslightly\ssmaller\sand\sfaster\scode\sthat\sis\seasier\sto\stest. +D 2016-05-02T10:25:42.392 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -443,7 +443,7 @@ F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 465bb820f9760602959ba8d279cdae621206d696 +F src/vdbe.c 4bad04212736526845fda9ca674afafb10078b2b F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -457,9 +457,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c bae50f2f18f9e8584549a77363858623b07e4915 -F src/whereInt.h 7de94b751f088fe3fdc8cc04a491376f0900a059 -F src/wherecode.c 8fdad9fbba723df1c1e8d07e7ea8507572040340 +F src/where.c 019e5b10dedcf54ef077ce23dd8fce38d614dcf4 +F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 +F src/wherecode.c 28951741be3974701186281ced0564e9586a0db3 F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 459a0b456da69112605b37adc9af27d79e35a4d7 -R 23212a22e435d3100aef78ab9c45b327 -U dan -Z 034fcb062ad20342a7b230d87b3ffc20 +P 820c57bb24ad3d8663ca512e4022268b940bb2ee +R c58e65d0f2e2d03ddd82d7f66bccab45 +U drh +Z 38f3015d7db64980369a2f7c9273004f diff --git a/manifest.uuid b/manifest.uuid index 6ff03c7829..d98c57c9ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -820c57bb24ad3d8663ca512e4022268b940bb2ee \ No newline at end of file +54c63b329288729031f45b7778752552cd90e226 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 469ab86e42..dc8201595b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1091,10 +1091,12 @@ case OP_String8: { /* same as TK_STRING, out2 */ ** ** The string value P4 of length P1 (bytes) is stored in register P2. ** -** If P5!=0 and the content of register P3 is greater than zero, then +** If P3 is not zero and the content of register P3 is equal to P5, then ** the datatype of the register P2 is converted to BLOB. The content is ** the same sequence of bytes, it is merely interpreted as a BLOB instead -** of a string, as if it had been CAST. +** of a string, as if it had been CAST. In other words: +** +** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) */ case OP_String: { /* out2 */ assert( pOp->p4.z!=0 ); @@ -1105,12 +1107,11 @@ case OP_String: { /* out2 */ pOut->enc = encoding; UPDATE_MAX_BLOBSIZE(pOut); #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS - if( pOp->p5 ){ - assert( pOp->p3>0 ); + if( pOp->p3>0 ){ assert( pOp->p3<=(p->nMem+1 - p->nCursor) ); pIn3 = &aMem[pOp->p3]; assert( pIn3->flags & MEM_Int ); - if( pIn3->u.i ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term; + if( pIn3->u.i==pOp->p5 ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term; } #endif break; @@ -5966,21 +5967,6 @@ case OP_DecrJumpZero: { /* jump, in1 */ } -/* Opcode: JumpZeroIncr P1 P2 * * * -** Synopsis: if (r[P1]++)==0 ) goto P2 -** -** The register P1 must contain an integer. If register P1 is initially -** zero, then jump to P2. Increment register P1 regardless of whether or -** not the jump is taken. -*/ -case OP_JumpZeroIncr: { /* jump, in1 */ - pIn1 = &aMem[pOp->p1]; - assert( pIn1->flags&MEM_Int ); - VdbeBranchTaken(pIn1->u.i==0, 2); - if( (pIn1->u.i++)==0 ) goto jump_to_p2; - break; -} - /* Opcode: AggStep0 * P2 P3 P4 P5 ** Synopsis: accum=r[P3] step(r[P2@P5]) ** diff --git a/src/where.c b/src/where.c index ca810a3b16..d45a872c85 100644 --- a/src/where.c +++ b/src/where.c @@ -4607,13 +4607,8 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ } #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS if( pLevel->addrLikeRep ){ - int op; - if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){ - op = OP_DecrJumpZero; - }else{ - op = OP_JumpZeroIncr; - } - sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep); + sqlite3VdbeAddOp2(v, OP_DecrJumpZero, (int)(pLevel->iLikeRepCntr>>1), + pLevel->addrLikeRep); VdbeCoverage(v); } #endif diff --git a/src/whereInt.h b/src/whereInt.h index 252905aa5a..d33d995af1 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -70,7 +70,7 @@ struct WhereLevel { int addrFirst; /* First instruction of interior of the loop */ int addrBody; /* Beginning of the body of this loop */ #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS - int iLikeRepCntr; /* LIKE range processing counter register */ + u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */ int addrLikeRep; /* LIKE range processing address */ #endif u8 iFrom; /* Which entry in the FROM clause */ diff --git a/src/wherecode.c b/src/wherecode.c index 8105e99dde..77543a9388 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -560,9 +560,10 @@ static int codeAllEqualityTerms( #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS /* -** If the most recently coded instruction is a constant range contraint -** that originated from the LIKE optimization, then change the P3 to be -** pLoop->iLikeRepCntr and set P5. +** If the most recently coded instruction is a constant range constraint +** (a string literal) that originated from the LIKE optimization, then +** set P3 and P5 on the OP_String opcode so that the string will be cast +** to a BLOB at appropriate times. ** ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range ** expression: "x>='ABC' AND x<'abd'". But this requires that the range @@ -587,8 +588,8 @@ static void whereLikeOptimizationStringFixup( assert( pOp!=0 ); assert( pOp->opcode==OP_String8 || pTerm->pWC->pWInfo->pParse->db->mallocFailed ); - pOp->p3 = pLevel->iLikeRepCntr; - pOp->p5 = 1; + pOp->p3 = (int)(pLevel->iLikeRepCntr>>1); /* Register holding counter */ + pOp->p5 = (u8)(pLevel->iLikeRepCntr&1); /* ASC or DESC */ } } #else @@ -1175,14 +1176,17 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){ assert( pRangeStart!=0 ); /* LIKE opt constraints */ assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */ - pLevel->iLikeRepCntr = ++pParse->nMem; - testcase( bRev ); - testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC ); - sqlite3VdbeAddOp2(v, OP_Integer, - bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC), - pLevel->iLikeRepCntr); + pLevel->iLikeRepCntr = (u32)++pParse->nMem; + sqlite3VdbeAddOp2(v, OP_Integer, 1, (int)pLevel->iLikeRepCntr); VdbeComment((v, "LIKE loop counter")); pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v); + /* iLikeRepCntr actually stores 2x the counter register number. The + ** bottom bit indicates whether the search order is ASC or DESC. */ + testcase( bRev ); + testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC ); + assert( (bRev & ~1)==0 ); + pLevel->iLikeRepCntr <<=1; + pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC); } #endif if( pRangeStart==0 @@ -1696,11 +1700,17 @@ Bitmask sqlite3WhereCodeOneLoopStart( continue; } if( pTerm->wtFlags & TERM_LIKECOND ){ + /* If the TERM_LIKECOND flag is set, that means that the range search + ** is sufficient to guarantee that the LIKE operator is true, so we + ** can skip the call to the like(A,B) function. But this only works + ** for strings. So do not skip the call to the function on the pass + ** that compares BLOBs. */ #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS continue; #else - assert( pLevel->iLikeRepCntr>0 ); - skipLikeAddr = sqlite3VdbeAddOp1(v, OP_IfNot, pLevel->iLikeRepCntr); + u32 x = pLevel->iLikeRepCntr; + assert( x>0 ); + skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)? OP_IfNot : OP_If, (int)(x>>1)); VdbeCoverage(v); #endif } From 57a07ba9a938ead154cc629a8357cb025b14a7b1 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 May 2016 12:18:56 +0000 Subject: [PATCH 007/302] Disable the multi-row one-pass DELETE optimization when the WHERE clause contains a subquery. Fix for ticket [dc6ebeda9396087]. FossilOrigin-Name: 3f221f592a9a19009076e568566c59801cd3fc32 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/delete.c | 5 +++-- test/delete4.test | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4b7ff45c68..1b3f03c036 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sway\sthe\sLIKE\soptimization\sis\simplemented,\sresulting\sin\nslightly\ssmaller\sand\sfaster\scode\sthat\sis\seasier\sto\stest. -D 2016-05-02T10:25:42.392 +C Disable\sthe\smulti-row\sone-pass\sDELETE\soptimization\swhen\sthe\sWHERE\sclause\ncontains\sa\ssubquery.\s\sFix\sfor\sticket\s[dc6ebeda9396087]. +D 2016-05-02T12:18:56.634 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -330,7 +330,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b -F src/delete.c 78eb999114ec04fcf1b7d123ccedb4b5b734930e +F src/delete.c 362f89f8e6783e672c4ab06b90fca0177f9a576d F src/expr.c 8796c0739b2ad091e6779253f62aad6e767e2be1 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb @@ -617,7 +617,7 @@ F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab -F test/delete4.test 738044ee892ee0c84e0848e36ba92c55f907d52b +F test/delete4.test 21d2113217eeaacac2d99defe14fe6611615ae86 F test/descidx1.test 6d03b44c8538fe0eb4924e19fba10cdd8f3c9240 F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d F test/descidx3.test 09ddbe3f5295f482d2f8b687cf6db8bad7acd9a2 @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 820c57bb24ad3d8663ca512e4022268b940bb2ee -R c58e65d0f2e2d03ddd82d7f66bccab45 +P 54c63b329288729031f45b7778752552cd90e226 +R 31fbd50c446b686ccdad6a76f26cbea2 U drh -Z 38f3015d7db64980369a2f7c9273004f +Z 89acbaae560b0638ea30c0a72d46ae74 diff --git a/manifest.uuid b/manifest.uuid index d98c57c9ad..a267b82408 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54c63b329288729031f45b7778752552cd90e226 \ No newline at end of file +3f221f592a9a19009076e568566c59801cd3fc32 \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index e3af2d7a78..258b39cc3e 100644 --- a/src/delete.c +++ b/src/delete.c @@ -239,11 +239,12 @@ void sqlite3DeleteFrom( int addrBypass = 0; /* Address of jump over the delete logic */ int addrLoop = 0; /* Top of the delete loop */ int addrEphOpen = 0; /* Instruction to open the Ephemeral table */ + int bComplex; /* True if there are triggers or FKs or or + ** subqueries in the WHERE clause */ #ifndef SQLITE_OMIT_TRIGGER int isView; /* True if attempting to delete from a view */ Trigger *pTrigger; /* List of table triggers, if required */ - int bComplex; /* True if there are either triggers or FKs */ #endif memset(&sContext, 0, sizeof(sContext)); @@ -271,7 +272,6 @@ void sqlite3DeleteFrom( #else # define pTrigger 0 # define isView 0 -# define bComplex 0 #endif #ifdef SQLITE_OMIT_VIEW # undef isView @@ -374,6 +374,7 @@ void sqlite3DeleteFrom( #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ { u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; + if( pWhere && ExprHasProperty(pWhere, EP_Subquery) ) bComplex = 1; wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW); if( HasRowid(pTab) ){ /* For a rowid table, initialize the RowSet to an empty set */ diff --git a/test/delete4.test b/test/delete4.test index 7622b7525e..34ba9aaef8 100644 --- a/test/delete4.test +++ b/test/delete4.test @@ -161,4 +161,27 @@ do_execsql_test 5.0 { SELECT a FROM t1 WHERE b=2; } {} +# 2016-05-02 +# Ticket https://www.sqlite.org/src/tktview/dc6ebeda93960877 +# A subquery in the WHERE clause of a one-pass DELETE can cause an +# incorrect answer. +# +db close +forcedelete test.db +sqlite3 db test.db +do_execsql_test 6.0 { + CREATE TABLE t2(x INT); + INSERT INTO t2(x) VALUES(1),(2),(3),(4),(5); + DELETE FROM t2 WHERE EXISTS(SELECT 1 FROM t2 AS v WHERE v.x=t2.x-1); + SELECT x FROM t2; +} {1} +do_execsql_test 6.1 { + DROP TABLE IF EXISTS t2; + CREATE TABLE t2(x INT); + INSERT INTO t2(x) VALUES(1),(2),(3),(4),(5); + DELETE FROM t2 WHERE EXISTS(SELECT 1 FROM t2 AS v WHERE v.x=t2.x+1); + SELECT x FROM t2; +} {5} + + finish_test From cf7e7557b59bbab2c512615aa9d02a896c7e08de Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 May 2016 13:57:19 +0000 Subject: [PATCH 008/302] Fix harmless LLVM compiler warnings in the srcck1.c utility program used during the build process. FossilOrigin-Name: e4af967533f290862dfba1d9ef44d4c9ddd8a01b --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/srcck1.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 1b3f03c036..8fad26fa93 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\smulti-row\sone-pass\sDELETE\soptimization\swhen\sthe\sWHERE\sclause\ncontains\sa\ssubquery.\s\sFix\sfor\sticket\s[dc6ebeda9396087]. -D 2016-05-02T12:18:56.634 +C Fix\sharmless\sLLVM\scompiler\swarnings\sin\sthe\ssrcck1.c\sutility\sprogram\sused\nduring\sthe\sbuild\sprocess. +D 2016-05-02T13:57:19.631 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1454,7 +1454,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/sqldiff.c ca315aca4e2d24233e8f2000edea5880c53d1875 -F tool/srcck1.c 4f65e1a6748e42f24c0ea629dddc934d821c729a +F tool/srcck1.c 4c39bdfa9a92edd20233ee720df84dbeb2417602 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh c5a617b8c61a0926747a56c65f5671ef8ac0e148 @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 54c63b329288729031f45b7778752552cd90e226 -R 31fbd50c446b686ccdad6a76f26cbea2 +P 3f221f592a9a19009076e568566c59801cd3fc32 +R 9e19502e796cc0b447ced5695bd13d5a U drh -Z 89acbaae560b0638ea30c0a72d46ae74 +Z 98cb934422c4b3de5638d36de23360d8 diff --git a/manifest.uuid b/manifest.uuid index a267b82408..b95adc4417 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3f221f592a9a19009076e568566c59801cd3fc32 \ No newline at end of file +e4af967533f290862dfba1d9ef44d4c9ddd8a01b \ No newline at end of file diff --git a/tool/srcck1.c b/tool/srcck1.c index f92610f544..e95765185f 100644 --- a/tool/srcck1.c +++ b/tool/srcck1.c @@ -111,11 +111,11 @@ static unsigned int findCloseParen(const char *z){ ** Print error messages whenever a side effect is found. Return the number ** of problems seen. */ -static unsigned int findAllSideEffects(const unsigned char *z){ +static unsigned int findAllSideEffects(const char *z){ unsigned int lineno = 1; /* Line number */ unsigned int i; unsigned int nErr = 0; - unsigned char c, prevC = 0; + char c, prevC = 0; for(i=0; (c = z[i])!=0; prevC=c, i++){ if( c=='\n' ){ lineno++; continue; } if( isalpha(c) && !isalpha(prevC) ){ @@ -125,7 +125,7 @@ static unsigned int findAllSideEffects(const unsigned char *z){ || strncmp(&z[i],"testcase(",9)==0 ){ unsigned int n; - unsigned const char *z2 = &z[i+5]; + const char *z2 = &z[i+5]; while( z2[0]!='(' ){ z2++; } z2++; n = findCloseParen(z2); @@ -141,7 +141,7 @@ static unsigned int findAllSideEffects(const unsigned char *z){ } int main(int argc, char **argv){ - unsigned char *z; + char *z; unsigned int nErr = 0; if( argc!=2 ){ fprintf(stderr, "Usage: %s FILENAME\n", argv[0]); From b1c6995c58cc3ab59539a6a2254045dad9877ef7 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 May 2016 16:59:49 +0000 Subject: [PATCH 009/302] Fix a test case in temptable2.test so that it works on systems that lack a coherient cache (ex: OpenBSD) and thus do not support the "PRAGMA mmap_size" command. FossilOrigin-Name: 088cf83872f6477c3b297c58d6f8a5def7025daf --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/temptable2.test | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 8fad26fa93..d418547198 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\sLLVM\scompiler\swarnings\sin\sthe\ssrcck1.c\sutility\sprogram\sused\nduring\sthe\sbuild\sprocess. -D 2016-05-02T13:57:19.631 +C Fix\sa\stest\scase\sin\stemptable2.test\sso\sthat\sit\sworks\son\ssystems\sthat\nlack\sa\scoherient\scache\s(ex:\sOpenBSD)\sand\sthus\sdo\snot\ssupport\sthe\n"PRAGMA\smmap_size"\scommand. +D 2016-05-02T16:59:49.933 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1113,7 +1113,7 @@ F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 -F test/temptable2.test c3d8c138f493207612960bbd6a8c50e84975e2ee +F test/temptable2.test efeb3ce7aaf515a1f8ebf5e27390426fb977f998 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 F test/tester.tcl 3ace46dee55f07e28a1e3ab03258b929fefcee5b F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3f221f592a9a19009076e568566c59801cd3fc32 -R 9e19502e796cc0b447ced5695bd13d5a +P e4af967533f290862dfba1d9ef44d4c9ddd8a01b +R cf9611bb2e200af1ab3bcf6e6340a559 U drh -Z 98cb934422c4b3de5638d36de23360d8 +Z af0809554b03e07ad79015deb62b6895 diff --git a/manifest.uuid b/manifest.uuid index b95adc4417..d5de45a24b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e4af967533f290862dfba1d9ef44d4c9ddd8a01b \ No newline at end of file +088cf83872f6477c3b297c58d6f8a5def7025daf \ No newline at end of file diff --git a/test/temptable2.test b/test/temptable2.test index 890b3b996d..72bcf1ac50 100644 --- a/test/temptable2.test +++ b/test/temptable2.test @@ -343,14 +343,15 @@ do_execsql_test 10.1 { INSERT INTO t2 VALUES(3, 4); } -if {[permutation]!="journaltest"} { - # The journaltest permutation does not support mmap, so this part of - # the test is omitted. - do_execsql_test 10.2 { PRAGMA mmap_size = 512000 } 512000 +ifcapable mmap { + if {[permutation]!="journaltest"} { + # The journaltest permutation does not support mmap, so this part of + # the test is omitted. + do_execsql_test 10.2 { PRAGMA mmap_size = 512000 } 512000 + } } do_execsql_test 10.3 { SELECT * FROM t2 } {1 2 3 4} do_execsql_test 10.4 { PRAGMA integrity_check } ok finish_test - From 39f98c52d023e0503196864c2090b6369af1effd Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 2 May 2016 19:05:05 +0000 Subject: [PATCH 010/302] Remove some randomness from test script temptable2.test. FossilOrigin-Name: 5830cf72e9e870830d088399f1ccb03ed6522582 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/temptable2.test | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d418547198..95c5a353ec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sin\stemptable2.test\sso\sthat\sit\sworks\son\ssystems\sthat\nlack\sa\scoherient\scache\s(ex:\sOpenBSD)\sand\sthus\sdo\snot\ssupport\sthe\n"PRAGMA\smmap_size"\scommand. -D 2016-05-02T16:59:49.933 +C Remove\ssome\srandomness\sfrom\stest\sscript\stemptable2.test. +D 2016-05-02T19:05:05.108 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -1113,7 +1113,7 @@ F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 -F test/temptable2.test efeb3ce7aaf515a1f8ebf5e27390426fb977f998 +F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 F test/tester.tcl 3ace46dee55f07e28a1e3ab03258b929fefcee5b F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e4af967533f290862dfba1d9ef44d4c9ddd8a01b -R cf9611bb2e200af1ab3bcf6e6340a559 -U drh -Z af0809554b03e07ad79015deb62b6895 +P 088cf83872f6477c3b297c58d6f8a5def7025daf +R 237f2aea599511d792221ce999e030ab +U dan +Z f86754e59f932bdb68bb3e5db8c95fe0 diff --git a/manifest.uuid b/manifest.uuid index d5de45a24b..8a1882b583 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -088cf83872f6477c3b297c58d6f8a5def7025daf \ No newline at end of file +5830cf72e9e870830d088399f1ccb03ed6522582 \ No newline at end of file diff --git a/test/temptable2.test b/test/temptable2.test index 72bcf1ac50..ffa69b6150 100644 --- a/test/temptable2.test +++ b/test/temptable2.test @@ -230,7 +230,7 @@ do_execsql_test 8.1 { CREATE TABLE t2(a, b); CREATE INDEX i2 ON t2(a, b); WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<20 ) - INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x; + INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x ORDER BY 1, 2; PRAGMA page_count; } {13} @@ -242,7 +242,7 @@ do_test 8.2 { CREATE TABLE t1(a, b); CREATE INDEX i1 ON t1(a, b); WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100 ) - INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x; + INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x ORDER BY 1, 2; PRAGMA page_count; } tmp } {10} From 48cd59a57d680b53b9fca3b74058c594040d4e8d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 3 May 2016 00:04:55 +0000 Subject: [PATCH 011/302] Avoid left-shifts of signed integers. FossilOrigin-Name: 0715ce164333e27671efbec8796f238df98cc287 --- ext/session/sqlite3session.c | 15 +++++++-------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test1.c | 8 ++++---- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index e333dffcc7..70ca840dae 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -278,19 +278,18 @@ static int sessionVarintGet(u8 *aBuf, int *piVal){ return getVarint32(aBuf, *piVal); } +/* Load an unaligned and unsigned 32-bit integer */ +#define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]) + /* ** Read a 64-bit big-endian integer value from buffer aRec[]. Return ** the value read. */ static sqlite3_int64 sessionGetI64(u8 *aRec){ - return (((sqlite3_int64)aRec[0]) << 56) - + (((sqlite3_int64)aRec[1]) << 48) - + (((sqlite3_int64)aRec[2]) << 40) - + (((sqlite3_int64)aRec[3]) << 32) - + (((sqlite3_int64)aRec[4]) << 24) - + (((sqlite3_int64)aRec[5]) << 16) - + (((sqlite3_int64)aRec[6]) << 8) - + (((sqlite3_int64)aRec[7]) << 0); + u64 x = SESSION_UINT32(aRec); + u32 y = SESSION_UINT32(aRec+4); + x = (x<<32) + y; + return (sqlite3_int64)x; } /* diff --git a/manifest b/manifest index 95c5a353ec..27faecd64e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\srandomness\sfrom\stest\sscript\stemptable2.test. -D 2016-05-02T19:05:05.108 +C Avoid\sleft-shifts\sof\ssigned\sintegers. +D 2016-05-03T00:04:55.196 F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 @@ -293,7 +293,7 @@ F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 F ext/session/session_common.tcl a1293167d14774b5e728836720497f40fe4ea596 F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 -F ext/session/sqlite3session.c beb43b6b888801bb006320bc236baa95f4cc32ae +F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 F ext/session/sqlite3session.h 64e9e7f185725ef43b97f4a9a0c0df0669844f1d F ext/session/test_session.c 464f2c8bf502795d95969387eb8e93f68c513c15 F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 @@ -387,7 +387,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 -F src/test1.c ee8fd5c32acb93fb6fe885ca4801cfab85f5563f +F src/test1.c c0e5b69f99e95a2c9f55fdb6e46b44f1a15292d8 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c 0df6f8dbb4cbaa7106397c70a271fa6a43659042 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 088cf83872f6477c3b297c58d6f8a5def7025daf -R 237f2aea599511d792221ce999e030ab -U dan -Z f86754e59f932bdb68bb3e5db8c95fe0 +P 5830cf72e9e870830d088399f1ccb03ed6522582 +R 350580348db69c537adc1a64222fc40a +U drh +Z 10c9aec7cf14a46e7039005f7f038452 diff --git a/manifest.uuid b/manifest.uuid index 8a1882b583..9202d19d19 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5830cf72e9e870830d088399f1ccb03ed6522582 \ No newline at end of file +0715ce164333e27671efbec8796f238df98cc287 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 5b7581af7b..ee71b854b9 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6700,8 +6700,8 @@ static int sorter_test_sort4_helper( const char *zSql2; int nStep; int iStep; - int iCksum1 = 0; - int iCksum2 = 0; + unsigned int iCksum1 = 0; + unsigned int iCksum2 = 0; int rc; int iB; sqlite3 *db; @@ -6728,7 +6728,7 @@ static int sorter_test_sort4_helper( return TCL_ERROR; } - iCksum1 += (iCksum1 << 3) + a; + iCksum1 += (iCksum1 << 3) + (unsigned int)a; } rc = sqlite3_finalize(pStmt); if( rc!=SQLITE_OK ) goto sql_error; @@ -6737,7 +6737,7 @@ static int sorter_test_sort4_helper( if( rc!=SQLITE_OK ) goto sql_error; for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){ int a = sqlite3_column_int(pStmt, 0); - iCksum2 += (iCksum2 << 3) + a; + iCksum2 += (iCksum2 << 3) + (unsigned int)a; } rc = sqlite3_finalize(pStmt); if( rc!=SQLITE_OK ) goto sql_error; From 5e18d402007272ff2b305f066ed67dba92b2f155 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 3 May 2016 13:14:18 +0000 Subject: [PATCH 012/302] Turn the session extension off by default. Enable using --enable-session on configure scripts, or using the SESSION=1 argument to nmake on Windows. FossilOrigin-Name: e462cde2a50c39cc2f8d8624aada19280b8226eb --- Makefile.in | 1 - Makefile.msc | 9 +++++++++ autoconf/Makefile.am | 2 +- autoconf/Makefile.msc | 9 +++++++++ autoconf/configure.ac | 12 ++++++++++++ configure | 44 +++++++++++++++++++++++++++++-------------- configure.ac | 10 ++++++++++ manifest | 29 +++++++++++++++------------- manifest.uuid | 2 +- test/releasetest.tcl | 7 +++++-- 10 files changed, 93 insertions(+), 32 deletions(-) diff --git a/Makefile.in b/Makefile.in index e4687626f0..78480de9e0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -82,7 +82,6 @@ TEMP_STORE = -DSQLITE_TEMP_STORE=@TEMP_STORE@ # The same set of OMIT and ENABLE flags should be passed to the # LEMON parser generator and the mkkeywordhash tool as well. OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@ -OPT_FEATURE_FLAGS += -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK TCC += $(OPT_FEATURE_FLAGS) diff --git a/Makefile.msc b/Makefile.msc index e65f99d758..3eb50c1eae 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -264,6 +264,15 @@ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 +!ENDIF + +# Enable support for the session extension if the SESSION=1 argument is +# present on the nmake command-line +# +!IFNDEF SESSION +SESSION = 0 +!ENDIF +!IF $(SESSION)!=0 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1 !ENDIF diff --git a/autoconf/Makefile.am b/autoconf/Makefile.am index cca23ba67d..e8211596d9 100644 --- a/autoconf/Makefile.am +++ b/autoconf/Makefile.am @@ -1,5 +1,5 @@ -AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE +AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE lib_LTLIBRARIES = libsqlite3.la libsqlite3_la_SOURCES = sqlite3.c diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index ed99ce9587..dcb69dab06 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -249,6 +249,15 @@ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 +!ENDIF + +# Enable support for the session extension if the SESSION=1 argument is +# present on the nmake command-line +# +!IFNDEF SESSION +SESSION = 0 +!ENDIF +!IF $(SESSION)!=0 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1 !ENDIF diff --git a/autoconf/configure.ac b/autoconf/configure.ac index f86a39c37b..d1fe50603f 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -122,6 +122,18 @@ fi AC_SUBST(JSON1_FLAGS) #----------------------------------------------------------------------- +#----------------------------------------------------------------------- +# --enable-session +# +AC_ARG_ENABLE(session, [AS_HELP_STRING( + [--enable-session], [enable the session extension [default=no]])], + [], [enable_session=no]) +if test x"$enable_session" == "xyes"; then + SESSION_FLAGS="-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK" +fi +AC_SUBST(SESSION_FLAGS) +#----------------------------------------------------------------------- + #----------------------------------------------------------------------- # --enable-static-shell # diff --git a/configure b/configure index 27cb1ea0b9..3b746fedbb 100755 --- a/configure +++ b/configure @@ -908,6 +908,7 @@ enable_fts4 enable_fts5 enable_json1 enable_rtree +enable_session enable_gcov ' ac_precious_vars='build_alias @@ -1556,6 +1557,7 @@ Optional Features: --enable-fts5 Enable the FTS5 extension --enable-json1 Enable the JSON1 extension --enable-rtree Enable the RTREE extension + --enable-session Enable the SESSION extension --enable-gcov Enable coverage testing using gcov Optional Packages: @@ -3923,13 +3925,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3926: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3928: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3929: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3931: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3932: output\"" >&5) + (eval echo "\"\$as_me:3934: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5135,7 +5137,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5138 "configure"' > conftest.$ac_ext + echo '#line 5140 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6660,11 +6662,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6663: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6665: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6667: \$? = $ac_status" >&5 + echo "$as_me:6669: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -6999,11 +7001,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7002: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7004: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7006: \$? = $ac_status" >&5 + echo "$as_me:7008: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7104,11 +7106,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7107: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7109: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7111: \$? = $ac_status" >&5 + echo "$as_me:7113: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7159,11 +7161,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7162: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7164: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7166: \$? = $ac_status" >&5 + echo "$as_me:7168: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9539,7 +9541,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9542 "configure" +#line 9544 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9635,7 +9637,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9638 "configure" +#line 9640 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11494,6 +11496,20 @@ if test "${enable_rtree}" = "yes" ; then OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_RTREE" fi +######### +# See whether we should enable the SESSION extension +# Check whether --enable-session was given. +if test "${enable_session+set}" = set; then : + enableval=$enable_session; enable_session=yes +else + enable_session=no +fi + +if test "${enable_session}" = "yes" ; then + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_SESSION" + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_PREUPDATE_HOOK" +fi + ######### # attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter for option in $CFLAGS $CPPFLAGS diff --git a/configure.ac b/configure.ac index 08c8867f06..2c97885ade 100644 --- a/configure.ac +++ b/configure.ac @@ -615,6 +615,16 @@ if test "${enable_rtree}" = "yes" ; then OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_RTREE" fi +######### +# See whether we should enable the SESSION extension +AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session], + [Enable the SESSION extension]), + [enable_session=yes],[enable_session=no]) +if test "${enable_session}" = "yes" ; then + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_SESSION" + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_PREUPDATE_HOOK" +fi + ######### # attempt to duplicate any OMITS and ENABLES into the $(OPT_FEATURE_FLAGS) parameter for option in $CFLAGS $CPPFLAGS diff --git a/manifest b/manifest index 27faecd64e..5a2a7dcf1e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Avoid\sleft-shifts\sof\ssigned\sintegers. -D 2016-05-03T00:04:55.196 -F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8 +C Turn\sthe\ssession\sextension\soff\sby\sdefault.\s\sEnable\susing\s--enable-session\son\nconfigure\sscripts,\sor\susing\sthe\sSESSION=1\sargument\sto\snmake\son\sWindows. +D 2016-05-03T13:14:18.288 +F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836 +F Makefile.msc a7f34be67d16284e4208370365a9728094861194 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 5d234da9b5dae329fab75ff75884cfe0a9cb3fda F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -10,11 +10,11 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 -F autoconf/Makefile.am 42f7eb1fb2b06ddd6c6adab3e4388cc0a237ba40 -F autoconf/Makefile.msc dc0d0500e4a827cb3891d08d846dd6dd40241b51 +F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 +F autoconf/Makefile.msc ac014aab0b8314d6baa30cbd1dd4ce983f306b5d F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 -F autoconf/configure.ac d807b567f73a2b0986ccdd206b782cecb4d08fff +F autoconf/configure.ac e2299fe80eb256dafdc68cf250e37ea1a0a6ec71 F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure dbd42c55ca6b65e0fb37ef54121755f26a890edf x -F configure.ac 89e4e02a83d8a1528011f8395621b8c3186b4089 +F configure df9f793ad47eaeb3648a9090fbc0b96955e88b5a x +F configure.ac 02b972db825685b4b0cca0234b2aa97f71bd15a5 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -998,7 +998,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/regexp2.test aa7ffcc21350007a78361b82bcf3b74d12227144 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl f2519836bebefcc7db36b4946e8028d4885baa59 +F test/releasetest.tcl 7d80014d0245b3f9d02d393d420bf03ca155aec0 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5 @@ -1486,7 +1486,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5830cf72e9e870830d088399f1ccb03ed6522582 -R 350580348db69c537adc1a64222fc40a +P 0715ce164333e27671efbec8796f238df98cc287 +R b2e26094738bdcbd727f209d6b0330cd +T *branch * session-make +T *sym-session-make * +T -sym-trunk * U drh -Z 10c9aec7cf14a46e7039005f7f038452 +Z 7002cda7adeb2152eae684546f496804 diff --git a/manifest.uuid b/manifest.uuid index 9202d19d19..deb3ca1f64 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0715ce164333e27671efbec8796f238df98cc287 \ No newline at end of file +e462cde2a50c39cc2f8d8624aada19280b8226eb \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 15f64e3218..2961fc385d 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -51,10 +51,12 @@ array set ::Configs [strip_comments { "Default" { -O2 --disable-amalgamation --disable-shared + --enable-session } "Sanitize" { CC=clang -fsanitize=undefined -DSQLITE_ENABLE_STAT4 + --enable-session } "Have-Not" { # The "Have-Not" configuration sets all possible -UHAVE_feature options @@ -106,7 +108,7 @@ array set ::Configs [strip_comments { -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_STMT_SCANSTATUS - --enable-json1 --enable-fts5 + --enable-json1 --enable-fts5 --enable-session } "Debug-One" { --disable-shared @@ -132,6 +134,7 @@ array set ::Configs [strip_comments { -DSQLITE_ENABLE_RBU -DSQLITE_MAX_ATTACHED=125 -DLONGDOUBLE_TYPE=double + --enable-session } "Device-One" { -O2 @@ -168,7 +171,7 @@ array set ::Configs [strip_comments { -DSQLITE_OMIT_TRACE=1 -DSQLITE_TEMP_STORE=3 -DSQLITE_THREADSAFE=2 - --enable-json1 --enable-fts5 + --enable-json1 --enable-fts5 --enable-session } "Locking-Style" { -O2 From 12b35ea980c777c5c76f7e528567d799f8eade9c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 3 May 2016 19:40:54 +0000 Subject: [PATCH 013/302] Minor style tweaks in the MSVC makefile. FossilOrigin-Name: 1b43358f8979c4f18519e824e0d5f6ef2250107c --- Makefile.msc | 13 ++++++++----- autoconf/Makefile.msc | 13 ++++++++----- manifest | 17 ++++++++--------- manifest.uuid | 2 +- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 3eb50c1eae..bb9790d312 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -198,6 +198,12 @@ DEBUG = 0 OPTIMIZATIONS = 2 !ENDIF +# Set this to non-0 to enable support for the session extension. +# +!IFNDEF SESSION +SESSION = 0 +!ENDIF + # Set the source code file to be used by executables and libraries when # they need the amalgamation. # @@ -266,12 +272,9 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 !ENDIF -# Enable support for the session extension if the SESSION=1 argument is -# present on the nmake command-line +# Should the session extension be enabled? If so, add compilation options +# to enable it. # -!IFNDEF SESSION -SESSION = 0 -!ENDIF !IF $(SESSION)!=0 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1 diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index dcb69dab06..7f62bcb129 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -183,6 +183,12 @@ DEBUG = 0 OPTIMIZATIONS = 2 !ENDIF +# Set this to non-0 to enable support for the session extension. +# +!IFNDEF SESSION +SESSION = 0 +!ENDIF + # Set the source code file to be used by executables and libraries when # they need the amalgamation. # @@ -251,12 +257,9 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 !ENDIF -# Enable support for the session extension if the SESSION=1 argument is -# present on the nmake command-line +# Should the session extension be enabled? If so, add compilation options +# to enable it. # -!IFNDEF SESSION -SESSION = 0 -!ENDIF !IF $(SESSION)!=0 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1 diff --git a/manifest b/manifest index 59f321b3e0..b85ef558d9 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C The\ssession\sextension\sis\sdisabled\sby\sdefault.\s\sTo\senable\sit\susing\n--enable-session\son\s./configure\son\sunix\sand\sadd\sSESSION=1\sto\sthe\snmake\non\sWindows.\s\sOr\sadd\s-DSQLITE_ENABLE_SESSION\sand\n-DSQLITE_ENABLE_PREUPDATE_HOOK\sto\sbuild\smanually. -D 2016-05-03T14:57:07.139 +C Minor\sstyle\stweaks\sin\sthe\sMSVC\smakefile. +D 2016-05-03T19:40:54.328 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc a7f34be67d16284e4208370365a9728094861194 +F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 5d234da9b5dae329fab75ff75884cfe0a9cb3fda F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -11,7 +11,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 -F autoconf/Makefile.msc ac014aab0b8314d6baa30cbd1dd4ce983f306b5d +F autoconf/Makefile.msc 0eca137c12542bd76c253a2d24380f29ade59b95 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac e2299fe80eb256dafdc68cf250e37ea1a0a6ec71 @@ -1486,8 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0715ce164333e27671efbec8796f238df98cc287 e462cde2a50c39cc2f8d8624aada19280b8226eb -R b2e26094738bdcbd727f209d6b0330cd -T +closed e462cde2a50c39cc2f8d8624aada19280b8226eb -U drh -Z be2a8ff6db06dcbc7ab32e285c183e7e +P bcaa650e8796984b275eceba0ed477f360295d01 +R 962b079d2f6aa84ad32617180232ff75 +U mistachkin +Z 45ce4bc83f501da24480cd14c4b0de07 diff --git a/manifest.uuid b/manifest.uuid index 2c0b2458e8..1744b7bee1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bcaa650e8796984b275eceba0ed477f360295d01 \ No newline at end of file +1b43358f8979c4f18519e824e0d5f6ef2250107c \ No newline at end of file From c88ae52d868d8da91931ef3863e96ca661b4356d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 4 May 2016 11:28:03 +0000 Subject: [PATCH 014/302] Disable the PagerDontWrite() optimization for temp tables. It can cause database corruption if a page passed to PagerDontWrite() is dirty at the start of a transaction that is subsequently rolled back. FossilOrigin-Name: 6341ab2ffef298ca16b323358afbea4a4c1fb0e1 --- manifest | 15 ++++----- manifest.uuid | 2 +- src/pager.c | 8 ++++- test/tempdb2.test | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 test/tempdb2.test diff --git a/manifest b/manifest index b85ef558d9..0570c6e3af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sstyle\stweaks\sin\sthe\sMSVC\smakefile. -D 2016-05-03T19:40:54.328 +C Disable\sthe\sPagerDontWrite()\soptimization\sfor\stemp\stables.\sIt\scan\scause\sdatabase\scorruption\sif\sa\spage\spassed\sto\sPagerDontWrite()\sis\sdirty\sat\sthe\sstart\sof\sa\stransaction\sthat\sis\ssubsequently\srolled\sback. +D 2016-05-04T11:28:03.301 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c a8d30c49c231e9a20d05257613db922532588963 +F src/pager.c c512873311087cd22372f2b076fc869e090e8e16 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c b3230ecfc7f797063fbe167f2845da363e8f07f8 @@ -1111,6 +1111,7 @@ F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 +F test/tempdb2.test 4fc92055f2a3f7626c0f2eabbb637dc021b311d5 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e @@ -1486,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bcaa650e8796984b275eceba0ed477f360295d01 -R 962b079d2f6aa84ad32617180232ff75 -U mistachkin -Z 45ce4bc83f501da24480cd14c4b0de07 +P 1b43358f8979c4f18519e824e0d5f6ef2250107c +R ddb8134dc049c780758987466a2a1e86 +U dan +Z 527ddc60688e8fba4830106202c052a2 diff --git a/manifest.uuid b/manifest.uuid index 1744b7bee1..ae5eab176f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b43358f8979c4f18519e824e0d5f6ef2250107c \ No newline at end of file +6341ab2ffef298ca16b323358afbea4a4c1fb0e1 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d24337cd50..8ef0492e57 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6008,10 +6008,16 @@ int sqlite3PagerIswriteable(DbPage *pPg){ ** ** Tests show that this optimization can quadruple the speed of large ** DELETE operations. +** +** This optimization cannot be used with a temp-file, as the page may +** have been dirty at the start of the transaction. In that case, if +** memory pressure forces page pPg out of the cache, the data does need +** to be written out to disk so that it may be read back in if the +** current transaction is rolled back. */ void sqlite3PagerDontWrite(PgHdr *pPg){ Pager *pPager = pPg->pPager; - if( (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){ + if( !pPager->tempFile && (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){ PAGERTRACE(("DONT_WRITE page %d of %d\n", pPg->pgno, PAGERID(pPager))); IOTRACE(("CLEAN %p %d\n", pPager, pPg->pgno)) pPg->flags |= PGHDR_DONT_WRITE; diff --git a/test/tempdb2.test b/test/tempdb2.test new file mode 100644 index 0000000000..bc2822e71e --- /dev/null +++ b/test/tempdb2.test @@ -0,0 +1,77 @@ +# 2016 March 3 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix tempdb2 + +db close +sqlite3 db "" + +proc int2str {i} { string range [string repeat "$i." 450] 0 899 } +db func int2str int2str + +#------------------------------------------------------------------------- +# +# 1.1: Write a big transaction to the db. One so large that it forces +# the file to be created and the cache flushed to disk on COMMIT. +# +# 1.2: Write a small transaction - one small enough that it remains in +# memory on COMMIT. All the pages of table [t1] are now dirty. +# +# 1.3: Delete the contents of [t1]. This moves all of its leaves to the +# free-list and causes the btree layer to call PagerDontWrite() on +# each of them. +# +# Then do a big update on table [t2]. So big that the former leaves +# of [t1] are forced out of the cache. Then roll back the transaction. +# If the PagerDontWrite() calls are honoured and the data is not written +# to disk, the update made in test 1.2 will be lost at this point. Or, if +# they are ignored (as they should be for temp databases), the update +# will be safely written out to disk before the cache entries are +# discarded. +# +do_execsql_test 1.1 { + PRAGMA page_size=1024; + PRAGMA cache_size=50; + + BEGIN; + CREATE TABLE t1(a INTEGER PRIMARY KEY, b); + INSERT INTO t1 VALUES(1, int2str(1)); + INSERT INTO t1 VALUES(2, int2str(1)); + INSERT INTO t1 VALUES(3, int2str(1)); + + CREATE TABLE t2(a INTEGER PRIMARY KEY, b); + WITH c(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100 ) + INSERT INTO t2 SELECT x, int2str(x) FROM c; + COMMIT; + + PRAGMA lock_status; +} {main unlocked temp closed} + +do_execsql_test 1.2 { + UPDATE t1 SET b=int2str(2); + SELECT b=int2str(2) FROM t1 +} {1 1 1} + +do_execsql_test 1.3 { + BEGIN; + DELETE FROM t1; + UPDATE t2 SET b=int2str(a+1); + ROLLBACK; +} + +do_execsql_test 1.4 { + SELECT b=int2str(2) FROM t1 +} {1 1 1} + +finish_test + From 582c080289f2152eea2e0dc5ae33fff38a571e9f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 4 May 2016 14:20:15 +0000 Subject: [PATCH 015/302] Portability enhancements to the configure script on the amalgamation tarball. FossilOrigin-Name: 7184c4b8869ffc00944abdd8d2c521cb11ea5824 --- autoconf/configure.ac | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index d1fe50603f..6b37a0517a 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -103,7 +103,7 @@ AC_SUBST(DYNAMIC_EXTENSION_FLAGS) AC_ARG_ENABLE(fts5, [AS_HELP_STRING( [--enable-fts5], [include fts5 support [default=no]])], [], [enable_fts5=no]) -if test x"$enable_fts5" == "xyes"; then +if test x"$enable_fts5" = "xyes"; then AC_SEARCH_LIBS(log, m) FTS5_FLAGS=-DSQLITE_ENABLE_FTS5 fi @@ -116,7 +116,7 @@ AC_SUBST(FTS5_FLAGS) AC_ARG_ENABLE(json1, [AS_HELP_STRING( [--enable-json1], [include json1 support [default=no]])], [], [enable_json1=no]) -if test x"$enable_json1" == "xyes"; then +if test x"$enable_json1" = "xyes"; then JSON1_FLAGS=-DSQLITE_ENABLE_JSON1 fi AC_SUBST(JSON1_FLAGS) @@ -128,7 +128,7 @@ AC_SUBST(JSON1_FLAGS) AC_ARG_ENABLE(session, [AS_HELP_STRING( [--enable-session], [enable the session extension [default=no]])], [], [enable_session=no]) -if test x"$enable_session" == "xyes"; then +if test x"$enable_session" = "xyes"; then SESSION_FLAGS="-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK" fi AC_SUBST(SESSION_FLAGS) @@ -141,7 +141,7 @@ AC_ARG_ENABLE(static-shell, [AS_HELP_STRING( [--enable-static-shell], [statically link libsqlite3 into shell tool [default=yes]])], [], [enable_static_shell=yes]) -if test x"$enable_static_shell" == "xyes"; then +if test x"$enable_static_shell" = "xyes"; then EXTRA_SHELL_OBJ=sqlite3-sqlite3.$OBJEXT else EXTRA_SHELL_OBJ=libsqlite3.la diff --git a/manifest b/manifest index 0570c6e3af..fc948d48f2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\sPagerDontWrite()\soptimization\sfor\stemp\stables.\sIt\scan\scause\sdatabase\scorruption\sif\sa\spage\spassed\sto\sPagerDontWrite()\sis\sdirty\sat\sthe\sstart\sof\sa\stransaction\sthat\sis\ssubsequently\srolled\sback. -D 2016-05-04T11:28:03.301 +C Portability\senhancements\sto\sthe\sconfigure\sscript\son\sthe\samalgamation\starball. +D 2016-05-04T14:20:15.883 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -14,7 +14,7 @@ F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 F autoconf/Makefile.msc 0eca137c12542bd76c253a2d24380f29ade59b95 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 -F autoconf/configure.ac e2299fe80eb256dafdc68cf250e37ea1a0a6ec71 +F autoconf/configure.ac ad7001cdde3d6ae6053bc0b66009869d7c5012a8 F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1b43358f8979c4f18519e824e0d5f6ef2250107c -R ddb8134dc049c780758987466a2a1e86 -U dan -Z 527ddc60688e8fba4830106202c052a2 +P 6341ab2ffef298ca16b323358afbea4a4c1fb0e1 +R a3cd249f5ae281a2f2bd8ab97d7cb0bc +U drh +Z 6738ef2f38ef30f9c397b3159a787329 diff --git a/manifest.uuid b/manifest.uuid index ae5eab176f..341201e617 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6341ab2ffef298ca16b323358afbea4a4c1fb0e1 \ No newline at end of file +7184c4b8869ffc00944abdd8d2c521cb11ea5824 \ No newline at end of file From 91da70728092c246963b7521c51361e4d007f3cf Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 4 May 2016 14:45:30 +0000 Subject: [PATCH 016/302] Only disable the one-pass DELETE optimization if the WHERE clause contains a correlated subquery. Uncorrelated subqueries are allowed. This is a refinement of check-in [3f221f592a9a1] that is the fix for ticket [dc6ebeda9396087]. FossilOrigin-Name: aae389692a2ed2cc92151d51fb2cd5a16921c469 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/delete.c | 2 +- src/resolve.c | 1 + src/sqliteInt.h | 1 + 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index fc948d48f2..a7d16f5cd6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Portability\senhancements\sto\sthe\sconfigure\sscript\son\sthe\samalgamation\starball. -D 2016-05-04T14:20:15.883 +C Only\sdisable\sthe\sone-pass\sDELETE\soptimization\sif\sthe\sWHERE\sclause\scontains\na\scorrelated\ssubquery.\s\sUncorrelated\ssubqueries\sare\sallowed.\s\sThis\sis\sa\nrefinement\sof\scheck-in\s[3f221f592a9a1]\sthat\sis\sthe\sfix\sfor\nticket\s[dc6ebeda9396087]. +D 2016-05-04T14:45:30.802 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -330,7 +330,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b -F src/delete.c 362f89f8e6783e672c4ab06b90fca0177f9a576d +F src/delete.c 3f16e7ceb9e5084b127e0a4e10a9b06ca66c0b2e F src/expr.c 8796c0739b2ad091e6779253f62aad6e767e2be1 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb @@ -375,14 +375,14 @@ F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c b8f7174e5f8c33c44ded3a25a973d0bb89228c20 +F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 49eb91c588a2bab36647368e031dc5b66928149d F src/select.c fd4a7ce2937497181063cfedb92058ac89491a5d F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h f4a53f3547dab80dc7db975fa1192d9bad1f38e8 +F src/sqliteInt.h c8483dd77894a72d38a76b6251a4ac949a37d6e8 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6341ab2ffef298ca16b323358afbea4a4c1fb0e1 -R a3cd249f5ae281a2f2bd8ab97d7cb0bc +P 7184c4b8869ffc00944abdd8d2c521cb11ea5824 +R 0a6e5fa4a5a2f4a10bd60c5e077cbc66 U drh -Z 6738ef2f38ef30f9c397b3159a787329 +Z 06351e9e2a2d525f9337b5a6815ea254 diff --git a/manifest.uuid b/manifest.uuid index 341201e617..f6fcd613ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7184c4b8869ffc00944abdd8d2c521cb11ea5824 \ No newline at end of file +aae389692a2ed2cc92151d51fb2cd5a16921c469 \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index 258b39cc3e..06a016438c 100644 --- a/src/delete.c +++ b/src/delete.c @@ -374,7 +374,7 @@ void sqlite3DeleteFrom( #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ { u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; - if( pWhere && ExprHasProperty(pWhere, EP_Subquery) ) bComplex = 1; + if( sNC.ncFlags & NC_VarSelect ) bComplex = 1; wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW); if( HasRowid(pTab) ){ /* For a rowid table, initialize the RowSet to an empty set */ diff --git a/src/resolve.c b/src/resolve.c index 8e290af123..77ce37f6d7 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -763,6 +763,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ assert( pNC->nRef>=nRef ); if( nRef!=pNC->nRef ){ ExprSetProperty(pExpr, EP_VarSelect); + pNC->ncFlags |= NC_VarSelect; } } break; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 76bf809624..783f0f56c3 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2597,6 +2597,7 @@ struct NameContext { #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ #define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ +#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ /* From 9fe3fbbc3522fd4683af2664db008bcde3e733e6 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 4 May 2016 19:04:20 +0000 Subject: [PATCH 017/302] Fix typo in comment. No changes to code. FossilOrigin-Name: 6c43ba1c8753a4029e127078652f265c408a01c0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/delete.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a7d16f5cd6..6d5d323836 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Only\sdisable\sthe\sone-pass\sDELETE\soptimization\sif\sthe\sWHERE\sclause\scontains\na\scorrelated\ssubquery.\s\sUncorrelated\ssubqueries\sare\sallowed.\s\sThis\sis\sa\nrefinement\sof\scheck-in\s[3f221f592a9a1]\sthat\sis\sthe\sfix\sfor\nticket\s[dc6ebeda9396087]. -D 2016-05-04T14:45:30.802 +C Fix\stypo\sin\scomment.\s\sNo\schanges\sto\scode. +D 2016-05-04T19:04:20.094 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -330,7 +330,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b -F src/delete.c 3f16e7ceb9e5084b127e0a4e10a9b06ca66c0b2e +F src/delete.c 912908dea57778737d4bab632f00e48b550d10ea F src/expr.c 8796c0739b2ad091e6779253f62aad6e767e2be1 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7184c4b8869ffc00944abdd8d2c521cb11ea5824 -R 0a6e5fa4a5a2f4a10bd60c5e077cbc66 -U drh -Z 06351e9e2a2d525f9337b5a6815ea254 +P aae389692a2ed2cc92151d51fb2cd5a16921c469 +R 7eec09085d0724a070665f564c0beb44 +U mistachkin +Z d55bbbb1bc35091ae5bebd4e60554f06 diff --git a/manifest.uuid b/manifest.uuid index f6fcd613ae..1471b0ed2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aae389692a2ed2cc92151d51fb2cd5a16921c469 \ No newline at end of file +6c43ba1c8753a4029e127078652f265c408a01c0 \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index 06a016438c..dab1fd40cd 100644 --- a/src/delete.c +++ b/src/delete.c @@ -239,7 +239,7 @@ void sqlite3DeleteFrom( int addrBypass = 0; /* Address of jump over the delete logic */ int addrLoop = 0; /* Top of the delete loop */ int addrEphOpen = 0; /* Instruction to open the Ephemeral table */ - int bComplex; /* True if there are triggers or FKs or or + int bComplex; /* True if there are triggers or FKs or ** subqueries in the WHERE clause */ #ifndef SQLITE_OMIT_TRIGGER From 4e80d5fcf1e05bb1d81a9acf02d74fc16ab79b9f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 4 May 2016 21:06:21 +0000 Subject: [PATCH 018/302] Disable the session extension API if SQLITE_ENABLE_SESSION is not defined. FossilOrigin-Name: 71af9ac165ac02272f4886f69bd9ab4770fd7bb6 --- ext/session/sqlite3session.h | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index 71f02159cf..23d9a33aef 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -1,5 +1,5 @@ -#ifndef __SQLITESESSION_H_ +#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) #define __SQLITESESSION_H_ 1 /* @@ -1274,4 +1274,4 @@ int sqlite3changegroup_output_strm(sqlite3_changegroup*, } #endif -#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */ +#endif /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */ diff --git a/manifest b/manifest index 6d5d323836..12eedad414 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment.\s\sNo\schanges\sto\scode. -D 2016-05-04T19:04:20.094 +C Disable\sthe\ssession\sextension\sAPI\sif\sSQLITE_ENABLE_SESSION\sis\snot\sdefined. +D 2016-05-04T21:06:21.506 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -294,7 +294,7 @@ F ext/session/session_common.tcl a1293167d14774b5e728836720497f40fe4ea596 F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 -F ext/session/sqlite3session.h 64e9e7f185725ef43b97f4a9a0c0df0669844f1d +F ext/session/sqlite3session.h 69bf73cfd71e58f2ae5d2aa935b2c1a541aee555 F ext/session/test_session.c 464f2c8bf502795d95969387eb8e93f68c513c15 F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aae389692a2ed2cc92151d51fb2cd5a16921c469 -R 7eec09085d0724a070665f564c0beb44 -U mistachkin -Z d55bbbb1bc35091ae5bebd4e60554f06 +P 6c43ba1c8753a4029e127078652f265c408a01c0 +R a7d4cc11d472462953b7d84c093e9aa1 +U drh +Z c3eb846652f8b95f225fc6721b0d9cb4 diff --git a/manifest.uuid b/manifest.uuid index 1471b0ed2d..32ae23744e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c43ba1c8753a4029e127078652f265c408a01c0 \ No newline at end of file +71af9ac165ac02272f4886f69bd9ab4770fd7bb6 \ No newline at end of file From ad5a9d715f247e72274e91f10ece95cfff3d74fc Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2016 11:53:12 +0000 Subject: [PATCH 019/302] Renumber internal constants in the printf() implemention for a small performance improvement. FossilOrigin-Name: 69d11447f4b1a8c536c3b6573d2a3419da870412 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/printf.c | 36 ++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 12eedad414..8e5f6ffbdc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\ssession\sextension\sAPI\sif\sSQLITE_ENABLE_SESSION\sis\snot\sdefined. -D 2016-05-04T21:06:21.506 +C Renumber\sinternal\sconstants\sin\sthe\sprintf()\simplemention\sfor\sa\ssmall\nperformance\simprovement. +D 2016-05-05T11:53:12.439 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -373,7 +373,7 @@ F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e -F src/printf.c 63e6fb12bbe702dd664dc3703776c090383a5a26 +F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 49eb91c588a2bab36647368e031dc5b66928149d @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6c43ba1c8753a4029e127078652f265c408a01c0 -R a7d4cc11d472462953b7d84c093e9aa1 +P 71af9ac165ac02272f4886f69bd9ab4770fd7bb6 +R 89655379113728f544ce9a18ad294b0b U drh -Z c3eb846652f8b95f225fc6721b0d9cb4 +Z f65addcdc03169dedb02067b28293d6c diff --git a/manifest.uuid b/manifest.uuid index 32ae23744e..4a4e62d8ed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -71af9ac165ac02272f4886f69bd9ab4770fd7bb6 \ No newline at end of file +69d11447f4b1a8c536c3b6573d2a3419da870412 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 238997f37d..a888d50b94 100644 --- a/src/printf.c +++ b/src/printf.c @@ -15,26 +15,26 @@ ** Conversion types fall into various categories as defined by the ** following enumeration. */ -#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */ -#define etFLOAT 2 /* Floating point. %f */ -#define etEXP 3 /* Exponentional notation. %e and %E */ -#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */ -#define etSIZE 5 /* Return number of characters processed so far. %n */ -#define etSTRING 6 /* Strings. %s */ -#define etDYNSTRING 7 /* Dynamically allocated strings. %z */ -#define etPERCENT 8 /* Percent symbol. %% */ -#define etCHARX 9 /* Characters. %c */ +#define etRADIX 0 /* Integer types. %d, %x, %o, and so forth */ +#define etFLOAT 1 /* Floating point. %f */ +#define etEXP 2 /* Exponentional notation. %e and %E */ +#define etGENERIC 3 /* Floating or exponential, depending on exponent. %g */ +#define etSIZE 4 /* Return number of characters processed so far. %n */ +#define etSTRING 5 /* Strings. %s */ +#define etDYNSTRING 6 /* Dynamically allocated strings. %z */ +#define etPERCENT 7 /* Percent symbol. %% */ +#define etCHARX 8 /* Characters. %c */ /* The rest are extensions, not normally found in printf() */ -#define etSQLESCAPE 10 /* Strings with '\'' doubled. %q */ -#define etSQLESCAPE2 11 /* Strings with '\'' doubled and enclosed in '', +#define etSQLESCAPE 9 /* Strings with '\'' doubled. %q */ +#define etSQLESCAPE2 10 /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ -#define etTOKEN 12 /* a pointer to a Token structure */ -#define etSRCLIST 13 /* a pointer to a SrcList */ -#define etPOINTER 14 /* The %p conversion */ -#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ -#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ +#define etTOKEN 11 /* a pointer to a Token structure */ +#define etSRCLIST 12 /* a pointer to a SrcList */ +#define etPOINTER 13 /* The %p conversion */ +#define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */ +#define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ -#define etINVALID 0 /* Any unrecognized conversion type */ +#define etINVALID 16 /* Any unrecognized conversion type */ /* @@ -189,7 +189,7 @@ void sqlite3VXPrintf( etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ - etByte xtype = 0; /* Conversion paradigm */ + etByte xtype = etINVALID; /* Conversion paradigm */ u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */ u8 useIntern; /* Ok to use internal conversions (ex: %T) */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ From da110bfecec0b590ee6321c4f57bf98c950905da Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2016 17:15:23 +0000 Subject: [PATCH 020/302] Initial check-in of the "scrub.exe" utility program prototype. Not yet fully functional. In particular, no scrubbing is done. FossilOrigin-Name: bdf2ec77d1542d4e9b68218f558710a3efc15823 --- Makefile.in | 4 + Makefile.msc | 3 + ext/misc/scrub.c | 306 +++++++++++++++++++++++++++++++++++++++++++++++ main.mk | 3 + manifest | 20 ++-- manifest.uuid | 2 +- 6 files changed, 329 insertions(+), 9 deletions(-) create mode 100644 ext/misc/scrub.c diff --git a/Makefile.in b/Makefile.in index 78480de9e0..4e10d4e231 100644 --- a/Makefile.in +++ b/Makefile.in @@ -589,6 +589,10 @@ sqlite3$(TEXE): $(TOP)/src/shell.c sqlite3.c sqldiff$(TEXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) +scrub$(TEXE): $(TOP)/ext/misc/scrub.c sqlite3.o + $(LTLINK) -o $@ -I. -DSCRUB_STANDALONE \ + $(TOP)/ext/misc/scrub.c sqlite3.o $(TLIBS) + srcck1$(BEXE): $(TOP)/tool/srcck1.c $(BCC) -o srcck1$(BEXE) $(TOP)/tool/srcck1.c diff --git a/Makefile.msc b/Makefile.msc index bb9790d312..408a516364 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1455,6 +1455,9 @@ $(SQLITE3EXE): $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_S sqldiff.exe: $(TOP)\tool\sqldiff.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) $(TOP)\tool\sqldiff.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) +scrub.exe: $(TOP)\ext\misc\scrub.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) $(TOP)\ext\misc\scrub.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) + srcck1.exe: $(TOP)\tool\srcck1.c $(BCC) $(NO_WARN) -Fe$@ $(TOP)\tool\srcck1.c diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c new file mode 100644 index 0000000000..fbf2f8c2b7 --- /dev/null +++ b/ext/misc/scrub.c @@ -0,0 +1,306 @@ +/* +** 2016-05-05 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file implements a utility function (and a utility program) that +** makes a copy of an SQLite database while simultaneously zeroing out all +** deleted content. +** +** Normally (when PRAGMA secure_delete=OFF, which is the default) when SQLite +** deletes content, it does not overwrite the deleted content but rather marks +** the region of the file that held that content as being reusable. This can +** cause deleted content to recoverable from the database file. This stale +** content is removed by the VACUUM command, but VACUUM can be expensive for +** large databases. When in PRAGMA secure_delete=ON mode, the deleted content +** is zeroed, but secure_delete=ON has overhead as well. +** +** This utility attempts to make a copy of a complete SQLite database where +** all of the deleted content is zeroed out in the copy, and it attempts to +** do so while being faster than running VACUUM. +** +** Usage: +** +** int sqlite3_scrub_backup( +** const char *zSourceFile, // Source database filename +** const char *zDestFile, // Destination database filename +** char **pzErrMsg // Write error message here +** ); +** +** Simply call the API above specifying the filename of the source database +** and the name of the backup copy. The source database must already exist +** and can be in active use. (A read lock is held during the backup.) The +** destination file should not previously exist. If the pzErrMsg parameter +** is non-NULL and if an error occurs, then an error message might be written +** into memory obtained from sqlite3_malloc() and *pzErrMsg made to point to +** that error message. But if the error is an OOM, the error might not be +** reported. The routine always returns non-zero if there is an error. +** +** If compiled with -DSCRUB_STANDALONE then a main() procedure is added and +** this file becomes a standalone program that can be run as follows: +** +** ./sqlite3scrub SOURCE DEST +*/ +#include "sqlite3.h" +#include +#include +#include +#include +#include + +typedef struct ScrubState ScrubState; +typedef unsigned char u8; + +/* State information for a scrub-and-backup operation */ +struct ScrubState { + const char *zSrcFile; /* Name of the source file */ + const char *zDestFile; /* Name of the destination file */ + int rcErr; /* Error code */ + char *zErr; /* Error message text */ + sqlite3 *dbSrc; /* Source database connection */ + sqlite3_file *pSrc; /* Source file handle */ + sqlite3 *dbDest; /* Destination database connection */ + sqlite3_file *pDest; /* Destination file handle */ + unsigned int szPage; /* Page size */ + unsigned int nPage; /* Number of pages */ + u8 *page1; /* Content of page 1 */ +}; + +/* Store an error message */ +static void scrubBackupErr(ScrubState *p, const char *zFormat, ...){ + va_list ap; + sqlite3_free(p->zErr); + va_start(ap, zFormat); + p->zErr = sqlite3_vmprintf(zFormat, ap); + va_end(ap); + if( p->rcErr==0 ) p->rcErr = SQLITE_ERROR; +} + +/* Allocate memory to hold a single page of content */ +static u8 *scrubBackupAllocPage(ScrubState *p){ + u8 *pPage; + if( p->rcErr ) return 0; + pPage = sqlite3_malloc( p->szPage ); + if( pPage==0 ) p->rcErr = SQLITE_NOMEM; + return pPage; +} + +/* Read a page from the source database into memory. Use the memory +** provided by pBuf if not NULL or allocate a new page if pBuf==NULL. +*/ +static u8 *scrubBackupRead(ScrubState *p, int pgno, u8 *pBuf){ + int rc; + sqlite3_int64 iOff; + u8 *pOut = pBuf; + if( p->rcErr ) return 0; + if( pOut==0 ){ + pOut = scrubBackupAllocPage(p); + if( pOut==0 ) return 0; + } + iOff = (pgno-1)*(sqlite3_int64)p->szPage; + rc = p->pSrc->pMethods->xRead(p->pSrc, pOut, p->szPage, iOff); + if( rc!=SQLITE_OK ){ + if( pBuf==0 ) sqlite3_free(pOut); + pOut = 0; + scrubBackupErr(p, "read failed for page %d", pgno); + p->rcErr = SQLITE_IOERR; + } + return pOut; +} + +/* Write a page to the destination database */ +static void scrubBackupWrite(ScrubState *p, int pgno, u8 *pData){ + int rc; + sqlite3_int64 iOff; + if( p->rcErr ) return; + iOff = (pgno-1)*(sqlite3_int64)p->szPage; + rc = p->pDest->pMethods->xWrite(p->pDest, pData, p->szPage, iOff); + if( rc!=SQLITE_OK ){ + scrubBackupErr(p, "write failed for page %d", pgno); + p->rcErr = SQLITE_IOERR; + } +} + +/* Prepare a statement against the "db" database. */ +static sqlite3_stmt *scrubBackupPrepare( + ScrubState *p, /* Backup context */ + sqlite3 *db, /* Database to prepare against */ + const char *zSql /* SQL statement */ +){ + sqlite3_stmt *pStmt; + if( p->rcErr ) return 0; + p->rcErr = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); + if( p->rcErr ){ + scrubBackupErr(p, "SQL error \"%s\" on \"%s\"", + sqlite3_errmsg(db), zSql); + sqlite3_finalize(pStmt); + return 0; + } + return pStmt; +} + + +/* Open the source database file */ +static void scrubBackupOpenSrc(ScrubState *p){ + sqlite3_stmt *pStmt; + int rc; + /* Open the source database file */ + p->rcErr = sqlite3_open_v2(p->zSrcFile, &p->dbSrc, + SQLITE_OPEN_READONLY | + SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0); + if( p->rcErr ){ + scrubBackupErr(p, "cannot open source database: %s", + sqlite3_errmsg(p->dbSrc)); + return; + } + p->rcErr = sqlite3_exec(p->dbSrc, "BEGIN", 0, 0, 0); + if( p->rcErr ){ + scrubBackupErr(p, + "cannot start a read transaction on the source database: %s", + sqlite3_errmsg(p->dbSrc)); + return; + } + pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_size"); + if( pStmt==0 ) return; + rc = sqlite3_step(pStmt); + if( rc==SQLITE_ROW ){ + p->szPage = sqlite3_column_int(pStmt, 0); + }else{ + scrubBackupErr(p, "unable to determine the page size"); + } + sqlite3_finalize(pStmt); + if( p->rcErr ) return; + pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_count"); + if( pStmt==0 ) return; + rc = sqlite3_step(pStmt); + if( rc==SQLITE_ROW ){ + p->nPage = sqlite3_column_int(pStmt, 0); + }else{ + scrubBackupErr(p, "unable to determine the size of the source database"); + } + sqlite3_finalize(pStmt); + sqlite3_file_control(p->dbSrc, "main", SQLITE_FCNTL_FILE_POINTER, &p->pSrc); + if( p->pSrc==0 || p->pSrc->pMethods==0 ){ + scrubBackupErr(p, "cannot get the source file handle"); + p->rcErr = SQLITE_ERROR; + } +} + +/* Create and open the destination file */ +static void scrubBackupOpenDest(ScrubState *p){ + sqlite3_stmt *pStmt; + int rc; + char *zSql; + if( p->rcErr ) return; + p->rcErr = sqlite3_open_v2(p->zDestFile, &p->dbDest, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | + SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0); + if( p->rcErr ){ + scrubBackupErr(p, "cannot open destination database: %s", + sqlite3_errmsg(p->dbDest)); + return; + } + zSql = sqlite3_mprintf("PRAGMA page_size(%u);", p->szPage); + if( zSql==0 ){ + p->rcErr = SQLITE_NOMEM; + return; + } + p->rcErr = sqlite3_exec(p->dbDest, zSql, 0, 0, 0); + sqlite3_free(zSql); + if( p->rcErr ){ + scrubBackupErr(p, + "cannot set the page size on the destination database: %s", + sqlite3_errmsg(p->dbDest)); + return; + } + sqlite3_exec(p->dbDest, "PRAGMA journal_mode=OFF;", 0, 0, 0); + p->rcErr = sqlite3_exec(p->dbDest, "BEGIN EXCLUSIVE;", 0, 0, 0); + if( p->rcErr ){ + scrubBackupErr(p, + "cannot start a write transaction on the destination database: %s", + sqlite3_errmsg(p->dbDest)); + return; + } + pStmt = scrubBackupPrepare(p, p->dbDest, "PRAGMA page_count;"); + if( pStmt==0 ) return; + rc = sqlite3_step(pStmt); + if( rc!=SQLITE_ROW ){ + scrubBackupErr(p, "cannot measure the size of the destination"); + }else if( sqlite3_column_int(pStmt, 0)>1 ){ + scrubBackupErr(p, "destination database is not empty - holds %d pages", + sqlite3_column_int(pStmt, 0)); + } + sqlite3_finalize(pStmt); + sqlite3_file_control(p->dbDest, "main", SQLITE_FCNTL_FILE_POINTER, &p->pDest); + if( p->pDest==0 || p->pDest->pMethods==0 ){ + scrubBackupErr(p, "cannot get the destination file handle"); + p->rcErr = SQLITE_ERROR; + } +} + +int sqlite3_scrub_backup( + const char *zSrcFile, /* Source file */ + const char *zDestFile, /* Destination file */ + char **pzErr /* Write error here if non-NULL */ +){ + ScrubState s; + unsigned int i; + u8 *pBuf = 0; + u8 *pData; + + memset(&s, 0, sizeof(s)); + s.zSrcFile = zSrcFile; + s.zDestFile = zDestFile; + + scrubBackupOpenSrc(&s); + scrubBackupOpenDest(&s); + pBuf = scrubBackupAllocPage(&s); + + for(i=1; s.rcErr==0 && i<=s.nPage; i++){ + pData = scrubBackupRead(&s, i, pBuf); + scrubBackupWrite(&s, i, pData); + } + + /* Close the destination database without closing the transaction. If we + ** commit, page zero will be overwritten. */ + sqlite3_close(s.dbDest); + + sqlite3_close(s.dbSrc); + sqlite3_free(s.page1); + if( pzErr ){ + *pzErr = s.zErr; + }else{ + sqlite3_free(s.zErr); + } + return s.rcErr; +} + +#ifdef SCRUB_STANDALONE +/* The main() routine when this utility is run as a stand-alone program */ +int main(int argc, char **argv){ + char *zErr = 0; + int rc; + if( argc!=3 ){ + fprintf(stderr,"Usage: %s SOURCE DESTINATION\n", argv[0]); + exit(1); + } + rc = sqlite3_scrub_backup(argv[1], argv[2], &zErr); + if( rc==SQLITE_NOMEM ){ + fprintf(stderr, "%s: out of memory\n", argv[0]); + exit(1); + } + if( zErr ){ + fprintf(stderr, "%s: %s\n", argv[0], zErr); + sqlite3_free(zErr); + exit(1); + } + return 0; +} +#endif diff --git a/main.mk b/main.mk index 1e791416d8..f200dc2092 100644 --- a/main.mk +++ b/main.mk @@ -488,6 +488,9 @@ sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) $(THREADLIB) +scrub$(EXE): $(TOP)/ext/misc/scrub.c sqlite3.o + $(TCC) -I. -DSCRUB_STANDALONE -o scrub$(EXE) $(TOP)/ext/misc/scrub.c sqlite3.o $(THREADLIB) + srcck1$(EXE): $(TOP)/tool/srcck1.c $(BCC) -o srcck1$(EXE) $(TOP)/tool/srcck1.c diff --git a/manifest b/manifest index 8e5f6ffbdc..919f2e5e0d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Renumber\sinternal\sconstants\sin\sthe\sprintf()\simplemention\sfor\sa\ssmall\nperformance\simprovement. -D 2016-05-05T11:53:12.439 -F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 +C Initial\scheck-in\sof\sthe\s"scrub.exe"\sutility\sprogram\sprototype.\s\sNot\syet\nfully\sfunctional.\s\sIn\sparticular,\sno\sscrubbing\sis\sdone. +D 2016-05-05T17:15:23.301 +F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd +F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 5d234da9b5dae329fab75ff75884cfe0a9cb3fda F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -215,6 +215,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a +F ext/misc/scrub.c 76a9c795078a65bd021d5b5cd9e4655e7d0306c0 F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be @@ -302,7 +303,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk a283660f75c3c4b75d8c9d12a40fa38a066eee9d +F main.mk 0fb2b051c9dbcf7f26a8455cf115ae9457448b93 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1487,7 +1488,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71af9ac165ac02272f4886f69bd9ab4770fd7bb6 -R 89655379113728f544ce9a18ad294b0b +P 69d11447f4b1a8c536c3b6573d2a3419da870412 +R 98e582093972832acc05b11fc975c102 +T *branch * scrub-backup +T *sym-scrub-backup * +T -sym-trunk * U drh -Z f65addcdc03169dedb02067b28293d6c +Z e2196386eaeffd3910bcf89f26dcb9bb diff --git a/manifest.uuid b/manifest.uuid index 4a4e62d8ed..6832a682a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69d11447f4b1a8c536c3b6573d2a3419da870412 \ No newline at end of file +bdf2ec77d1542d4e9b68218f558710a3efc15823 \ No newline at end of file From 2a9bd02645c6616e877e090d8a2f7c8bfee77809 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2016 23:09:57 +0000 Subject: [PATCH 021/302] Finished implementation compiles, but untested. FossilOrigin-Name: aeb88bdf6fe9e5839b1503ab5740b27bc09d4842 --- ext/misc/scrub.c | 286 +++++++++++++++++++++++++++++++++++++++++++++-- manifest | 15 +-- manifest.uuid | 2 +- 3 files changed, 282 insertions(+), 21 deletions(-) diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c index fbf2f8c2b7..424db6baf5 100644 --- a/ext/misc/scrub.c +++ b/ext/misc/scrub.c @@ -57,6 +57,9 @@ typedef struct ScrubState ScrubState; typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; + /* State information for a scrub-and-backup operation */ struct ScrubState { @@ -68,8 +71,9 @@ struct ScrubState { sqlite3_file *pSrc; /* Source file handle */ sqlite3 *dbDest; /* Destination database connection */ sqlite3_file *pDest; /* Destination file handle */ - unsigned int szPage; /* Page size */ - unsigned int nPage; /* Number of pages */ + u32 szPage; /* Page size */ + u32 szUsable; /* Usable bytes on each page */ + u32 nPage; /* Number of pages */ u8 *page1; /* Content of page 1 */ }; @@ -116,7 +120,7 @@ static u8 *scrubBackupRead(ScrubState *p, int pgno, u8 *pBuf){ } /* Write a page to the destination database */ -static void scrubBackupWrite(ScrubState *p, int pgno, u8 *pData){ +static void scrubBackupWrite(ScrubState *p, int pgno, const u8 *pData){ int rc; sqlite3_int64 iOff; if( p->rcErr ) return; @@ -245,33 +249,293 @@ static void scrubBackupOpenDest(ScrubState *p){ } } +/* Read a 32-bit big-endian integer */ +static u32 scrubBackupInt32(const u8 *a){ + u32 v = a[3]; + v += ((u32)a[2])<<8; + v += ((u32)a[1])<<16; + v += ((u32)a[0])<<24; + return v; +} + +/* Read a 16-bit big-endian integer */ +static u32 scrubBackupInt16(const u8 *a){ + return (a[0]<<8) + a[1]; +} + +/* +** Read a varint. Put the value in *pVal and return the number of bytes. +*/ +static int scrubBackupVarint(const u8 *z, sqlite3_int64 *pVal){ + sqlite3_int64 v = 0; + int i; + for(i=0; i<8; i++){ + v = (v<<7) + (z[i]&0x7f); + if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; } + } + v = (v<<8) + (z[i]&0xff); + *pVal = v; + return 9; +} + +/* +** Return the number of bytes in a varint. +*/ +static int scrubBackupVarintSize(const u8 *z){ + int i; + for(i=0; i<8; i++){ + if( (z[i]&0x80)==0 ){ return i+1; } + } + return 9; +} + +/* +** Copy the freelist trunk page given, and all its descendents, +** zeroing out as much as possible in the process. +*/ +static void scrubBackupFreelist(ScrubState *p, int pgno, u32 nFree){ + u8 *a, *aBuf; + u32 n, mx; + + if( p->rcErr ) return; + aBuf = scrubBackupAllocPage(p); + if( aBuf==0 ) return; + + while( pgno && nFree){ + a = scrubBackupRead(p, pgno, aBuf); + if( a==0 ) break; + n = scrubBackupInt32(&a[4]); + mx = p->szUsable/4 - 2; + if( nszPage); + } + scrubBackupWrite(p, iLeaf, aZero); + nFree--; + } +#endif + } + sqlite3_free(aBuf); +} + +/* +** Copy an overflow chain from source to destination. Zero out any +** unused tail at the end of the overflow chain. +*/ +static void scrubBackupOverflow(ScrubState *p, int pgno, u32 nByte){ + u8 *a, *aBuf; + + aBuf = scrubBackupAllocPage(p); + if( aBuf==0 ) return; + while( nByte>0 && pgno!=0 ){ + a = scrubBackupRead(p, pgno, aBuf); + if( a ) break; + if( nByte >= (p->szUsable)-4 ){ + nByte -= (p->szUsable) - 4; + }else{ + u32 x = (p->szUsable - 4) - nByte; + u32 i = p->szUsable - x; + memset(&a[i], 0, x); + nByte = 0; + } + scrubBackupWrite(p, pgno, a); + pgno = scrubBackupInt32(a); + } + sqlite3_free(aBuf); +} + + +/* +** Copy B-Tree page pgno, and all of its children, from source to destination. +** Zero out deleted content during the copy. +*/ +static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ + u8 *a; + u32 i, n, pc; + u32 nCell; + u32 nPrefix; + u32 szHdr; + u32 iChild; + u8 *aTop; + u8 *aCell; + u32 x, y; + + + if( p->rcErr ) return; + if( iDepth>50 ){ + scrubBackupErr(p, "corrupt: b-tree too deep at page %d", pgno); + return; + } + if( pgno==1 ){ + a = p->page1; + }else{ + a = scrubBackupRead(p, pgno, 0); + if( a==0 ) return; + } + nPrefix = pgno==1 ? 100 : 0; + aTop = &a[nPrefix]; + szHdr = 8 + 4*(aTop[0]==0x02 || aTop[0]==0x05); + aCell = aTop + szHdr; + nCell = scrubBackupInt16(&aTop[3]); + + /* Zero out the gap between the cell index and the start of the + ** cell content area */ + x = scrubBackupInt16(&aTop[5]); /* First byte of cell content area */ + if( x>p->szUsable ) goto btree_corrupt; + y = szHdr + nPrefix + nCell*2; + if( y>x ) goto btree_corrupt; + if( y(p->szUsable)-4 ) goto btree_corrupt; + n = scrubBackupInt16(&a[pc+2]); + if( pc+n>(p->szUsable) ) goto btree_corrupt; + if( n>4 ) memset(&a[pc+4], 0, n-4); + x = scrubBackupInt16(&a[pc]); + if( x0 ) goto btree_corrupt; + pc = x; + } + + /* Write this one page */ + scrubBackupWrite(p, pgno, a); + + /* Walk the tree and process child pages */ + for(i=0; i p->szUsable-3 ) goto btree_corrupt; + if( aTop[0]==0x05 || aTop[0]==0x02 ){ + if( pc+4 > p->szUsable ) goto btree_corrupt; + iChild = scrubBackupInt32(&a[pc]); + pc += 4; + scrubBackupBtree(p, iChild, iDepth+1); + if( aTop[0]==0x05 ) continue; + } + pc += scrubBackupVarint(&a[pc], &P); + if( pc >= p->szUsable ) goto btree_corrupt; + if( aTop[0]==0x0d ){ + X = p->szUsable - 35; + }else{ + X = ((p->szUsable - 12)*64/255) - 23; + } + if( P<=X ){ + /* All content is local. No overflow */ + continue; + } + M = ((p->szUsable - 12)*32/255)-23; + K = M + ((P-M)%(p->szUsable-4)); + if( aTop[0]==0x0d ){ + pc += scrubBackupVarintSize(&a[pc]); + if( pc > (p->szUsable-4) ) goto btree_corrupt; + } + nLocal = K<=X ? K : M; + if( pc+nLocal > p->szUsable-4 ) goto btree_corrupt; + iChild = scrubBackupInt32(&a[pc+nLocal]); + scrubBackupOverflow(p, iChild, P-nLocal); + } + + /* Walk the right-most tree */ + if( aTop[0]==0x05 || aTop[0]==0x02 ){ + iChild = scrubBackupInt32(&aTop[8]); + scrubBackupBtree(p, iChild, iDepth+1); + } + + /* All done */ + if( pgno>1 ) sqlite3_free(a); + return; + +btree_corrupt: + scrubBackupErr(p, "corruption on page %d of source database", pgno); + if( pgno>1 ) sqlite3_free(a); +} + +/* +** Copy all ptrmap pages from source to destination. +** This routine is only called if the source database is in autovacuum +** or incremental vacuum mode. +*/ +static void scrubBackupPtrmap(ScrubState *p){ + u32 pgno = 2; + u32 J = p->szUsable/5; + u32 iLock = (1073742335/p->szPage)+1; + u8 *a, *pBuf; + if( p->rcErr ) return; + pBuf = scrubBackupAllocPage(p); + if( pBuf==0 ) return; + while( pgno<=p->nPage ){ + a = scrubBackupRead(p, pgno, pBuf); + if( a==0 ) break; + scrubBackupWrite(p, pgno, a); + pgno += J+1; + if( pgno==iLock ) pgno++; + } + sqlite3_free(pBuf); +} + int sqlite3_scrub_backup( const char *zSrcFile, /* Source file */ const char *zDestFile, /* Destination file */ char **pzErr /* Write error here if non-NULL */ ){ ScrubState s; - unsigned int i; - u8 *pBuf = 0; - u8 *pData; + u32 n, i; + sqlite3_stmt *pStmt; memset(&s, 0, sizeof(s)); s.zSrcFile = zSrcFile; s.zDestFile = zDestFile; + /* Open both source and destination databases */ scrubBackupOpenSrc(&s); scrubBackupOpenDest(&s); - pBuf = scrubBackupAllocPage(&s); - for(i=1; s.rcErr==0 && i<=s.nPage; i++){ - pData = scrubBackupRead(&s, i, pBuf); - scrubBackupWrite(&s, i, pData); + /* Read in page 1 */ + s.page1 = scrubBackupRead(&s, 1, 0); + if( s.page1==0 ) goto scrub_abort; + s.szUsable = s.szPage - s.page1[20]; + + /* Copy the freelist */ + n = scrubBackupInt32(&s.page1[36]); + i = scrubBackupInt32(&s.page1[32]); + if( n ) scrubBackupFreelist(&s, i, n); + + /* Copy ptrmap pages */ + n = scrubBackupInt32(&s.page1[52]); + if( n ) scrubBackupPtrmap(&s); + + /* Copy all of the btrees */ + scrubBackupBtree(&s, 1, 0); + pStmt = scrubBackupPrepare(&s, s.dbSrc, + "SELECT rootpage FROM sqlite_master WHERE rootpage IS NOT NULL"); + if( pStmt==0 ) goto scrub_abort; + while( sqlite3_step(pStmt)==SQLITE_ROW ){ + i = (u32)sqlite3_column_int(pStmt, 0); + scrubBackupBtree(&s, i, 0); } + sqlite3_finalize(pStmt); +scrub_abort: /* Close the destination database without closing the transaction. If we ** commit, page zero will be overwritten. */ sqlite3_close(s.dbDest); - sqlite3_close(s.dbSrc); sqlite3_free(s.page1); if( pzErr ){ diff --git a/manifest b/manifest index 919f2e5e0d..fff7842874 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\scheck-in\sof\sthe\s"scrub.exe"\sutility\sprogram\sprototype.\s\sNot\syet\nfully\sfunctional.\s\sIn\sparticular,\sno\sscrubbing\sis\sdone. -D 2016-05-05T17:15:23.301 +C Finished\simplementation\scompiles,\sbut\suntested. +D 2016-05-05T23:09:57.111 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -215,7 +215,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a -F ext/misc/scrub.c 76a9c795078a65bd021d5b5cd9e4655e7d0306c0 +F ext/misc/scrub.c 831d12a1ba776815eb946ee5a267997842384074 F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be @@ -1488,10 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 69d11447f4b1a8c536c3b6573d2a3419da870412 -R 98e582093972832acc05b11fc975c102 -T *branch * scrub-backup -T *sym-scrub-backup * -T -sym-trunk * +P bdf2ec77d1542d4e9b68218f558710a3efc15823 +R 3a64deda8cf94b6b4577af97769133ef U drh -Z e2196386eaeffd3910bcf89f26dcb9bb +Z 668555cf9e940e9598a6c547736364c9 diff --git a/manifest.uuid b/manifest.uuid index 6832a682a5..73eea5130f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bdf2ec77d1542d4e9b68218f558710a3efc15823 \ No newline at end of file +aeb88bdf6fe9e5839b1503ab5740b27bc09d4842 \ No newline at end of file From e04369e29e01d375fa17c206365407e8baaa0109 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2016 23:39:30 +0000 Subject: [PATCH 022/302] Working when run against sqlite.fossil. FossilOrigin-Name: b0bd9dd6255be161ea289ba6caa3fbd568128f62 --- ext/misc/scrub.c | 34 ++++++++++++++++++---------------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c index 424db6baf5..153625abed 100644 --- a/ext/misc/scrub.c +++ b/ext/misc/scrub.c @@ -342,7 +342,7 @@ static void scrubBackupOverflow(ScrubState *p, int pgno, u32 nByte){ if( aBuf==0 ) return; while( nByte>0 && pgno!=0 ){ a = scrubBackupRead(p, pgno, aBuf); - if( a ) break; + if( a==0 ) break; if( nByte >= (p->szUsable)-4 ){ nByte -= (p->szUsable) - 4; }else{ @@ -372,6 +372,7 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ u8 *aTop; u8 *aCell; u32 x, y; + int ln = 0; if( p->rcErr ) return; @@ -394,21 +395,21 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ /* Zero out the gap between the cell index and the start of the ** cell content area */ x = scrubBackupInt16(&aTop[5]); /* First byte of cell content area */ - if( x>p->szUsable ) goto btree_corrupt; + if( x>p->szUsable ){ ln=__LINE__; goto btree_corrupt; } y = szHdr + nPrefix + nCell*2; - if( y>x ) goto btree_corrupt; + if( y>x ){ ln=__LINE__; goto btree_corrupt; } if( y0 && pc(p->szUsable)-4 ) goto btree_corrupt; + if( pc>(p->szUsable)-4 ){ ln=__LINE__; goto btree_corrupt; } n = scrubBackupInt16(&a[pc+2]); - if( pc+n>(p->szUsable) ) goto btree_corrupt; + if( pc+n>(p->szUsable) ){ ln=__LINE__; goto btree_corrupt; } if( n>4 ) memset(&a[pc+4], 0, n-4); x = scrubBackupInt16(&a[pc]); - if( x0 ) goto btree_corrupt; + if( x0 ){ ln=__LINE__; goto btree_corrupt; } pc = x; } @@ -419,18 +420,18 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ for(i=0; i p->szUsable-3 ) goto btree_corrupt; + pc = scrubBackupInt16(&aCell[i*2]); + if( pc <= szHdr ){ ln=__LINE__; goto btree_corrupt; } + if( pc > p->szUsable-3 ){ ln=__LINE__; goto btree_corrupt; } if( aTop[0]==0x05 || aTop[0]==0x02 ){ - if( pc+4 > p->szUsable ) goto btree_corrupt; + if( pc+4 > p->szUsable ){ ln=__LINE__; goto btree_corrupt; } iChild = scrubBackupInt32(&a[pc]); pc += 4; scrubBackupBtree(p, iChild, iDepth+1); if( aTop[0]==0x05 ) continue; } pc += scrubBackupVarint(&a[pc], &P); - if( pc >= p->szUsable ) goto btree_corrupt; + if( pc >= p->szUsable ){ ln=__LINE__; goto btree_corrupt; } if( aTop[0]==0x0d ){ X = p->szUsable - 35; }else{ @@ -444,10 +445,10 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ K = M + ((P-M)%(p->szUsable-4)); if( aTop[0]==0x0d ){ pc += scrubBackupVarintSize(&a[pc]); - if( pc > (p->szUsable-4) ) goto btree_corrupt; + if( pc > (p->szUsable-4) ){ ln=__LINE__; goto btree_corrupt; } } nLocal = K<=X ? K : M; - if( pc+nLocal > p->szUsable-4 ) goto btree_corrupt; + if( pc+nLocal > p->szUsable-4 ){ ln=__LINE__; goto btree_corrupt; } iChild = scrubBackupInt32(&a[pc+nLocal]); scrubBackupOverflow(p, iChild, P-nLocal); } @@ -463,7 +464,8 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){ return; btree_corrupt: - scrubBackupErr(p, "corruption on page %d of source database", pgno); + scrubBackupErr(p, "corruption on page %d of source database (errid=%d)", + pgno, ln); if( pgno>1 ) sqlite3_free(a); } @@ -524,7 +526,7 @@ int sqlite3_scrub_backup( /* Copy all of the btrees */ scrubBackupBtree(&s, 1, 0); pStmt = scrubBackupPrepare(&s, s.dbSrc, - "SELECT rootpage FROM sqlite_master WHERE rootpage IS NOT NULL"); + "SELECT rootpage FROM sqlite_master WHERE coalesce(rootpage,0)>0"); if( pStmt==0 ) goto scrub_abort; while( sqlite3_step(pStmt)==SQLITE_ROW ){ i = (u32)sqlite3_column_int(pStmt, 0); diff --git a/manifest b/manifest index fff7842874..3ded627744 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Finished\simplementation\scompiles,\sbut\suntested. -D 2016-05-05T23:09:57.111 +C Working\swhen\srun\sagainst\ssqlite.fossil. +D 2016-05-05T23:39:30.803 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -215,7 +215,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a -F ext/misc/scrub.c 831d12a1ba776815eb946ee5a267997842384074 +F ext/misc/scrub.c 548a116cb0b4d8705eac392ab13d28fe2aebefe6 F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bdf2ec77d1542d4e9b68218f558710a3efc15823 -R 3a64deda8cf94b6b4577af97769133ef +P aeb88bdf6fe9e5839b1503ab5740b27bc09d4842 +R 6bcd08fd9f0774891e37784b87170024 U drh -Z 668555cf9e940e9598a6c547736364c9 +Z cbd8d4738f2e299be1c42951defbac8d diff --git a/manifest.uuid b/manifest.uuid index 73eea5130f..fee828267f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aeb88bdf6fe9e5839b1503ab5740b27bc09d4842 \ No newline at end of file +b0bd9dd6255be161ea289ba6caa3fbd568128f62 \ No newline at end of file From 8271630e81940729a34dd614d09a23851b078a42 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2016 23:59:22 +0000 Subject: [PATCH 023/302] Additional error reporting. Open the source database read/write so that it can delete the WAL file when done. FossilOrigin-Name: d2efd3c176f0eba2d78105f0bb3161db38bd4bab --- ext/misc/scrub.c | 17 ++++++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c index 153625abed..12adcd7bd9 100644 --- a/ext/misc/scrub.c +++ b/ext/misc/scrub.c @@ -157,7 +157,7 @@ static void scrubBackupOpenSrc(ScrubState *p){ int rc; /* Open the source database file */ p->rcErr = sqlite3_open_v2(p->zSrcFile, &p->dbSrc, - SQLITE_OPEN_READONLY | + SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0); if( p->rcErr ){ scrubBackupErr(p, "cannot open source database: %s", @@ -538,6 +538,9 @@ scrub_abort: /* Close the destination database without closing the transaction. If we ** commit, page zero will be overwritten. */ sqlite3_close(s.dbDest); + + /* But do close out the read-transaction on the source database */ + sqlite3_exec(s.dbSrc, "COMMIT;", 0, 0, 0); sqlite3_close(s.dbSrc); sqlite3_free(s.page1); if( pzErr ){ @@ -549,6 +552,17 @@ scrub_abort: } #ifdef SCRUB_STANDALONE +/* Error and warning log */ +static void errorLogCallback(void *pNotUsed, int iErr, const char *zMsg){ + const char *zType; + switch( iErr&0xff ){ + case SQLITE_WARNING: zType = "WARNING"; break; + case SQLITE_NOTICE: zType = "NOTICE"; break; + default: zType = "ERROR"; break; + } + fprintf(stderr, "%s: %s\n", zType, zMsg); +} + /* The main() routine when this utility is run as a stand-alone program */ int main(int argc, char **argv){ char *zErr = 0; @@ -557,6 +571,7 @@ int main(int argc, char **argv){ fprintf(stderr,"Usage: %s SOURCE DESTINATION\n", argv[0]); exit(1); } + sqlite3_config(SQLITE_CONFIG_LOG, errorLogCallback, 0); rc = sqlite3_scrub_backup(argv[1], argv[2], &zErr); if( rc==SQLITE_NOMEM ){ fprintf(stderr, "%s: out of memory\n", argv[0]); diff --git a/manifest b/manifest index 3ded627744..0f9b581c85 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Working\swhen\srun\sagainst\ssqlite.fossil. -D 2016-05-05T23:39:30.803 +C Additional\serror\sreporting.\s\sOpen\sthe\ssource\sdatabase\sread/write\sso\sthat\nit\scan\sdelete\sthe\sWAL\sfile\swhen\sdone. +D 2016-05-05T23:59:22.078 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -215,7 +215,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a -F ext/misc/scrub.c 548a116cb0b4d8705eac392ab13d28fe2aebefe6 +F ext/misc/scrub.c a3380a5ff0698f88a56a23c999ee5e53768ac3ae F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aeb88bdf6fe9e5839b1503ab5740b27bc09d4842 -R 6bcd08fd9f0774891e37784b87170024 +P b0bd9dd6255be161ea289ba6caa3fbd568128f62 +R dbc8e27f8b8809d87c6c9be80d710e34 U drh -Z cbd8d4738f2e299be1c42951defbac8d +Z 950b8c8bc6ebdccefe511e872cba5384 diff --git a/manifest.uuid b/manifest.uuid index fee828267f..46b409542f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0bd9dd6255be161ea289ba6caa3fbd568128f62 \ No newline at end of file +d2efd3c176f0eba2d78105f0bb3161db38bd4bab \ No newline at end of file From 70077d173323e074cbbe40c8234a7b3949b1a5c7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 6 May 2016 11:31:10 +0000 Subject: [PATCH 024/302] Do not scan indexes that have the integer primary key as their left-most column. This fixes the crash of ticket [16c9801ceba] but it seems like the wrong fix. More investigation needed. FossilOrigin-Name: 50312273ffaf1bd4bfdc73865fa0b19166968429 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/where.c | 2 +- test/intpkey.test | 14 +++++++++++++- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8e5f6ffbdc..fb2ac900b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Renumber\sinternal\sconstants\sin\sthe\sprintf()\simplemention\sfor\sa\ssmall\nperformance\simprovement. -D 2016-05-05T11:53:12.439 +C Do\snot\sscan\sindexes\sthat\shave\sthe\sinteger\sprimary\skey\sas\stheir\sleft-most\ncolumn.\s\sThis\sfixes\sthe\scrash\sof\sticket\s[16c9801ceba]\sbut\sit\sseems\slike\nthe\swrong\sfix.\s\sMore\sinvestigation\sneeded. +D 2016-05-06T11:31:10.902 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -457,7 +457,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 019e5b10dedcf54ef077ce23dd8fce38d614dcf4 +F src/where.c a7ce00ffd7844495582af957a222602e517b14de F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 F src/wherecode.c 28951741be3974701186281ced0564e9586a0db3 F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e @@ -847,7 +847,7 @@ F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc -F test/intpkey.test 153b70e32d008f4f4b2dff8daf448a6110b62a9c +F test/intpkey.test 18ec1f3f39a18ed51d2dbd9ce184cc421191ff70 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 @@ -1487,7 +1487,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71af9ac165ac02272f4886f69bd9ab4770fd7bb6 -R 89655379113728f544ce9a18ad294b0b +P 69d11447f4b1a8c536c3b6573d2a3419da870412 +R 88ac4ed286db19382d4843a346c44c60 +T *branch * ticket-16c9801ce +T *sym-ticket-16c9801ce * +T -sym-trunk * U drh -Z f65addcdc03169dedb02067b28293d6c +Z a8fa257e80e1a139c1678ae44101daf6 diff --git a/manifest.uuid b/manifest.uuid index 4a4e62d8ed..1745de5e7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69d11447f4b1a8c536c3b6573d2a3419da870412 \ No newline at end of file +50312273ffaf1bd4bfdc73865fa0b19166968429 \ No newline at end of file diff --git a/src/where.c b/src/where.c index d45a872c85..9aa068d660 100644 --- a/src/where.c +++ b/src/where.c @@ -289,7 +289,7 @@ static WhereTerm *whereScanInit( j = iColumn; iColumn = pIdx->aiColumn[j]; if( iColumn==XN_EXPR ) pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr; - if( iColumn==pIdx->pTable->iPKey ) iColumn = XN_ROWID; + if( iColumn==pIdx->pTable->iPKey && j>0 ) iColumn = XN_ROWID; } if( pIdx && iColumn>=0 ){ pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; diff --git a/test/intpkey.test b/test/intpkey.test index c6be5418aa..0158ad7766 100644 --- a/test/intpkey.test +++ b/test/intpkey.test @@ -614,6 +614,18 @@ do_execsql_test intpkey-16.1 { PRAGMA table_info=t16a; } {0 id INTEGER 0 {} 1 1 b TEXT 0 {} 0 2 c INT 0 {} 0} - +# 2016-05-06 ticket https://www.sqlite.org/src/tktview/16c9801ceba4923939085 +# When the schema contains an index on the IPK and no other index +# and a WHERE clause on a delete uses an OR where both sides referencing +# the IPK, then it is possible that the OP_Delete will fail because there +# deferred seek of the OP_Seek is not resolved prior to reaching the OP_Delete. +# +do_execsql_test intpkey-17.0 { + CREATE TABLE t17(x INTEGER PRIMARY KEY, y TEXT); + INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe'); + CREATE INDEX t17x ON t17(x); + DELETE FROM t17 WHERE x=99 OR x<130; + SELECT * FROM t17; +} {248 giraffe} finish_test From d49c6930b16bae906c8017c9bf498869bce4ca39 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 6 May 2016 15:16:02 +0000 Subject: [PATCH 025/302] Fix a bug in sqlite_analyzer causing it report (slightly) incorrect values for the number of entries in indexes or WITHOUT ROWID tables. FossilOrigin-Name: dc37750d4e87d0c529785adceeebd838b8f8591d --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/spaceanal.tcl | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 8e5f6ffbdc..7c1f55f984 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Renumber\sinternal\sconstants\sin\sthe\sprintf()\simplemention\sfor\sa\ssmall\nperformance\simprovement. -D 2016-05-05T11:53:12.439 +C Fix\sa\sbug\sin\ssqlite_analyzer\scausing\sit\sreport\s(slightly)\sincorrect\svalues\sfor\sthe\snumber\sof\sentries\sin\sindexes\sor\sWITHOUT\sROWID\stables. +D 2016-05-06T15:16:02.765 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -1447,7 +1447,7 @@ F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 F tool/showstat4.c bda40d6e395df7edb6e9ea630784d3d762c35b4b F tool/showwal.c ec79959834f7b21f1e0a2aa52bb7c056d2203977 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe -F tool/spaceanal.tcl 93c1fdc9733c525b17a2024c7df193daa002e037 +F tool/spaceanal.tcl 85d90e6674d8298e3eaf82dbcef3abc2d5317f3e F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71af9ac165ac02272f4886f69bd9ab4770fd7bb6 -R 89655379113728f544ce9a18ad294b0b -U drh -Z f65addcdc03169dedb02067b28293d6c +P 69d11447f4b1a8c536c3b6573d2a3419da870412 +R 56e7e963139ae94efddd96a9288ff8e5 +U dan +Z 82199c527d2c64b9169490d91c3a80bb diff --git a/manifest.uuid b/manifest.uuid index 4a4e62d8ed..aa435a5204 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69d11447f4b1a8c536c3b6573d2a3419da870412 \ No newline at end of file +dc37750d4e87d0c529785adceeebd838b8f8591d \ No newline at end of file diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index 38d954162e..eef1192a1d 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -152,6 +152,7 @@ set tabledef {CREATE TABLE space_used( name clob, -- Name of a table or index in the database file tblname clob, -- Name of associated table is_index boolean, -- TRUE if it is an index, false for a table + is_without_rowid boolean, -- TRUE if WITHOUT ROWID table nentry int, -- Number of entries in the BTree leaf_entries int, -- Number of leaf entries depth int, -- Depth of the b-tree @@ -184,7 +185,7 @@ set sql { SELECT name, tbl_name FROM sqlite_master WHERE rootpage>0 } foreach {name tblname} [concat sqlite_master sqlite_master [db eval $sql]] { set is_index [expr {$name!=$tblname}] - set idx_btree [expr {$is_index || [is_without_rowid $name]}] + set is_without_rowid [is_without_rowid $name] db eval { SELECT sum(ncell) AS nentry, @@ -235,6 +236,7 @@ foreach {name tblname} [concat sqlite_master sqlite_master [db eval $sql]] { $name, $tblname, $is_index, + $is_without_rowid, $nentry, $leaf_entries, $depth, @@ -330,12 +332,15 @@ proc subreport {title where showFrag} { # following query returns exactly one row (because it is an aggregate). # # The results of the query are stored directly by SQLite into local - # variables (i.e. $nentry, $nleaf etc.). + # variables (i.e. $nentry, $payload etc.). # mem eval " SELECT - int(sum(nentry)) AS nentry, - int(sum(leaf_entries)) AS nleaf, + int(sum( + CASE WHEN (is_without_rowid OR is_index) THEN nentry + ELSE leaf_entries + END + )) AS nentry, int(sum(payload)) AS payload, int(sum(ovfl_payload)) AS ovfl_payload, max(mx_payload) AS mx_payload, @@ -375,8 +380,8 @@ proc subreport {title where showFrag} { set storage [expr {$total_pages*$pageSize}] set payload_percent [percent $payload $storage {of storage consumed}] set total_unused [expr {$ovfl_unused+$int_unused+$leaf_unused}] - set avg_payload [divide $payload $nleaf] - set avg_unused [divide $total_unused $nleaf] + set avg_payload [divide $payload $nentry] + set avg_unused [divide $total_unused $nentry] if {$int_pages>0} { # TODO: Is this formula correct? set nTab [mem eval " @@ -390,12 +395,12 @@ proc subreport {title where showFrag} { "] set avg_fanout [format %.2f $avg_fanout] } - set ovfl_cnt_percent [percent $ovfl_cnt $nleaf {of all entries}] + set ovfl_cnt_percent [percent $ovfl_cnt $nentry {of all entries}] # Print out the sub-report statistics. # statline {Percentage of total database} $total_pages_percent - statline {Number of entries} $nleaf + statline {Number of entries} $nentry statline {Bytes of storage consumed} $storage if {$compressed_size!=$storage} { set compressed_size [expr {$compressed_size+$compressOverhead*$total_pages}] From bcf6884afdbcdf193308dd393e1360e5f8f4289a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 6 May 2016 16:06:59 +0000 Subject: [PATCH 026/302] In the WHERE generator, when building code for a DELETE operation, make sure that seeks to the main table are not deferred. This is a better fix for the [16c9801ceba49] bug than the previous. FossilOrigin-Name: 150dd09ebd7b17234a79e1811a0fae8b0a7a40d5 --- manifest | 23 ++++++++++------------- manifest.uuid | 2 +- src/delete.c | 2 +- src/sqliteInt.h | 1 + src/where.c | 2 +- src/wherecode.c | 7 +++++-- test/intpkey.test | 8 ++++++++ 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index fb2ac900b5..459b5d3727 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sscan\sindexes\sthat\shave\sthe\sinteger\sprimary\skey\sas\stheir\sleft-most\ncolumn.\s\sThis\sfixes\sthe\scrash\sof\sticket\s[16c9801ceba]\sbut\sit\sseems\slike\nthe\swrong\sfix.\s\sMore\sinvestigation\sneeded. -D 2016-05-06T11:31:10.902 +C In\sthe\sWHERE\sgenerator,\swhen\sbuilding\scode\sfor\sa\sDELETE\soperation,\smake\ssure\nthat\sseeks\sto\sthe\smain\stable\sare\snot\sdeferred.\nThis\sis\sa\sbetter\sfix\sfor\sthe\s[16c9801ceba49]\sbug\sthan\sthe\sprevious. +D 2016-05-06T16:06:59.602 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -330,7 +330,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b -F src/delete.c 912908dea57778737d4bab632f00e48b550d10ea +F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f F src/expr.c 8796c0739b2ad091e6779253f62aad6e767e2be1 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb @@ -382,7 +382,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h c8483dd77894a72d38a76b6251a4ac949a37d6e8 +F src/sqliteInt.h 4ab5884aa7dd1cfbb1a34f60d8a919f6584c4aa1 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -457,9 +457,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c a7ce00ffd7844495582af957a222602e517b14de +F src/where.c 019e5b10dedcf54ef077ce23dd8fce38d614dcf4 F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 -F src/wherecode.c 28951741be3974701186281ced0564e9586a0db3 +F src/wherecode.c 6e2da2449d5589b2ce988afae125a61cad665c86 F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -847,7 +847,7 @@ F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc -F test/intpkey.test 18ec1f3f39a18ed51d2dbd9ce184cc421191ff70 +F test/intpkey.test bd82146463500ecb5e793b5ea2865eaa1c7bdfb6 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 @@ -1487,10 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 69d11447f4b1a8c536c3b6573d2a3419da870412 -R 88ac4ed286db19382d4843a346c44c60 -T *branch * ticket-16c9801ce -T *sym-ticket-16c9801ce * -T -sym-trunk * +P 50312273ffaf1bd4bfdc73865fa0b19166968429 +R 0aaabe1d44ff452855f4b1d0d09524f8 U drh -Z a8fa257e80e1a139c1678ae44101daf6 +Z 9200ae75c074ea360e36df5da26c6a08 diff --git a/manifest.uuid b/manifest.uuid index 1745de5e7c..709cd8f436 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -50312273ffaf1bd4bfdc73865fa0b19166968429 \ No newline at end of file +150dd09ebd7b17234a79e1811a0fae8b0a7a40d5 \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index dab1fd40cd..e9e669e21c 100644 --- a/src/delete.c +++ b/src/delete.c @@ -373,7 +373,7 @@ void sqlite3DeleteFrom( }else #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ { - u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; + u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK|WHERE_SEEK_TABLE; if( sNC.ncFlags & NC_VarSelect ) bComplex = 1; wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW); if( HasRowid(pTab) ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 783f0f56c3..de06f6d7d8 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2543,6 +2543,7 @@ struct SrcList { #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ #define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */ #define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */ +#define WHERE_SEEK_TABLE 0x8000 /* Always seek the main table */ /* Allowed return values from sqlite3WhereIsDistinct() */ diff --git a/src/where.c b/src/where.c index 9aa068d660..d45a872c85 100644 --- a/src/where.c +++ b/src/where.c @@ -289,7 +289,7 @@ static WhereTerm *whereScanInit( j = iColumn; iColumn = pIdx->aiColumn[j]; if( iColumn==XN_EXPR ) pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr; - if( iColumn==pIdx->pTable->iPKey && j>0 ) iColumn = XN_ROWID; + if( iColumn==pIdx->pTable->iPKey ) iColumn = XN_ROWID; } if( pIdx && iColumn>=0 ){ pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; diff --git a/src/wherecode.c b/src/wherecode.c index 77543a9388..c1397b8a29 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1324,7 +1324,9 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ }else if( HasRowid(pIdx->pTable) ){ - if( pWInfo->eOnePass!=ONEPASS_OFF ){ + if( pWInfo->eOnePass!=ONEPASS_OFF + || (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 + ){ iRowidReg = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); @@ -1520,7 +1522,8 @@ Bitmask sqlite3WhereCodeOneLoopStart( wctrlFlags = WHERE_OMIT_OPEN_CLOSE | WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY - | WHERE_NO_AUTOINDEX; + | WHERE_NO_AUTOINDEX + | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE); for(ii=0; iinTerm; ii++){ WhereTerm *pOrTerm = &pOrWc->a[ii]; if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ diff --git a/test/intpkey.test b/test/intpkey.test index 0158ad7766..4680e2270e 100644 --- a/test/intpkey.test +++ b/test/intpkey.test @@ -627,5 +627,13 @@ do_execsql_test intpkey-17.0 { DELETE FROM t17 WHERE x=99 OR x<130; SELECT * FROM t17; } {248 giraffe} +do_execsql_test intpkey-17.1 { + DROP INDEX t17x; + DELETE FROM t17; + INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe'); + CREATE INDEX t17x ON t17(abs(x)); + DELETE FROM t17 WHERE abs(x) IS NULL OR abs(x)<130; + SELECT * FROM t17; +} {248 giraffe} finish_test From 39332fb0f7cf2247cd31bb6f9ca76ca54d07fc05 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 6 May 2016 16:30:34 +0000 Subject: [PATCH 027/302] Fix an error in main.mk causing testfixture to use individual fts5 source code files instead of fts5.c. FossilOrigin-Name: 933a1c818c1d1ccec8680e1ba87f2cbe37cc9f7d --- main.mk | 3 +-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/main.mk b/main.mk index 1e791416d8..9111b1ab64 100644 --- a/main.mk +++ b/main.mk @@ -388,8 +388,7 @@ TESTSRC2 = \ $(TOP)/ext/fts3/fts3_write.c \ $(TOP)/ext/async/sqlite3async.c \ $(TOP)/ext/session/sqlite3session.c \ - $(TOP)/ext/session/test_session.c \ - $(FTS5_SRC) + $(TOP)/ext/session/test_session.c # Header files used by all library source files. # diff --git a/manifest b/manifest index 7c1f55f984..0525e61f73 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\ssqlite_analyzer\scausing\sit\sreport\s(slightly)\sincorrect\svalues\sfor\sthe\snumber\sof\sentries\sin\sindexes\sor\sWITHOUT\sROWID\stables. -D 2016-05-06T15:16:02.765 +C Fix\san\serror\sin\smain.mk\scausing\stestfixture\sto\suse\sindividual\sfts5\ssource\scode\sfiles\sinstead\sof\sfts5.c. +D 2016-05-06T16:30:34.529 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -302,7 +302,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk a283660f75c3c4b75d8c9d12a40fa38a066eee9d +F main.mk 86e6a8d79186ace5ff8b306093da1728d953f796 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 69d11447f4b1a8c536c3b6573d2a3419da870412 -R 56e7e963139ae94efddd96a9288ff8e5 +P dc37750d4e87d0c529785adceeebd838b8f8591d +R c15766ea1c9925837a701d30f137e7d3 U dan -Z 82199c527d2c64b9169490d91c3a80bb +Z ee202f54aac91dd67f57f6a979bc066b diff --git a/manifest.uuid b/manifest.uuid index aa435a5204..e0a918072d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc37750d4e87d0c529785adceeebd838b8f8591d \ No newline at end of file +933a1c818c1d1ccec8680e1ba87f2cbe37cc9f7d \ No newline at end of file From a3fd75d4265306f6aefecafe6368c57e16fc60b9 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 6 May 2016 18:47:23 +0000 Subject: [PATCH 028/302] Corrections to comments on the whereScanInit() interface. FossilOrigin-Name: ab7ab415d19524f6c3901e474d3a154f55d28530 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/where.c | 14 +++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 6fd1d2d402..a7874dbd66 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sDELETE\soperations,\smake\ssure\sthat\sseeks\son\sthe\smain\stable\sare\snot\ndeferred,\ssince\sif\sthey\sare\sand\snone\sof\sthe\sindexes\sreference\scolumns\sof\nthe\stable,\sthe\sseek\smight\snever\soccur\suntil\sthe\sOP_Delete\sopcode,\swhich\sis\ntoo\slate.\s\sFix\sfor\sticket\s[16c9801ceba49]. -D 2016-05-06T16:49:54.299 +C Corrections\sto\scomments\son\sthe\swhereScanInit()\sinterface. +D 2016-05-06T18:47:23.830 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -457,7 +457,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 019e5b10dedcf54ef077ce23dd8fce38d614dcf4 +F src/where.c fd321cc2c5ee346a2e146b93892ed01bb7a839c0 F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 F src/wherecode.c 6e2da2449d5589b2ce988afae125a61cad665c86 F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e @@ -1487,8 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 933a1c818c1d1ccec8680e1ba87f2cbe37cc9f7d 150dd09ebd7b17234a79e1811a0fae8b0a7a40d5 -R 999c47253628cf8504ca9429ccbba492 -T +closed 150dd09ebd7b17234a79e1811a0fae8b0a7a40d5 +P 93a2bace5704f7ecad56541a6b3e06a88f7f393f +R 3ca4ebdcc8bebe388d97851d25aa812d U drh -Z 0a4c84a453e835d42d347d7d3d2d52db +Z e6d944ba38affdbccc4e07da270b6c3d diff --git a/manifest.uuid b/manifest.uuid index f2214b4f51..b4a061c620 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -93a2bace5704f7ecad56541a6b3e06a88f7f393f \ No newline at end of file +ab7ab415d19524f6c3901e474d3a154f55d28530 \ No newline at end of file diff --git a/src/where.c b/src/where.c index d45a872c85..0c3f05f7f2 100644 --- a/src/where.c +++ b/src/where.c @@ -261,7 +261,10 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ ** ** The scanner will be searching the WHERE clause pWC. It will look ** for terms of the form "X " where X is column iColumn of table -** iCur. The must be one of the operators described by opMask. +** iCur. Or if pIdx!=0 then X is column iColumn of index pIdx. pIdx +** must be one of the indexes of table iCur. +** +** The must be one of the operators described by opMask. ** ** If the search is for X and the WHERE clause contains terms of the ** form X=Y then this routine might also return terms of the form @@ -309,11 +312,12 @@ static WhereTerm *whereScanInit( /* ** Search for a term in the WHERE clause that is of the form "X " -** where X is a reference to the iColumn of table iCur and is one of -** the WO_xx operator codes specified by the op parameter. -** Return a pointer to the term. Return 0 if not found. +** where X is a reference to the iColumn of table iCur or of index pIdx +** if pIdx!=0 and is one of the WO_xx operator codes specified by +** the op parameter. Return a pointer to the term. Return 0 if not found. ** -** If pIdx!=0 then search for terms matching the iColumn-th column of pIdx +** If pIdx!=0 then it must be one of the indexes of table iCur. +** Search for terms matching the iColumn-th column of pIdx ** rather than the iColumn-th column of table iCur. ** ** The term returned might by Y= if there is another constraint in From f09c48233a1238f45be65b57986e543d7178711f Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 6 May 2016 20:23:12 +0000 Subject: [PATCH 029/302] Simplification to the logic used to decide between OP_Seek and OP_NotExists. Use OP_NotExists for both DELETE and UPDATE. FossilOrigin-Name: 3a695263183303e3f64eb2320752d0fdef53eaf2 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/update.c | 3 ++- src/wherecode.c | 4 +--- test/intpkey.test | 8 +++++++- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index a7874dbd66..dc724954ef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Corrections\sto\scomments\son\sthe\swhereScanInit()\sinterface. -D 2016-05-06T18:47:23.830 +C Simplification\sto\sthe\slogic\sused\sto\sdecide\sbetween\sOP_Seek\sand\sOP_NotExists.\nUse\sOP_NotExists\sfor\sboth\sDELETE\sand\sUPDATE. +D 2016-05-06T20:23:12.122 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -439,7 +439,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3b29883b0ce4a6c6f643965b66b5ca6613178e59 F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 -F src/update.c 3e67ab3c0814635f355fb1f8ab010a2b9e016e7d +F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 @@ -459,7 +459,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c fd321cc2c5ee346a2e146b93892ed01bb7a839c0 F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 -F src/wherecode.c 6e2da2449d5589b2ce988afae125a61cad665c86 +F src/wherecode.c 23fc19ca546ce323ba5c4be96b88e3ba08cf6b8f F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -847,7 +847,7 @@ F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc -F test/intpkey.test bd82146463500ecb5e793b5ea2865eaa1c7bdfb6 +F test/intpkey.test 890cc2df52c2dd10ae5ef922c1edcdfa2a4228f8 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 93a2bace5704f7ecad56541a6b3e06a88f7f393f -R 3ca4ebdcc8bebe388d97851d25aa812d +P ab7ab415d19524f6c3901e474d3a154f55d28530 +R f6a10a5aa5f2ff9434de04bd402f6c3f U drh -Z e6d944ba38affdbccc4e07da270b6c3d +Z 447839f87caf188b0aa6e0197947c00d diff --git a/manifest.uuid b/manifest.uuid index b4a061c620..51f86604f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ab7ab415d19524f6c3901e474d3a154f55d28530 \ No newline at end of file +3a695263183303e3f64eb2320752d0fdef53eaf2 \ No newline at end of file diff --git a/src/update.c b/src/update.c index 7b38c5bcc5..1436501264 100644 --- a/src/update.c +++ b/src/update.c @@ -352,7 +352,8 @@ void sqlite3Update( if( HasRowid(pTab) ){ sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid); pWInfo = sqlite3WhereBegin( - pParse, pTabList, pWhere, 0, 0, WHERE_ONEPASS_DESIRED, iIdxCur + pParse, pTabList, pWhere, 0, 0, + WHERE_ONEPASS_DESIRED | WHERE_SEEK_TABLE, iIdxCur ); if( pWInfo==0 ) goto update_cleanup; okOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); diff --git a/src/wherecode.c b/src/wherecode.c index c1397b8a29..aee50c3142 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1324,9 +1324,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ }else if( HasRowid(pIdx->pTable) ){ - if( pWInfo->eOnePass!=ONEPASS_OFF - || (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 - ){ + if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 ){ iRowidReg = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); diff --git a/test/intpkey.test b/test/intpkey.test index 4680e2270e..12802ca44b 100644 --- a/test/intpkey.test +++ b/test/intpkey.test @@ -631,9 +631,15 @@ do_execsql_test intpkey-17.1 { DROP INDEX t17x; DELETE FROM t17; INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe'); - CREATE INDEX t17x ON t17(abs(x)); + CREATE UNIQUE INDEX t17x ON t17(abs(x)); DELETE FROM t17 WHERE abs(x) IS NULL OR abs(x)<130; SELECT * FROM t17; } {248 giraffe} +do_execsql_test intpkey-17.2 { + DELETE FROM t17; + INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe'); + UPDATE FROM t17 SET y='ostrich' WHERE abs(x)=248; + SELECT * FROM t17 ORDER BY +x; +} {123 elephant 248 ostrich} finish_test From 3eead2702294f5f9cbf50328a12e7dab6f4a3069 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 7 May 2016 12:15:15 +0000 Subject: [PATCH 030/302] Fix typo in the intpkey-17.2 test. FossilOrigin-Name: a45fda657d987f5c923d141584841a6c62dfb504 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/intpkey.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index dc724954ef..39e77dbc87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sto\sthe\slogic\sused\sto\sdecide\sbetween\sOP_Seek\sand\sOP_NotExists.\nUse\sOP_NotExists\sfor\sboth\sDELETE\sand\sUPDATE. -D 2016-05-06T20:23:12.122 +C Fix\stypo\sin\sthe\sintpkey-17.2\stest. +D 2016-05-07T12:15:15.906 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -847,7 +847,7 @@ F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc -F test/intpkey.test 890cc2df52c2dd10ae5ef922c1edcdfa2a4228f8 +F test/intpkey.test ac71107a49a06492b69b82aafaf225400598d3c8 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ab7ab415d19524f6c3901e474d3a154f55d28530 -R f6a10a5aa5f2ff9434de04bd402f6c3f +P 3a695263183303e3f64eb2320752d0fdef53eaf2 +R 51aec2bae3f4c90b051a05d513fd048f U drh -Z 447839f87caf188b0aa6e0197947c00d +Z 7d38c3073c92b6f84127f76ce4d99aa3 diff --git a/manifest.uuid b/manifest.uuid index 51f86604f1..572dd73cd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3a695263183303e3f64eb2320752d0fdef53eaf2 \ No newline at end of file +a45fda657d987f5c923d141584841a6c62dfb504 \ No newline at end of file diff --git a/test/intpkey.test b/test/intpkey.test index 12802ca44b..a56cab4c69 100644 --- a/test/intpkey.test +++ b/test/intpkey.test @@ -638,7 +638,7 @@ do_execsql_test intpkey-17.1 { do_execsql_test intpkey-17.2 { DELETE FROM t17; INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe'); - UPDATE FROM t17 SET y='ostrich' WHERE abs(x)=248; + UPDATE t17 SET y='ostrich' WHERE abs(x)=248; SELECT * FROM t17 ORDER BY +x; } {123 elephant 248 ostrich} From e8da01c189b2bde0fca85ae549cecdd022869e7c Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 7 May 2016 12:15:34 +0000 Subject: [PATCH 031/302] Make the sqlite3DeleteTable() routine smaller and faster. FossilOrigin-Name: d75140b851a34a5eb66041e294e421628efbc5ba --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 17 +++++++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 39e77dbc87..c4b4c5d9f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\sthe\sintpkey-17.2\stest. -D 2016-05-07T12:15:15.906 +C Make\sthe\ssqlite3DeleteTable()\sroutine\ssmaller\sand\sfaster. +D 2016-05-07T12:15:34.317 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -324,7 +324,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 3ae6aea66cc4e13d30162ff0d0d43c7088e34abf F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 42e8ee74dfa3a4b99bfb2c201f8a66ab50688d95 +F src/build.c d65be62254ca9df36e1e1c433324f0333f80009c F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3a695263183303e3f64eb2320752d0fdef53eaf2 -R 51aec2bae3f4c90b051a05d513fd048f +P a45fda657d987f5c923d141584841a6c62dfb504 +R de01d2c88028a3b709951f9d3730409b U drh -Z 7d38c3073c92b6f84127f76ce4d99aa3 +Z c83c111125ba50dd275150f90f412c72 diff --git a/manifest.uuid b/manifest.uuid index 572dd73cd1..216472cb11 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a45fda657d987f5c923d141584841a6c62dfb504 \ No newline at end of file +d75140b851a34a5eb66041e294e421628efbc5ba \ No newline at end of file diff --git a/src/build.c b/src/build.c index c7541bc9d8..2fa4e3102f 100644 --- a/src/build.c +++ b/src/build.c @@ -592,16 +592,10 @@ void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){ ** db parameter can be used with db->pnBytesFreed to measure the memory ** used by the Table object. */ -void sqlite3DeleteTable(sqlite3 *db, Table *pTable){ +static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){ Index *pIndex, *pNext; TESTONLY( int nLookaside; ) /* Used to verify lookaside not used for schema */ - assert( !pTable || pTable->nRef>0 ); - - /* Do not delete the table until the reference count reaches zero. */ - if( !pTable ) return; - if( ((!db || db->pnBytesFreed==0) && (--pTable->nRef)>0) ) return; - /* Record the number of outstanding lookaside allocations in schema Tables ** prior to doing any free() operations. Since schema Tables do not use ** lookaside, this number should not change. */ @@ -641,6 +635,13 @@ void sqlite3DeleteTable(sqlite3 *db, Table *pTable){ /* Verify that no lookaside memory was used by schema tables */ assert( nLookaside==0 || nLookaside==db->lookaside.nOut ); } +void sqlite3DeleteTable(sqlite3 *db, Table *pTable){ + /* Do not delete the table until the reference count reaches zero. */ + if( !pTable ) return; + if( ((!db || db->pnBytesFreed==0) && (--pTable->nRef)>0) ) return; + deleteTable(db, pTable); +} + /* ** Unlink the given table from the hash tables and the delete the @@ -2221,7 +2222,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ pTable->nCol = 0; nErr++; } - if( pSelTab ) sqlite3DeleteTable(db, pSelTab); + sqlite3DeleteTable(db, pSelTab); sqlite3SelectDelete(db, pSel); db->lookaside.bDisable--; } else { From 170b66493df878f5599dc78670086937e23c92f1 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 9 May 2016 18:05:44 +0000 Subject: [PATCH 032/302] Fix the FTS5 xQueryPhrase() API function so that it recognizes column filters. FossilOrigin-Name: 48505cde05d74748454dc135d4ec25954ecf020e --- ext/fts5/fts5_expr.c | 11 +++++++++++ ext/fts5/test/fts5aux.test | 32 ++++++++++++++++++++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index eada84f70e..a48fa6e9d0 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1655,6 +1655,17 @@ int sqlite3Fts5ExprClonePhrase( pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*)); } + if( rc==SQLITE_OK ){ + Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset; + if( pColsetOrig ){ + int nByte = sizeof(Fts5Colset) + pColsetOrig->nCol * sizeof(int); + Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte); + if( pColset ){ + memcpy(pColset, pColsetOrig, nByte); + } + pNew->pRoot->pNear->pColset = pColset; + } + } for(i=0; rc==SQLITE_OK && inTerm; i++){ int tflags = 0; diff --git a/ext/fts5/test/fts5aux.test b/ext/fts5/test/fts5aux.test index 995fe85784..fa3167a4d1 100644 --- a/ext/fts5/test/fts5aux.test +++ b/ext/fts5/test/fts5aux.test @@ -246,5 +246,37 @@ foreach {tn lRow res} { } $res } +#------------------------------------------------------------------------- +# Test the built-in bm25() demo. +# +reset_db +do_execsql_test 9.1 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b); + INSERT INTO t1 VALUES('a', NULL); -- 1 + INSERT INTO t1 VALUES('a', NULL); -- 2 + INSERT INTO t1 VALUES('a', NULL); -- 3 + INSERT INTO t1 VALUES('a', NULL); -- 4 + INSERT INTO t1 VALUES('a', NULL); -- 5 + INSERT INTO t1 VALUES('a', NULL); -- 6 + INSERT INTO t1 VALUES('a', NULL); -- 7 + INSERT INTO t1 VALUES('a', NULL); -- 8 + INSERT INTO t1 VALUES(NULL, 'a a b'); -- 9 + INSERT INTO t1 VALUES(NULL, 'b b a'); -- 10 +} + +do_execsql_test 9.2 { + SELECT rowid FROM t1('a AND b') ORDER BY rank; +} { + 10 9 +} + +do_execsql_test 9.3 { + SELECT rowid FROM t1('b:a AND b:b') ORDER BY rank; +} { + 9 10 +} + + + finish_test diff --git a/manifest b/manifest index c4b4c5d9f8..5e1631de3d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\ssqlite3DeleteTable()\sroutine\ssmaller\sand\sfaster. -D 2016-05-07T12:15:34.317 +C Fix\sthe\sFTS5\sxQueryPhrase()\sAPI\sfunction\sso\sthat\sit\srecognizes\scolumn\sfilters. +D 2016-05-09T18:05:44.940 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -102,7 +102,7 @@ F ext/fts5/fts5Int.h 3677076aecbf645a7f2a019115c6a4ec3272dd78 F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 -F ext/fts5/fts5_expr.c 5ca4bafe29aa3d27683c90e836192e4aefd20a3f +F ext/fts5/fts5_expr.c da2b33c2aac91e96641c0a7cf2bbaa36eb2667f7 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 F ext/fts5/fts5_main.c b4a0fc5bf17f2f1f056ee76cdd7d2af08b360f55 @@ -131,7 +131,7 @@ F ext/fts5/test/fts5ak.test fb26389985407826f6076bb9f382c67d3db6b5d9 F ext/fts5/test/fts5al.test 18c277f5986df0a3d9071dfd7128afeb16fe9d5d F ext/fts5/test/fts5alter.test 6022c61467a82aa11c70822ccad22b328dcf0d04 F ext/fts5/test/fts5auto.test 401c20e89f1114d733b94809be1e6f893e16c09e -F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f +F ext/fts5/test/fts5aux.test 5dd158a1e7869e27e9762a2a452b189c728d1be3 F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5bigtok.test 017a9397b14e7598883a6328ead4a6539b42d59a @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a45fda657d987f5c923d141584841a6c62dfb504 -R de01d2c88028a3b709951f9d3730409b -U drh -Z c83c111125ba50dd275150f90f412c72 +P d75140b851a34a5eb66041e294e421628efbc5ba +R 0be9ab31bb2adcc738c00ca21c762730 +U dan +Z f838a2dc20bbd55fb4fc1e757536b6a8 diff --git a/manifest.uuid b/manifest.uuid index 216472cb11..77d39a83e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d75140b851a34a5eb66041e294e421628efbc5ba \ No newline at end of file +48505cde05d74748454dc135d4ec25954ecf020e \ No newline at end of file From ba1079ba2ace74d04c4add64a41f3d195fb2bb95 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 9 May 2016 19:03:42 +0000 Subject: [PATCH 033/302] Update a comment in fts5.h. No changes to code. FossilOrigin-Name: 14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea --- ext/fts5/fts5.h | 12 +++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 96ecb38e33..b32e2132dd 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -143,11 +143,13 @@ struct Fts5PhraseIter { ** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid ** ** with $p set to a phrase equivalent to the phrase iPhrase of the -** current query is executed. For each row visited, the callback function -** passed as the fourth argument is invoked. The context and API objects -** passed to the callback function may be used to access the properties of -** each matched row. Invoking Api.xUserData() returns a copy of the pointer -** passed as the third argument to pUserData. +** current query is executed. Any column filter that applies to +** phrase iPhrase of the current query is included in $p. For each +** row visited, the callback function passed as the fourth argument +** is invoked. The context and API objects passed to the callback +** function may be used to access the properties of each matched row. +** Invoking Api.xUserData() returns a copy of the pointer passed as +** the third argument to pUserData. ** ** If the callback function returns any value other than SQLITE_OK, the ** query is abandoned and the xQueryPhrase function returns immediately. diff --git a/manifest b/manifest index 5e1631de3d..8e82d9444c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sFTS5\sxQueryPhrase()\sAPI\sfunction\sso\sthat\sit\srecognizes\scolumn\sfilters. -D 2016-05-09T18:05:44.940 +C Update\sa\scomment\sin\sfts5.h.\sNo\schanges\sto\scode. +D 2016-05-09T19:03:42.623 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -97,7 +97,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 -F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7 +F ext/fts5/fts5.h b770c5e0a8d2ee071ddffc7ab722dbf3474a8abe F ext/fts5/fts5Int.h 3677076aecbf645a7f2a019115c6a4ec3272dd78 F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d75140b851a34a5eb66041e294e421628efbc5ba -R 0be9ab31bb2adcc738c00ca21c762730 +P 48505cde05d74748454dc135d4ec25954ecf020e +R 1969cb0ebb207c1f7d211b0f782f1262 U dan -Z f838a2dc20bbd55fb4fc1e757536b6a8 +Z aa90d8f8ef0b8ff7fa6722d460d8bb52 diff --git a/manifest.uuid b/manifest.uuid index 77d39a83e2..1a4227599e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48505cde05d74748454dc135d4ec25954ecf020e \ No newline at end of file +14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea \ No newline at end of file From a72a15e45a322b60c8a592a971fd4142e04cdb49 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 9 May 2016 19:58:56 +0000 Subject: [PATCH 034/302] Omit the unnecessary WHERE_REOPEN_IDX flag in the WHERE interface. FossilOrigin-Name: da94a6e0ebacad8f235dcd653a25474327f26137 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/where.c | 2 +- src/wherecode.c | 1 - 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 8e82d9444c..cf88c90ca0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\scomment\sin\sfts5.h.\sNo\schanges\sto\scode. -D 2016-05-09T19:03:42.623 +C Omit\sthe\sunnecessary\sWHERE_REOPEN_IDX\sflag\sin\sthe\sWHERE\sinterface. +D 2016-05-09T19:58:56.729 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -382,7 +382,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 8ec741711b8f42aae2c7a22e3d04f15270e0b6be +F src/sqliteInt.h 47a90c85a42210a05387051aaaa661f5c307703d F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -457,9 +457,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c fd321cc2c5ee346a2e146b93892ed01bb7a839c0 +F src/where.c ad8ad50ccf25795f6830b6b864bbfcd060ff08dd F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 -F src/wherecode.c 23fc19ca546ce323ba5c4be96b88e3ba08cf6b8f +F src/wherecode.c d227fca7d766a10fe4ba4d812210f5631f5a98b3 F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1487,7 +1487,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48505cde05d74748454dc135d4ec25954ecf020e -R 1969cb0ebb207c1f7d211b0f782f1262 -U dan -Z aa90d8f8ef0b8ff7fa6722d460d8bb52 +P 14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea +R 91f64055039542194e221b2aa9a3eada +T *branch * dev +T *sym-dev * +T -sym-trunk * +U drh +Z 6a1a8543c69edff1da4c7cb6389abc41 diff --git a/manifest.uuid b/manifest.uuid index 1a4227599e..6ae6f055ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea \ No newline at end of file +da94a6e0ebacad8f235dcd653a25474327f26137 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f9635a4eb0..69f1f544f1 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2540,7 +2540,7 @@ struct SrcList { #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ -#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ + /* 0x1000 not currently used */ #define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */ #define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */ #define WHERE_SEEK_TABLE 0x8000 /* Do not defer seeks on main table */ diff --git a/src/where.c b/src/where.c index 0c3f05f7f2..849d0ae5bd 100644 --- a/src/where.c +++ b/src/where.c @@ -4479,7 +4479,7 @@ WhereInfo *sqlite3WhereBegin( pWInfo->aiCurOnePass[1] = iIndexCur; }else if( iAuxArg && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){ iIndexCur = iAuxArg; - if( wctrlFlags & WHERE_REOPEN_IDX ) op = OP_ReopenIdx; + op = OP_ReopenIdx; }else{ iIndexCur = pParse->nTab++; } diff --git a/src/wherecode.c b/src/wherecode.c index aee50c3142..a42fa1f843 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1629,7 +1629,6 @@ Bitmask sqlite3WhereCodeOneLoopStart( ){ assert( pSubWInfo->a[0].iIdxCur==iCovCur ); pCov = pSubLoop->u.btree.pIndex; - wctrlFlags |= WHERE_REOPEN_IDX; }else{ pCov = 0; } From f52a697e046e796394e063dcbc949ba9d090de40 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 9 May 2016 22:32:18 +0000 Subject: [PATCH 035/302] Remove some forgotten debugging lines from test/sort5.test. FossilOrigin-Name: f5875489810101c13a7917bde86e6a23b088e386 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/sort5.test | 4 ---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 8e82d9444c..dfa6d4ca41 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\scomment\sin\sfts5.h.\sNo\schanges\sto\scode. -D 2016-05-09T19:03:42.623 +C Remove\ssome\sforgotten\sdebugging\slines\sfrom\stest/sort5.test. +D 2016-05-09T22:32:18.802 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -1075,7 +1075,7 @@ F test/sort.test c2adc635c2564241fefec0b3a68391ef6868fd3b F test/sort2.test cc23b7c19d684657559e8a55b02f7fcee03851d0 F test/sort3.test 1480ed7c4c157682542224e05e3b75faf4a149e5 F test/sort4.test 5c34d9623a4ae5921d956dfa2b70e77ed0fc6e5c -F test/sort5.test e47ec7a490b9b36787755874175d8f413a3883d9 +F test/sort5.test 9cf239aca33cc461653f69377dfd75de4c388b2f F test/sortfault.test d4ccf606a0c77498e2beb542764fd9394acb4d66 F test/speed1.test f2974a91d79f58507ada01864c0e323093065452 F test/speed1p.explain d841e650a04728b39e6740296b852dccdca9b2cb @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48505cde05d74748454dc135d4ec25954ecf020e -R 1969cb0ebb207c1f7d211b0f782f1262 -U dan -Z aa90d8f8ef0b8ff7fa6722d460d8bb52 +P 14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea +R 57e3080f83e57cc4e840dda774a2fe9d +U drh +Z 049f4fad0b7cefc11bbb8ea38ffce642 diff --git a/manifest.uuid b/manifest.uuid index 1a4227599e..d5fc4ae80b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea \ No newline at end of file +f5875489810101c13a7917bde86e6a23b088e386 \ No newline at end of file diff --git a/test/sort5.test b/test/sort5.test index 9fb2dff281..bc1bdb3e8c 100644 --- a/test/sort5.test +++ b/test/sort5.test @@ -78,10 +78,7 @@ execsql { CREATE TABLE t1(x) } # each a bit over 100 bytes in size. In total a little more than 1MiB # of data. # -breakpoint foreach {tn pgsz cachesz bTemp} { - 2 1024 1000 1 - 1 4096 1000 0 2 1024 1000 1 @@ -113,4 +110,3 @@ foreach {tn pgsz cachesz bTemp} { } finish_test - From 83561932a5b4c170b1706561dada44885bf3db4f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 9 May 2016 22:35:06 +0000 Subject: [PATCH 036/302] Enhancements to test/sort5.test so that it works with SEE. FossilOrigin-Name: 8a39c8ee49e6e80c83613546cf328801c80b7c4d --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/sort5.test | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index dfa6d4ca41..3eb47ea56f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sforgotten\sdebugging\slines\sfrom\stest/sort5.test. -D 2016-05-09T22:32:18.802 +C Enhancements\sto\stest/sort5.test\sso\sthat\sit\sworks\swith\sSEE. +D 2016-05-09T22:35:06.768 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -1075,7 +1075,7 @@ F test/sort.test c2adc635c2564241fefec0b3a68391ef6868fd3b F test/sort2.test cc23b7c19d684657559e8a55b02f7fcee03851d0 F test/sort3.test 1480ed7c4c157682542224e05e3b75faf4a149e5 F test/sort4.test 5c34d9623a4ae5921d956dfa2b70e77ed0fc6e5c -F test/sort5.test 9cf239aca33cc461653f69377dfd75de4c388b2f +F test/sort5.test 30cc17768e0c06ecb048e08efec59c11811fd186 F test/sortfault.test d4ccf606a0c77498e2beb542764fd9394acb4d66 F test/speed1.test f2974a91d79f58507ada01864c0e323093065452 F test/speed1p.explain d841e650a04728b39e6740296b852dccdca9b2cb @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 14e53d0e2f62d82ae1d64a72fd9711548e3bf5ea -R 57e3080f83e57cc4e840dda774a2fe9d +P f5875489810101c13a7917bde86e6a23b088e386 +R 06ee44fd877a285d72041ef6be8504fa U drh -Z 049f4fad0b7cefc11bbb8ea38ffce642 +Z 8edbf80d5eb509893c5370ddbed126a1 diff --git a/manifest.uuid b/manifest.uuid index d5fc4ae80b..a35da66dd1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f5875489810101c13a7917bde86e6a23b088e386 \ No newline at end of file +8a39c8ee49e6e80c83613546cf328801c80b7c4d \ No newline at end of file diff --git a/test/sort5.test b/test/sort5.test index bc1bdb3e8c..6ada81c9cc 100644 --- a/test/sort5.test +++ b/test/sort5.test @@ -94,6 +94,12 @@ foreach {tn pgsz cachesz bTemp} { PRAGMA cache_size = $cachesz; " + if {[db one {PRAGMA page_size}]!=$pgsz} { + # SEE is not able to change page sizes and that messes up the + # results that follow. + continue + } + do_test 2.$tn.1 { set ::iTemp 0 catch { array unset F } From 3791c9c288365c2851151896c21f7acaf50e02cc Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 9 May 2016 23:11:47 +0000 Subject: [PATCH 037/302] Fixes to requirements marks. No changes to code. FossilOrigin-Name: 79ecd0ef20c12198e950a730871444a980a0f1b2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 16 ++++++++-------- test/snapshot.test | 4 ---- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 3eb47ea56f..141cba74d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\stest/sort5.test\sso\sthat\sit\sworks\swith\sSEE. -D 2016-05-09T22:35:06.768 +C Fixes\sto\srequirements\smarks.\s\sNo\schanges\sto\scode. +D 2016-05-09T23:11:47.940 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -321,7 +321,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c f60f0aa55d25d853ffde53d0b0370a7bb7ee41ce F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 3ae6aea66cc4e13d30162ff0d0d43c7088e34abf +F src/btree.c e53a01547d61a3d567daf7a7acc30122fe071aef F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d65be62254ca9df36e1e1c433324f0333f80009c @@ -1067,7 +1067,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test 3adc4ef09d407b501f899a6c329bdf45dc725c1b +F test/snapshot.test a19465046168b4420b5afeed37c3214e42a49f4a F test/snapshot_fault.test 062ff0438a074978d45e9f9a92e7ad459b74ee73 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 @@ -1487,7 +1487,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f5875489810101c13a7917bde86e6a23b088e386 -R 06ee44fd877a285d72041ef6be8504fa +P 8a39c8ee49e6e80c83613546cf328801c80b7c4d +R 01d61c4cbbe70cd264566714c11f8bfc U drh -Z 8edbf80d5eb509893c5370ddbed126a1 +Z 2c227e9e751dfce43bc8d679164f39de diff --git a/manifest.uuid b/manifest.uuid index a35da66dd1..f366d629a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a39c8ee49e6e80c83613546cf328801c80b7c4d \ No newline at end of file +79ecd0ef20c12198e950a730871444a980a0f1b2 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 0e30df7f47..7e6b050f83 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1676,11 +1676,11 @@ static int decodeFlags(MemPage *pPage, int flagByte){ pPage->xCellSize = cellSizePtr; pBt = pPage->pBt; if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){ - /* EVIDENCE-OF: R-03640-13415 A value of 5 means the page is an interior - ** table b-tree page. */ + /* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an + ** interior table b-tree page. */ assert( (PTF_LEAFDATA|PTF_INTKEY)==5 ); - /* EVIDENCE-OF: R-20501-61796 A value of 13 means the page is a leaf - ** table b-tree page. */ + /* EVIDENCE-OF: R-26900-09176 A value of 13 (0x0d) means the page is a + ** leaf table b-tree page. */ assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 ); pPage->intKey = 1; if( pPage->leaf ){ @@ -1694,11 +1694,11 @@ static int decodeFlags(MemPage *pPage, int flagByte){ pPage->maxLocal = pBt->maxLeaf; pPage->minLocal = pBt->minLeaf; }else if( flagByte==PTF_ZERODATA ){ - /* EVIDENCE-OF: R-27225-53936 A value of 2 means the page is an interior - ** index b-tree page. */ + /* EVIDENCE-OF: R-43316-37308 A value of 2 (0x02) means the page is an + ** interior index b-tree page. */ assert( (PTF_ZERODATA)==2 ); - /* EVIDENCE-OF: R-16571-11615 A value of 10 means the page is a leaf - ** index b-tree page. */ + /* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a + ** leaf index b-tree page. */ assert( (PTF_ZERODATA|PTF_LEAF)==10 ); pPage->intKey = 0; pPage->intKeyLeaf = 0; diff --git a/test/snapshot.test b/test/snapshot.test index 6dff11bbb9..b2d61941a7 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -352,10 +352,6 @@ do_test 6.4 { db2 eval { SELECT * FROM x1 } } {z zz zzz} -# EVIDENCE-OF: R-55491-50411 A snapshot will fail to open if the -# database connection D has not previously completed at least one read -# operation against the database file. -# do_test 6.5 { db2 close sqlite3 db2 test.db From d12bc6022baa21a826a537145b8e57e4417d09cd Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 10 May 2016 20:03:08 +0000 Subject: [PATCH 038/302] Fix a problem in sqlite3PagerMovepage() when working on a temp table for which pages have been spilled. FossilOrigin-Name: 20cf8811caf705b482be100baecb3ef72aee2d5a --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/pager.c | 3 +-- test/temptable3.test | 29 +++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 test/temptable3.test diff --git a/manifest b/manifest index 141cba74d7..74f59a6a58 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\srequirements\smarks.\s\sNo\schanges\sto\scode. -D 2016-05-09T23:11:47.940 +C Fix\sa\sproblem\sin\ssqlite3PagerMovepage()\swhen\sworking\son\sa\stemp\stable\sfor\swhich\npages\shave\sbeen\sspilled. +D 2016-05-10T20:03:08.453 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c c512873311087cd22372f2b076fc869e090e8e16 +F src/pager.c dd77be61e439d2bc8d5d4cb8c29595f3ff1c446c F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c b3230ecfc7f797063fbe167f2845da363e8f07f8 @@ -1115,6 +1115,7 @@ F test/tempdb2.test 4fc92055f2a3f7626c0f2eabbb637dc021b311d5 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e +F test/temptable3.test 9542fcacdb9a0eb7cf5307527bb92292383b04da F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 F test/tester.tcl 3ace46dee55f07e28a1e3ab03258b929fefcee5b F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 @@ -1487,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8a39c8ee49e6e80c83613546cf328801c80b7c4d -R 01d61c4cbbe70cd264566714c11f8bfc +P 79ecd0ef20c12198e950a730871444a980a0f1b2 +R 12f0dc762faa7f80daee4e78c774b1d6 U drh -Z 2c227e9e751dfce43bc8d679164f39de +Z 8009b8aea3267bebcd4c327c4f222d7d diff --git a/manifest.uuid b/manifest.uuid index f366d629a4..9d89bebfac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -79ecd0ef20c12198e950a730871444a980a0f1b2 \ No newline at end of file +20cf8811caf705b482be100baecb3ef72aee2d5a \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 8ef0492e57..daddab4d5a 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6926,8 +6926,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){ ** to exist, in case the transaction needs to roll back. Use pPgOld ** as the original page since it has already been allocated. */ - if( pPager->tempFile ){ - assert( pPgOld ); + if( pPager->tempFile && pPgOld ){ sqlite3PcacheMove(pPgOld, origPgno); sqlite3PagerUnrefNotNull(pPgOld); } diff --git a/test/temptable3.test b/test/temptable3.test new file mode 100644 index 0000000000..f3a8449ef1 --- /dev/null +++ b/test/temptable3.test @@ -0,0 +1,29 @@ +# 2016-05-10 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix temptable3 + +db close +sqlite3 db {} +do_execsql_test 1.1 { + PRAGMA cache_size = 1; + PRAGMA page_size = 1024; + PRAGMA auto_vacuum = 2; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES( randomblob(800) ); + INSERT INTO t1 VALUES( randomblob(800) ); + CREATE TABLE t2(x); + PRAGMA integrity_check; +} {ok} + +finish_test From 78d1c9056736719a23fc7d418934dd76d4aed4ef Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 10 May 2016 20:16:43 +0000 Subject: [PATCH 039/302] Add another test case to temptable3.test. FossilOrigin-Name: 223640243efc52c14bb2bb540833a2a624eaa41a --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/temptable3.test | 12 ++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 74f59a6a58..1310387dcc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\ssqlite3PagerMovepage()\swhen\sworking\son\sa\stemp\stable\sfor\swhich\npages\shave\sbeen\sspilled. -D 2016-05-10T20:03:08.453 +C Add\sanother\stest\scase\sto\stemptable3.test. +D 2016-05-10T20:16:43.237 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -1115,7 +1115,7 @@ F test/tempdb2.test 4fc92055f2a3f7626c0f2eabbb637dc021b311d5 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e -F test/temptable3.test 9542fcacdb9a0eb7cf5307527bb92292383b04da +F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 F test/tester.tcl 3ace46dee55f07e28a1e3ab03258b929fefcee5b F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 79ecd0ef20c12198e950a730871444a980a0f1b2 -R 12f0dc762faa7f80daee4e78c774b1d6 -U drh -Z 8009b8aea3267bebcd4c327c4f222d7d +P 20cf8811caf705b482be100baecb3ef72aee2d5a +R 3a9fed64484c9373e69d538aa10775ab +U dan +Z 7b172879dcc2b05a1f7487ac7eeeddea diff --git a/manifest.uuid b/manifest.uuid index 9d89bebfac..25c22c63af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -20cf8811caf705b482be100baecb3ef72aee2d5a \ No newline at end of file +223640243efc52c14bb2bb540833a2a624eaa41a \ No newline at end of file diff --git a/test/temptable3.test b/test/temptable3.test index f3a8449ef1..16f51d7832 100644 --- a/test/temptable3.test +++ b/test/temptable3.test @@ -26,4 +26,16 @@ do_execsql_test 1.1 { PRAGMA integrity_check; } {ok} +db close +sqlite3 db {} +do_execsql_test 1.2 { + PRAGMA cache_size = 1; + PRAGMA auto_vacuum = 2; + CREATE TABLE t1(x); + CREATE TABLE t2(x UNIQUE); + INSERT INTO t2 VALUES(1), (2), (3); + DROP TABLE t1; + PRAGMA integrity_check; +} {ok} + finish_test From 5c8e0928042ff5f5d1c1f967dd82f6850776c2c4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 May 2016 10:57:04 +0000 Subject: [PATCH 040/302] Add pcache tracing macros. Off by default. Requires changing an "#if 0" and recompiling to enable. FossilOrigin-Name: d9313d19c75a62f558b3df6b15595b15bbfa0b62 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pcache.c | 28 +++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1310387dcc..421ae8bf69 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sanother\stest\scase\sto\stemptable3.test. -D 2016-05-10T20:16:43.237 +C Add\spcache\stracing\smacros.\s\sOff\sby\sdefault.\s\sRequires\schanging\san\s"#if\s0"\nand\srecompiling\sto\senable. +D 2016-05-11T10:57:04.047 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c dd77be61e439d2bc8d5d4cb8c29595f3ff1c446c F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c b3230ecfc7f797063fbe167f2845da363e8f07f8 +F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6 F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 20cf8811caf705b482be100baecb3ef72aee2d5a -R 3a9fed64484c9373e69d538aa10775ab -U dan -Z 7b172879dcc2b05a1f7487ac7eeeddea +P 223640243efc52c14bb2bb540833a2a624eaa41a +R 0792de46be2b6fbaa9f6c79c63b41f67 +U drh +Z 0ddceb59c6efe2505feeee700b7e5172 diff --git a/manifest.uuid b/manifest.uuid index 25c22c63af..45bc4fc6fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -223640243efc52c14bb2bb540833a2a624eaa41a \ No newline at end of file +d9313d19c75a62f558b3df6b15595b15bbfa0b62 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index f700c2ff66..7505547c25 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -31,6 +31,16 @@ struct PCache { sqlite3_pcache *pCache; /* Pluggable cache module */ }; +/* +** Debug tracing macros +*/ +#if defined(SQLITE_DEBUG) && 0 + int sqlite3PcacheTrace = 1; +# define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;} +#else +# define pcacheTrace(X) +#endif + /********************************** Linked List Management ********************/ /* Allowed values for second argument to pcacheManageDirtyList() */ @@ -47,6 +57,9 @@ struct PCache { static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ PCache *p = pPage->pCache; + pcacheTrace(("%p.DIRTYLIST.%s %d\n", p, + addRemove==1 ? "REMOVE" : addRemove==2 ? "ADD" : "FRONT", + pPage->pgno)); if( addRemove & PCACHE_DIRTYLIST_REMOVE ){ assert( pPage->pDirtyNext || pPage==p->pDirtyTail ); assert( pPage->pDirtyPrev || pPage==p->pDirty ); @@ -106,6 +119,7 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ */ static void pcacheUnpin(PgHdr *p){ if( p->pCache->bPurgeable ){ + pcacheTrace(("%p.UNPIN %d\n", p->pCache, p->pgno)); sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0); } } @@ -176,6 +190,7 @@ int sqlite3PcacheOpen( p->pStress = pStress; p->szCache = 100; p->szSpill = 1; + pcacheTrace(("%p.OPEN szPage %d bPurgeable %d\n",p,szPage,bPurgeable)); return sqlite3PcacheSetPageSize(p, szPage); } @@ -198,6 +213,7 @@ int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){ } pCache->pCache = pNew; pCache->szPage = szPage; + pcacheTrace(("%p.PAGESIZE %d\n",pCache,szPage)); } return SQLITE_OK; } @@ -232,6 +248,7 @@ sqlite3_pcache_page *sqlite3PcacheFetch( int createFlag /* If true, create page if it does not exist already */ ){ int eCreate; + sqlite3_pcache_page *pRes; assert( pCache!=0 ); assert( pCache->pCache!=0 ); @@ -249,7 +266,10 @@ sqlite3_pcache_page *sqlite3PcacheFetch( assert( eCreate==0 || eCreate==1 || eCreate==2 ); assert( createFlag==0 || pCache->eCreate==eCreate ); assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) ); - return sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate); + pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate); + pcacheTrace(("%p.FETCH %d%s (result: %p)\n",pCache,pgno, + createFlag?" create":"",pRes)); + return pRes; } /* @@ -294,6 +314,7 @@ int sqlite3PcacheFetchStress( sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache), numberOfCachePages(pCache)); #endif + pcacheTrace(("%p.SPILL %d\n",pCache,pPg->pgno)); rc = pCache->xStress(pCache->pStress, pPg); if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ return rc; @@ -407,6 +428,7 @@ void sqlite3PcacheMakeDirty(PgHdr *p){ p->flags &= ~PGHDR_DONT_WRITE; if( p->flags & PGHDR_CLEAN ){ p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN); + pcacheTrace(("%p.DIRTY %d\n",p->pCache,p->pgno)); assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY ); pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD); } @@ -423,6 +445,7 @@ void sqlite3PcacheMakeClean(PgHdr *p){ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE); p->flags |= PGHDR_CLEAN; + pcacheTrace(("%p.CLEAN %d\n",p->pCache,p->pgno)); if( p->nRef==0 ){ pcacheUnpin(p); } @@ -468,6 +491,7 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){ PCache *pCache = p->pCache; assert( p->nRef>0 ); assert( newPgno>0 ); + pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); p->pgno = newPgno; if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){ @@ -488,6 +512,7 @@ void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){ if( pCache->pCache ){ PgHdr *p; PgHdr *pNext; + pcacheTrace(("%p.TRUNCATE %d\n",pCache,pgno)); for(p=pCache->pDirty; p; p=pNext){ pNext = p->pDirtyNext; /* This routine never gets call with a positive pgno except right @@ -518,6 +543,7 @@ void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){ */ void sqlite3PcacheClose(PCache *pCache){ assert( pCache->pCache!=0 ); + pcacheTrace(("%p.CLOSE\n",pCache)); sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache); } From 65c6420335cfd78615ea7432ce862da7027171bc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 May 2016 11:04:17 +0000 Subject: [PATCH 041/302] Always truncate, rather than persist, the rollback journal of a TEMP database. FossilOrigin-Name: 42fb6f1e99a6c31889819a0302679d598dc0ab1b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 421ae8bf69..a8c8e54249 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\spcache\stracing\smacros.\s\sOff\sby\sdefault.\s\sRequires\schanging\san\s"#if\s0"\nand\srecompiling\sto\senable. -D 2016-05-11T10:57:04.047 +C Always\struncate,\srather\sthan\spersist,\sthe\srollback\sjournal\sof\sa\sTEMP\sdatabase. +D 2016-05-11T11:04:17.716 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c dd77be61e439d2bc8d5d4cb8c29595f3ff1c446c +F src/pager.c 146d724b2c35f5d2d98676188681db9ade33486d F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 223640243efc52c14bb2bb540833a2a624eaa41a -R 0792de46be2b6fbaa9f6c79c63b41f67 +P d9313d19c75a62f558b3df6b15595b15bbfa0b62 +R 4210b2f60d7aff505c38881d5c5427ee U drh -Z 0ddceb59c6efe2505feeee700b7e5172 +Z a22a7f46bad36a1990f0c6b07c454824 diff --git a/manifest.uuid b/manifest.uuid index 45bc4fc6fa..eb889327ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9313d19c75a62f558b3df6b15595b15bbfa0b62 \ No newline at end of file +42fb6f1e99a6c31889819a0302679d598dc0ab1b \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index daddab4d5a..359e233606 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1997,7 +1997,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL) ){ - rc = zeroJournalHdr(pPager, hasMaster); + rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile); pPager->journalOff = 0; }else{ /* This branch may be executed with Pager.journalMode==MEMORY if From a37e0cfb2205c8ddcb71e08bb1ed1ce859cec8fc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 May 2016 12:47:46 +0000 Subject: [PATCH 042/302] Do not reset the page cache when a rollback journal truncate fails, as doing so can cause loss of information for an in-memory TEMP file. FossilOrigin-Name: 345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 12 +++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a8c8e54249..a0a2ed640a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\struncate,\srather\sthan\spersist,\sthe\srollback\sjournal\sof\sa\sTEMP\sdatabase. -D 2016-05-11T11:04:17.716 +C Do\snot\sreset\sthe\spage\scache\swhen\sa\srollback\sjournal\struncate\sfails,\sas\sdoing\nso\scan\scause\sloss\sof\sinformation\sfor\san\sin-memory\sTEMP\sfile. +D 2016-05-11T12:47:46.752 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 146d724b2c35f5d2d98676188681db9ade33486d +F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d9313d19c75a62f558b3df6b15595b15bbfa0b62 -R 4210b2f60d7aff505c38881d5c5427ee +P 42fb6f1e99a6c31889819a0302679d598dc0ab1b +R 6af21f51682f416bafd722831c805292 U drh -Z a22a7f46bad36a1990f0c6b07c454824 +Z f092752ae332e4cfbb76f62bab02296e diff --git a/manifest.uuid b/manifest.uuid index eb889327ae..39ea1115d0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -42fb6f1e99a6c31889819a0302679d598dc0ab1b \ No newline at end of file +345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 359e233606..d2dd639892 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2032,12 +2032,14 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ sqlite3BitvecDestroy(pPager->pInJournal); pPager->pInJournal = 0; pPager->nRec = 0; - if( MEMDB || pagerFlushOnCommit(pPager) ){ - sqlite3PcacheCleanAll(pPager->pPCache); - }else{ - sqlite3PcacheClearWritable(pPager->pPCache); + if( rc==SQLITE_OK ){ + if( MEMDB || pagerFlushOnCommit(pPager) ){ + sqlite3PcacheCleanAll(pPager->pPCache); + }else{ + sqlite3PcacheClearWritable(pPager->pPCache); + } + sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize); } - sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize); if( pagerUseWal(pPager) ){ /* Drop the WAL write-lock, if any. Also, if the connection was in From b2ef900ade31284cbd710bf2fe2c4a88400eed6a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 11 May 2016 15:41:15 +0000 Subject: [PATCH 043/302] Remove some a small amount of redundant code related to PCache.pSynced from pcache.c. FossilOrigin-Name: 9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pcache.c | 28 ++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index a0a2ed640a..a51e55cb83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sreset\sthe\spage\scache\swhen\sa\srollback\sjournal\struncate\sfails,\sas\sdoing\nso\scan\scause\sloss\sof\sinformation\sfor\san\sin-memory\sTEMP\sfile. -D 2016-05-11T12:47:46.752 +C Remove\ssome\sa\ssmall\samount\sof\sredundant\scode\srelated\sto\sPCache.pSynced\sfrom\spcache.c. +D 2016-05-11T15:41:15.317 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6 +F src/pcache.c 4af980bc2a987cf81ddbe867d238c9ccdbaac95c F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 42fb6f1e99a6c31889819a0302679d598dc0ab1b -R 6af21f51682f416bafd722831c805292 -U drh -Z f092752ae332e4cfbb76f62bab02296e +P 345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 +R 410857f6cadf18a1818aed66391afc72 +U dan +Z b239392669bc1d86adff0f06ee03f5ae diff --git a/manifest.uuid b/manifest.uuid index 39ea1115d0..9b2b37fae9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 \ No newline at end of file +9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index 7505547c25..54b4044a01 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -15,6 +15,22 @@ /* ** A complete page cache is an instance of this structure. +** +** pDirty, pDirtyTail, pSynced: +** All dirty pages are linked into the doubly linked list using +** PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order +** such that p was added to the list more recently than p->pDirtyNext. +** PCache.pDirty points to the first (newest) element in the list and +** pDirtyTail to the last (oldest). +** +** The PCache.pSynced variable is used to optimize searching for a dirty +** page to eject from the cache mid-transaction. It is better to eject +** a page that does not require a journal sync than one that does. +** Therefore, pSynced is maintained to that it *almost* always points +** to either the oldest page in the pDirty/pDirtyTail list that has a +** clear PGHDR_NEED_SYNC flag or to a page that is older than this one +** (so that the right page to eject can be found by following pDirtyPrev +** pointers). */ struct PCache { PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */ @@ -66,11 +82,7 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ /* Update the PCache1.pSynced variable if necessary. */ if( p->pSynced==pPage ){ - PgHdr *pSynced = pPage->pDirtyPrev; - while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){ - pSynced = pSynced->pDirtyPrev; - } - p->pSynced = pSynced; + p->pSynced = pPage->pDirtyPrev; } if( pPage->pDirtyNext ){ @@ -296,7 +308,11 @@ int sqlite3PcacheFetchStress( ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC ** cleared), but if that is not possible settle for any other ** unreferenced dirty page. - */ + ** + ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC + ** flag is currently referenced, then the following may leave pSynced + ** set incorrectly (pointing to other than the LRU page with NEED_SYNC + ** cleared). This is Ok, as pSynced is just an optimization. */ for(pPg=pCache->pSynced; pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); pPg=pPg->pDirtyPrev From 401907e3ff7616e85469752102c52f4bdaf7d73c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 11 May 2016 20:03:23 +0000 Subject: [PATCH 044/302] Remove a redundant condition from pcache.c. Add an OPTIMIZATION-IF-TRUE comment to another condition that requires it. FossilOrigin-Name: 3bfd2621d13b4f842f3af6d35519653f4eb8cad7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a51e55cb83..6c5a26e092 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sa\ssmall\samount\sof\sredundant\scode\srelated\sto\sPCache.pSynced\sfrom\spcache.c. -D 2016-05-11T15:41:15.317 +C Remove\sa\sredundant\scondition\sfrom\spcache.c.\sAdd\san\sOPTIMIZATION-IF-TRUE\scomment\sto\sanother\scondition\sthat\srequires\sit. +D 2016-05-11T20:03:23.145 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 4af980bc2a987cf81ddbe867d238c9ccdbaac95c +F src/pcache.c 95ee5008eddda9c61b8d053de8eebf72cf5df7c6 F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 345ce1c9f64f2a424663b4dfcbe4586d9df7bff6 -R 410857f6cadf18a1818aed66391afc72 +P 9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 +R bd613f88cc94ba593741d724ce8bf946 U dan -Z b239392669bc1d86adff0f06ee03f5ae +Z ba94a14dc94ea0c9562dd2071f1152d6 diff --git a/manifest.uuid b/manifest.uuid index 9b2b37fae9..034ae63216 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 \ No newline at end of file +3bfd2621d13b4f842f3af6d35519653f4eb8cad7 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index 54b4044a01..4051bee00e 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -94,10 +94,15 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ if( pPage->pDirtyPrev ){ pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext; }else{ + /* If there are now no dirty pages in the cache, set eCreate to 2. + ** This is an optimization that allows sqlite3PcacheFetch() to skip + ** searching for a dirty page to eject from the cache when it might + ** otherwise have to. */ assert( pPage==p->pDirty ); p->pDirty = pPage->pDirtyNext; - if( p->pDirty==0 && p->bPurgeable ){ - assert( p->eCreate==1 ); + assert( p->bPurgeable || p->eCreate==2 ); + if( p->pDirty==0 ){ /*OPTIMIZATION-IF-TRUE*/ + assert( p->bPurgeable==0 || p->eCreate==1 ); p->eCreate = 2; } } @@ -266,6 +271,7 @@ sqlite3_pcache_page *sqlite3PcacheFetch( assert( pCache->pCache!=0 ); assert( createFlag==3 || createFlag==0 ); assert( pgno>0 ); + assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) ); /* eCreate defines what to do if the page does not exist. ** 0 Do not allocate a new page. (createFlag==0) From 72e6a399073fd63bb5e8bc1db07a95365d2a2e2b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 May 2016 23:54:14 +0000 Subject: [PATCH 045/302] For in-memory databases, it does not matter if pcache entries are marked "clean" or "writable". FossilOrigin-Name: ad601c7962a60a11699cf31f1faee09b95d5c710 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/pager.c | 2 +- src/pcache.c | 8 +++++++- src/pcache.h | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 6c5a26e092..5293168132 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sredundant\scondition\sfrom\spcache.c.\sAdd\san\sOPTIMIZATION-IF-TRUE\scomment\sto\sanother\scondition\sthat\srequires\sit. -D 2016-05-11T20:03:23.145 +C For\sin-memory\sdatabases,\sit\sdoes\snot\smatter\sif\spcache\sentries\sare\smarked\n"clean"\sor\s"writable". +D 2016-05-11T23:54:14.261 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,11 +364,11 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa +F src/pager.c 76fe5ad6998772a6abda30145c181e99e7743a1d F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 95ee5008eddda9c61b8d053de8eebf72cf5df7c6 -F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9 +F src/pcache.c 132a78c71bd510fde0085bfc44608bc64b945d48 +F src/pcache.h 33b40350df1b6c278e019dee37f87e1bac276223 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c @@ -1488,7 +1488,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 -R bd613f88cc94ba593741d724ce8bf946 -U dan -Z ba94a14dc94ea0c9562dd2071f1152d6 +P 3bfd2621d13b4f842f3af6d35519653f4eb8cad7 +R 399bfb6002bea3bb0fdfe001a40139f7 +T *branch * pager-dev +T *sym-pager-dev * +T -sym-trunk * +U drh +Z 75fe10a9420951c23350bd3808039177 diff --git a/manifest.uuid b/manifest.uuid index 034ae63216..3e5a24e018 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3bfd2621d13b4f842f3af6d35519653f4eb8cad7 \ No newline at end of file +ad601c7962a60a11699cf31f1faee09b95d5c710 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d2dd639892..3f33fae811 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2033,7 +2033,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ pPager->pInJournal = 0; pPager->nRec = 0; if( rc==SQLITE_OK ){ - if( MEMDB || pagerFlushOnCommit(pPager) ){ + if( pagerFlushOnCommit(pPager) ){ sqlite3PcacheCleanAll(pPager->pPCache); }else{ sqlite3PcacheClearWritable(pPager->pPCache); diff --git a/src/pcache.c b/src/pcache.c index 4051bee00e..f30b60e94a 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -14,7 +14,13 @@ #include "sqliteInt.h" /* -** A complete page cache is an instance of this structure. +** A complete page cache is an instance of this structure. Every +** entry in the cache holds a single page of the database file. The +** btree layer only operates on the cached copy of the database pages. +** +** A page cache entry is "clean" if it exactly matches what is currently +** on disk. A page is "dirty" if it has been modified and needs to be +** persisted to disk. ** ** pDirty, pDirtyTail, pSynced: ** All dirty pages are linked into the doubly linked list using diff --git a/src/pcache.h b/src/pcache.h index 04bce289d0..8e0f12e094 100644 --- a/src/pcache.h +++ b/src/pcache.h @@ -26,7 +26,7 @@ struct PgHdr { sqlite3_pcache_page *pPage; /* Pcache object page handle */ void *pData; /* Page data */ void *pExtra; /* Extra content */ - PgHdr *pDirty; /* Transient list of dirty pages */ + PgHdr *pDirty; /* Transient list of dirty sorted by pgno */ Pager *pPager; /* The pager this page is part of */ Pgno pgno; /* Page number for this page */ #ifdef SQLITE_CHECK_PAGES From 613723d9fda58600335959dd38a31968e1323bd9 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 12 May 2016 09:48:23 +0000 Subject: [PATCH 046/302] Add a missing OPTIMIZATION-IF-FALSE comment to pcache.c. FossilOrigin-Name: bc202e5b418d5a57bfc766883c4417c94829d96e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache.c | 10 +++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6c5a26e092..796ba4e548 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sredundant\scondition\sfrom\spcache.c.\sAdd\san\sOPTIMIZATION-IF-TRUE\scomment\sto\sanother\scondition\sthat\srequires\sit. -D 2016-05-11T20:03:23.145 +C Add\sa\smissing\sOPTIMIZATION-IF-FALSE\scomment\sto\spcache.c. +D 2016-05-12T09:48:23.099 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 95ee5008eddda9c61b8d053de8eebf72cf5df7c6 +F src/pcache.c 481e549dec06c01e8db84f80af835b3386a83bb0 F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9cc8cad78fdfe044ad6726ebfe6909c1e242fa55 -R bd613f88cc94ba593741d724ce8bf946 +P 3bfd2621d13b4f842f3af6d35519653f4eb8cad7 +R 1f5b4032d8f04ae7caac9d7a76ea1776 U dan -Z ba94a14dc94ea0c9562dd2071f1152d6 +Z c8fcd1a1ab31e8e9159bebaf1a63834b diff --git a/manifest.uuid b/manifest.uuid index 034ae63216..5372f9c927 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3bfd2621d13b4f842f3af6d35519653f4eb8cad7 \ No newline at end of file +bc202e5b418d5a57bfc766883c4417c94829d96e \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index 4051bee00e..8634a79188 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -124,7 +124,15 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ } } p->pDirty = pPage; - if( !p->pSynced && 0==(pPage->flags&PGHDR_NEED_SYNC) ){ + + /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set + ** pSynced to point to it. Checking the NEED_SYNC flag is an + ** optimization, as if pSynced points to a page with the NEED_SYNC + ** flag set sqlite3PcacheFetchStress() searches through all newer + ** entries of the dirty-list for a page with NEED_SYNC clear anyway. */ + if( !p->pSynced + && 0==(pPage->flags&PGHDR_NEED_SYNC) /*OPTIMIZATION-IF-FALSE*/ + ){ p->pSynced = pPage; } } From 42bee5f4d6cefc9e467d6c7203a530f815e42b36 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 12 May 2016 12:01:20 +0000 Subject: [PATCH 047/302] Remove an unnecessary call to sqlite3PcacheMakeClean() inside of the ROLLBACK logic. FossilOrigin-Name: 0dc50d9915cd88916229ca5c3834de82fa16f017 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pager.c | 31 ++++--------------------------- src/pcache.c | 2 +- 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index 796ba4e548..eff6cd9a5e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\sOPTIMIZATION-IF-FALSE\scomment\sto\spcache.c. -D 2016-05-12T09:48:23.099 +C Remove\san\sunnecessary\scall\sto\ssqlite3PcacheMakeClean()\sinside\sof\sthe\sROLLBACK\nlogic. +D 2016-05-12T12:01:20.280 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,10 +364,10 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa +F src/pager.c b7f9341d1c8917d0050f11597c588d0b4e379df9 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 481e549dec06c01e8db84f80af835b3386a83bb0 +F src/pcache.c 0e8453c2aaa8a72e09c58edeb0f0976dc652e827 F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3bfd2621d13b4f842f3af6d35519653f4eb8cad7 -R 1f5b4032d8f04ae7caac9d7a76ea1776 -U dan -Z c8fcd1a1ab31e8e9159bebaf1a63834b +P bc202e5b418d5a57bfc766883c4417c94829d96e +R 94f384a80fd36cfa7eab53c97f52730e +U drh +Z 3db2648b2bf79fa343d087598efa8f84 diff --git a/manifest.uuid b/manifest.uuid index 5372f9c927..e0fbea1e69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc202e5b418d5a57bfc766883c4417c94829d96e \ No newline at end of file +0dc50d9915cd88916229ca5c3834de82fa16f017 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d2dd639892..654cc640d3 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2387,33 +2387,10 @@ static int pager_playback_one_page( pData = pPg->pData; memcpy(pData, (u8*)aData, pPager->pageSize); pPager->xReiniter(pPg); - if( isMainJrnl && (!isSavepnt || *pOffset<=pPager->journalHdr) ){ - /* If the contents of this page were just restored from the main - ** journal file, then its content must be as they were when the - ** transaction was first opened. In this case we can mark the page - ** as clean, since there will be no need to write it out to the - ** database. - ** - ** There is one exception to this rule. If the page is being rolled - ** back as part of a savepoint (or statement) rollback from an - ** unsynced portion of the main journal file, then it is not safe - ** to mark the page as clean. This is because marking the page as - ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is - ** already in the journal file (recorded in Pager.pInJournal) and - ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to - ** again within this transaction, it will be marked as dirty but - ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially - ** be written out into the database file before its journal file - ** segment is synced. If a crash occurs during or following this, - ** database corruption may ensue. - ** - ** Update: Another exception is for temp files that are not - ** in-memory databases. In this case the page may have been dirty - ** at the start of the transaction. - */ - assert( !pagerUseWal(pPager) ); - if( pPager->tempFile==0 ) sqlite3PcacheMakeClean(pPg); - } + /* It used to be that sqlite3PcacheMakeClean(pPg) was called here. But + ** that call was dangerous and had no detectable benefit since the cache + ** is normally cleaned by sqlite3PcacheCleanAll() after rollback and so + ** has been removed. */ pager_set_pagehash(pPg); /* If this was page 1, then restore the value of Pager.dbFileVers. diff --git a/src/pcache.c b/src/pcache.c index 8634a79188..fab6ad32a2 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -470,7 +470,7 @@ void sqlite3PcacheMakeDirty(PgHdr *p){ ** make it so. */ void sqlite3PcacheMakeClean(PgHdr *p){ - if( (p->flags & PGHDR_DIRTY) ){ + if( ALWAYS((p->flags & PGHDR_DIRTY)!=0) ){ assert( (p->flags & PGHDR_CLEAN)==0 ); pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE); From 82c0447701840cb933cad5b15243cd9c07d885a5 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 12 May 2016 17:06:04 +0000 Subject: [PATCH 048/302] Add extra OPTIMIZATION-IF-FALSE comments where required to pcache.c. FossilOrigin-Name: 9d55b8f541de43deb82d460d32005fd62f5430b2 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/pcache.c | 9 ++++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index e3477b52b0..d2c32e5bc9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sin-memory\sdatabases,\sit\sdoes\snot\smatter\sif\spcache\sentries\sare\smarked\n"clean"\sor\s"writable". -D 2016-05-12T12:08:48.058 +C Add\sextra\sOPTIMIZATION-IF-FALSE\scomments\swhere\srequired\sto\spcache.c. +D 2016-05-12T17:06:04.756 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c baef5d8d31d220001fc61013f401c98950749201 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 5291b6ab838132f856fe8067ca25772d221c4864 +F src/pcache.c 3ef140add88d8d3eee3a80a79412f450bd216d3b F src/pcache.h 33b40350df1b6c278e019dee37f87e1bac276223 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,8 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0dc50d9915cd88916229ca5c3834de82fa16f017 ad601c7962a60a11699cf31f1faee09b95d5c710 -R 7667d141b3239c7f232de8ca756273cf -T +closed ad601c7962a60a11699cf31f1faee09b95d5c710 -U drh -Z 488a663f0afeb720045f9ee67fd9acb5 +P 06c1e27ca868f247f8c27b03eb19aac004f28650 +R e01f1d97945350d1485afdc3dc2f5468 +U dan +Z fe74337e6648e1a589818404220bbdb0 diff --git a/manifest.uuid b/manifest.uuid index 90f4a0036f..8e69ca85ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06c1e27ca868f247f8c27b03eb19aac004f28650 \ No newline at end of file +9d55b8f541de43deb82d460d32005fd62f5430b2 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index ee7914a444..f8fe901776 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -424,8 +424,11 @@ void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){ if( (--p->nRef)==0 ){ if( p->flags&PGHDR_CLEAN ){ pcacheUnpin(p); - }else if( p->pDirtyPrev!=0 ){ - /* Move the page to the head of the dirty list. */ + }else if( p->pDirtyPrev!=0 ){ /*OPTIMIZATION-IF-FALSE*/ + /* Move the page to the head of the dirty list. If p->pDirtyPrev==0, + ** then page p is already at the head of the dirty list and the + ** following call would be a no-op. Hence the OPTIMIZATION-IF-FALSE + ** tag above. */ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); } } @@ -460,7 +463,7 @@ void sqlite3PcacheDrop(PgHdr *p){ */ void sqlite3PcacheMakeDirty(PgHdr *p){ assert( p->nRef>0 ); - if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ + if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/ p->flags &= ~PGHDR_DONT_WRITE; if( p->flags & PGHDR_CLEAN ){ p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN); From d22f5099b598c228aeb0c0617f7b82806cedfb6b Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 12 May 2016 18:38:45 +0000 Subject: [PATCH 049/302] Add an assert in pager.c to confirm that pPager->tempFile is always true for in-memory databases. FossilOrigin-Name: 3fd71092063bf1d30e03cf2497ea9c57b3ec82eb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d2c32e5bc9..8176f2e890 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\sOPTIMIZATION-IF-FALSE\scomments\swhere\srequired\sto\spcache.c. -D 2016-05-12T17:06:04.756 +C Add\san\sassert\sin\spager.c\sto\sconfirm\sthat\spPager->tempFile\sis\salways\strue\nfor\sin-memory\sdatabases. +D 2016-05-12T18:38:45.335 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c baef5d8d31d220001fc61013f401c98950749201 +F src/pager.c 9089b6f318c96d973f0f26ce866452f514c71120 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c 3ef140add88d8d3eee3a80a79412f450bd216d3b @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 06c1e27ca868f247f8c27b03eb19aac004f28650 -R e01f1d97945350d1485afdc3dc2f5468 -U dan -Z fe74337e6648e1a589818404220bbdb0 +P 9d55b8f541de43deb82d460d32005fd62f5430b2 +R 3abb8b47feac8b594036edc1e8dce6ec +U drh +Z 8914057de4b6310e97cb7f42ae3b951d diff --git a/manifest.uuid b/manifest.uuid index 8e69ca85ac..f608f87e2f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d55b8f541de43deb82d460d32005fd62f5430b2 \ No newline at end of file +3fd71092063bf1d30e03cf2497ea9c57b3ec82eb \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 75cde3c024..70fccca158 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6831,6 +6831,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){ /* In order to be able to rollback, an in-memory database must journal ** the page we are moving from. */ + assert( pPager->tempFile || !MEMDB ); if( pPager->tempFile ){ rc = sqlite3PagerWrite(pPg); if( rc ) return rc; From a7a45973e9876fbfc265b2d533e953278772dd63 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 12 May 2016 19:05:35 +0000 Subject: [PATCH 050/302] Simplification of the sqlite3FaultSim() call inside of sqlite3PagerCommitPhaseOne(). FossilOrigin-Name: 1b0f4cc362cda1dc175aa363ae4e612b7d1164c3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8176f2e890..f574e48e65 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sassert\sin\spager.c\sto\sconfirm\sthat\spPager->tempFile\sis\salways\strue\nfor\sin-memory\sdatabases. -D 2016-05-12T18:38:45.335 +C Simplification\sof\sthe\ssqlite3FaultSim()\scall\sinside\sof\nsqlite3PagerCommitPhaseOne(). +D 2016-05-12T19:05:35.053 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 9089b6f318c96d973f0f26ce866452f514c71120 +F src/pager.c b6b3f2aff301cb025b23a8586666c91355cb3c69 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c 3ef140add88d8d3eee3a80a79412f450bd216d3b @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9d55b8f541de43deb82d460d32005fd62f5430b2 -R 3abb8b47feac8b594036edc1e8dce6ec +P 3fd71092063bf1d30e03cf2497ea9c57b3ec82eb +R 86cdc8fab77fed5ebeb6f9ac3a200e04 U drh -Z 8914057de4b6310e97cb7f42ae3b951d +Z 30e0270ee86eb0dad7cf2e94ccef570b diff --git a/manifest.uuid b/manifest.uuid index f608f87e2f..f5d7ecb7b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3fd71092063bf1d30e03cf2497ea9c57b3ec82eb \ No newline at end of file +1b0f4cc362cda1dc175aa363ae4e612b7d1164c3 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 70fccca158..d8ea37122e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6196,7 +6196,7 @@ int sqlite3PagerCommitPhaseOne( if( NEVER(pPager->errCode) ) return pPager->errCode; /* Provide the ability to easily simulate an I/O error during testing */ - if( (rc = sqlite3FaultSim(400))!=SQLITE_OK ) return rc; + if( sqlite3FaultSim(400) ) return SQLITE_IOERR; PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", pPager->zFilename, zMaster, pPager->dbSize)); From 5f65ff277db11629ed47babde6a867f95d8f1c75 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 12 May 2016 19:17:09 +0000 Subject: [PATCH 051/302] Disable ALWAYS and NEVER when compiled with SQLITE_MUTATION_TEST. FossilOrigin-Name: 24d9fbc1d0f99b90577ecd6edcd3bc1abc76633f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f574e48e65..7f6e396120 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sof\sthe\ssqlite3FaultSim()\scall\sinside\sof\nsqlite3PagerCommitPhaseOne(). -D 2016-05-12T19:05:35.053 +C Disable\sALWAYS\sand\sNEVER\swhen\scompiled\swith\sSQLITE_MUTATION_TEST. +D 2016-05-12T19:17:09.294 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -382,7 +382,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 8ec741711b8f42aae2c7a22e3d04f15270e0b6be +F src/sqliteInt.h 4fe51e4e26d9d576040198cef4f78df3d987387d F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3fd71092063bf1d30e03cf2497ea9c57b3ec82eb -R 86cdc8fab77fed5ebeb6f9ac3a200e04 +P 1b0f4cc362cda1dc175aa363ae4e612b7d1164c3 +R cbaa515ed65f02858509b96594eef6a3 U drh -Z 30e0270ee86eb0dad7cf2e94ccef570b +Z d111db0e0c72ae873465e360a322abe1 diff --git a/manifest.uuid b/manifest.uuid index f5d7ecb7b3..ccf535ef95 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b0f4cc362cda1dc175aa363ae4e612b7d1164c3 \ No newline at end of file +24d9fbc1d0f99b90577ecd6edcd3bc1abc76633f \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f9635a4eb0..c90d4dc9ae 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -411,7 +411,7 @@ ** be true and false so that the unreachable code they specify will ** not be counted as untested code. */ -#if defined(SQLITE_COVERAGE_TEST) +#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) # define ALWAYS(X) (1) # define NEVER(X) (0) #elif !defined(NDEBUG) From 7aeb216a19ab7108537f8dbaa32a05edb25f80c4 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2016 04:24:25 +0000 Subject: [PATCH 052/302] Additional debugging and tracing logic for pcache.c, turned off by default using an "#if 0". FossilOrigin-Name: 32a62e3bd46cf58586617d3f8b1a971c91df205e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache.c | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7f6e396120..521c3c6b38 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sALWAYS\sand\sNEVER\swhen\scompiled\swith\sSQLITE_MUTATION_TEST. -D 2016-05-12T19:17:09.294 +C Additional\sdebugging\sand\stracing\slogic\sfor\spcache.c,\sturned\soff\sby\sdefault\nusing\san\s"#if\s0". +D 2016-05-13T04:24:25.046 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c b6b3f2aff301cb025b23a8586666c91355cb3c69 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 3ef140add88d8d3eee3a80a79412f450bd216d3b +F src/pcache.c ad5ce697dc5a734caddb2b1eac83b195da95ddbe F src/pcache.h 33b40350df1b6c278e019dee37f87e1bac276223 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1b0f4cc362cda1dc175aa363ae4e612b7d1164c3 -R cbaa515ed65f02858509b96594eef6a3 +P 24d9fbc1d0f99b90577ecd6edcd3bc1abc76633f +R d638f11a5a2154aefeed14f79e8ebc4d U drh -Z d111db0e0c72ae873465e360a322abe1 +Z 291bccc6a32f88cd8cda8747cf2307e8 diff --git a/manifest.uuid b/manifest.uuid index ccf535ef95..527363daba 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24d9fbc1d0f99b90577ecd6edcd3bc1abc76633f \ No newline at end of file +32a62e3bd46cf58586617d3f8b1a971c91df205e \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index f8fe901776..6c07b20f57 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -57,10 +57,35 @@ struct PCache { ** Debug tracing macros */ #if defined(SQLITE_DEBUG) && 0 - int sqlite3PcacheTrace = 1; + int sqlite3PcacheTrace = 2; # define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;} -#else + void pcacheDump(PCache *pCache){ + int N; + int i, j; + sqlite3_pcache_page *pLower; + PgHdr *pPg; + unsigned char *a; + + if( sqlite3PcacheTrace<2 ) return; + if( pCache->pCache==0 ) return; + N = sqlite3PcachePagecount(pCache); + if( N>5 ) N = 5; + for(i=1; i<=N; i++){ + pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0); + if( pLower==0 ) continue; + pPg = (PgHdr*)pLower->pExtra; + printf("%3d: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags); + a = (unsigned char *)pLower->pBuf; + for(j=0; j<12; j++) printf("%02x", a[j]); + printf("\n"); + if( pPg->pPage==0 ){ + sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0); + } + } + } + #else # define pcacheTrace(X) +# define pcacheDump(X) #endif /********************************** Linked List Management ********************/ @@ -142,6 +167,7 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){ p->pSynced = pPage; } } + pcacheDump(p); } /* @@ -152,6 +178,7 @@ static void pcacheUnpin(PgHdr *p){ if( p->pCache->bPurgeable ){ pcacheTrace(("%p.UNPIN %d\n", p->pCache, p->pgno)); sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0); + pcacheDump(p->pCache); } } @@ -352,6 +379,7 @@ int sqlite3PcacheFetchStress( #endif pcacheTrace(("%p.SPILL %d\n",pCache,pPg->pgno)); rc = pCache->xStress(pCache->pStress, pPg); + pcacheDump(pCache); if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ return rc; } @@ -496,6 +524,7 @@ void sqlite3PcacheMakeClean(PgHdr *p){ */ void sqlite3PcacheCleanAll(PCache *pCache){ PgHdr *p; + pcacheTrace(("%p.CLEAN-ALL\n",pCache)); while( (p = pCache->pDirty)!=0 ){ sqlite3PcacheMakeClean(p); } @@ -506,6 +535,7 @@ void sqlite3PcacheCleanAll(PCache *pCache){ */ void sqlite3PcacheClearWritable(PCache *pCache){ PgHdr *p; + pcacheTrace(("%p.CLEAR-WRITEABLE\n",pCache)); for(p=pCache->pDirty; p; p=p->pDirtyNext){ p->flags &= ~(PGHDR_NEED_SYNC|PGHDR_WRITEABLE); } From 935c4d8484c2416bd3f885b286c1ee9efada3338 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2016 11:50:00 +0000 Subject: [PATCH 053/302] Fix pager_end_transaction() to ensure that a ROLLBACK does not clobber unwritten pages in a TEMP file pcache. FossilOrigin-Name: 9495d33879221c1821331dc72c61a6a3d182f526 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 521c3c6b38..61125eca3d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\sdebugging\sand\stracing\slogic\sfor\spcache.c,\sturned\soff\sby\sdefault\nusing\san\s"#if\s0". -D 2016-05-13T04:24:25.046 +C Fix\spager_end_transaction()\sto\sensure\sthat\sa\sROLLBACK\sdoes\snot\sclobber\nunwritten\spages\sin\sa\sTEMP\sfile\spcache. +D 2016-05-13T11:50:00.812 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c b6b3f2aff301cb025b23a8586666c91355cb3c69 +F src/pager.c 64f42bd0d20f180f99727ce5a3755a97c9a12700 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c ad5ce697dc5a734caddb2b1eac83b195da95ddbe @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 24d9fbc1d0f99b90577ecd6edcd3bc1abc76633f -R d638f11a5a2154aefeed14f79e8ebc4d +P 32a62e3bd46cf58586617d3f8b1a971c91df205e +R 7ea6babb6ca28821d5ebb371842cc2c9 U drh -Z 291bccc6a32f88cd8cda8747cf2307e8 +Z 5e0d604d556f91727b00c6f570867611 diff --git a/manifest.uuid b/manifest.uuid index 527363daba..bed68c74ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32a62e3bd46cf58586617d3f8b1a971c91df205e \ No newline at end of file +9495d33879221c1821331dc72c61a6a3d182f526 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index d8ea37122e..095fce5374 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2033,7 +2033,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ pPager->pInJournal = 0; pPager->nRec = 0; if( rc==SQLITE_OK ){ - if( pagerFlushOnCommit(pPager) ){ + if( !pPager->tempFile || (bCommit && pagerFlushOnCommit(pPager)) ){ sqlite3PcacheCleanAll(pPager->pPCache); }else{ sqlite3PcacheClearWritable(pPager->pPCache); From 4bf7d21f5647d96ece52fc0a95f01ab5a142a954 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2016 12:12:38 +0000 Subject: [PATCH 054/302] Clarification of the pagerFlushOnCommit() logic. FossilOrigin-Name: 3401d9dcdbec390564574e8d2972c944c204e025 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 26 +++++++++++++++----------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 61125eca3d..12e791556f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\spager_end_transaction()\sto\sensure\sthat\sa\sROLLBACK\sdoes\snot\sclobber\nunwritten\spages\sin\sa\sTEMP\sfile\spcache. -D 2016-05-13T11:50:00.812 +C Clarification\sof\sthe\spagerFlushOnCommit()\slogic. +D 2016-05-13T12:12:38.291 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,7 +364,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 64f42bd0d20f180f99727ce5a3755a97c9a12700 +F src/pager.c 665c5a4da55952ac144c29d83e7f24393ce80dce F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c ad5ce697dc5a734caddb2b1eac83b195da95ddbe @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 32a62e3bd46cf58586617d3f8b1a971c91df205e -R 7ea6babb6ca28821d5ebb371842cc2c9 +P 9495d33879221c1821331dc72c61a6a3d182f526 +R 6b2058239dcedcc73d7ba7314be4d002 U drh -Z 5e0d604d556f91727b00c6f570867611 +Z 481738e778b68e5e24387a60a8825df4 diff --git a/manifest.uuid b/manifest.uuid index bed68c74ab..b9dc436b75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9495d33879221c1821331dc72c61a6a3d182f526 \ No newline at end of file +3401d9dcdbec390564574e8d2972c944c204e025 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 095fce5374..0cf2278562 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1876,20 +1876,24 @@ static int pager_error(Pager *pPager, int rc){ static int pager_truncate(Pager *pPager, Pgno nPage); /* -** The write transaction open on the pager passed as the only argument is -** being committed. This function returns true if all dirty pages should -** be flushed to disk, or false otherwise. Pages should be flushed to disk -** unless one of the following is true: +** The write transaction open on pPager is being committed (bCommit==1) +** or rolled back (bCommit==0). ** -** * The db is an in-memory database. +** Return TRUE if and only if all dirty pages should be flushed to disk. ** -** * The db is a temporary database and the db file has not been opened. +** Rules: ** -** * The db is a temporary database and the cache contains less than -** C/4 dirty pages, where C is the configured cache-size. +** * For non-TEMP databases, always sync to disk. This is necessary +** for transactions to be durable. +** +** * Sync TEMP database only on a COMMIT (not a ROLLBACK) when the backing +** file has been created already (via a spill on pagerStress()) and +** when the number of dirty pages in memory exceeds 25% of the total +** cache size. */ -static int pagerFlushOnCommit(Pager *pPager){ +static int pagerFlushOnCommit(Pager *pPager, int bCommit){ if( pPager->tempFile==0 ) return 1; + if( !bCommit ) return 0; if( !isOpen(pPager->fd) ) return 0; return (sqlite3PCachePercentDirty(pPager->pPCache)>=25); } @@ -2033,7 +2037,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ pPager->pInJournal = 0; pPager->nRec = 0; if( rc==SQLITE_OK ){ - if( !pPager->tempFile || (bCommit && pagerFlushOnCommit(pPager)) ){ + if( pagerFlushOnCommit(pPager, bCommit) ){ sqlite3PcacheCleanAll(pPager->pPCache); }else{ sqlite3PcacheClearWritable(pPager->pPCache); @@ -6206,7 +6210,7 @@ int sqlite3PagerCommitPhaseOne( assert( MEMDB==0 || pPager->tempFile ); assert( isOpen(pPager->fd) || pPager->tempFile ); - if( 0==pagerFlushOnCommit(pPager) ){ + if( 0==pagerFlushOnCommit(pPager, 1) ){ /* If this is an in-memory db, or no pages have been written to, or this ** function has already been called, it is mostly a no-op. However, any ** backup in progress needs to be restarted. */ From a0f6b124ad1bec65832726b4d18f3a1dec397926 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2016 15:22:06 +0000 Subject: [PATCH 055/302] Remove the unused PGHDR_NEED_READ flag. Add invariant checking (during SQLITE_DEBUG builds only) for the PgHdr object. FossilOrigin-Name: 771c5411e9ebcad00fb4b97556b519488284b87b --- manifest | 16 +++++++------- manifest.uuid | 2 +- src/pager.c | 2 +- src/pcache.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++--- src/pcache.h | 12 ++++++---- 5 files changed, 76 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 12e791556f..5b2f5a2c42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarification\sof\sthe\spagerFlushOnCommit()\slogic. -D 2016-05-13T12:12:38.291 +C Remove\sthe\sunused\sPGHDR_NEED_READ\sflag.\s\sAdd\sinvariant\schecking\s(during\nSQLITE_DEBUG\sbuilds\sonly)\sfor\sthe\sPgHdr\sobject. +D 2016-05-13T15:22:06.587 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -364,11 +364,11 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 665c5a4da55952ac144c29d83e7f24393ce80dce +F src/pager.c 3910579bfbe323dfabed2b95d201159b61b8ef42 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c ad5ce697dc5a734caddb2b1eac83b195da95ddbe -F src/pcache.h 33b40350df1b6c278e019dee37f87e1bac276223 +F src/pcache.c e93f1e1b4c6134d59b4bd4f3f684f406987ef299 +F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9495d33879221c1821331dc72c61a6a3d182f526 -R 6b2058239dcedcc73d7ba7314be4d002 +P 3401d9dcdbec390564574e8d2972c944c204e025 +R 440a1b1b52d8bc83687d285c09ed1eae U drh -Z 481738e778b68e5e24387a60a8825df4 +Z 63614a0e4a8fa1151ab9567f8bbeafca diff --git a/manifest.uuid b/manifest.uuid index b9dc436b75..67d06a22f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3401d9dcdbec390564574e8d2972c944c204e025 \ No newline at end of file +771c5411e9ebcad00fb4b97556b519488284b87b \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 0cf2278562..b24267e58a 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2377,7 +2377,6 @@ static int pager_playback_one_page( assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)!=0 ); pPager->doNotSpill &= ~SPILLFLAG_ROLLBACK; if( rc!=SQLITE_OK ) return rc; - pPg->flags &= ~PGHDR_NEED_READ; sqlite3PcacheMakeDirty(pPg); } if( pPg ){ @@ -6005,6 +6004,7 @@ void sqlite3PagerDontWrite(PgHdr *pPg){ IOTRACE(("CLEAN %p %d\n", pPager, pPg->pgno)) pPg->flags |= PGHDR_DONT_WRITE; pPg->flags &= ~PGHDR_WRITEABLE; + testcase( pPg->flags & PGHDR_NEED_SYNC ); pager_set_pagehash(pPg); } } diff --git a/src/pcache.c b/src/pcache.c index 6c07b20f57..d778f9aedc 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -53,11 +53,18 @@ struct PCache { sqlite3_pcache *pCache; /* Pluggable cache module */ }; +/********************************** Test and Debug Logic **********************/ /* -** Debug tracing macros +** Debug tracing macros. Enable by by changing the "0" to "1" and +** recompiling. +** +** When sqlite3PcacheTrace is 1, single line trace messages are issued. +** When sqlite3PcacheTrace is 2, a dump of the pcache showing all cache entries +** is displayed for many operations, resulting in a lot of output. */ #if defined(SQLITE_DEBUG) && 0 - int sqlite3PcacheTrace = 2; + int sqlite3PcacheTrace = 2; /* 0: off 1: simple 2: cache dumps */ + int sqlite3PcacheMxDump = 9999; /* Max cache entries for pcacheDump() */ # define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;} void pcacheDump(PCache *pCache){ int N; @@ -69,7 +76,7 @@ struct PCache { if( sqlite3PcacheTrace<2 ) return; if( pCache->pCache==0 ) return; N = sqlite3PcachePagecount(pCache); - if( N>5 ) N = 5; + if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump; for(i=1; i<=N; i++){ pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0); if( pLower==0 ) continue; @@ -88,6 +95,46 @@ struct PCache { # define pcacheDump(X) #endif +/* +** Check invariants on a PgHdr entry. Return true if everything is OK. +** Return false if any invariant is violated. +** +** This routine is for use inside of assert() statements only. For +** example: +** +** assert( sqlite3PcachePageSanity(pPg) ); +*/ +#if SQLITE_DEBUG +int sqlite3PcachePageSanity(PgHdr *pPg){ + PCache *pCache; + assert( pPg!=0 ); + assert( pPg->pgno>0 ); /* Page number is 1 or more */ + pCache = pPg->pCache; + assert( pCache!=0 ); /* Every page has an associated PCache */ + if( pPg->flags & PGHDR_CLEAN ){ + assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */ + assert( pCache->pDirty!=pPg ); /* CLEAN pages not on dirty list */ + assert( pCache->pDirtyTail!=pPg ); + } + /* WRITEABLE pages must also be DIRTY */ + if( pPg->flags & PGHDR_WRITEABLE ){ + assert( pPg->flags & PGHDR_DIRTY ); /* WRITEABLE implies DIRTY */ + } + /* NEED_SYNC can be set independently of WRITEABLE. This can happen, + ** for example, when using the sqlite3PagerDontWrite() optimization: + ** (1) Page X is journalled, and gets WRITEABLE and NEED_SEEK. + ** (2) Page X moved to freelist, WRITEABLE is cleared + ** (3) Page X reused, WRITEABLE is set again + ** If NEED_SYNC had been cleared in step 2, then it would not be reset + ** in step 3, and page might be written into the database without first + ** syncing the rollback journal, which might cause corruption on a power + ** loss. + */ + return 1; +} +#endif /* SQLITE_DEBUG */ + + /********************************** Linked List Management ********************/ /* Allowed values for second argument to pcacheManageDirtyList() */ @@ -439,6 +486,7 @@ PgHdr *sqlite3PcacheFetchFinish( } pCache->nRefSum++; pPgHdr->nRef++; + assert( sqlite3PcachePageSanity(pPgHdr) ); return pPgHdr; } @@ -467,6 +515,7 @@ void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){ */ void sqlite3PcacheRef(PgHdr *p){ assert(p->nRef>0); + assert( sqlite3PcachePageSanity(p) ); p->nRef++; p->pCache->nRefSum++; } @@ -478,6 +527,7 @@ void sqlite3PcacheRef(PgHdr *p){ */ void sqlite3PcacheDrop(PgHdr *p){ assert( p->nRef==1 ); + assert( sqlite3PcachePageSanity(p) ); if( p->flags&PGHDR_DIRTY ){ pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); } @@ -491,6 +541,7 @@ void sqlite3PcacheDrop(PgHdr *p){ */ void sqlite3PcacheMakeDirty(PgHdr *p){ assert( p->nRef>0 ); + assert( sqlite3PcachePageSanity(p) ); if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/ p->flags &= ~PGHDR_DONT_WRITE; if( p->flags & PGHDR_CLEAN ){ @@ -499,6 +550,7 @@ void sqlite3PcacheMakeDirty(PgHdr *p){ assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY ); pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD); } + assert( sqlite3PcachePageSanity(p) ); } } @@ -507,12 +559,14 @@ void sqlite3PcacheMakeDirty(PgHdr *p){ ** make it so. */ void sqlite3PcacheMakeClean(PgHdr *p){ + assert( sqlite3PcachePageSanity(p) ); if( ALWAYS((p->flags & PGHDR_DIRTY)!=0) ){ assert( (p->flags & PGHDR_CLEAN)==0 ); pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE); p->flags |= PGHDR_CLEAN; pcacheTrace(("%p.CLEAN %d\n",p->pCache,p->pgno)); + assert( sqlite3PcachePageSanity(p) ); if( p->nRef==0 ){ pcacheUnpin(p); } @@ -560,6 +614,7 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){ PCache *pCache = p->pCache; assert( p->nRef>0 ); assert( newPgno>0 ); + assert( sqlite3PcachePageSanity(p) ); pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno)); sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno); p->pgno = newPgno; diff --git a/src/pcache.h b/src/pcache.h index 8e0f12e094..9012edf22e 100644 --- a/src/pcache.h +++ b/src/pcache.h @@ -51,11 +51,10 @@ struct PgHdr { #define PGHDR_WRITEABLE 0x004 /* Journaled and ready to modify */ #define PGHDR_NEED_SYNC 0x008 /* Fsync the rollback journal before ** writing this page to the database */ -#define PGHDR_NEED_READ 0x010 /* Content is unread */ -#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ -#define PGHDR_MMAP 0x040 /* This is an mmap page object */ +#define PGHDR_DONT_WRITE 0x010 /* Do not write content to disk */ +#define PGHDR_MMAP 0x020 /* This is an mmap page object */ -#define PGHDR_WAL_APPEND 0x080 /* Appended to wal file */ +#define PGHDR_WAL_APPEND 0x040 /* Appended to wal file */ /* Initialize and shutdown the page cache subsystem */ int sqlite3PcacheInitialize(void); @@ -138,6 +137,11 @@ int sqlite3PcachePagecount(PCache*); void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)); #endif +#if defined(SQLITE_DEBUG) +/* Check invariants on a PgHdr object */ +int sqlite3PcachePageSanity(PgHdr*); +#endif + /* Set and get the suggested cache-size for the specified pager-cache. ** ** If no global maximum is configured, then the system attempts to limit From 3b02a07e7d91d95467b5d8935fcbc81ae7e7f9f2 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2016 17:22:33 +0000 Subject: [PATCH 056/302] Improvements to a comment in the pcache.c file. No changes to code. FossilOrigin-Name: b369980f0c4550a9034833caa2c7c85d6030f5ff --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache.c | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 5b2f5a2c42..b655548911 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunused\sPGHDR_NEED_READ\sflag.\s\sAdd\sinvariant\schecking\s(during\nSQLITE_DEBUG\sbuilds\sonly)\sfor\sthe\sPgHdr\sobject. -D 2016-05-13T15:22:06.587 +C Improvements\sto\sa\scomment\sin\sthe\spcache.c\sfile.\s\sNo\schanges\sto\scode. +D 2016-05-13T17:22:33.997 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -367,7 +367,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 3910579bfbe323dfabed2b95d201159b61b8ef42 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c e93f1e1b4c6134d59b4bd4f3f684f406987ef299 +F src/pcache.c f398c0084399e7481482cbc6a578a3cc4c3675f3 F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3401d9dcdbec390564574e8d2972c944c204e025 -R 440a1b1b52d8bc83687d285c09ed1eae +P 771c5411e9ebcad00fb4b97556b519488284b87b +R fc31f84edb2e71fa53cb5f4572b3042f U drh -Z 63614a0e4a8fa1151ab9567f8bbeafca +Z 0bbb954743a2d2dee1416e855a012aec diff --git a/manifest.uuid b/manifest.uuid index 67d06a22f0..26bf44c3d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -771c5411e9ebcad00fb4b97556b519488284b87b \ No newline at end of file +b369980f0c4550a9034833caa2c7c85d6030f5ff \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index d778f9aedc..d628320334 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -129,6 +129,13 @@ int sqlite3PcachePageSanity(PgHdr *pPg){ ** in step 3, and page might be written into the database without first ** syncing the rollback journal, which might cause corruption on a power ** loss. + ** + ** Another example is when the database page size is smaller than the + ** disk sector size. When any page of a sector is journalled, all pages + ** in that sector are marked NEED_SYNC even if they are still CLEAN, just + ** in case they are later modified, since all pages in the same sector + ** must be journalled and synced before any of those pages can be safely + ** written. */ return 1; } From 697c9eaa907474554aaaf97ad71f07c2a151c7ac Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 16 May 2016 11:55:09 +0000 Subject: [PATCH 057/302] Disable shell.exe test cases for UTF8 filenames as they do not work on MinGW. FossilOrigin-Name: 386bcbba8ed733ee84958e6bd6e9d33c150e6c18 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/shell1.test | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index b655548911..f2eb278bdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sa\scomment\sin\sthe\spcache.c\sfile.\s\sNo\schanges\sto\scode. -D 2016-05-13T17:22:33.997 +C Disable\sshell.exe\stest\scases\sfor\sUTF8\sfilenames\sas\sthey\sdo\snot\swork\son\sMinGW. +D 2016-05-16T11:55:09.207 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -1053,7 +1053,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 2f2aee20db294b9924e81f6ccbe60f19e21e8506 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 023657b3f8ba108dbd5ff2ebc8fceb3cf6d4ff9f +F test/shell1.test c90b0415cea6eeefb86b4ab1651b06247922ca52 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9 @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 771c5411e9ebcad00fb4b97556b519488284b87b -R fc31f84edb2e71fa53cb5f4572b3042f +P b369980f0c4550a9034833caa2c7c85d6030f5ff +R d8533b8fd6cbe0fbe7678e18e240aa96 U drh -Z 0bbb954743a2d2dee1416e855a012aec +Z 2e128c8e8599dacb44997bdb31a5993e diff --git a/manifest.uuid b/manifest.uuid index 26bf44c3d1..0837743ae1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b369980f0c4550a9034833caa2c7c85d6030f5ff \ No newline at end of file +386bcbba8ed733ee84958e6bd6e9d33c150e6c18 \ No newline at end of file diff --git a/test/shell1.test b/test/shell1.test index 760c85fadc..498cd64a9f 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -915,6 +915,9 @@ do_test shell1-5.0 { } } {} +# These test cases do not work on MinGW +if 0 { + # The string used here is the word "test" in Chinese. # In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95 set test \u6D4B\u8BD5 @@ -951,5 +954,6 @@ do_test shell1-6.1 { } forcedelete test3.db } {} +} finish_test From ee7de914d4cce9ab3eee31dfae7ec93807fab70e Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 16 May 2016 14:35:15 +0000 Subject: [PATCH 058/302] Do not run snapshot_fault.test as part of the inmemory_journal permutation. FossilOrigin-Name: 995c084bde44e678facc5f5d95a2335ce61e57b0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/permutations.test | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f2eb278bdd..c05146f793 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sshell.exe\stest\scases\sfor\sUTF8\sfilenames\sas\sthey\sdo\snot\swork\son\sMinGW. -D 2016-05-16T11:55:09.207 +C Do\snot\srun\ssnapshot_fault.test\sas\spart\sof\sthe\sinmemory_journal\spermutation. +D 2016-05-16T14:35:15.401 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -977,7 +977,7 @@ F test/parser1.test 222b5cbf3e2e659fec1bf7d723488c8b9c94f1d0 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff -F test/permutations.test b6b3e165fdc1b8c82a820033646dbfc6a7a01746 +F test/permutations.test 544a2f317fc5045bc512ae432f89eae303c0d640 F test/pragma.test 1e94755164a3a3264cd39836de4bebcb7809e5f8 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed @@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b369980f0c4550a9034833caa2c7c85d6030f5ff -R d8533b8fd6cbe0fbe7678e18e240aa96 -U drh -Z 2e128c8e8599dacb44997bdb31a5993e +P 386bcbba8ed733ee84958e6bd6e9d33c150e6c18 +R 0e39e66ffd1d7cd6d62e8fa571ff36a1 +U dan +Z 786140f96f9b408e2c11236687959ca4 diff --git a/manifest.uuid b/manifest.uuid index 0837743ae1..c971be0382 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -386bcbba8ed733ee84958e6bd6e9d33c150e6c18 \ No newline at end of file +995c084bde44e678facc5f5d95a2335ce61e57b0 \ No newline at end of file diff --git a/test/permutations.test b/test/permutations.test index df3f500cda..f4784cfcee 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -746,6 +746,11 @@ test_suite "inmemory_journal" -description { # WAL mode is different. wal* tkt-2d1a5c67d.test backcompat.test e_wal* rowallock.test + + # This test does not work as the "PRAGMA journal_mode = memory" + # statement switches the database out of wal mode at inopportune + # times. + snapshot_fault.test }] ifcapable mem3 { From 0d2c3a0e11e47b1251a41c5f297cd336e6ac89a1 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 17 May 2016 21:17:51 +0000 Subject: [PATCH 059/302] Enhance the scrub utility program so that it does a FULL checkpoint prior to starting the backup, to ensure that the database file content matches what needs to be backed up without having to look at the WAL file. FossilOrigin-Name: ab1c5ce50f139070d7a322f43132a93c8af2ed68 --- ext/misc/scrub.c | 9 ++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c index 12adcd7bd9..1d21fc5389 100644 --- a/ext/misc/scrub.c +++ b/ext/misc/scrub.c @@ -164,13 +164,20 @@ static void scrubBackupOpenSrc(ScrubState *p){ sqlite3_errmsg(p->dbSrc)); return; } - p->rcErr = sqlite3_exec(p->dbSrc, "BEGIN", 0, 0, 0); + p->rcErr = sqlite3_exec(p->dbSrc, "SELECT 1 FROM sqlite_master; BEGIN;", + 0, 0, 0); if( p->rcErr ){ scrubBackupErr(p, "cannot start a read transaction on the source database: %s", sqlite3_errmsg(p->dbSrc)); return; } + rc = sqlite3_wal_checkpoint_v2(p->dbSrc, "main", SQLITE_CHECKPOINT_FULL, + 0, 0); + if( rc ){ + scrubBackupErr(p, "cannot checkpoint the source database"); + return; + } pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_size"); if( pStmt==0 ) return; rc = sqlite3_step(pStmt); diff --git a/manifest b/manifest index 9b5c6f0b2e..8af4221406 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\slatest\schanges\sfrom\strunk. -D 2016-05-17T17:11:21.184 +C Enhance\sthe\sscrub\sutility\sprogram\sso\sthat\sit\sdoes\sa\sFULL\scheckpoint\sprior\sto\nstarting\sthe\sbackup,\sto\sensure\sthat\sthe\sdatabase\sfile\scontent\smatches\swhat\sneeds\nto\sbe\sbacked\sup\swithout\shaving\sto\slook\sat\sthe\sWAL\sfile. +D 2016-05-17T21:17:51.530 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -215,7 +215,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a -F ext/misc/scrub.c a3380a5ff0698f88a56a23c999ee5e53768ac3ae +F ext/misc/scrub.c ea0903701e3ac02b4466ce9cffd0325c7ddbfcf0 F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d2efd3c176f0eba2d78105f0bb3161db38bd4bab 995c084bde44e678facc5f5d95a2335ce61e57b0 -R c8a04e46ce574c9cb7d04e9b64f57621 +P 5021dfe1f3f723a5938d547a0308f1d63103702d +R a2f9971160f157164223781dabeb5e95 U drh -Z 19bb7af983a6a8b12079243584bed878 +Z 2fde01a79f5811045a1dffd48050935f diff --git a/manifest.uuid b/manifest.uuid index ba749ac7fb..30152d3b67 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5021dfe1f3f723a5938d547a0308f1d63103702d \ No newline at end of file +ab1c5ce50f139070d7a322f43132a93c8af2ed68 \ No newline at end of file From 55bcaf6829131233488f57035bc8c2dc6bbdaed1 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 18 May 2016 10:57:30 +0000 Subject: [PATCH 060/302] Version 3.13.0 FossilOrigin-Name: fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2 --- manifest | 13 ++++++++----- manifest.uuid | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index c05146f793..3230f21680 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\ssnapshot_fault.test\sas\spart\sof\sthe\sinmemory_journal\spermutation. -D 2016-05-16T14:35:15.401 +C Version\s3.13.0 +D 2016-05-18T10:57:30.274 F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd @@ -1488,7 +1488,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 386bcbba8ed733ee84958e6bd6e9d33c150e6c18 +P 995c084bde44e678facc5f5d95a2335ce61e57b0 R 0e39e66ffd1d7cd6d62e8fa571ff36a1 -U dan -Z 786140f96f9b408e2c11236687959ca4 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.13.0 * +U drh +Z ecdfa0c32602745fc488e92155fa5f0d diff --git a/manifest.uuid b/manifest.uuid index c971be0382..8ab055941c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -995c084bde44e678facc5f5d95a2335ce61e57b0 \ No newline at end of file +fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2 \ No newline at end of file From 4ca239fd559de1d6ddb551eb4141729c14ea90b5 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2016 11:12:43 +0000 Subject: [PATCH 061/302] Small size reduction and performance improvement in the OP_Column opcode. FossilOrigin-Name: 0d7730611be974162d9a064a041957d04d55b6d3 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ed2ee43fc4..1b36c9380b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"scrub"\sutility\sprogram\sthat\ssimultaneously\sbacks-up\sa\slive\sdatabase\nand\serases\sall\sdeleted\scontent. -D 2016-05-18T21:03:27.980 +C Small\ssize\sreduction\sand\sperformance\simprovement\sin\sthe\sOP_Column\sopcode. +D 2016-05-19T11:12:43.914 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -444,7 +444,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 4bad04212736526845fda9ca674afafb10078b2b +F src/vdbe.c d9701a72283b84a3a48b285846a9789ae541a1fd F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1489,8 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 915416d15f43c4e1d3afa8121bb6fa09f9f67e30 ab1c5ce50f139070d7a322f43132a93c8af2ed68 -R d7177fcfb6d0afbc5b91ed78ec9dbdb9 -T +closed ab1c5ce50f139070d7a322f43132a93c8af2ed68 +P c981ab2a4771f8c5e95e2e85e37a02a4bd0e36ee +R b1335b5684d992944fc28b0ddd0864fa U drh -Z c9dd9bd914e72b28b0a6b209c46c7aec +Z 965b22aefdb31f818dd701e1987d5b24 diff --git a/manifest.uuid b/manifest.uuid index a5036d52e9..c2be5cd870 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c981ab2a4771f8c5e95e2e85e37a02a4bd0e36ee \ No newline at end of file +0d7730611be974162d9a064a041957d04d55b6d3 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index dc8201595b..ed12df9ac6 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2403,6 +2403,7 @@ case OP_Column: { /* If the cursor cache is stale, bring it up-to-date */ rc = sqlite3VdbeCursorMoveto(&pC, &p2); + if( rc ) goto abort_due_to_error; assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); pDest = &aMem[pOp->p3]; @@ -2416,7 +2417,6 @@ case OP_Column: { assert( pC->eCurType!=CURTYPE_SORTER ); pCrsr = pC->uc.pCursor; - if( rc ) goto abort_due_to_error; if( pC->cacheStatus!=p->cacheCtr ){ if( pC->nullRow ){ if( pC->eCurType==CURTYPE_PSEUDO ){ From 21690ff7fc270bec87f17c603957198355c39923 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 19 May 2016 16:21:30 +0000 Subject: [PATCH 062/302] Add test cases to test some fts3/4 edge case behaviour surrounding the '*' character. FossilOrigin-Name: 1f577e1f08159aeaaf19a7020d9004dd6103d57b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts3expr.test | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1b36c9380b..30689d702a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\ssize\sreduction\sand\sperformance\simprovement\sin\sthe\sOP_Column\sopcode. -D 2016-05-19T11:12:43.914 +C Add\stest\scases\sto\stest\ssome\sfts3/4\sedge\scase\sbehaviour\ssurrounding\sthe\s'*'\scharacter. +D 2016-05-19T16:21:30.935 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -747,7 +747,7 @@ F test/fts3defer2.test c540f5f5c2840f70c68fd9b597df817ec7170468 F test/fts3defer3.test dd53fc13223c6d8264a98244e9b19abd35ed71cd F test/fts3drop.test 1b906e293d6773812587b3dc458cb9e8f3f0c297 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 -F test/fts3expr.test 3401d47b229c4504424caf362cc4ff704cad4162 +F test/fts3expr.test 9466627007804d855bf9df2a0cfb3dac23686fdc F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3expr3.test c4d4a7d6327418428c96e0a3a1137c251b8dfbf8 F test/fts3expr4.test c39a15d676b14fc439d9bf845aa7bddcf4a74dc3 @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c981ab2a4771f8c5e95e2e85e37a02a4bd0e36ee -R b1335b5684d992944fc28b0ddd0864fa -U drh -Z 965b22aefdb31f818dd701e1987d5b24 +P 0d7730611be974162d9a064a041957d04d55b6d3 +R 75d6e6df9086a2f9f36eca9902564b2b +U dan +Z dcfe2b5ad39143edc6be65e7ccceeb89 diff --git a/manifest.uuid b/manifest.uuid index c2be5cd870..c1125dfeb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0d7730611be974162d9a064a041957d04d55b6d3 \ No newline at end of file +1f577e1f08159aeaaf19a7020d9004dd6103d57b \ No newline at end of file diff --git a/test/fts3expr.test b/test/fts3expr.test index 6e23faf633..b186a157d1 100644 --- a/test/fts3expr.test +++ b/test/fts3expr.test @@ -514,4 +514,8 @@ do_test fts3expr-9.1 { test_fts3expr "f (e NEAR/2 a)" } {AND {PHRASE 3 0 f} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}} +do_test fts3expr-10.1 { test_fts3expr "abc *" } {PHRASE 3 0 abc} +do_test fts3expr-10.2 { test_fts3expr "*" } {} +do_test fts3expr-10.3 { test_fts3expr "abc*" } {PHRASE 3 0 abc+} + finish_test From 0eda6cd80d27e97ed9b87ed1e373acfe7cd65007 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2016 16:58:42 +0000 Subject: [PATCH 063/302] Performance improvement in the OP_Column opcode. FossilOrigin-Name: 4737cadc414c5f6d256fcceacb19d80d66a8c8e7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbe.c | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 30689d702a..d978122ed4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sto\stest\ssome\sfts3/4\sedge\scase\sbehaviour\ssurrounding\sthe\s'*'\scharacter. -D 2016-05-19T16:21:30.935 +C Performance\simprovement\sin\sthe\sOP_Column\sopcode. +D 2016-05-19T16:58:42.935 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -444,7 +444,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c d9701a72283b84a3a48b285846a9789ae541a1fd +F src/vdbe.c ee42e2b8f77c4bf6cf9b29be7b2235b0fc6aeca6 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0d7730611be974162d9a064a041957d04d55b6d3 -R 75d6e6df9086a2f9f36eca9902564b2b -U dan -Z dcfe2b5ad39143edc6be65e7ccceeb89 +P 1f577e1f08159aeaaf19a7020d9004dd6103d57b +R e89ba2854e43a6ca2d4e88d579ae2259 +U drh +Z 6f1f0837aba6646cc9cdae7372a9992d diff --git a/manifest.uuid b/manifest.uuid index c1125dfeb6..b52d532ceb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f577e1f08159aeaaf19a7020d9004dd6103d57b \ No newline at end of file +4737cadc414c5f6d256fcceacb19d80d66a8c8e7 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index ed12df9ac6..eecefade24 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2485,14 +2485,15 @@ case OP_Column: { rc = SQLITE_CORRUPT_BKPT; goto abort_due_to_error; } + }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/ + /* The following goto is an optimization. It can be omitted and + ** everything will still work. But OP_Column is measurably faster + ** by skipping the subsequent conditional, which is always true. + */ + zData = pC->aRow; + assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */ + goto op_column_read_header; } - - /* The following goto is an optimization. It can be omitted and - ** everything will still work. But OP_Column is measurably faster - ** by skipping the subsequent conditional, which is always true. - */ - assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */ - goto op_column_read_header; } /* Make sure at least the first p2+1 entries of the header have been @@ -2502,7 +2503,6 @@ case OP_Column: { /* If there is more header available for parsing in the record, try ** to extract additional fields up through the p2+1-th field */ - op_column_read_header: if( pC->iHdrOffsetaRow==0 ){ @@ -2515,11 +2515,11 @@ case OP_Column: { } /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */ + op_column_read_header: i = pC->nHdrParsed; offset64 = aOffset[i]; zHdr = zData + pC->iHdrOffset; zEndHdr = zData + aOffset[0]; - assert( i<=p2 && zHdr Date: Thu, 19 May 2016 17:51:19 +0000 Subject: [PATCH 064/302] Optimization marks in vdbe.c. No logic changes. FossilOrigin-Name: cf2737415aff7de7e133da174b645324c99d5758 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d978122ed4..32ce760d51 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\simprovement\sin\sthe\sOP_Column\sopcode. -D 2016-05-19T16:58:42.935 +C Optimization\smarks\sin\svdbe.c.\s\sNo\slogic\schanges. +D 2016-05-19T17:51:19.307 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -444,7 +444,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c ee42e2b8f77c4bf6cf9b29be7b2235b0fc6aeca6 +F src/vdbe.c d71b935d2b21bef874680c34329adedc3b021101 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1f577e1f08159aeaaf19a7020d9004dd6103d57b -R e89ba2854e43a6ca2d4e88d579ae2259 +P 4737cadc414c5f6d256fcceacb19d80d66a8c8e7 +R 9f8362ea36557124657ddc486fb3880d U drh -Z 6f1f0837aba6646cc9cdae7372a9992d +Z f893c9ab14ca925d78367a321ac969dc diff --git a/manifest.uuid b/manifest.uuid index b52d532ceb..72112d1271 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4737cadc414c5f6d256fcceacb19d80d66a8c8e7 \ No newline at end of file +cf2737415aff7de7e133da174b645324c99d5758 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index eecefade24..6d96f85548 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2417,7 +2417,7 @@ case OP_Column: { assert( pC->eCurType!=CURTYPE_SORTER ); pCrsr = pC->uc.pCursor; - if( pC->cacheStatus!=p->cacheCtr ){ + if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/ if( pC->nullRow ){ if( pC->eCurType==CURTYPE_PSEUDO ){ assert( pC->uc.pseudoTableReg>0 ); @@ -2464,7 +2464,7 @@ case OP_Column: { aOffset[0] = offset; - if( availaRow does not have to hold the entire row, but it does at least ** need to cover the header of the record. If pC->aRow does not contain ** the complete header, then set it to zero, forcing the header to be From ce943bc8340461e82156e7d3c8ac1835afab6027 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2016 18:56:33 +0000 Subject: [PATCH 065/302] Clean up the WHERE_* macros used for the wctrlFlags parameter on the sqlite3WhereBegin() interface, freeing up some bits to be used for other things. FossilOrigin-Name: d01305841da94b2d47e32744802f69525bf590df --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqliteInt.h | 24 ++++++++++++------------ src/where.c | 32 ++++++++++++++++---------------- src/wherecode.c | 14 +++++--------- 5 files changed, 42 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 32ce760d51..9444553652 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Optimization\smarks\sin\svdbe.c.\s\sNo\slogic\schanges. -D 2016-05-19T17:51:19.307 +C Clean\sup\sthe\sWHERE_*\smacros\sused\sfor\sthe\swctrlFlags\sparameter\son\sthe\s\nsqlite3WhereBegin()\sinterface,\sfreeing\sup\ssome\sbits\sto\sbe\sused\sfor\sother\sthings. +D 2016-05-19T18:56:33.988 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -383,7 +383,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 7c600fe863a30b39ba9afcedba5ee3dad657f8c2 +F src/sqliteInt.h 36ad4f5a86e1bef5e34c301b60bb24837f87d662 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -458,9 +458,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c ad8ad50ccf25795f6830b6b864bbfcd060ff08dd +F src/where.c 72fd2e1258625c1aee8e33a529914aea2d487422 F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 -F src/wherecode.c d227fca7d766a10fe4ba4d812210f5631f5a98b3 +F src/wherecode.c e3f18fcda2d7f8218a09dc33cf495dca0efa6e3e F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4737cadc414c5f6d256fcceacb19d80d66a8c8e7 -R 9f8362ea36557124657ddc486fb3880d +P cf2737415aff7de7e133da174b645324c99d5758 +R b3dd248e38fe4d745483b43457d811f8 U drh -Z f893c9ab14ca925d78367a321ac969dc +Z 077055ad654ddf765f85d8f018c402ea diff --git a/manifest.uuid b/manifest.uuid index 72112d1271..3688ab723e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf2737415aff7de7e133da174b645324c99d5758 \ No newline at end of file +d01305841da94b2d47e32744802f69525bf590df \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6fb027cacc..a232e7b894 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2531,19 +2531,19 @@ struct SrcList { #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ -#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ -#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ -#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ -#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ -#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */ -#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */ -#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ -#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ -#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ - /* 0x1000 not currently used */ -#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */ +#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */ +#define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */ +#define WHERE_OR_SUBCLAUSE 0x0020 /* Sub-WHERE for an OR term */ +#define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */ +#define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ +#define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ +#define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ +#define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */ + /* 0x0800 not currently used */ + /* 0x1000 not currently used */ + /* 0x2000 not currently used */ #define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */ -#define WHERE_SEEK_TABLE 0x8000 /* Do not defer seeks on main table */ + /* 0x8000 not currently used */ /* Allowed return values from sqlite3WhereIsDistinct() */ diff --git a/src/where.c b/src/where.c index 849d0ae5bd..f6f6f68eab 100644 --- a/src/where.c +++ b/src/where.c @@ -2635,7 +2635,7 @@ static int whereLoopAddBtree( #ifndef SQLITE_OMIT_AUTOMATIC_INDEX /* Automatic indexes */ if( !pBuilder->pOrSet /* Not part of an OR optimization */ - && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0 + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */ && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ @@ -3947,7 +3947,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ Index *pIdx; pWInfo = pBuilder->pWInfo; - if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0; + if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0; assert( pWInfo->pTabList->nSrc>=1 ); pItem = pWInfo->pTabList->a; pTab = pItem->pTab; @@ -4094,7 +4094,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL. ** ** The iIdxCur parameter is the cursor number of an index. If -** WHERE_ONETABLE_ONLY is set, iIdxCur is the cursor number of an index +** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index ** to use for OR clause processing. The WHERE clause should use this ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is ** the first cursor in an array of cursors for all indices. iIdxCur should @@ -4108,7 +4108,7 @@ WhereInfo *sqlite3WhereBegin( ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */ ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */ u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */ - int iAuxArg /* If WHERE_ONETABLE_ONLY is set, index cursor number + int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number ** If WHERE_USE_LIMIT, then the limit amount */ ){ int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ @@ -4127,11 +4127,11 @@ WhereInfo *sqlite3WhereBegin( assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || ( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 - && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 + && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 )); - /* Only one of WHERE_ONETABLE_ONLY or WHERE_USE_LIMIT */ - assert( (wctrlFlags & WHERE_ONETABLE_ONLY)==0 + /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */ + assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 || (wctrlFlags & WHERE_USE_LIMIT)==0 ); /* Variable initialization */ @@ -4159,11 +4159,11 @@ WhereInfo *sqlite3WhereBegin( } /* This function normally generates a nested loop for all tables in - ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should + ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should ** only generate code for the first table in pTabList and assume that ** any cursors associated with subsequent tables are uninitialized. */ - nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc; + nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc; /* Allocate and initialize the WhereInfo structure that will become the ** return value. A single allocation is used to store the WhereInfo @@ -4239,7 +4239,7 @@ WhereInfo *sqlite3WhereBegin( ** Note that bitmasks are created for all pTabList->nSrc tables in ** pTabList, not just the first nTabList tables. nTabList is normally ** equal to pTabList->nSrc but might be shortened to 1 if the - ** WHERE_ONETABLE_ONLY flag is set. + ** WHERE_OR_SUBCLAUSE flag is set. */ for(ii=0; iinSrc; ii++){ createMask(pMaskSet, pTabList->a[ii].iCursor); @@ -4422,7 +4422,7 @@ WhereInfo *sqlite3WhereBegin( }else #endif if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 - && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){ + && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ int op = OP_OpenRead; if( pWInfo->eOnePass!=ONEPASS_OFF ){ op = OP_OpenWrite; @@ -4461,7 +4461,7 @@ WhereInfo *sqlite3WhereBegin( /* iAuxArg is always set if to a positive value if ONEPASS is possible */ assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 ); if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx) - && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 + && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){ /* This is one term of an OR-optimization using the PRIMARY KEY of a ** WITHOUT ROWID table. No need for a separate index */ @@ -4477,7 +4477,7 @@ WhereInfo *sqlite3WhereBegin( } op = OP_OpenWrite; pWInfo->aiCurOnePass[1] = iIndexCur; - }else if( iAuxArg && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){ + }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){ iIndexCur = iAuxArg; op = OP_ReopenIdx; }else{ @@ -4541,7 +4541,7 @@ WhereInfo *sqlite3WhereBegin( pLevel->addrBody = sqlite3VdbeCurrentAddr(v); notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady); pWInfo->iContinue = pLevel->addrCont; - if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_ONETABLE_ONLY)==0 ){ + if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){ sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain); } } @@ -4664,12 +4664,12 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ /* Close all of the cursors that were opened by sqlite3WhereBegin. ** Except, do not close cursors that will be reused by the OR optimization - ** (WHERE_OMIT_OPEN_CLOSE). And do not close the OP_OpenWrite cursors + ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors ** created for the ONEPASS optimization. */ if( (pTab->tabFlags & TF_Ephemeral)==0 && pTab->pSelect==0 - && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ int ws = pLoop->wsFlags; if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){ diff --git a/src/wherecode.c b/src/wherecode.c index a42fa1f843..054b1b1078 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -126,7 +126,7 @@ int sqlite3WhereExplainOneScan( pLoop = pLevel->pWLoop; flags = pLoop->wsFlags; - if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return 0; + if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0; isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0)) @@ -776,7 +776,7 @@ static void codeDeferredSeek( assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 ); sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur); - if( (pWInfo->wctrlFlags & WHERE_FORCE_TABLE) + if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE) && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask) ){ int i; @@ -831,7 +831,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); bRev = (pWInfo->revMask>>iLevel)&1; omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 - && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0; + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0; VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName)); /* Create labels for the "break" and "continue" instructions @@ -1517,11 +1517,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** eliminating duplicates from other WHERE clauses, the action for each ** sub-WHERE clause is to to invoke the main loop body as a subroutine. */ - wctrlFlags = WHERE_OMIT_OPEN_CLOSE - | WHERE_FORCE_TABLE - | WHERE_ONETABLE_ONLY - | WHERE_NO_AUTOINDEX - | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE); + wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE); for(ii=0; iinTerm; ii++){ WhereTerm *pOrTerm = &pOrWc->a[ii]; if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ @@ -1690,7 +1686,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ testcase( pWInfo->untestedTerms==0 - && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ); + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ); pWInfo->untestedTerms = 1; continue; } From bc5eac00c2a093597cbb743891d8fbbb6312a50e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2016 19:31:30 +0000 Subject: [PATCH 066/302] Fixup comments on wctrlFlags value definitions. FossilOrigin-Name: 58b516e8c0b00a41bc0364eab267bc2ecb9efeff --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9444553652..89053f9deb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clean\sup\sthe\sWHERE_*\smacros\sused\sfor\sthe\swctrlFlags\sparameter\son\sthe\s\nsqlite3WhereBegin()\sinterface,\sfreeing\sup\ssome\sbits\sto\sbe\sused\sfor\sother\sthings. -D 2016-05-19T18:56:33.988 +C Fixup\scomments\son\swctrlFlags\svalue\sdefinitions. +D 2016-05-19T19:31:30.127 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -383,7 +383,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 36ad4f5a86e1bef5e34c301b60bb24837f87d662 +F src/sqliteInt.h 19de316bfce65ff074b379a67b493a446f3cf8ee F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cf2737415aff7de7e133da174b645324c99d5758 -R b3dd248e38fe4d745483b43457d811f8 +P d01305841da94b2d47e32744802f69525bf590df +R be830660ecf90ba00189952af638cb97 U drh -Z 077055ad654ddf765f85d8f018c402ea +Z 54bddff0ee366139e2fb13081e6cf75a diff --git a/manifest.uuid b/manifest.uuid index 3688ab723e..177ef2d35a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d01305841da94b2d47e32744802f69525bf590df \ No newline at end of file +58b516e8c0b00a41bc0364eab267bc2ecb9efeff \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a232e7b894..c795036666 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2533,7 +2533,8 @@ struct SrcList { #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ #define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */ #define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */ -#define WHERE_OR_SUBCLAUSE 0x0020 /* Sub-WHERE for an OR term */ +#define WHERE_OR_SUBCLAUSE 0x0020 /* Processing a sub-WHERE as part of + ** the OR optimization */ #define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */ #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ @@ -2542,7 +2543,7 @@ struct SrcList { /* 0x0800 not currently used */ /* 0x1000 not currently used */ /* 0x2000 not currently used */ -#define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */ +#define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ /* 0x8000 not currently used */ /* Allowed return values from sqlite3WhereIsDistinct() From a536df4e7ffedd6a3169d44b854fc40c3af4d354 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2016 22:13:37 +0000 Subject: [PATCH 067/302] In a query with both ORDER BY and LIMIT, if the inner loop satisfies the ORDER BY then try to cut short each invocation of the inner loop once the LIMIT has been satisfied. This check-in is a partial implementation only. FossilOrigin-Name: 852d1eda6ecca1171f6ed800b06f5b4854672002 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/select.c | 22 ++++++++++++++++++++++ src/sqliteInt.h | 1 + src/where.c | 16 +++++++++++++++- src/whereInt.h | 3 ++- 6 files changed, 53 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 89053f9deb..d01cdd7db8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixup\scomments\son\swctrlFlags\svalue\sdefinitions. -D 2016-05-19T19:31:30.127 +C In\sa\squery\swith\sboth\sORDER\sBY\sand\sLIMIT,\sif\sthe\sinner\sloop\ssatisfies\sthe\s\nORDER\sBY\sthen\stry\sto\scut\sshort\seach\sinvocation\sof\sthe\sinner\sloop\sonce\sthe\nLIMIT\shas\sbeen\ssatisfied.\s\sThis\scheck-in\sis\sa\spartial\simplementation\sonly. +D 2016-05-19T22:13:37.318 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -378,12 +378,12 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 49eb91c588a2bab36647368e031dc5b66928149d -F src/select.c fd4a7ce2937497181063cfedb92058ac89491a5d +F src/select.c 131eeddfcaf3777c4acd4727bf742b98af8183b5 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 19de316bfce65ff074b379a67b493a446f3cf8ee +F src/sqliteInt.h 863cf0d421611ccfa30541ee5ffe761c896ffa5b F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -458,8 +458,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 72fd2e1258625c1aee8e33a529914aea2d487422 -F src/whereInt.h 3b1fc240e322613ba4e9dc857ca9c7c3390acc74 +F src/where.c a7454e62ca13f1ff54892339022f8cb0a8bb3728 +F src/whereInt.h 6e18240be400bef8e4dbafea605251707c5dbf49 F src/wherecode.c e3f18fcda2d7f8218a09dc33cf495dca0efa6e3e F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1489,7 +1489,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d01305841da94b2d47e32744802f69525bf590df -R be830660ecf90ba00189952af638cb97 +P 58b516e8c0b00a41bc0364eab267bc2ecb9efeff +R 766495aa6109f75a3c3b0e829e8d3b47 +T *branch * orderby-limit +T *sym-orderby-limit * +T -sym-trunk * U drh -Z 54bddff0ee366139e2fb13081e6cf75a +Z 1f191cc43f073ab10b6b672b5a12f950 diff --git a/manifest.uuid b/manifest.uuid index 177ef2d35a..ec9b410bfa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58b516e8c0b00a41bc0364eab267bc2ecb9efeff \ No newline at end of file +852d1eda6ecca1171f6ed800b06f5b4854672002 \ No newline at end of file diff --git a/src/select.c b/src/select.c index eb37536b6f..080ccf3480 100644 --- a/src/select.c +++ b/src/select.c @@ -56,6 +56,7 @@ struct SortCtx { int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */ int labelDone; /* Jump here when done, ex: LIMIT reached */ u8 sortFlags; /* Zero or more SORTFLAG_* bits */ + u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */ }; #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ @@ -589,9 +590,29 @@ static void pushOntoSorter( sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord); if( iLimit ){ int addr; + int r1 = 0; + /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit + ** register is initialized with value of LIMIT+OFFSET.) After the sorter + ** fills up, delete the least entry in the sorter after each insert. + ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */ addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v); sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor); + if( pSort->bOrderedInnerLoop ){ + r1 = ++pParse->nMem; + sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1); + VdbeComment((v, "seq")); + } sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor); + if( pSort->bOrderedInnerLoop ){ + /* If the inner loop is driven by an index such that values from + ** the same iteration of the inner loop are in sorted order, then + ** immediately jump to the next iteration of an inner loop if the + ** entry from the current iteration does not fit into the top + ** LIMIT+OFFSET entries of the sorter. */ + int iBrk = sqlite3VdbeCurrentAddr(v) + 2; + sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1); + VdbeCoverage(v); + } sqlite3VdbeJumpHere(v, addr); } } @@ -5176,6 +5197,7 @@ int sqlite3Select( } if( sSort.pOrderBy ){ sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo); + sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo); if( sSort.nOBSat==sSort.pOrderBy->nExpr ){ sSort.pOrderBy = 0; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c795036666..7adfd3779b 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3637,6 +3637,7 @@ void sqlite3WhereEnd(WhereInfo*); LogEst sqlite3WhereOutputRowCount(WhereInfo*); int sqlite3WhereIsDistinct(WhereInfo*); int sqlite3WhereIsOrdered(WhereInfo*); +int sqlite3WhereOrderedInnerLoop(WhereInfo*); int sqlite3WhereIsSorted(WhereInfo*); int sqlite3WhereContinueLabel(WhereInfo*); int sqlite3WhereBreakLabel(WhereInfo*); diff --git a/src/where.c b/src/where.c index f6f6f68eab..521d2e19ec 100644 --- a/src/where.c +++ b/src/where.c @@ -51,6 +51,18 @@ int sqlite3WhereIsOrdered(WhereInfo *pWInfo){ return pWInfo->nOBSat; } +/* +** Return TRUE if the innermost loop of the WHERE clause implementation +** returns rows in ORDER BY order for complete run of the inner loop. +** +** Across multiple iterations of outer loops, the output rows need not be +** sorted. As long as rows are sorted for just the innermost loop, this +** routine can return TRUE. +*/ +int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){ + return pWInfo->bOrderedInnerLoop; +} + /* ** Return the VDBE address or label to jump to in order to continue ** immediately with the next row of a WHERE clause. @@ -3898,8 +3910,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ } }else{ pWInfo->nOBSat = pFrom->isOrdered; - if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0; pWInfo->revMask = pFrom->revLoop; + if( pWInfo->nOBSat<=0 ){ + pWInfo->nOBSat = 0; + } } if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP) && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0 diff --git a/src/whereInt.h b/src/whereInt.h index d33d995af1..ed6b198e4b 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -418,8 +418,9 @@ struct WhereInfo { u8 sorted; /* True if really sorted (not just grouped) */ u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */ u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ - u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */ + u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ u8 nLevel; /* Number of nested loop */ + u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */ int iTop; /* The very beginning of the WHERE loop */ int iContinue; /* Jump here to continue with next record */ int iBreak; /* Jump here to break out of the loop */ From d711e522292566c8ef055da3af8f095dabea6781 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2016 22:40:04 +0000 Subject: [PATCH 068/302] Appears to work now. Needs test cases, more comments, and code optimization. FossilOrigin-Name: 990fe50c9182f74c9b54a12602c4c30d891273e6 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/where.c | 29 ++++++++++++++++++++++++----- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index d01cdd7db8..39cec630ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sa\squery\swith\sboth\sORDER\sBY\sand\sLIMIT,\sif\sthe\sinner\sloop\ssatisfies\sthe\s\nORDER\sBY\sthen\stry\sto\scut\sshort\seach\sinvocation\sof\sthe\sinner\sloop\sonce\sthe\nLIMIT\shas\sbeen\ssatisfied.\s\sThis\scheck-in\sis\sa\spartial\simplementation\sonly. -D 2016-05-19T22:13:37.318 +C Appears\sto\swork\snow.\s\sNeeds\stest\scases,\smore\scomments,\sand\scode\soptimization. +D 2016-05-19T22:40:04.862 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -383,7 +383,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 863cf0d421611ccfa30541ee5ffe761c896ffa5b +F src/sqliteInt.h 09621b4b7dba808b24262c2480ea75b045001853 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -458,7 +458,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c a7454e62ca13f1ff54892339022f8cb0a8bb3728 +F src/where.c 0e54a03d11d4e99ad25528f42ff4c9a6fa7a23da F src/whereInt.h 6e18240be400bef8e4dbafea605251707c5dbf49 F src/wherecode.c e3f18fcda2d7f8218a09dc33cf495dca0efa6e3e F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e @@ -1489,10 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58b516e8c0b00a41bc0364eab267bc2ecb9efeff -R 766495aa6109f75a3c3b0e829e8d3b47 -T *branch * orderby-limit -T *sym-orderby-limit * -T -sym-trunk * +P 852d1eda6ecca1171f6ed800b06f5b4854672002 +R 664cd7ecddde2637b78c890f65cd5e15 U drh -Z 1f191cc43f073ab10b6b672b5a12f950 +Z a9319f97e8df1737542ca3813ad100bc diff --git a/manifest.uuid b/manifest.uuid index ec9b410bfa..2ec1166f5a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -852d1eda6ecca1171f6ed800b06f5b4854672002 \ No newline at end of file +990fe50c9182f74c9b54a12602c4c30d891273e6 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7adfd3779b..b15d788093 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2540,7 +2540,7 @@ struct SrcList { #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ #define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */ - /* 0x0800 not currently used */ +#define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ /* 0x1000 not currently used */ /* 0x2000 not currently used */ #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ diff --git a/src/where.c b/src/where.c index 521d2e19ec..cb008b7df4 100644 --- a/src/where.c +++ b/src/where.c @@ -3262,7 +3262,7 @@ static i8 wherePathSatisfiesOrderBy( WhereInfo *pWInfo, /* The WHERE clause */ ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */ WherePath *pPath, /* The WherePath to check */ - u16 wctrlFlags, /* Might contain WHERE_GROUPBY or WHERE_DISTINCTBY */ + u16 wctrlFlags, /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */ u16 nLoop, /* Number of entries in pPath->aLoop[] */ WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */ Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */ @@ -3273,6 +3273,7 @@ static i8 wherePathSatisfiesOrderBy( u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */ u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */ u8 isMatch; /* iColumn matches a term of the ORDER BY clause */ + u16 eqOpMask; /* Allowed equality operators */ u16 nKeyCol; /* Number of key columns in pIndex */ u16 nColumn; /* Total number of ordered columns in the index */ u16 nOrderBy; /* Number terms in the ORDER BY clause */ @@ -3323,9 +3324,16 @@ static i8 wherePathSatisfiesOrderBy( obDone = MASKBIT(nOrderBy)-1; orderDistinctMask = 0; ready = 0; + eqOpMask = WO_EQ | WO_IS | WO_ISNULL; + if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN; for(iLoop=0; isOrderDistinct && obSat0 ) ready |= pLoop->maskSelf; - pLoop = iLoopaLoop[iLoop] : pLast; + if( iLoopaLoop[iLoop]; + if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue; + }else{ + pLoop = pLast; + } if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){ if( pLoop->u.vtab.isOrdered ) obSat = obDone; break; @@ -3343,7 +3351,7 @@ static i8 wherePathSatisfiesOrderBy( if( pOBExpr->op!=TK_COLUMN ) continue; if( pOBExpr->iTable!=iCur ) continue; pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, - ~ready, WO_EQ|WO_ISNULL|WO_IS, 0); + ~ready, eqOpMask, 0); if( pTerm==0 ) continue; if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){ const char *z1, *z2; @@ -3383,10 +3391,12 @@ static i8 wherePathSatisfiesOrderBy( for(j=0; ju.btree.nEq && pLoop->nSkip==0 - && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL|WO_IS))!=0 + && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0 ){ if( i & WO_ISNULL ){ testcase( isOrderDistinct ); @@ -3913,6 +3923,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pWInfo->revMask = pFrom->revLoop; if( pWInfo->nOBSat<=0 ){ pWInfo->nOBSat = 0; + if( nLoop>0 ){ + Bitmask m; + int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, + WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m); + if( rc==pWInfo->pOrderBy->nExpr ){ + pWInfo->bOrderedInnerLoop = 1; + pWInfo->revMask = m; + } + } } } if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP) From 73fa4737ce3c357b6b4a96e83944af8f8019f53b Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 00:21:42 +0000 Subject: [PATCH 069/302] A few simple test cases for the ORDER BY LIMIT optimization. FossilOrigin-Name: 08849eab0f6ef29eaf6d2ce9c692de9b953dbd27 --- manifest | 11 ++++--- manifest.uuid | 2 +- test/limit2.test | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 test/limit2.test diff --git a/manifest b/manifest index 39cec630ce..3f35f82e00 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Appears\sto\swork\snow.\s\sNeeds\stest\scases,\smore\scomments,\sand\scode\soptimization. -D 2016-05-19T22:40:04.862 +C A\sfew\ssimple\stest\scases\sfor\sthe\sORDER\sBY\sLIMIT\soptimization. +D 2016-05-20T00:21:42.961 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -878,6 +878,7 @@ F test/like.test 81632c437a947bf1f7130b19537da6a1a844806a F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e +F test/limit2.test 55c9f4d08c89311e00afd75045ee1a2aca205cb4 F test/loadext.test 42a3b8166dfcadcb0e0c8710dc520d97c31a8b98 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -1489,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 852d1eda6ecca1171f6ed800b06f5b4854672002 -R 664cd7ecddde2637b78c890f65cd5e15 +P 990fe50c9182f74c9b54a12602c4c30d891273e6 +R b3508f6593a9fbd22c3973de159c4a41 U drh -Z a9319f97e8df1737542ca3813ad100bc +Z 1bcf9218783f46102cc72fd7dcd4a1fb diff --git a/manifest.uuid b/manifest.uuid index 2ec1166f5a..277784dcaf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -990fe50c9182f74c9b54a12602c4c30d891273e6 \ No newline at end of file +08849eab0f6ef29eaf6d2ce9c692de9b953dbd27 \ No newline at end of file diff --git a/test/limit2.test b/test/limit2.test new file mode 100644 index 0000000000..f415f3263b --- /dev/null +++ b/test/limit2.test @@ -0,0 +1,82 @@ +# 2016-05-20 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the LIMIT in combination with ORDER BY +# and in particular, the optimizations in the inner loop that cause an +# early exit of the inner loop when the LIMIT is reached and the inner +# loop is emitting rows in ORDER BY order. + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_execsql_test limit2-100 { + CREATE TABLE t1(a,b); + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000) + INSERT INTO t1(a,b) SELECT 1, (x*17)%1000 + 1000 FROM c; + INSERT INTO t1(a,b) VALUES(2,2),(3,1006),(4,4),(5,9999); + CREATE INDEX t1ab ON t1(a,b); +} +set sqlite_search_count 0 +do_execsql_test limit2-100.1 { + SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b LIMIT 5; +} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} +set fast_count $sqlite_search_count +set sqlite_search_count 0 +do_execsql_test limit2-100.2 { + SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b LIMIT 5; +} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} +do_test limit2-100.3 { + set slow_count $sqlite_search_count + expr {$fast_count < 0.02*$slow_count} +} {1} + +do_execsql_test limit2-110 { + CREATE TABLE t2(x,y); + INSERT INTO t2(x,y) VALUES('a',1),('a',2),('a',3),('a',4); + INSERT INTO t2(x,y) VALUES('b',1),('c',2),('d',3),('e',4); + CREATE INDEX t2xy ON t2(x,y); +} +set sqlite_search_count 0 +do_execsql_test limit2-110.1 { + SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY t1.b LIMIT 5; +} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} +set fast_count $sqlite_search_count +set sqlite_search_count 0 +do_execsql_test limit2-110.2 { + SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY +t1.b LIMIT 5; +} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} +set slow_count $sqlite_search_count +do_test limit2-110.3 { + expr {$fast_count < 0.02*$slow_count} +} {1} + +do_execsql_test limit2-120 { + DROP INDEX t1ab; + CREATE INDEX t1ab ON t1(a,b DESC); +} +set sqlite_search_count 0 +do_execsql_test limit2-120.1 { + SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b DESC LIMIT 5; +} {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |} +set fast_count $sqlite_search_count +set sqlite_search_count 0 +do_execsql_test limit2-120.2 { + SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b DESC LIMIT 5; +} {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |} +do_test limit2-120.3 { + set slow_count $sqlite_search_count + expr {$fast_count < 0.02*$slow_count} +} {1} + + + +finish_test From 17e0c4736839a3f9db7832ad8d997c89444a60ff Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 12:22:16 +0000 Subject: [PATCH 070/302] Autoconf configure.ac adjustment to try to get it to look for both editline and readline automatically. FossilOrigin-Name: 645bd696dfd86d8c93080f6ebfddbc9639ec088b --- autoconf/configure.ac | 5 +++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 6b37a0517a..01f8b0d03d 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -41,14 +41,15 @@ AC_ARG_ENABLE(editline, [AS_HELP_STRING( AC_ARG_ENABLE(readline, [AS_HELP_STRING( [--enable-readline], [use readline])], - [], [enable_readline=no]) + [], [enable_readline=yes]) if test x"$enable_editline" != xno ; then sLIBS=$LIBS LIBS="" AC_SEARCH_LIBS([readline],[edit],[enable_readline=no],[enable_editline=no]) READLINE_LIBS=$LIBS if test x"$LIBS" != "x"; then - AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) + AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) + enable_readline=no else unset ac_cv_search_readline fi diff --git a/manifest b/manifest index 89053f9deb..21af3597e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixup\scomments\son\swctrlFlags\svalue\sdefinitions. -D 2016-05-19T19:31:30.127 +C Autoconf\sconfigure.ac\sadjustment\sto\stry\sto\sget\sit\sto\slook\sfor\sboth\seditline\nand\sreadline\sautomatically. +D 2016-05-20T12:22:16.170 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -14,7 +14,7 @@ F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 F autoconf/Makefile.msc 0eca137c12542bd76c253a2d24380f29ade59b95 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 -F autoconf/configure.ac ad7001cdde3d6ae6053bc0b66009869d7c5012a8 +F autoconf/configure.ac 7754404e955900cfdeba08862cdfa802eca5b0af F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1489,7 +1489,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d01305841da94b2d47e32744802f69525bf590df -R be830660ecf90ba00189952af638cb97 +P 58b516e8c0b00a41bc0364eab267bc2ecb9efeff +R 1ccdb41fa76e9f52d7032b7d9c7cb950 U drh -Z 54bddff0ee366139e2fb13081e6cf75a +Z 54717b5e62279adb2d1cf6e8a28ff9fe diff --git a/manifest.uuid b/manifest.uuid index 177ef2d35a..d3cfa1aab3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58b516e8c0b00a41bc0364eab267bc2ecb9efeff \ No newline at end of file +645bd696dfd86d8c93080f6ebfddbc9639ec088b \ No newline at end of file From 6326d9f6f14620a10b4254febcd5ae53f181e8f5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 13:44:58 +0000 Subject: [PATCH 071/302] Set the NULLEQ flag on the sequence counter comparison in the ORDER BY LIMIT optimization, to avoid coverage complaints about not testing the NULL case. FossilOrigin-Name: ed1b30dc932a7c03e173b130c5f55f9989c7e0b4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 3f35f82e00..7eaabf0f13 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\sfew\ssimple\stest\scases\sfor\sthe\sORDER\sBY\sLIMIT\soptimization. -D 2016-05-20T00:21:42.961 +C Set\sthe\sNULLEQ\sflag\son\sthe\ssequence\scounter\scomparison\sin\sthe\sORDER\sBY\sLIMIT\noptimization,\sto\savoid\scoverage\scomplaints\sabout\snot\stesting\sthe\sNULL\scase. +D 2016-05-20T13:44:58.389 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -378,7 +378,7 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 49eb91c588a2bab36647368e031dc5b66928149d -F src/select.c 131eeddfcaf3777c4acd4727bf742b98af8183b5 +F src/select.c a0c4abf54bc6bd3a9c77a36ef3d1676045706cb2 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 990fe50c9182f74c9b54a12602c4c30d891273e6 -R b3508f6593a9fbd22c3973de159c4a41 +P 08849eab0f6ef29eaf6d2ce9c692de9b953dbd27 +R 8c75a4632edf1c4d959356bd614336cd U drh -Z 1bcf9218783f46102cc72fd7dcd4a1fb +Z 54e2cd90f1a7f48806580b84bc51f48b diff --git a/manifest.uuid b/manifest.uuid index 277784dcaf..65694bee6c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -08849eab0f6ef29eaf6d2ce9c692de9b953dbd27 \ No newline at end of file +ed1b30dc932a7c03e173b130c5f55f9989c7e0b4 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 080ccf3480..495d47e20b 100644 --- a/src/select.c +++ b/src/select.c @@ -611,6 +611,7 @@ static void pushOntoSorter( ** LIMIT+OFFSET entries of the sorter. */ int iBrk = sqlite3VdbeCurrentAddr(v) + 2; sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1); + sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); VdbeCoverage(v); } sqlite3VdbeJumpHere(v, addr); From b982bfea377ca0dd015022d942d768b7603b5e27 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 14:54:54 +0000 Subject: [PATCH 072/302] Optimizations to link list merge sort code in vdbesort.c, pcache.c, and rowset.c. Resulting binaries are 10 bytes smaller and use 0.03% fewer CPU cycles. FossilOrigin-Name: 9033afbb31b28a8ad6856ac1f773d8e83bc9ec1c --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/pcache.c | 21 ++++++++++++--------- src/rowset.c | 37 ++++++++++++++++++------------------- src/vdbesort.c | 25 ++++++++++++++++--------- 5 files changed, 55 insertions(+), 47 deletions(-) diff --git a/manifest b/manifest index 018cac9cb3..d2da250b48 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\squeries\swith\sboth\sORDER\sBY\sand\sLIMIT,\sif\sthe\srows\sof\sthe\sinner\sloop\sare\nemitted\sin\sORDER\sBY\sorder\sand\sthe\sLIMIT\shas\sbeen\sreached,\sthen\soptimize\sby\nexiting\sthe\sinner\sloop\sand\scontinuing\swith\sthe\snext\scycle\sof\sthe\sfirst\souter\nloop. -D 2016-05-20T14:11:37.786 +C Optimizations\sto\slink\slist\smerge\ssort\scode\sin\svdbesort.c,\spcache.c,\sand\nrowset.c.\s\sResulting\sbinaries\sare\s10\sbytes\ssmaller\sand\suse\s0.03%\sfewer\sCPU\ncycles. +D 2016-05-20T14:54:54.663 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -368,7 +368,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 3910579bfbe323dfabed2b95d201159b61b8ef42 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c f398c0084399e7481482cbc6a578a3cc4c3675f3 +F src/pcache.c 50fb5728dbfb92461f89f8763ff8b60d0dbeba2c F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 @@ -377,7 +377,7 @@ F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 -F src/rowset.c 49eb91c588a2bab36647368e031dc5b66928149d +F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c a0c4abf54bc6bd3a9c77a36ef3d1676045706cb2 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 @@ -451,7 +451,7 @@ F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c F src/vdbeaux.c ace1875da40b7185e604586768d5ac90de7e4f7f F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb -F src/vdbesort.c 0a8f98366ae794442e6d1ef71d9553226d885d19 +F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 F src/vtab.c 23b6cdfa996152d43b390504ed4a942c8caf3a00 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 @@ -1490,8 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 645bd696dfd86d8c93080f6ebfddbc9639ec088b ed1b30dc932a7c03e173b130c5f55f9989c7e0b4 -R b166646a4114a46c17faadb7ecf63948 -T +closed ed1b30dc932a7c03e173b130c5f55f9989c7e0b4 +P 559733b09e9630fac9d9318a7ecbaba9134e9160 +R db641f928488147ea4b353a0a8e4e73d U drh -Z aa696592564772ea00c367935ddfa343 +Z 8f08ede060795a413d5c246d730b7a0d diff --git a/manifest.uuid b/manifest.uuid index 048e943fec..9b60eaacba 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -559733b09e9630fac9d9318a7ecbaba9134e9160 \ No newline at end of file +9033afbb31b28a8ad6856ac1f773d8e83bc9ec1c \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index d628320334..ad9fa4f46b 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -692,24 +692,26 @@ void sqlite3PcacheClear(PCache *pCache){ static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){ PgHdr result, *pTail; pTail = &result; - while( pA && pB ){ + assert( pA!=0 && pB!=0 ); + for(;;){ if( pA->pgnopgno ){ pTail->pDirty = pA; pTail = pA; pA = pA->pDirty; + if( pA==0 ){ + pTail->pDirty = pB; + break; + } }else{ pTail->pDirty = pB; pTail = pB; pB = pB->pDirty; + if( pB==0 ){ + pTail->pDirty = pA; + break; + } } } - if( pA ){ - pTail->pDirty = pA; - }else if( pB ){ - pTail->pDirty = pB; - }else{ - pTail->pDirty = 0; - } return result.pDirty; } @@ -750,7 +752,8 @@ static PgHdr *pcacheSortDirtyList(PgHdr *pIn){ } p = a[0]; for(i=1; ipRight==0 || pA->v<=pA->pRight->v ); assert( pB->pRight==0 || pB->v<=pB->pRight->v ); - if( pA->vv ){ - pTail->pRight = pA; + if( pA->v<=pB->v ){ + if( pA->vv ) pTail = pTail->pRight = pA; pA = pA->pRight; - pTail = pTail->pRight; - }else if( pB->vv ){ - pTail->pRight = pB; - pB = pB->pRight; - pTail = pTail->pRight; + if( pA==0 ){ + pTail->pRight = pB; + break; + } }else{ - pA = pA->pRight; + pTail = pTail->pRight = pB; + pB = pB->pRight; + if( pB==0 ){ + pTail->pRight = pA; + break; + } } } - if( pA ){ - assert( pA->pRight==0 || pA->v<=pA->pRight->v ); - pTail->pRight = pA; - }else{ - assert( pB==0 || pB->pRight==0 || pB->v<=pB->pRight->v ); - pTail->pRight = pB; - } return head.pRight; } @@ -286,9 +284,10 @@ static struct RowSetEntry *rowSetEntrySort(struct RowSetEntry *pIn){ aBucket[i] = pIn; pIn = pNext; } - pIn = 0; - for(i=0; ixCompare( pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal @@ -1364,15 +1363,22 @@ static void vdbeSorterMerge( *pp = p1; pp = &p1->u.pNext; p1 = p1->u.pNext; + if( p1==0 ){ + *pp = p2; + break; + } }else{ *pp = p2; pp = &p2->u.pNext; p2 = p2->u.pNext; bCached = 0; + if( p2==0 ){ + *pp = p1; + break; + } } } - *pp = p1 ? p1 : p2; - *ppOut = pFinal; + return pFinal; } /* @@ -1425,7 +1431,7 @@ static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){ p->u.pNext = 0; for(i=0; aSlot[i]; i++){ - vdbeSorterMerge(pTask, p, aSlot[i], &p); + p = vdbeSorterMerge(pTask, p, aSlot[i]); aSlot[i] = 0; } aSlot[i] = p; @@ -1434,7 +1440,8 @@ static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){ p = 0; for(i=0; i<64; i++){ - vdbeSorterMerge(pTask, p, aSlot[i], &p); + if( aSlot[i]==0 ) continue; + p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i]; } pList->pList = p; From 01c736db40121708554723c753e8cb46db569908 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 15:15:07 +0000 Subject: [PATCH 073/302] Use sqlite3VdbeAddOp0() to code OP_Expire, to save a few bytes. FossilOrigin-Name: 3d55d24dcb27f07d1e645738ee4707e4df923036 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 2 +- src/pragma.c | 2 +- src/vtab.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index d2da250b48..b57bbea74a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Optimizations\sto\slink\slist\smerge\ssort\scode\sin\svdbesort.c,\spcache.c,\sand\nrowset.c.\s\sResulting\sbinaries\sare\s10\sbytes\ssmaller\sand\suse\s0.03%\sfewer\sCPU\ncycles. -D 2016-05-20T14:54:54.663 +C Use\ssqlite3VdbeAddOp0()\sto\scode\sOP_Expire,\sto\ssave\sa\sfew\sbytes. +D 2016-05-20T15:15:07.708 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -325,7 +325,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c e53a01547d61a3d567daf7a7acc30122fe071aef F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c d65be62254ca9df36e1e1c433324f0333f80009c +F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -371,7 +371,7 @@ F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c 50fb5728dbfb92461f89f8763ff8b60d0dbeba2c F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d -F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84 +F src/pragma.c 9fdce031ddcb57f0f56e4a8b421b7e7a77de73b0 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 @@ -453,7 +453,7 @@ F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 -F src/vtab.c 23b6cdfa996152d43b390504ed4a942c8caf3a00 +F src/vtab.c ce0f2ebb589b459b32c640b33af64bfa5b29aaf8 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 559733b09e9630fac9d9318a7ecbaba9134e9160 -R db641f928488147ea4b353a0a8e4e73d +P 9033afbb31b28a8ad6856ac1f773d8e83bc9ec1c +R 1cd6e2cbb63bca846e6fd848dfba7f80 U drh -Z 8f08ede060795a413d5c246d730b7a0d +Z cefb033da9b34db496e79185da92ee9c diff --git a/manifest.uuid b/manifest.uuid index 9b60eaacba..8722763d5a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9033afbb31b28a8ad6856ac1f773d8e83bc9ec1c \ No newline at end of file +3d55d24dcb27f07d1e645738ee4707e4df923036 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 2fa4e3102f..565101356a 100644 --- a/src/build.c +++ b/src/build.c @@ -3365,7 +3365,7 @@ Index *sqlite3CreateIndex( sqlite3ChangeCookie(pParse, iDb); sqlite3VdbeAddParseSchemaOp(v, iDb, sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName)); - sqlite3VdbeAddOp1(v, OP_Expire, 0); + sqlite3VdbeAddOp0(v, OP_Expire); } sqlite3VdbeJumpHere(v, pIndex->tnum); diff --git a/src/pragma.c b/src/pragma.c index e0a0255ec0..330e999090 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1030,7 +1030,7 @@ void sqlite3Pragma( ** compiler (eg. count_changes). So add an opcode to expire all ** compiled SQL statements after modifying a pragma value. */ - sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); + sqlite3VdbeAddOp0(v, OP_Expire); setAllPagerFlags(db); } break; diff --git a/src/vtab.c b/src/vtab.c index 802a8cac3a..2fe105a296 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -418,7 +418,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ v = sqlite3GetVdbe(pParse); sqlite3ChangeCookie(pParse, iDb); - sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); + sqlite3VdbeAddOp0(v, OP_Expire); zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); From c0a195b88578326a7e20b981b9f368357fce55c0 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 15:24:14 +0000 Subject: [PATCH 074/302] Increase the version number to 3.14.0 since we are already making significant code changes. FossilOrigin-Name: 1a0d05765fa2e69ccd4c98782cf9f5c5b2897719 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 4eba2a62eb..f982feb41b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.13.0 +3.14.0 diff --git a/configure b/configure index 3b746fedbb..22a646c2b6 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.13.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.14.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.13.0' -PACKAGE_STRING='sqlite 3.13.0' +PACKAGE_VERSION='3.14.0' +PACKAGE_STRING='sqlite 3.14.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1461,7 +1461,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.13.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.14.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1526,7 +1526,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.13.0:";; + short | recursive ) echo "Configuration of sqlite 3.14.0:";; esac cat <<\_ACEOF @@ -1648,7 +1648,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.13.0 +sqlite configure 3.14.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2067,7 +2067,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.13.0, which was +It was created by sqlite $as_me 3.14.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12095,7 +12095,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.13.0, which was +This file was extended by sqlite $as_me 3.14.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12161,7 +12161,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.13.0 +sqlite config.status 3.14.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index b57bbea74a..6ef842be89 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Use\ssqlite3VdbeAddOp0()\sto\scode\sOP_Expire,\sto\ssave\sa\sfew\sbytes. -D 2016-05-20T15:15:07.708 +C Increase\sthe\sversion\snumber\sto\s3.14.0\ssince\swe\sare\salready\smaking\ssignificant\ncode\schanges. +D 2016-05-20T15:24:14.463 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 -F VERSION 5d234da9b5dae329fab75ff75884cfe0a9cb3fda +F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -30,7 +30,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure df9f793ad47eaeb3648a9090fbc0b96955e88b5a x +F configure 96fdf3870e30c6f60c6a56d27f5f6e4159b9bdc6 x F configure.ac 02b972db825685b4b0cca0234b2aa97f71bd15a5 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9033afbb31b28a8ad6856ac1f773d8e83bc9ec1c -R 1cd6e2cbb63bca846e6fd848dfba7f80 +P 3d55d24dcb27f07d1e645738ee4707e4df923036 +R 89664580415a847eedcfc718be56bf0d U drh -Z cefb033da9b34db496e79185da92ee9c +Z 8bf855953d20db149698d180b3489eaf diff --git a/manifest.uuid b/manifest.uuid index 8722763d5a..1aa0fd4a5f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d55d24dcb27f07d1e645738ee4707e4df923036 \ No newline at end of file +1a0d05765fa2e69ccd4c98782cf9f5c5b2897719 \ No newline at end of file From f431a87c7cb50114aad67b893811ce122dabc88e Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 15:53:47 +0000 Subject: [PATCH 075/302] Performance optimization and size reduction on the freeP4() routine. FossilOrigin-Name: 4dc56e8684e0c74fb311c7f0ef1c367da8c7bf70 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 6ef842be89..72e47730ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sthe\sversion\snumber\sto\s3.14.0\ssince\swe\sare\salready\smaking\ssignificant\ncode\schanges. -D 2016-05-20T15:24:14.463 +C Performance\soptimization\sand\ssize\sreduction\son\sthe\sfreeP4()\sroutine. +D 2016-05-20T15:53:47.755 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -448,7 +448,7 @@ F src/vdbe.c d71b935d2b21bef874680c34329adedc3b021101 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c -F src/vdbeaux.c ace1875da40b7185e604586768d5ac90de7e4f7f +F src/vdbeaux.c 1d6b9a979d1036db7bc39990e9e683f19520bc5c F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3d55d24dcb27f07d1e645738ee4707e4df923036 -R 89664580415a847eedcfc718be56bf0d +P 1a0d05765fa2e69ccd4c98782cf9f5c5b2897719 +R 734aa09fb2d1f30b69a973bc3d2e2b77 U drh -Z 8bf855953d20db149698d180b3489eaf +Z d36b58bb8581f51b9b8f33e10b0489c2 diff --git a/manifest.uuid b/manifest.uuid index 1aa0fd4a5f..da9f09cbad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a0d05765fa2e69ccd4c98782cf9f5c5b2897719 \ No newline at end of file +4dc56e8684e0c74fb311c7f0ef1c367da8c7bf70 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 0f9dab8e19..bce676f10c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -791,7 +791,7 @@ void sqlite3VdbeJumpHere(Vdbe *p, int addr){ ** the FuncDef is not ephermal, then do nothing. */ static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ - if( ALWAYS(pDef) && (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){ + if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){ sqlite3DbFree(db, pDef); } } @@ -801,12 +801,20 @@ static void vdbeFreeOpArray(sqlite3 *, Op *, int); /* ** Delete a P4 value if necessary. */ +static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){ + if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); + sqlite3DbFree(db, p); +} +static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){ + freeEphemeralFunction(db, p->pFunc); + sqlite3DbFree(db, p); +} static void freeP4(sqlite3 *db, int p4type, void *p4){ assert( db ); switch( p4type ){ case P4_FUNCCTX: { - freeEphemeralFunction(db, ((sqlite3_context*)p4)->pFunc); - /* Fall through into the next case */ + freeP4FuncCtx(db, (sqlite3_context*)p4); + break; } case P4_REAL: case P4_INT64: @@ -837,9 +845,7 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){ if( db->pnBytesFreed==0 ){ sqlite3ValueFree((sqlite3_value*)p4); }else{ - Mem *p = (Mem*)p4; - if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); - sqlite3DbFree(db, p); + freeP4Mem(db, (Mem*)p4); } break; } From d20b2a41094ff53858415ad788a09ebfedad01ff Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 18:09:01 +0000 Subject: [PATCH 076/302] Remove the sqlite3PagerClearCache() routine, which does not accomplish anything useful. FossilOrigin-Name: f250166bb3c1b0c58e703b334825cf6210758fda --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/backup.c | 2 -- src/pager.c | 10 ---------- src/pager.h | 1 - 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 72e47730ac..264470f9ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\sand\ssize\sreduction\son\sthe\sfreeP4()\sroutine. -D 2016-05-20T15:53:47.755 +C Remove\sthe\ssqlite3PagerClearCache()\sroutine,\swhich\sdoes\snot\saccomplish\sanything\nuseful. +D 2016-05-20T18:09:01.269 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -319,7 +319,7 @@ F src/alter.c 1bb0709b3048e24217b80ec6bd78a3e99a47c01b F src/analyze.c 37fedc80ac966ce1745811746e68e4d8fa64c7fe F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 -F src/backup.c f60f0aa55d25d853ffde53d0b0370a7bb7ee41ce +F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c e53a01547d61a3d567daf7a7acc30122fe071aef @@ -365,8 +365,8 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 3910579bfbe323dfabed2b95d201159b61b8ef42 -F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681 +F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 +F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c 50fb5728dbfb92461f89f8763ff8b60d0dbeba2c F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a0d05765fa2e69ccd4c98782cf9f5c5b2897719 -R 734aa09fb2d1f30b69a973bc3d2e2b77 +P 4dc56e8684e0c74fb311c7f0ef1c367da8c7bf70 +R f1ca77b965b4fac61acdc31594820a52 U drh -Z d36b58bb8581f51b9b8f33e10b0489c2 +Z c5c16d4ca102bc8075809f03a41e82f3 diff --git a/manifest.uuid b/manifest.uuid index da9f09cbad..e1934ce2a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4dc56e8684e0c74fb311c7f0ef1c367da8c7bf70 \ No newline at end of file +f250166bb3c1b0c58e703b334825cf6210758fda \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 455671a1ad..3df56e5384 100644 --- a/src/backup.c +++ b/src/backup.c @@ -784,8 +784,6 @@ int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ rc = sqlite3_backup_finish(&b); if( rc==SQLITE_OK ){ pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED; - }else{ - sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); } assert( sqlite3BtreeIsInTrans(pTo)==0 ); diff --git a/src/pager.c b/src/pager.c index b24267e58a..1ae831d148 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7157,16 +7157,6 @@ sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){ return &pPager->pBackup; } -#ifndef SQLITE_OMIT_VACUUM -/* -** Unless this is an in-memory or temporary database, clear the pager cache. -*/ -void sqlite3PagerClearCache(Pager *pPager){ - assert( MEMDB==0 || pPager->tempFile ); - if( pPager->tempFile==0 ) pager_reset(pPager); -} -#endif - #ifndef SQLITE_OMIT_WAL /* ** This function is called when the user invokes "PRAGMA wal_checkpoint", diff --git a/src/pager.h b/src/pager.h index 077fcd8b7f..69d3bb4435 100644 --- a/src/pager.h +++ b/src/pager.h @@ -203,7 +203,6 @@ const char *sqlite3PagerJournalname(Pager*); void *sqlite3PagerTempSpace(Pager*); int sqlite3PagerIsMemdb(Pager*); void sqlite3PagerCacheStat(Pager *, int, int, int *); -void sqlite3PagerClearCache(Pager *); int sqlite3SectorSize(sqlite3_file *); /* Functions used to truncate the database file. */ From a1851efc5d4807178198ca9bbc344ae2a33ef495 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 19:51:28 +0000 Subject: [PATCH 077/302] Slight performance improvement in the OP_Column opcode. FossilOrigin-Name: 5c157474391f90f24e8867c77fbc6564c7955ecc --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 264470f9ab..9f9a5c97ad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\ssqlite3PagerClearCache()\sroutine,\swhich\sdoes\snot\saccomplish\sanything\nuseful. -D 2016-05-20T18:09:01.269 +C Slight\sperformance\simprovement\sin\sthe\sOP_Column\sopcode. +D 2016-05-20T19:51:28.931 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -444,7 +444,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c d71b935d2b21bef874680c34329adedc3b021101 +F src/vdbe.c 9d0872c73555b335d7e658bb9b6fd69798ba551c F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4dc56e8684e0c74fb311c7f0ef1c367da8c7bf70 -R f1ca77b965b4fac61acdc31594820a52 +P f250166bb3c1b0c58e703b334825cf6210758fda +R 67f498d524675be2828322b33e8cc61d U drh -Z c5c16d4ca102bc8075809f03a41e82f3 +Z 6bf519f6e91709086e486df141738a73 diff --git a/manifest.uuid b/manifest.uuid index e1934ce2a2..5befa41016 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f250166bb3c1b0c58e703b334825cf6210758fda \ No newline at end of file +5c157474391f90f24e8867c77fbc6564c7955ecc \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 6d96f85548..9f36a3feb2 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2575,9 +2575,10 @@ case OP_Column: { assert( p2nHdrParsed ); assert( rc==SQLITE_OK ); assert( sqlite3VdbeCheckMemInvariants(pDest) ); - if( VdbeMemDynamic(pDest) ) sqlite3VdbeMemSetNull(pDest); + if( VdbeMemDynamic(pDest) ){ + sqlite3VdbeMemSetNull(pDest); + } assert( t==pC->aType[p2] ); - pDest->enc = encoding; if( pC->szRow>=aOffset[p2+1] ){ /* This is the common case where the desired content fits on the original ** page - where the content is not on an overflow page */ @@ -2591,6 +2592,7 @@ case OP_Column: { */ static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; pDest->n = len = (t-12)/2; + pDest->enc = encoding; if( pDest->szMalloc < len+2 ){ pDest->flags = MEM_Null; if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; @@ -2603,6 +2605,7 @@ case OP_Column: { pDest->flags = aFlag[t&1]; } }else{ + pDest->enc = encoding; /* This branch happens only when content is on overflow pages */ if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0 && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)) From 2380f3f1d04e9dd1abf2c20517aba61b174e98bd Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 20 May 2016 20:58:30 +0000 Subject: [PATCH 078/302] Fix typo in comment. FossilOrigin-Name: 9db8f2147339ba519c4ec32e34068e9f4a25e099 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pcache.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9f9a5c97ad..59b91454b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slight\sperformance\simprovement\sin\sthe\sOP_Column\sopcode. -D 2016-05-20T19:51:28.931 +C Fix\stypo\sin\scomment. +D 2016-05-20T20:58:30.520 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -368,7 +368,7 @@ F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e -F src/pcache.c 50fb5728dbfb92461f89f8763ff8b60d0dbeba2c +F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d F src/pragma.c 9fdce031ddcb57f0f56e4a8b421b7e7a77de73b0 @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f250166bb3c1b0c58e703b334825cf6210758fda -R 67f498d524675be2828322b33e8cc61d -U drh -Z 6bf519f6e91709086e486df141738a73 +P 5c157474391f90f24e8867c77fbc6564c7955ecc +R 24d15d6cfb006c0761a9dcc11f99e304 +U mistachkin +Z 03dddc8d9c707d4b35ca07d5a2fcd8f4 diff --git a/manifest.uuid b/manifest.uuid index 5befa41016..7ce09e7144 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c157474391f90f24e8867c77fbc6564c7955ecc \ No newline at end of file +9db8f2147339ba519c4ec32e34068e9f4a25e099 \ No newline at end of file diff --git a/src/pcache.c b/src/pcache.c index ad9fa4f46b..ccbcc96cd0 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -687,7 +687,7 @@ void sqlite3PcacheClear(PCache *pCache){ /* ** Merge two lists of pages connected by pDirty and in pgno order. -** Do not both fixing the pDirtyPrev pointers. +** Do not bother fixing the pDirtyPrev pointers. */ static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){ PgHdr result, *pTail; From 170c27662386424490d8a73130b8c71c86a10a32 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 21:40:11 +0000 Subject: [PATCH 079/302] Another optimization on the OP_Column opcode. FossilOrigin-Name: 1765672c2599eb03d39c52cd2dc32ea1e5ee069e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbe.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 59b91454b0..1cd3edacb4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment. -D 2016-05-20T20:58:30.520 +C Another\soptimization\son\sthe\sOP_Column\sopcode. +D 2016-05-20T21:40:11.890 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -444,7 +444,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 9d0872c73555b335d7e658bb9b6fd69798ba551c +F src/vdbe.c 975ac1d3d326bcb36b4e99255daeaf81ff6659d1 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1490,7 +1490,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c157474391f90f24e8867c77fbc6564c7955ecc -R 24d15d6cfb006c0761a9dcc11f99e304 -U mistachkin -Z 03dddc8d9c707d4b35ca07d5a2fcd8f4 +P 9db8f2147339ba519c4ec32e34068e9f4a25e099 +R b59019073443c960ff19359461f0425d +U drh +Z be39c49e0fa0986f111ad70cd504ec49 diff --git a/manifest.uuid b/manifest.uuid index 7ce09e7144..f85b5caaae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9db8f2147339ba519c4ec32e34068e9f4a25e099 \ No newline at end of file +1765672c2599eb03d39c52cd2dc32ea1e5ee069e \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 9f36a3feb2..36c014a7d0 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2531,9 +2531,7 @@ case OP_Column: { pC->aType[i++] = t; aOffset[i] = (u32)(offset64 & 0xffffffff); }while( i<=p2 && zHdrnHdrParsed = i; - pC->iHdrOffset = (u32)(zHdr - zData); - + /* The record is corrupt if any of the following are true: ** (1) the bytes of the header extend past the declared header size ** (2) the entire header was used but not all data was used @@ -2546,8 +2544,10 @@ case OP_Column: { rc = SQLITE_CORRUPT_BKPT; goto abort_due_to_error; } - if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); + pC->nHdrParsed = i; + pC->iHdrOffset = (u32)(zHdr - zData); + if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); }else{ t = 0; } From 860a95fd017588038a35e105b185f1f6654b79d5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 20 May 2016 23:51:14 +0000 Subject: [PATCH 080/302] Add a simple TCL script for summing cachegrind information for each VDBE opcdoe. FossilOrigin-Name: 96cf821b6a69e2e8df33271b7bb674bd12a1ef7b --- manifest | 11 ++++++----- manifest.uuid | 2 +- tool/opcodesum.tcl | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 tool/opcodesum.tcl diff --git a/manifest b/manifest index 1cd3edacb4..d563744dae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\soptimization\son\sthe\sOP_Column\sopcode. -D 2016-05-20T21:40:11.890 +C Add\sa\ssimple\sTCL\sscript\sfor\ssumming\scachegrind\sinformation\sfor\seach\sVDBE\nopcdoe. +D 2016-05-20T23:51:14.900 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1439,6 +1439,7 @@ F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97 +F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/replace.tcl 7727c60a04299b65a92f5e1590896fea0f25b9e0 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a @@ -1490,7 +1491,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9db8f2147339ba519c4ec32e34068e9f4a25e099 -R b59019073443c960ff19359461f0425d +P 1765672c2599eb03d39c52cd2dc32ea1e5ee069e +R 247c58a1e4c62949bc3249c61dcdd977 U drh -Z be39c49e0fa0986f111ad70cd504ec49 +Z 3e7f8cdf9cdb094239005245e5b11ebd diff --git a/manifest.uuid b/manifest.uuid index f85b5caaae..1f418b0d95 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1765672c2599eb03d39c52cd2dc32ea1e5ee069e \ No newline at end of file +96cf821b6a69e2e8df33271b7bb674bd12a1ef7b \ No newline at end of file diff --git a/tool/opcodesum.tcl b/tool/opcodesum.tcl new file mode 100644 index 0000000000..47dff32b90 --- /dev/null +++ b/tool/opcodesum.tcl @@ -0,0 +1,34 @@ +#!/usr/bin/tclsh +# +# Run this script, redirecting input from cachegrind output, to compute the +# number of CPU cycles used by each VDBE opcode. +# +# The cachegrind output should be configured so that it reports a single +# column of Ir at the left margin. Ex: +# +# cg_annotation --show=Ir --auto=yes cachegrind.out.* | tclsh opcodesum.tcl +# +set currentop x +set ncycle(x) 0 +while {![eof stdin]} { + set line [string map {\173 x \175 x \042 x} [gets stdin]] + if {[regexp { \. case OP_.*:} $line]} { + regexp {OP_(.+):} $line all currentop + set ncycle($currentop) 0 + } elseif {[lindex $line 1]=="default:" + && [regexp {really OP_Noop and OP_Explain} $line]} { + break + } elseif {[lindex $line 0]!="."} { + regsub -all {[^0-9]} [lindex $line 0] {} n + if {$n!=""} {incr ncycle($currentop) $n} + } +} +unset ncycle(x) +set results {} +foreach op [lsort [array names ncycle]] { + if {$ncycle($op)==0} continue + lappend results [list $ncycle($op) $op] +} +foreach entry [lsort -index 0 -int -decr $results] { + puts [format {%-16s %10d} [lindex $entry 1] [lindex $entry 0]] +} From ed90a4676e533d0887cb4d729304264ad15b2e24 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 May 2016 00:45:54 +0000 Subject: [PATCH 081/302] Add the shell-script used for routine performance testing. FossilOrigin-Name: 8e366f18f5bbd594390e7b091083e99639de324e --- manifest | 11 ++--- manifest.uuid | 2 +- tool/speed-check.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 tool/speed-check.sh diff --git a/manifest b/manifest index d563744dae..03a75c80e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\ssimple\sTCL\sscript\sfor\ssumming\scachegrind\sinformation\sfor\seach\sVDBE\nopcdoe. -D 2016-05-20T23:51:14.900 +C Add\sthe\sshell-script\sused\sfor\sroutine\sperformance\stesting. +D 2016-05-21T00:45:54.756 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1452,6 +1452,7 @@ F tool/showstat4.c bda40d6e395df7edb6e9ea630784d3d762c35b4b F tool/showwal.c ec79959834f7b21f1e0a2aa52bb7c056d2203977 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/spaceanal.tcl 85d90e6674d8298e3eaf82dbcef3abc2d5317f3e +F tool/speed-check.sh 45d3bf861b009993ff401f0d00e34a4cc937fce4 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1491,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1765672c2599eb03d39c52cd2dc32ea1e5ee069e -R 247c58a1e4c62949bc3249c61dcdd977 +P 96cf821b6a69e2e8df33271b7bb674bd12a1ef7b +R ca27df5abd7cea75d52374965a3f09f5 U drh -Z 3e7f8cdf9cdb094239005245e5b11ebd +Z 7380639ab417b2bbe053c05d7bd1cc2b diff --git a/manifest.uuid b/manifest.uuid index 1f418b0d95..4fc75f4fe0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96cf821b6a69e2e8df33271b7bb674bd12a1ef7b \ No newline at end of file +8e366f18f5bbd594390e7b091083e99639de324e \ No newline at end of file diff --git a/tool/speed-check.sh b/tool/speed-check.sh new file mode 100644 index 0000000000..d10f172d59 --- /dev/null +++ b/tool/speed-check.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# +# This is a template for a script used for day-to-day size and +# performance monitoring of SQLite. Typical usage: +# +# sh run-speed-test.sh trunk # Baseline measurement of trunk +# sh run-speed-test.sh x1 # Measure some experimental change +# fossil test-diff --tk cout-trunk.txt cout-x1.txt # View chanages +# +# There are multiple output files, all with a base name given by +# the first argument: +# +# summary-$BASE.txt # Copy of standard output +# cout-$BASE.txt # cachegrind output +# explain-$BASE.txt # EXPLAIN listings (only with --explain) +# +if test "$1" = "" +then + echo "Usage: $0 OUTPUTFILE [OPTIONS]" + exit +fi +NAME=$1 +shift +CC_OPTS="-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_MEMSYS5" +SPEEDTEST_OPTS="--shrink-memory --reprepare --heap 10000000 64" +SIZE=5 +doExplain=0 +doCachegrind=1 +while test "$1" != ""; do + case $1 in + --reprepare) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" + ;; + --autovacuum) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" + ;; + --utf16be) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" + ;; + --stats) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" + ;; + --without-rowid) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" + ;; + --nomemstat) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS $1" + ;; + --temp) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS --temp 6" + ;; + --wal) + SPEEDTEST_OPTS="$SPEEDTEST_OPTS --journal wal" + ;; + --size) + shift; SIZE=$1 + ;; + --explain) + doExplain=1 + ;; + --vdbeprofile) + rm -f vdbe_profile.out + CC_OPTS="$CC_OPTS -DVDBE_PROFILE" + doCachegrind=0 + ;; + --heap) + CC_OPTS="$CC_OPTS -DSQLITE_ENABLE_MEMSYS5" + shift; + SPEEDTEST_OPTS="$SPEEDTEST_OPTS --heap $1 64" + ;; + *) + CC_OPTS="$CC_OPTS $1" + ;; + esac + shift +done +SPEEDTEST_OPTS="$SPEEDTEST_OPTS --size $SIZE" +echo "NAME = $NAME" | tee summary-$NAME.txt +echo "SPEEDTEST_OPTS = $SPEEDTEST_OPTS" | tee -a summary-$NAME.txt +echo "CC_OPTS = $CC_OPTS" | tee -a summary-$NAME.txt +rm -f cachegrind.out.* speedtest1 speedtest1.db sqlite3.o +gcc -g -Os -Wall -I. $CC_OPTS -c sqlite3.c +size sqlite3.o | tee -a summary-$NAME.txt +if test $doExplain -eq 1; then + gcc -g -Os -Wall -I. $CC_OPTS \ + -DSQLITE_ENABLE_EXPLAIN_COMMENTS \ + ./shell.c ./sqlite3.c -o sqlite3 -ldl -lpthread +fi +SRC=./speedtest1.c +gcc -g -Os -Wall -I. $CC_OPTS $SRC ./sqlite3.o -o speedtest1 -ldl -lpthread +ls -l speedtest1 | tee -a summary-$NAME.txt +if test $doCachegrind -eq 1; then + valgrind --tool=cachegrind ./speedtest1 speedtest1.db \ + $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt +else + ./speedtest1 speedtest1.db $SPEEDTEST_OPTS 2>&1 | tee -a summary-$NAME.txt +fi +size sqlite3.o | tee -a summary-$NAME.txt +wc sqlite3.c +if test $doCachegrind -eq 1; then + cg_anno.tcl cachegrind.out.* >cout-$NAME.txt +fi +if test $doExplain -eq 1; then + ./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt +fi From cb89f4aba8e226adca32c5dad02a21220b80f177 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 May 2016 11:23:26 +0000 Subject: [PATCH 082/302] Small size reduction and performance increase in the sqlite3BtreeInsert() logic. FossilOrigin-Name: 656aa1ecf5129ae43c56a990e95038b5d8cbdcee --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 15 ++++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 03a75c80e4..836b8184c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sshell-script\sused\sfor\sroutine\sperformance\stesting. -D 2016-05-21T00:45:54.756 +C Small\ssize\sreduction\sand\sperformance\sincrease\sin\sthe\ssqlite3BtreeInsert()\nlogic. +D 2016-05-21T11:23:26.914 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -322,7 +322,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c e53a01547d61a3d567daf7a7acc30122fe071aef +F src/btree.c ab4ab00fa42b9f31a3c4f4232ab7dffe15a37728 F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 96cf821b6a69e2e8df33271b7bb674bd12a1ef7b -R ca27df5abd7cea75d52374965a3f09f5 +P 8e366f18f5bbd594390e7b091083e99639de324e +R 59f3ac52df516414b0292061ce466d2b U drh -Z 7380639ab417b2bbe053c05d7bd1cc2b +Z 1ed41a6ca1c9810f6f5090ac3b0958c0 diff --git a/manifest.uuid b/manifest.uuid index 4fc75f4fe0..6b45ee4bc0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e366f18f5bbd594390e7b091083e99639de324e \ No newline at end of file +656aa1ecf5129ae43c56a990e95038b5d8cbdcee \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7e6b050f83..033d9c24c3 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6310,6 +6310,8 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){ ** in pTemp or the original pCell) and also record its index. ** Allocating a new entry in pPage->aCell[] implies that ** pPage->nOverflow is incremented. +** +** *pRC must be SQLITE_OK when this routine is called. */ static void insertCell( MemPage *pPage, /* Page into which we are copying */ @@ -6325,8 +6327,7 @@ static void insertCell( u8 *data; /* The content of the whole page */ u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */ - if( *pRC ) return; - + assert( *pRC==SQLITE_OK ); assert( i>=0 && i<=pPage->nCell+pPage->nOverflow ); assert( MX_CELL(pPage->pBt)<=10921 ); assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB ); @@ -6832,8 +6833,10 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){ while( ((*(pOut++) = *(pCell++))&0x80) && pCellnCell, pSpace, (int)(pOut-pSpace), - 0, pPage->pgno, &rc); + if( rc==SQLITE_OK ){ + insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace), + 0, pPage->pgno, &rc); + } /* Set the right-child pointer of pParent to point to the new page. */ put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew); @@ -8215,7 +8218,9 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ pTmp = pBt->pTmpSpace; assert( pTmp!=0 ); rc = sqlite3PagerWrite(pLeaf->pDbPage); - insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc); + if( rc==SQLITE_OK ){ + insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc); + } dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc); if( rc ) return rc; } From 09a4e92c6da38a43c6cf774d18d101a8d322eb33 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 May 2016 12:29:04 +0000 Subject: [PATCH 083/302] Yet another minor size reduction and performance increase in the b-tree insert logic. FossilOrigin-Name: 1dbaf7a119edc5150a5d4be1b72f652a574e5bc5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 836b8184c2..052ef57828 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\ssize\sreduction\sand\sperformance\sincrease\sin\sthe\ssqlite3BtreeInsert()\nlogic. -D 2016-05-21T11:23:26.914 +C Yet\sanother\sminor\ssize\sreduction\sand\sperformance\sincrease\sin\sthe\sb-tree\ninsert\slogic. +D 2016-05-21T12:29:04.510 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -322,7 +322,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c ab4ab00fa42b9f31a3c4f4232ab7dffe15a37728 +F src/btree.c da39b19be8a0fad4eb8a3d9e2d95a8ccc3eb8dd1 F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e366f18f5bbd594390e7b091083e99639de324e -R 59f3ac52df516414b0292061ce466d2b +P 656aa1ecf5129ae43c56a990e95038b5d8cbdcee +R 213b2db355637b4ec446a3f8344f0ebf U drh -Z 1ed41a6ca1c9810f6f5090ac3b0958c0 +Z 69c744da391089b891fa26fe7438d9c6 diff --git a/manifest.uuid b/manifest.uuid index 6b45ee4bc0..d7ffdbf577 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -656aa1ecf5129ae43c56a990e95038b5d8cbdcee \ No newline at end of file +1dbaf7a119edc5150a5d4be1b72f652a574e5bc5 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 033d9c24c3..2e862ff697 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8059,6 +8059,7 @@ int sqlite3BtreeInsert( assert( pPage->leaf ); } insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); + assert( pPage->nOverflow==0 || rc==SQLITE_OK ); assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); /* If no error has occurred and pPage has an overflow cell, call balance() @@ -8082,7 +8083,8 @@ int sqlite3BtreeInsert( ** row without seeking the cursor. This can be a big performance boost. */ pCur->info.nSize = 0; - if( rc==SQLITE_OK && pPage->nOverflow ){ + if( pPage->nOverflow ){ + assert( rc==SQLITE_OK ); pCur->curFlags &= ~(BTCF_ValidNKey); rc = balance(pCur); From 16e2b9694a3abcf3f670df5232433bbcfedbb522 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 May 2016 19:10:21 +0000 Subject: [PATCH 084/302] Remove some unused legacy code from the btree insert logic. FossilOrigin-Name: 2ce1166717ac3c0cec37b2f6d70d8359fbaefc71 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 5 ----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 052ef57828..e2540ef87b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Yet\sanother\sminor\ssize\sreduction\sand\sperformance\sincrease\sin\sthe\sb-tree\ninsert\slogic. -D 2016-05-21T12:29:04.510 +C Remove\ssome\sunused\slegacy\scode\sfrom\sthe\sbtree\sinsert\slogic. +D 2016-05-21T19:10:21.800 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -322,7 +322,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c da39b19be8a0fad4eb8a3d9e2d95a8ccc3eb8dd1 +F src/btree.c 09df167470e82b34f92d60cdd1a44f397ae8e105 F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 656aa1ecf5129ae43c56a990e95038b5d8cbdcee -R 213b2db355637b4ec446a3f8344f0ebf +P 1dbaf7a119edc5150a5d4be1b72f652a574e5bc5 +R 46d65e39155fd1bfd348824fd7a5487b U drh -Z 69c744da391089b891fa26fe7438d9c6 +Z 20edc765018d44eea5900b69fe208cfe diff --git a/manifest.uuid b/manifest.uuid index d7ffdbf577..1710f63d06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1dbaf7a119edc5150a5d4be1b72f652a574e5bc5 \ No newline at end of file +2ce1166717ac3c0cec37b2f6d70d8359fbaefc71 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 2e862ff697..a747abedb0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6111,7 +6111,6 @@ static int fillInCell( if( pPage->intKey ){ pSrc = pData; nSrc = nData; - nData = 0; }else{ assert( nKey<=0x7fffffff && pKey!=0 ); nPayload = (int)nKey; @@ -6240,10 +6239,6 @@ static int fillInCell( pSrc += n; nSrc -= n; spaceLeft -= n; - if( nSrc==0 ){ - nSrc = nData; - pSrc = pData; - } } releasePage(pToRelease); return SQLITE_OK; From 8eeb4463d9e1df9cae9d535ad02b491d60b2014e Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 May 2016 20:03:42 +0000 Subject: [PATCH 085/302] Simplify the sqlite3BtreeInsert() interface by gathering the five arguments describing the content to be inserted into the new BtreePayload structure, and thus reducing the number of parameters from eight to four. FossilOrigin-Name: 55f348cdd24c7812ea4b63345514764b69f64dc8 --- manifest | 18 +++++++------- manifest.uuid | 2 +- src/btree.c | 69 ++++++++++++++++++++++++++------------------------- src/btree.h | 32 +++++++++++++++++++++--- src/test3.c | 16 ++++++------ src/vdbe.c | 39 +++++++++++++++-------------- 6 files changed, 103 insertions(+), 73 deletions(-) diff --git a/manifest b/manifest index e2540ef87b..72aeb9be8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssome\sunused\slegacy\scode\sfrom\sthe\sbtree\sinsert\slogic. -D 2016-05-21T19:10:21.800 +C Simplify\sthe\ssqlite3BtreeInsert()\sinterface\sby\sgathering\sthe\sfive\sarguments\ndescribing\sthe\scontent\sto\sbe\sinserted\sinto\sthe\snew\sBtreePayload\sstructure,\sand\nthus\sreducing\sthe\snumber\sof\sparameters\sfrom\seight\sto\sfour. +D 2016-05-21T20:03:42.980 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -322,8 +322,8 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 09df167470e82b34f92d60cdd1a44f397ae8e105 -F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 +F src/btree.c e312cc3fdff31fdcc727b973fa0f195573b86393 +F src/btree.h 1342a9b2cc2089e3534d3ef00204786783f6aea6 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 @@ -390,7 +390,7 @@ F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 F src/test1.c c0e5b69f99e95a2c9f55fdb6e46b44f1a15292d8 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b -F src/test3.c 0df6f8dbb4cbaa7106397c70a271fa6a43659042 +F src/test3.c d2c9efd2985ff8f5502ffd3253156984778d77d8 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 F src/test6.c 2c014d4977efd6107ec9eef3dfdec56ac516f824 @@ -444,7 +444,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 975ac1d3d326bcb36b4e99255daeaf81ff6659d1 +F src/vdbe.c f2706d5564d2b2887a27c909e8e1575250029503 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1dbaf7a119edc5150a5d4be1b72f652a574e5bc5 -R 46d65e39155fd1bfd348824fd7a5487b +P 2ce1166717ac3c0cec37b2f6d70d8359fbaefc71 +R 560ed5c35c4c6718e1a252b0b3f02845 U drh -Z 20edc765018d44eea5900b69fe208cfe +Z ca823f4324bb11c74d57e3f017091386 diff --git a/manifest.uuid b/manifest.uuid index 1710f63d06..bbbac57808 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ce1166717ac3c0cec37b2f6d70d8359fbaefc71 \ No newline at end of file +55f348cdd24c7812ea4b63345514764b69f64dc8 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index a747abedb0..44b25019d1 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6072,9 +6072,7 @@ static int clearCell( static int fillInCell( MemPage *pPage, /* The page that contains the cell */ unsigned char *pCell, /* Complete text of the cell */ - const void *pKey, i64 nKey, /* The key */ - const void *pData,int nData, /* The data */ - int nZero, /* Extra zero bytes to append to pData */ + const BtreePayload *pX, /* Payload with which to construct the cell */ int *pnSize /* Write cell size here */ ){ int nPayload; @@ -6098,24 +6096,23 @@ static int fillInCell( /* Fill in the header. */ nHeader = pPage->childPtrSize; - nPayload = nData + nZero; + nPayload = pX->nData + pX->nZero; if( pPage->intKeyLeaf ){ nHeader += putVarint32(&pCell[nHeader], nPayload); }else{ - assert( nData==0 ); - assert( nZero==0 ); + assert( pX->nData==0 ); + assert( pX->nZero==0 ); } - nHeader += putVarint(&pCell[nHeader], *(u64*)&nKey); + nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); - /* Fill in the payload size */ + /* Fill in the payload */ if( pPage->intKey ){ - pSrc = pData; - nSrc = nData; + pSrc = pX->pData; + nSrc = pX->nData; }else{ - assert( nKey<=0x7fffffff && pKey!=0 ); - nPayload = (int)nKey; - pSrc = pKey; - nSrc = (int)nKey; + assert( pX->nKey<=0x7fffffff && pX->pKey!=0 ); + nSrc = nPayload = (int)pX->nKey; + pSrc = pX->pKey; } if( nPayload<=pPage->maxLocal ){ n = nHeader + nPayload; @@ -6154,7 +6151,7 @@ static int fillInCell( CellInfo info; pPage->xParseCell(pPage, pCell, &info); assert( nHeader==(int)(info.pPayload - pCell) ); - assert( info.nKey==nKey ); + assert( info.nKey==pX->nKey ); assert( *pnSize == info.nSize ); assert( spaceLeft == info.nLocal ); } @@ -7923,13 +7920,19 @@ static int balance(BtCursor *pCur){ /* -** Insert a new record into the BTree. The key is given by (pKey,nKey) -** and the data is given by (pData,nData). The cursor is used only to -** define what table the record should be inserted into. The cursor -** is left pointing at a random location. +** Insert a new record into the BTree. The content of the new record +** is described by the pX object. The pCur cursor is used only to +** define what table the record should be inserted into, and is left +** pointing at a random location. ** -** For an INTKEY table, only the nKey value of the key is used. pKey is -** ignored. For a ZERODATA table, the pData and nData are both ignored. +** For a table btree (used for rowid tables), only the pX.nKey value of +** the key is used. The pX.pKey value must be NULL. The pX.nKey is the +** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields +** hold the content of the row. +** +** For an index btree (used for indexes and WITHOUT ROWID tables), the +** key is an arbitrary byte sequence stored in pX.pKey,nKey. The +** pX.pData,nData,nZero fields must be zero. ** ** If the seekResult parameter is non-zero, then a successful call to ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already @@ -7946,9 +7949,7 @@ static int balance(BtCursor *pCur){ */ int sqlite3BtreeInsert( BtCursor *pCur, /* Insert data into the table of this cursor */ - const void *pKey, i64 nKey, /* The key of the new record */ - const void *pData, int nData, /* The data of the new record */ - int nZero, /* Number of extra 0 bytes to append to data */ + const BtreePayload *pX, /* Content of the row to be inserted */ int appendBias, /* True if this is likely an append */ int seekResult /* Result of prior MovetoUnpacked() call */ ){ @@ -7978,7 +7979,7 @@ int sqlite3BtreeInsert( ** keys with no associated data. If the cursor was opened expecting an ** intkey table, the caller should be inserting integer keys with a ** blob of associated data. */ - assert( (pKey==0)==(pCur->pKeyInfo==0) ); + assert( (pX->pKey==0)==(pCur->pKeyInfo==0) ); /* Save the positions of any other cursors open on this table. ** @@ -7997,38 +7998,38 @@ int sqlite3BtreeInsert( } if( pCur->pKeyInfo==0 ){ - assert( pKey==0 ); + assert( pX->pKey==0 ); /* If this is an insert into a table b-tree, invalidate any incrblob ** cursors open on the row being replaced */ - invalidateIncrblobCursors(p, nKey, 0); + invalidateIncrblobCursors(p, pX->nKey, 0); /* If the cursor is currently on the last row and we are appending a ** new row onto the end, set the "loc" to avoid an unnecessary ** btreeMoveto() call */ - if( (pCur->curFlags&BTCF_ValidNKey)!=0 && nKey>0 - && pCur->info.nKey==nKey-1 ){ + if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0 + && pCur->info.nKey==pX->nKey-1 ){ loc = -1; }else if( loc==0 ){ - rc = sqlite3BtreeMovetoUnpacked(pCur, 0, nKey, appendBias, &loc); + rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc); if( rc ) return rc; } }else if( loc==0 ){ - rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc); + rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc); if( rc ) return rc; } assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) ); pPage = pCur->apPage[pCur->iPage]; - assert( pPage->intKey || nKey>=0 ); + assert( pPage->intKey || pX->nKey>=0 ); assert( pPage->leaf || !pPage->intKey ); TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", - pCur->pgnoRoot, nKey, nData, pPage->pgno, + pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno, loc==0 ? "overwrite" : "new entry")); assert( pPage->isInit ); newCell = pBt->pTmpSpace; assert( newCell!=0 ); - rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew); + rc = fillInCell(pPage, newCell, pX, &szNew); if( rc ) goto end_insert; assert( szNew==pPage->xCellSize(pPage, newCell) ); assert( szNew <= MX_CELL_SIZE(pBt) ); diff --git a/src/btree.h b/src/btree.h index 9ba233ac33..5ac119c40a 100644 --- a/src/btree.h +++ b/src/btree.h @@ -39,6 +39,7 @@ typedef struct Btree Btree; typedef struct BtCursor BtCursor; typedef struct BtShared BtShared; +typedef struct BtreePayload BtreePayload; int sqlite3BtreeOpen( @@ -250,9 +251,34 @@ int sqlite3BtreeDelete(BtCursor*, u8 flags); #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */ #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */ -int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, - const void *pData, int nData, - int nZero, int bias, int seekResult); +/* An instance of the BtreePayload object describes the content of a single +** entry in either an index or table btree. +** +** Index btrees (used for indexes and also WITHOUT ROWID tables) contain +** an arbitrary key and no data. These btrees have pKey,nKey set to their +** key and pData,nData,nZero set to zero. +** +** Table btrees (used for rowid tables) contain an integer rowid used as +** the key and passed in the nKey field. The pKey field is zero. +** pData,nData hold the content of the new entry. nZero extra zero bytes +** are appended to the end of the content when constructing the entry. +** +** This object is used to pass information into sqlite3BtreeInsert(). The +** same information used to be passed as five separate parameters. But placing +** the information into this object helps to keep the interface more +** organized and understandable, and it also helps the resulting code to +** run a little faster by using fewer registers for parameter passing. +*/ +struct BtreePayload { + const void *pKey; /* Key content for indexes. NULL for tables */ + sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */ + const void *pData; /* Data for tables. NULL for indexes */ + int nData; /* Size of pData. 0 if none. */ + int nZero; /* Extra zero data appended after pData,nData */ +}; + +int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload, + int bias, int seekResult); int sqlite3BtreeFirst(BtCursor*, int *pRes); int sqlite3BtreeLast(BtCursor*, int *pRes); int sqlite3BtreeNext(BtCursor*, int *pRes); diff --git a/src/test3.c b/src/test3.c index 817e8a88fd..1e4baf7577 100644 --- a/src/test3.c +++ b/src/test3.c @@ -618,27 +618,27 @@ static int btree_insert( ){ BtCursor *pCur; int rc; - void *pKey = 0; - int nKey = 0; - void *pData = 0; - int nData = 0; + BtreePayload x; if( objc!=4 && objc!=3 ){ Tcl_WrongNumArgs(interp, 1, objv, "?-intkey? CSR KEY VALUE"); return TCL_ERROR; } + memset(&x, 0, sizeof(x)); if( objc==4 ){ - if( Tcl_GetIntFromObj(interp, objv[2], &nKey) ) return TCL_ERROR; - pData = (void*)Tcl_GetByteArrayFromObj(objv[3], &nData); + if( Tcl_GetIntFromObj(interp, objv[2], &rc) ) return TCL_ERROR; + x.nKey = rc; + x.pData = (void*)Tcl_GetByteArrayFromObj(objv[3], &x.nData); }else{ - pKey = (void*)Tcl_GetByteArrayFromObj(objv[2], &nKey); + x.pKey = (void*)Tcl_GetByteArrayFromObj(objv[2], &rc); + x.nKey = rc; } pCur = (BtCursor*)sqlite3TestTextToPtr(Tcl_GetString(objv[1])); sqlite3_mutex_enter(pCur->pBtree->db->mutex); sqlite3BtreeEnter(pCur->pBtree); - rc = sqlite3BtreeInsert(pCur, pKey, nKey, pData, nData, 0, 0, 0); + rc = sqlite3BtreeInsert(pCur, &x, 0, 0); sqlite3BtreeLeave(pCur->pBtree); sqlite3_mutex_leave(pCur->pBtree->db->mutex); diff --git a/src/vdbe.c b/src/vdbe.c index 36c014a7d0..d512c0bc74 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4285,13 +4285,12 @@ case OP_Insert: case OP_InsertInt: { Mem *pData; /* MEM cell holding data for the record to be inserted */ Mem *pKey; /* MEM cell holding key for the record */ - i64 iKey; /* The integer ROWID or key for the record to be inserted */ VdbeCursor *pC; /* Cursor to table into which insert is written */ - int nZero; /* Number of zero-bytes to append */ int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ const char *zDb; /* database name - used by the update hook */ Table *pTab; /* Table structure - used by update and pre-update hooks */ int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ + BtreePayload x; /* Payload to be inserted */ op = 0; pData = &aMem[pOp->p2]; @@ -4310,10 +4309,10 @@ case OP_InsertInt: { assert( pKey->flags & MEM_Int ); assert( memIsValid(pKey) ); REGISTER_TRACE(pOp->p3, pKey); - iKey = pKey->u.i; + x.nKey = pKey->u.i; }else{ assert( pOp->opcode==OP_InsertInt ); - iKey = pOp->p3; + x.nKey = pOp->p3; } if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){ @@ -4334,26 +4333,28 @@ case OP_InsertInt: { && pOp->p4type==P4_TABLE && !(pOp->p5 & OPFLAG_ISUPDATE) ){ - sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2); + sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2); } #endif if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; - if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey; + if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = x.nKey; if( pData->flags & MEM_Null ){ - pData->z = 0; - pData->n = 0; + x.pData = 0; + x.nData = 0; }else{ assert( pData->flags & (MEM_Blob|MEM_Str) ); + x.pData = pData->z; + x.nData = pData->n; } seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0); if( pData->flags & MEM_Zero ){ - nZero = pData->u.nZero; + x.nZero = pData->u.nZero; }else{ - nZero = 0; + x.nZero = 0; } - rc = sqlite3BtreeInsert(pC->uc.pCursor, 0, iKey, - pData->z, pData->n, nZero, + x.pKey = 0; + rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, (pOp->p5 & OPFLAG_APPEND)!=0, seekResult ); pC->deferredMoveto = 0; @@ -4362,7 +4363,7 @@ case OP_InsertInt: { /* Invoke the update-hook if required. */ if( rc ) goto abort_due_to_error; if( db->xUpdateCallback && op ){ - db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey); + db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey); } break; } @@ -4977,8 +4978,7 @@ next_tail: case OP_SorterInsert: /* in2 */ case OP_IdxInsert: { /* in2 */ VdbeCursor *pC; - int nKey; - const char *zKey; + BtreePayload x; assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; @@ -4994,9 +4994,12 @@ case OP_IdxInsert: { /* in2 */ if( pOp->opcode==OP_SorterInsert ){ rc = sqlite3VdbeSorterWrite(pC, pIn2); }else{ - nKey = pIn2->n; - zKey = pIn2->z; - rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3, + x.nKey = pIn2->n; + x.pKey = pIn2->z; + x.nData = 0; + x.nZero = 0; + x.pData = 0; + rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3, ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) ); assert( pC->deferredMoveto==0 ); From dfc2daa7c383b1a088c729d1a3f373eda5cc992e Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 May 2016 23:25:29 +0000 Subject: [PATCH 086/302] More tweaks to improve the performance of the insert logic, slightly. FossilOrigin-Name: dec1307581216e01ad508ffe4455b957e3356654 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 19 +++++++++---------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 72aeb9be8e..5a3bac30b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\sthe\ssqlite3BtreeInsert()\sinterface\sby\sgathering\sthe\sfive\sarguments\ndescribing\sthe\scontent\sto\sbe\sinserted\sinto\sthe\snew\sBtreePayload\sstructure,\sand\nthus\sreducing\sthe\snumber\sof\sparameters\sfrom\seight\sto\sfour. -D 2016-05-21T20:03:42.980 +C More\stweaks\sto\simprove\sthe\sperformance\sof\sthe\sinsert\slogic,\sslightly. +D 2016-05-21T23:25:29.377 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -322,7 +322,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c e312cc3fdff31fdcc727b973fa0f195573b86393 +F src/btree.c 2128172fc1c420a6fa6878827fa595407795069a F src/btree.h 1342a9b2cc2089e3534d3ef00204786783f6aea6 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2ce1166717ac3c0cec37b2f6d70d8359fbaefc71 -R 560ed5c35c4c6718e1a252b0b3f02845 +P 55f348cdd24c7812ea4b63345514764b69f64dc8 +R c264a769216b385e0f4c9931cdb639d6 U drh -Z ca823f4324bb11c74d57e3f017091386 +Z 3ab4f00ccff5a15915c6caecbe082e94 diff --git a/manifest.uuid b/manifest.uuid index bbbac57808..ff5538c7f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -55f348cdd24c7812ea4b63345514764b69f64dc8 \ No newline at end of file +dec1307581216e01ad508ffe4455b957e3356654 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 44b25019d1..7a2b80c23b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6096,24 +6096,23 @@ static int fillInCell( /* Fill in the header. */ nHeader = pPage->childPtrSize; - nPayload = pX->nData + pX->nZero; - if( pPage->intKeyLeaf ){ + if( pPage->intKey ){ + nPayload = pX->nData + pX->nZero; + pSrc = pX->pData; + nSrc = pX->nData; + assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */ nHeader += putVarint32(&pCell[nHeader], nPayload); + nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); }else{ assert( pX->nData==0 ); assert( pX->nZero==0 ); - } - nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); - - /* Fill in the payload */ - if( pPage->intKey ){ - pSrc = pX->pData; - nSrc = pX->nData; - }else{ assert( pX->nKey<=0x7fffffff && pX->pKey!=0 ); nSrc = nPayload = (int)pX->nKey; pSrc = pX->pKey; + nHeader += putVarint32(&pCell[nHeader], nPayload); } + + /* Fill in the payload */ if( nPayload<=pPage->maxLocal ){ n = nHeader + nPayload; testcase( n==3 ); From 6831474341d6f532246158a59ed289e15424098a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 00:10:58 +0000 Subject: [PATCH 087/302] Update the configure script with additional hints on the location of tclConfig.sh, hints needed by the latest versions of Xcode. FossilOrigin-Name: 90411a28168f6dacf08242a25bed7d6269041417 --- configure | 14 ++++++++++++++ configure.ac | 14 ++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 22a646c2b6..f4d4c48077 100755 --- a/configure +++ b/configure @@ -10757,6 +10757,20 @@ else fi fi + # Recent versions of Xcode on Macs hid the tclConfig.sh file + # in a strange place. + if test x"${ac_cv_c_tclconfig}" = x ; then + if test x"$cross_compiling" = xno; then + for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib + do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="$i" + break + fi + done + fi + fi + # then check for a private Tcl installation if test x"${ac_cv_c_tclconfig}" = x ; then for i in \ diff --git a/configure.ac b/configure.ac index 2c97885ade..e5727ea7f2 100644 --- a/configure.ac +++ b/configure.ac @@ -334,6 +334,20 @@ if test "${use_tcl}" = "yes" ; then fi fi + # Recent versions of Xcode on Macs hid the tclConfig.sh file + # in a strange place. + if test x"${ac_cv_c_tclconfig}" = x ; then + if test x"$cross_compiling" = xno; then + for i in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk/usr/lib + do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="$i" + break + fi + done + fi + fi + # then check for a private Tcl installation if test x"${ac_cv_c_tclconfig}" = x ; then for i in \ diff --git a/manifest b/manifest index 5a3bac30b0..40f21b9ec2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\stweaks\sto\simprove\sthe\sperformance\sof\sthe\sinsert\slogic,\sslightly. -D 2016-05-21T23:25:29.377 +C Update\sthe\sconfigure\sscript\swith\sadditional\shints\son\sthe\slocation\sof\ntclConfig.sh,\shints\sneeded\sby\sthe\slatest\sversions\sof\sXcode. +D 2016-05-23T00:10:58.949 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 96fdf3870e30c6f60c6a56d27f5f6e4159b9bdc6 x -F configure.ac 02b972db825685b4b0cca0234b2aa97f71bd15a5 +F configure 25cf7eb52a88846e4c1978016a9db22763c54f41 x +F configure.ac 480e1a17d5316b1751c8edcb15b8e6b8ab0a6cc3 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 55f348cdd24c7812ea4b63345514764b69f64dc8 -R c264a769216b385e0f4c9931cdb639d6 +P dec1307581216e01ad508ffe4455b957e3356654 +R 335eb72f63a6d15e3459420d579ffc36 U drh -Z 3ab4f00ccff5a15915c6caecbe082e94 +Z 180e9fbd5ff0ebef42d9658da1e8cd36 diff --git a/manifest.uuid b/manifest.uuid index ff5538c7f9..68190eb678 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dec1307581216e01ad508ffe4455b957e3356654 \ No newline at end of file +90411a28168f6dacf08242a25bed7d6269041417 \ No newline at end of file From 711c9810dc0d366b739c3c0f8416b386fc856fa2 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 14:24:31 +0000 Subject: [PATCH 088/302] Fix comment typos and improve clarity of presention in Lemon. The output should be identical. FossilOrigin-Name: b91a5b8297756289d45c8fce0d3399c253517eb0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 47 +++++++++++++++++++++++++++-------------------- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 40f21b9ec2..6ea5de70eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sconfigure\sscript\swith\sadditional\shints\son\sthe\slocation\sof\ntclConfig.sh,\shints\sneeded\sby\sthe\slatest\sversions\sof\sXcode. -D 2016-05-23T00:10:58.949 +C Fix\scomment\stypos\sand\simprove\sclarity\sof\spresention\sin\sLemon.\s\sThe\soutput\nshould\sbe\sidentical. +D 2016-05-23T14:24:31.372 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1420,7 +1420,7 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c f38a55106d79b7a4c063abb958517d6c47dc6ac7 +F tool/lemon.c b622032dd14dc1315fedb81d73f4658354329fca F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dec1307581216e01ad508ffe4455b957e3356654 -R 335eb72f63a6d15e3459420d579ffc36 +P 90411a28168f6dacf08242a25bed7d6269041417 +R 996821eb90ee3795d9bf03c89106b9e7 U drh -Z 180e9fbd5ff0ebef42d9658da1e8cd36 +Z b4115b7928b4702f985a5c5bf63f70fa diff --git a/manifest.uuid b/manifest.uuid index 68190eb678..3a567c6fc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90411a28168f6dacf08242a25bed7d6269041417 \ No newline at end of file +b91a5b8297756289d45c8fce0d3399c253517eb0 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 01c8a1da96..2ad36eec4a 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -288,6 +288,8 @@ struct rule { const char *code; /* The code executed when this rule is reduced */ const char *codePrefix; /* Setup code before code[] above */ const char *codeSuffix; /* Breakdown code after code[] above */ + int noCode; /* True if this rule has no associated C code */ + int codeEmitted; /* True if the code has been emitted already */ struct symbol *precsym; /* Precedence symbol for this rule */ int index; /* An index number for this rule */ int iRule; /* Rule number as used in the generated tables */ @@ -349,7 +351,7 @@ struct state { struct config *bp; /* The basis configurations for this state */ struct config *cfp; /* All configurations in this set */ int statenum; /* Sequential number for this state */ - struct action *ap; /* Array of actions for this state */ + struct action *ap; /* List of actions for this state */ int nTknAct, nNtAct; /* Number of actions on terminals and nonterminals */ int iTknOfst, iNtOfst; /* yy_action[] offset for terminals and nonterms */ int iDfltReduce; /* Default action is to REDUCE by this rule */ @@ -1499,7 +1501,7 @@ static void handle_T_option(char *z){ lemon_strcpy(user_templatename, z); } -/* Merge together to lists of rules order by rule.iRule */ +/* Merge together to lists of rules ordered by rule.iRule */ static struct rule *Rule_merge(struct rule *pA, struct rule *pB){ struct rule *pFirst = 0; struct rule **ppPrev = &pFirst; @@ -1642,7 +1644,10 @@ int main(int argc, char **argv) for(i=1; ISUPPER(lem.symbols[i]->name[0]); i++); lem.nterminal = i; - /* Assign sequential rule numbers */ + /* Assign sequential rule numbers. Start with 0. Put rules that have no + ** reduce action C-code associated with them last, so that the switch() + ** statement that selects reduction actions will have a smaller jump table. + */ for(i=0, rp=lem.rule; rp; rp=rp->next){ rp->iRule = rp->code ? i++ : -1; } @@ -2211,6 +2216,7 @@ to follow the previous rule."); }else{ psp->prevrule->line = psp->tokenlineno; psp->prevrule->code = &x[1]; + psp->prevrule->noCode = 0; } }else if( x[0]=='[' ){ psp->state = PRECEDENCE_MARK_1; @@ -2317,6 +2323,7 @@ to follow the previous rule."); rp->lhsalias = psp->lhsalias; rp->nrhs = psp->nrhs; rp->code = 0; + rp->noCode = 1; rp->precsym = 0; rp->index = psp->gp->nrule++; rp->nextlhs = rp->lhs->rule; @@ -3527,9 +3534,8 @@ PRIVATE char *append_str(const char *zText, int n, int p1, int p2){ } /* -** zCode is a string that is the action associated with a rule. Expand -** the symbols in this string so that the refer to elements of the parser -** stack. +** Write and transform the rp->code string so that symbols are expanded. +** Populate the rp->codePrefix and rp->codeSuffix strings, as appropriate. ** ** Return 1 if the expanded code requires that "yylhsminor" local variable ** to be defined. @@ -3553,6 +3559,9 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ static char newlinestr[2] = { '\n', '\0' }; rp->code = newlinestr; rp->line = rp->ruleline; + rp->noCode = 1; + }else{ + rp->noCode = 0; } @@ -3568,6 +3577,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ append_str(" yy_destructor(yypParser,%d,&yymsp[%d].minor);\n", 0, rp->rhs[0]->index,1-rp->nrhs); rp->codePrefix = Strsafe(append_str(0,0,0,0)); + rp->noCode = 0; } }else if( rp->lhsalias==0 ){ /* There is no LHS value symbol. */ @@ -3715,7 +3725,10 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){ /* Suffix code generation complete */ cp = append_str(0,0,0,0); - if( cp && cp[0] ) rp->codeSuffix = Strsafe(cp); + if( cp && cp[0] ){ + rp->codeSuffix = Strsafe(cp); + rp->noCode = 0; + } return rc; } @@ -4396,13 +4409,9 @@ void ReportTable( /* First output rules other than the default: rule */ for(rp=lemp->rule; rp; rp=rp->next){ struct rule *rp2; /* Other rules with the same action */ - if( rp->code==0 ) continue; - if( rp->code[0]=='\n' - && rp->code[1]==0 - && rp->codePrefix==0 - && rp->codeSuffix==0 - ){ - /* No actions, so this will be part of the "default:" rule */ + if( rp->codeEmitted ) continue; + if( rp->noCode ){ + /* No C code actions, so this will be part of the "default:" rule */ continue; } fprintf(out," case %d: /* ", rp->iRule); @@ -4414,21 +4423,19 @@ void ReportTable( fprintf(out," case %d: /* ", rp2->iRule); writeRuleText(out, rp2); fprintf(out," */ yytestcase(yyruleno==%d);\n", rp2->iRule); lineno++; - rp2->code = 0; + rp2->codeEmitted = 1; } } emit_code(out,rp,lemp,&lineno); fprintf(out," break;\n"); lineno++; - rp->code = 0; + rp->codeEmitted = 1; } /* Finally, output the default: rule. We choose as the default: all ** empty actions. */ fprintf(out," default:\n"); lineno++; for(rp=lemp->rule; rp; rp=rp->next){ - if( rp->code==0 ) continue; - assert( rp->code[0]=='\n' && rp->code[1]==0 ); - assert( rp->codePrefix==0 ); - assert( rp->codeSuffix==0 ); + if( rp->codeEmitted ) continue; + assert( rp->noCode ); fprintf(out," /* (%d) ", rp->iRule); writeRuleText(out, rp); fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++; From c173ad80119821b941a4615133f6f718051cf686 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 16:15:02 +0000 Subject: [PATCH 089/302] Lemon enhancement: avoid unnecessary reduce actions that convert one non-terminal into another but have no side effects. FossilOrigin-Name: a86e782ad1aa6f5a8b2c54f9dcf0fa61960843f3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lemon.c | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6ea5de70eb..7893a5758b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scomment\stypos\sand\simprove\sclarity\sof\spresention\sin\sLemon.\s\sThe\soutput\nshould\sbe\sidentical. -D 2016-05-23T14:24:31.372 +C Lemon\senhancement:\savoid\sunnecessary\sreduce\sactions\sthat\sconvert\sone\nnon-terminal\sinto\sanother\sbut\shave\sno\sside\seffects. +D 2016-05-23T16:15:02.530 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1420,7 +1420,7 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c b622032dd14dc1315fedb81d73f4658354329fca +F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39 F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 90411a28168f6dacf08242a25bed7d6269041417 -R 996821eb90ee3795d9bf03c89106b9e7 +P b91a5b8297756289d45c8fce0d3399c253517eb0 +R e62078de0c6378c8386e96fef92b2fe6 U drh -Z b4115b7928b4702f985a5c5bf63f70fa +Z f3f44e1ca319aa39a93bd7b358420b1f diff --git a/manifest.uuid b/manifest.uuid index 3a567c6fc6..4af496871d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b91a5b8297756289d45c8fce0d3399c253517eb0 \ No newline at end of file +a86e782ad1aa6f5a8b2c54f9dcf0fa61960843f3 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 2ad36eec4a..d643b341e4 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -341,6 +341,7 @@ struct action { struct state *stp; /* The new state, if a shift */ struct rule *rp; /* The rule, if a reduce */ } x; + struct symbol *spOpt; /* SHIFTREDUCE optimization to this symbol */ struct action *next; /* Next action for this state */ struct action *collide; /* Next action with the same hash */ }; @@ -532,6 +533,7 @@ void Action_add( *app = newaction; newaction->type = type; newaction->sp = sp; + newaction->spOpt = 0; if( type==SHIFT ){ newaction->x.stp = (struct state *)arg; }else{ @@ -3167,6 +3169,9 @@ int PrintAction( result = 0; break; } + if( result && ap->spOpt ){ + fprintf(fp," /* because %s==%s */", ap->sp->name, ap->spOpt->name); + } return result; } @@ -4509,7 +4514,7 @@ void ReportHeader(struct lemon *lemp) void CompressTables(struct lemon *lemp) { struct state *stp; - struct action *ap, *ap2; + struct action *ap, *ap2, *nextap; struct rule *rp, *rp2, *rbest; int nbest, n; int i; @@ -4586,6 +4591,36 @@ void CompressTables(struct lemon *lemp) } } } + + /* If a SHIFTREDUCE action specifies a rule that has a single RHS term + ** (meaning that the SHIFTREDUCE will land back in the state where it + ** started) and if there is no C-code associated with the reduce action, + ** then we can go ahead and convert the action to be the same as the + ** action for the RHS of the rule. + */ + for(i=0; instate; i++){ + stp = lemp->sorted[i]; + for(ap=stp->ap; ap; ap=nextap){ + nextap = ap->next; + if( ap->type!=SHIFTREDUCE ) continue; + rp = ap->x.rp; + if( rp->noCode==0 ) continue; + if( rp->nrhs!=1 ) continue; +#if 1 + /* Only apply this optimization to non-terminals. It would be OK to + ** apply it to terminal symbols too, but that makes the parser tables + ** larger. */ + if( ap->sp->indexnterminal ) continue; +#endif + /* If we reach this point, it means the optimization can be applied */ + nextap = ap; + for(ap2=stp->ap; ap2 && (ap2==ap || ap2->sp!=rp->lhs); ap2=ap2->next){} + assert( ap2!=0 ); + ap->spOpt = ap2->sp; + ap->type = ap2->type; + ap->x = ap2->x; + } + } } From 5782bc27fa701e827f26cd1140531a1fa6652be5 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 23 May 2016 16:16:13 +0000 Subject: [PATCH 090/302] Improve the error messages generated by the rtree module when a constraint fails. FossilOrigin-Name: 3ad2531efb64b7c53b777ddf3681203217052b32 --- ext/rtree/rtree.c | 53 ++++++++++++++++++++++++++++++++++++++++--- ext/rtree/rtree1.test | 20 ++++++++-------- ext/rtree/rtree3.test | 31 ++++++++++++++++++++++++- manifest | 18 +++++++-------- manifest.uuid | 2 +- 5 files changed, 101 insertions(+), 23 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 012c48d6d1..311824aa85 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -2800,6 +2800,53 @@ static RtreeValue rtreeValueUp(sqlite3_value *v){ } #endif /* !defined(SQLITE_RTREE_INT_ONLY) */ +/* +** A constraint has failed while inserting a row into an rtree table. +** Assuming no OOM error occurs, this function sets the error message +** (at pRtree->base.zErrMsg) to an appropriate value and returns +** SQLITE_CONSTRAINT. +** +** Parameter iCol is the index of the leftmost column involved in the +** constraint failure. If it is 0, then the constraint that failed is +** the unique constraint on the id column. Otherwise, it is the rtree +** (c1<=c2) constraint on columns iCol and iCol+1 that has failed. +** +** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT. +*/ +static int rtreeConstraintError(Rtree *pRtree, int iCol){ + sqlite3_stmt *pStmt = 0; + char *zSql; + int rc; + + assert( iCol==0 || iCol%2 ); + zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", pRtree->zDb, pRtree->zName); + if( zSql ){ + rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0); + }else{ + rc = SQLITE_NOMEM; + } + sqlite3_free(zSql); + + if( rc==SQLITE_OK ){ + if( iCol==0 ){ + const char *zCol = sqlite3_column_name(pStmt, 0); + pRtree->base.zErrMsg = sqlite3_mprintf( + "UNIQUE constraint failed: %s.%s", pRtree->zName, zCol + ); + }else{ + const char *zCol1 = sqlite3_column_name(pStmt, iCol); + const char *zCol2 = sqlite3_column_name(pStmt, iCol+1); + pRtree->base.zErrMsg = sqlite3_mprintf( + "rtree constraint failed: %s.(%s<=%s)", pRtree->zName, zCol1, zCol2 + ); + } + } + + sqlite3_finalize(pStmt); + return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc); +} + + /* ** The xUpdate method for rtree module virtual tables. @@ -2850,7 +2897,7 @@ static int rtreeUpdate( cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]); cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]); if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){ - rc = SQLITE_CONSTRAINT; + rc = rtreeConstraintError(pRtree, ii+1); goto constraint; } } @@ -2861,7 +2908,7 @@ static int rtreeUpdate( cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]); cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]); if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){ - rc = SQLITE_CONSTRAINT; + rc = rtreeConstraintError(pRtree, ii+1); goto constraint; } } @@ -2882,7 +2929,7 @@ static int rtreeUpdate( if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){ rc = rtreeDeleteRowid(pRtree, cell.iRowid); }else{ - rc = SQLITE_CONSTRAINT; + rc = rtreeConstraintError(pRtree, 0); goto constraint; } } diff --git a/ext/rtree/rtree1.test b/ext/rtree/rtree1.test index c9192de192..9dc101a7b2 100644 --- a/ext/rtree/rtree1.test +++ b/ext/rtree/rtree1.test @@ -194,13 +194,13 @@ do_test rtree-2.1.3 { do_test rtree-2.2.1 { catchsql { INSERT INTO t1 VALUES(2, 1, 3, 2, 4) } -} {1 {constraint failed}} +} {1 {UNIQUE constraint failed: t1.ii}} do_test rtree-2.2.2 { catchsql { INSERT INTO t1 VALUES(4, 1, 3, 4, 2) } -} {1 {constraint failed}} +} {1 {rtree constraint failed: t1.(y1<=y2)}} do_test rtree-2.2.3 { catchsql { INSERT INTO t1 VALUES(4, 3, 1, 2, 4) } -} {1 {constraint failed}} +} {1 {rtree constraint failed: t1.(x1<=x2)}} do_test rtree-2.2.4 { execsql { SELECT ii FROM t1 ORDER BY ii } } {1 2 3} @@ -236,7 +236,7 @@ do_test rtree-3.1.3 { # Test the constraint on the coordinates (c[i]<=c[i+1] where (i%2==0)): do_test rtree-3.2.1 { catchsql { INSERT INTO t1 VALUES(7, 2, 6, 4, 3) } -} {1 {constraint failed}} +} {1 {rtree constraint failed: t1.(y1<=y2)}} do_test rtree-3.2.2 { catchsql { INSERT INTO t1 VALUES(8, 2, 6, 3, 3) } } {0 {}} @@ -490,11 +490,11 @@ foreach {tn sql_template testdata} { } 4 "INSERT %CONF% INTO t1 VALUES(2, 7, 6, 7, 7)" { - ROLLBACK 0 1 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6} - ABORT 0 1 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} + ROLLBACK 0 2 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6} + ABORT 0 2 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} IGNORE 0 0 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} - FAIL 0 1 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} - REPLACE 0 1 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} + FAIL 0 2 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} + REPLACE 0 2 {1 1 2 3 4 2 2 3 4 5 3 3 4 5 6 4 4 5 6 7} } } { @@ -510,7 +510,9 @@ foreach {tn sql_template testdata} { } set res(0) {0 {}} - set res(1) {1 {constraint failed}} + set res(1) {1 {UNIQUE constraint failed: t1.idx}} + set res(2) {1 {rtree constraint failed: t1.(x1<=x2)}} + do_catchsql_test $testname.1 $sql $res($error) do_test $testname.2 [list sql_uses_stmt db $sql] $uses do_execsql_test $testname.3 { SELECT * FROM t1 ORDER BY idx } $data diff --git a/ext/rtree/rtree3.test b/ext/rtree/rtree3.test index fea5513069..1d863c6cc2 100644 --- a/ext/rtree/rtree3.test +++ b/ext/rtree/rtree3.test @@ -47,7 +47,8 @@ ifcapable !rtree { # # rtree3-8: Test OOM while registering the r-tree module with sqlite. # - +# rtree3-11: OOM following a constraint failure +# do_faultsim_test rtree3-1 -faults oom* -prep { faultsim_delete_and_reopen } -body { @@ -234,4 +235,32 @@ do_faultsim_test rtree3-10 -faults oom-* -prep { faultsim_test_result {0 2} } + +do_test rtree3-11.prep { + faultsim_delete_and_reopen + execsql { + CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2); + INSERT INTO rt VALUES(1, 2, 3, 4, 5); + } + faultsim_save_and_close +} {} +do_faultsim_test rtree3-10.1 -faults oom-* -prep { + faultsim_restore_and_reopen + execsql { SELECT * FROM rt } +} -body { + execsql { INSERT INTO rt VALUES(1, 2, 3, 4, 5) } +} -test { + faultsim_test_result {1 {UNIQUE constraint failed: rt.ii}} \ + {1 {constraint failed}} +} +do_faultsim_test rtree3-10.2 -faults oom-* -prep { + faultsim_restore_and_reopen + execsql { SELECT * FROM rt } +} -body { + execsql { INSERT INTO rt VALUES(2, 2, 3, 5, 4) } +} -test { + faultsim_test_result {1 {rtree constraint failed: rt.(y1<=y2)}} \ + {1 {constraint failed}} +} + finish_test diff --git a/manifest b/manifest index 7893a5758b..1f97ff1987 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Lemon\senhancement:\savoid\sunnecessary\sreduce\sactions\sthat\sconvert\sone\nnon-terminal\sinto\sanother\sbut\shave\sno\sside\seffects. -D 2016-05-23T16:15:02.530 +C Improve\sthe\serror\smessages\sgenerated\sby\sthe\srtree\smodule\swhen\sa\sconstraint\sfails. +D 2016-05-23T16:16:13.470 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -253,11 +253,11 @@ F ext/rbu/sqlite3rbu.c bf36625990c6865ecf08bd844d8097ed2d0a6958 F ext/rbu/sqlite3rbu.h 2acd0a6344a6079de15c8dc9d84d3df83a665930 F ext/rbu/test_rbu.c 9bbdf6bd8efd58fbc4f192698df50569598fbb9e F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 0b870ccb7b58b734a2a8e1e2755a7c0ded070920 +F ext/rtree/rtree.c 7ebca7d18261f402d67de9e151be7fb2ed62b8f5 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e -F ext/rtree/rtree1.test 96a80c08440c932cd72aac50660e7af2612d2cda +F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba -F ext/rtree/rtree3.test a494da55c30ee0bc9b01a91c80c81b387b22d2dc +F ext/rtree/rtree3.test 2cafe8265d1ff28f206fce88d114f208349df482 F ext/rtree/rtree4.test c8fe384f60ebd49540a5fecc990041bf452eb6e0 F ext/rtree/rtree5.test 6a510494f12454bf57ef28f45bc7764ea279431e F ext/rtree/rtree6.test 773a90db2dce6a8353dd0d5b64bca69b29761196 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b91a5b8297756289d45c8fce0d3399c253517eb0 -R e62078de0c6378c8386e96fef92b2fe6 -U drh -Z f3f44e1ca319aa39a93bd7b358420b1f +P a86e782ad1aa6f5a8b2c54f9dcf0fa61960843f3 +R 656cb7a661842081cb14458e0c90ff63 +U dan +Z 1b4990ccdee5b0865b4104871945d857 diff --git a/manifest.uuid b/manifest.uuid index 4af496871d..194d4c4259 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a86e782ad1aa6f5a8b2c54f9dcf0fa61960843f3 \ No newline at end of file +3ad2531efb64b7c53b777ddf3681203217052b32 \ No newline at end of file From daa14559d207528cb76b1b58c32e0a4a479aa41e Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 18:06:51 +0000 Subject: [PATCH 091/302] Remove an extra "finish_test" from the end of rtreeC.test. FossilOrigin-Name: bfbb6dd84b5e1335e1eae857a03fa33a71fd67a5 --- ext/rtree/rtreeC.test | 4 ---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ext/rtree/rtreeC.test b/ext/rtree/rtreeC.test index 9a64df51d5..a26c401e0d 100644 --- a/ext/rtree/rtreeC.test +++ b/ext/rtree/rtreeC.test @@ -350,7 +350,3 @@ do_eqp_execsql_test 7.4 { } finish_test - - - -finish_test diff --git a/manifest b/manifest index 1f97ff1987..1cbb8b0021 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\serror\smessages\sgenerated\sby\sthe\srtree\smodule\swhen\sa\sconstraint\sfails. -D 2016-05-23T16:16:13.470 +C Remove\san\sextra\s"finish_test"\sfrom\sthe\send\sof\srtreeC.test. +D 2016-05-23T18:06:51.504 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -266,7 +266,7 @@ F ext/rtree/rtree8.test db79c812f9e4a11f9b1f3f9934007884610a713a F ext/rtree/rtree9.test b5eb13849545dfd271a54ff16784cb00d8792aea F ext/rtree/rtreeA.test ace05e729a36e342d40cf94e9efc7b4723d9dcdf F ext/rtree/rtreeB.test c85f9ce78766c4e68b8b89fbf2979ee9cfa82b4e -F ext/rtree/rtreeC.test 90aaaffe2fd4f0dcd12289cad5515f6d41f45ffd +F ext/rtree/rtreeC.test c0a9c67f2efa98b6fae12acb8a28348d231a481d F ext/rtree/rtreeD.test 636630357638f5983701550b37f0f5867130d2ca F ext/rtree/rtreeE.test 45a147a64a76306172819562309681d8e90f94bb F ext/rtree/rtreeF.test 66deb9fd1611c7ca2e374adba63debdc2dbb12b4 @@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a86e782ad1aa6f5a8b2c54f9dcf0fa61960843f3 -R 656cb7a661842081cb14458e0c90ff63 -U dan -Z 1b4990ccdee5b0865b4104871945d857 +P 3ad2531efb64b7c53b777ddf3681203217052b32 +R 181417728ff7d20d7df6a3bbac1c99fc +U drh +Z a9812f920562a373e5ac292c844442d4 diff --git a/manifest.uuid b/manifest.uuid index 194d4c4259..9fff038e15 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3ad2531efb64b7c53b777ddf3681203217052b32 \ No newline at end of file +bfbb6dd84b5e1335e1eae857a03fa33a71fd67a5 \ No newline at end of file From e62c2fe1795bb87994fbe068e19a5494cd088715 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 18:12:04 +0000 Subject: [PATCH 092/302] Fix RTREE so that it does not run queries against the sqlite_stat1 if that table does not exist. FossilOrigin-Name: 48526a2fe5373e3d19e8b813cc8a342d6b7c9c3d --- ext/rtree/rtree.c | 5 +++++ ext/rtree/rtreeG.test | 34 ++++++++++++++++++++++++++++++++++ manifest | 13 +++++++------ manifest.uuid | 2 +- 4 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 ext/rtree/rtreeG.test diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 311824aa85..fc69acd6fa 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -3012,6 +3012,11 @@ static int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){ int rc; i64 nRow = 0; + if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1", + 0,0,0,0,0,0)==SQLITE_ERROR ){ + pRtree->nRowEst = RTREE_DEFAULT_ROWEST; + return SQLITE_OK; + } zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName); if( zSql==0 ){ rc = SQLITE_NOMEM; diff --git a/ext/rtree/rtreeG.test b/ext/rtree/rtreeG.test new file mode 100644 index 0000000000..035822e4df --- /dev/null +++ b/ext/rtree/rtreeG.test @@ -0,0 +1,34 @@ +# 2016-05-32 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file contains tests for the r-tree module. +# +# Verify that no invalid SQL is run during initialization + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source $testdir/tester.tcl +ifcapable !rtree { finish_test ; return } + +db close +sqlite3_shutdown +test_sqlite3_log [list lappend ::log] +set ::log [list] +sqlite3 db test.db + + +set ::log {} +do_test rtreeG-1.1 { + db eval {CREATE VIRTUAL TABLE t1 USING rtree(a,b,c);} + set ::log +} {} + +finish_test diff --git a/manifest b/manifest index 1cbb8b0021..3d248c5ee4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sextra\s"finish_test"\sfrom\sthe\send\sof\srtreeC.test. -D 2016-05-23T18:06:51.504 +C Fix\sRTREE\sso\sthat\sit\sdoes\snot\srun\squeries\sagainst\sthe\ssqlite_stat1\sif\sthat\ntable\sdoes\snot\sexist. +D 2016-05-23T18:12:04.371 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -253,7 +253,7 @@ F ext/rbu/sqlite3rbu.c bf36625990c6865ecf08bd844d8097ed2d0a6958 F ext/rbu/sqlite3rbu.h 2acd0a6344a6079de15c8dc9d84d3df83a665930 F ext/rbu/test_rbu.c 9bbdf6bd8efd58fbc4f192698df50569598fbb9e F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 7ebca7d18261f402d67de9e151be7fb2ed62b8f5 +F ext/rtree/rtree.c d26a815b0df1c412a6881dae8d7fd3c9c08cce68 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -270,6 +270,7 @@ F ext/rtree/rtreeC.test c0a9c67f2efa98b6fae12acb8a28348d231a481d F ext/rtree/rtreeD.test 636630357638f5983701550b37f0f5867130d2ca F ext/rtree/rtreeE.test 45a147a64a76306172819562309681d8e90f94bb F ext/rtree/rtreeF.test 66deb9fd1611c7ca2e374adba63debdc2dbb12b4 +F ext/rtree/rtreeG.test fad67b4ec080cbe41bafb68517361b74ac4632d5 F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195 F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 9c5777af3d2921c7b4ae4954e8e5697502289d28 @@ -1492,7 +1493,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3ad2531efb64b7c53b777ddf3681203217052b32 -R 181417728ff7d20d7df6a3bbac1c99fc +P bfbb6dd84b5e1335e1eae857a03fa33a71fd67a5 +R 917b797124e2db7975ec6ce19d0d3f10 U drh -Z a9812f920562a373e5ac292c844442d4 +Z 1720c00f1c890b6da656d7cb35d019e7 diff --git a/manifest.uuid b/manifest.uuid index 9fff038e15..1a5b947ac2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfbb6dd84b5e1335e1eae857a03fa33a71fd67a5 \ No newline at end of file +48526a2fe5373e3d19e8b813cc8a342d6b7c9c3d \ No newline at end of file From f1e2c8e1ff8af08e2132dcdf2dd296abd8172b61 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 18:27:07 +0000 Subject: [PATCH 093/302] Fix the rtreeG.test test case. FossilOrigin-Name: 9589e9377118efc356c73ea1aab2d7e6c2f7fc36 --- ext/rtree/rtreeG.test | 36 ++++++++++++++++++++++++++++++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ext/rtree/rtreeG.test b/ext/rtree/rtreeG.test index 035822e4df..bffd17ecaa 100644 --- a/ext/rtree/rtreeG.test +++ b/ext/rtree/rtreeG.test @@ -26,9 +26,41 @@ sqlite3 db test.db set ::log {} -do_test rtreeG-1.1 { - db eval {CREATE VIRTUAL TABLE t1 USING rtree(a,b,c);} +do_execsql_test rtreeG-1.1 { + CREATE VIRTUAL TABLE t1 USING rtree(id,x0,x1,y0,y1); +} {} +do_test rtreeG-1.1log { set ::log } {} +do_execsql_test rtreeG-1.2 { + INSERT INTO t1 VALUES(1,10,15,5,23),(2,20,21,5,23),(3,10,15,20,30); + SELECT id from t1 WHERE x0>8 AND x1<16 AND y0>2 AND y1<25; +} {1} +do_test rtreeG-1.2log { + set ::log +} {} + +db close +sqlite3 db test.db +do_execsql_test rtreeG-1.3 { + SELECT id from t1 WHERE x0>8 AND x1<16 AND y0>2 AND y1<25; +} {1} +do_test rtreeG-1.3log { + set ::log +} {} + +do_execsql_test rtreeG-1.4 { + DROP TABLE t1; +} {} +do_test rtreeG-1.4log { + set ::log +} {} + +db close +sqlite3_shutdown +test_sqlite3_log +sqlite3_initialize +sqlite3 db test.db + finish_test diff --git a/manifest b/manifest index 3d248c5ee4..92ddb98a9d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sRTREE\sso\sthat\sit\sdoes\snot\srun\squeries\sagainst\sthe\ssqlite_stat1\sif\sthat\ntable\sdoes\snot\sexist. -D 2016-05-23T18:12:04.371 +C Fix\sthe\srtreeG.test\stest\scase. +D 2016-05-23T18:27:07.523 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -270,7 +270,7 @@ F ext/rtree/rtreeC.test c0a9c67f2efa98b6fae12acb8a28348d231a481d F ext/rtree/rtreeD.test 636630357638f5983701550b37f0f5867130d2ca F ext/rtree/rtreeE.test 45a147a64a76306172819562309681d8e90f94bb F ext/rtree/rtreeF.test 66deb9fd1611c7ca2e374adba63debdc2dbb12b4 -F ext/rtree/rtreeG.test fad67b4ec080cbe41bafb68517361b74ac4632d5 +F ext/rtree/rtreeG.test 3b185719630795f38594f64cd7d1de86a33f91f1 F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195 F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 9c5777af3d2921c7b4ae4954e8e5697502289d28 @@ -1493,7 +1493,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bfbb6dd84b5e1335e1eae857a03fa33a71fd67a5 -R 917b797124e2db7975ec6ce19d0d3f10 +P 48526a2fe5373e3d19e8b813cc8a342d6b7c9c3d +R f2db7693c08d0e8ea5e5a43c2bcc91ff U drh -Z 1720c00f1c890b6da656d7cb35d019e7 +Z 8e18f408557ba2afd41610ebc5947af3 diff --git a/manifest.uuid b/manifest.uuid index 1a5b947ac2..d9e8077dfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48526a2fe5373e3d19e8b813cc8a342d6b7c9c3d \ No newline at end of file +9589e9377118efc356c73ea1aab2d7e6c2f7fc36 \ No newline at end of file From 118ab6585988ff97286fcb49b5500d31d6ddc218 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 May 2016 21:56:24 +0000 Subject: [PATCH 094/302] Use a pointer to the top of the stack rather than an index into the stack in the Lemon-generated parser template, for about 6.6% parser performance gain. FossilOrigin-Name: 3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68 --- manifest | 13 +++---- manifest.uuid | 2 +- tool/lempar.c | 101 +++++++++++++++++++++++++++----------------------- 3 files changed, 62 insertions(+), 54 deletions(-) diff --git a/manifest b/manifest index f7ff8f22bc..8f4a53f747 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sa\sminor\serror\smessage\swhen\srunning\sRTREE\swithout\san\ssqlite_stat1\stable. -D 2016-05-23T19:02:58.893 +C Use\sa\spointer\sto\sthe\stop\sof\sthe\sstack\srather\sthan\san\sindex\sinto\sthe\sstack\nin\sthe\sLemon-generated\sparser\stemplate,\sfor\sabout\s6.6%\sparser\sperformance\sgain. +D 2016-05-23T21:56:24.427 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1422,7 +1422,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39 -F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6 +F tool/lempar.c 872383ebf36c13fdaff0f3692d4ff60e64ec49e2 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 @@ -1493,8 +1493,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3ad2531efb64b7c53b777ddf3681203217052b32 9589e9377118efc356c73ea1aab2d7e6c2f7fc36 -R f2db7693c08d0e8ea5e5a43c2bcc91ff -T +closed 9589e9377118efc356c73ea1aab2d7e6c2f7fc36 +P 276e92f5b4c1ee49eabb738b24d73d7af90fb13c +R f3a217ca3fc6adf56f5cf5443069e03b U drh -Z 97b14e25d3ed8655aacd892bebd6d043 +Z babb89b922e84c6e93d4048989d7622c diff --git a/manifest.uuid b/manifest.uuid index 9ebd599e42..9a4a91d8af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -276e92f5b4c1ee49eabb738b24d73d7af90fb13c \ No newline at end of file +3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index e313904082..b02fd21b77 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -203,9 +203,9 @@ typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { - int yyidx; /* Index of top element in stack */ + yyStackEntry *yytos; /* Pointer to top element of the stack */ #ifdef YYTRACKMAXSTACKDEPTH - int yyidxMax; /* Maximum value of yyidx */ + int yyhwm; /* High-water mark of the stack */ #endif #ifndef YYNOERRORRECOVERY int yyerrcnt; /* Shifts left before out of the error */ @@ -317,9 +317,9 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( pParser ){ - pParser->yyidx = -1; + pParser->yytos = 0; #ifdef YYTRACKMAXSTACKDEPTH - pParser->yyidxMax = 0; + pParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 pParser->yystack = NULL; @@ -369,8 +369,8 @@ static void yy_destructor( */ static void yy_pop_parser_stack(yyParser *pParser){ yyStackEntry *yytos; - assert( pParser->yyidx>=0 ); - yytos = &pParser->yystack[pParser->yyidx--]; + assert( pParser->yytos!=0 ); + yytos = pParser->yytos--; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sPopping %s\n", @@ -397,7 +397,7 @@ void ParseFree( #ifndef YYPARSEFREENEVERNULL if( pParser==0 ) return; #endif - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); + while( pParser->yytos>=pParser->yystack ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 free(pParser->yystack); #endif @@ -410,7 +410,7 @@ void ParseFree( #ifdef YYTRACKMAXSTACKDEPTH int ParseStackPeak(void *p){ yyParser *pParser = (yyParser*)p; - return pParser->yyidxMax; + return pParser->yyhwm; } #endif @@ -423,7 +423,7 @@ static unsigned int yy_find_shift_action( YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; + int stateno = pParser->yytos->stateno; if( stateno>=YY_MIN_REDUCE ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); @@ -516,13 +516,13 @@ static int yy_find_reduce_action( */ static void yyStackOverflow(yyParser *yypParser){ ParseARG_FETCH; - yypParser->yyidx--; + yypParser->yytos--; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ @@ -539,11 +539,11 @@ static void yyTraceShift(yyParser *yypParser, int yyNewState){ if( yyTraceFILE ){ if( yyNewStateyystack[yypParser->yyidx].major], + yyTracePrompt,yyTokenName[yypParser->yytos->major], yyNewState); }else{ fprintf(yyTraceFILE,"%sShift '%s'\n", - yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]); + yyTracePrompt,yyTokenName[yypParser->yytos->major]); } } } @@ -561,27 +561,28 @@ static void yy_shift( ParseTOKENTYPE yyMinor /* The minor token to shift in */ ){ yyStackEntry *yytos; - yypParser->yyidx++; + yypParser->yytos++; #ifdef YYTRACKMAXSTACKDEPTH - if( yypParser->yyidx>yypParser->yyidxMax ){ - yypParser->yyidxMax = yypParser->yyidx; + if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) ); } #endif #if YYSTACKDEPTH>0 - if( yypParser->yyidx>=YYSTACKDEPTH ){ + if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){ yyStackOverflow(yypParser); return; } #else - if( yypParser->yyidx>=yypParser->yystksz ){ + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ yyGrowStack(yypParser); - if( yypParser->yyidx>=yypParser->yystksz ){ + if( yypParser->yytos>=&yypParser->yystach[yypParser->yystksz] ){ yyStackOverflow(yypParser); return; } } #endif - yytos = &yypParser->yystack[yypParser->yyidx]; + yytos = yypParser->yytos; yytos->stateno = (YYACTIONTYPE)yyNewState; yytos->major = (YYCODETYPE)yyMajor; yytos->minor.yy0 = yyMinor; @@ -613,7 +614,7 @@ static void yy_reduce( yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; - yymsp = &yypParser->yystack[yypParser->yyidx]; + yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; @@ -627,19 +628,20 @@ static void yy_reduce( ** enough on the stack to push the LHS value */ if( yyRuleInfo[yyruleno].nrhs==0 ){ #ifdef YYTRACKMAXSTACKDEPTH - if( yypParser->yyidx>yypParser->yyidxMax ){ - yypParser->yyidxMax = yypParser->yyidx; + if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); } #endif #if YYSTACKDEPTH>0 - if( yypParser->yyidx>=YYSTACKDEPTH-1 ){ + if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){ yyStackOverflow(yypParser); return; } #else - if( yypParser->yyidx>=yypParser->yystksz-1 ){ + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ yyGrowStack(yypParser); - if( yypParser->yyidx>=yypParser->yystksz-1 ){ + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ yyStackOverflow(yypParser); return; } @@ -665,15 +667,17 @@ static void yy_reduce( yysize = yyRuleInfo[yyruleno].nrhs; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact <= YY_MAX_SHIFTREDUCE ){ - if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; - yypParser->yyidx -= yysize - 1; + if( yyact>YY_MAX_SHIFT ){ + yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; + } yymsp -= yysize-1; + yypParser->yytos = yymsp; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact); }else{ assert( yyact == YY_ACCEPT_ACTION ); - yypParser->yyidx -= yysize; + yypParser->yytos -= yysize; yy_accept(yypParser); } } @@ -691,7 +695,8 @@ static void yy_parse_failed( fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); } #endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); + yypParser->yytos = 0; /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ @@ -729,7 +734,8 @@ static void yy_accept( fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); + yypParser->yytos = 0; /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ @@ -775,14 +781,14 @@ void Parse( /* (re)initialize the parser, if necessary */ yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ + if( yypParser->yytos==0 ){ #if YYSTACKDEPTH<=0 if( yypParser->yystksz <=0 ){ yyStackOverflow(yypParser); return; } #endif - yypParser->yyidx = 0; + yypParser->yytos = yypParser->yystack; #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif @@ -809,7 +815,9 @@ void Parse( do{ yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyact <= YY_MAX_SHIFTREDUCE ){ - if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; + if( yyact > YY_MAX_SHIFT ){ + yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; + } yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; @@ -851,7 +859,7 @@ void Parse( if( yypParser->yyerrcnt<0 ){ yy_syntax_error(yypParser,yymajor,yyminor); } - yymx = yypParser->yystack[yypParser->yyidx].major; + yymx = yypParser->yytos->major; if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG if( yyTraceFILE ){ @@ -862,16 +870,15 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, + while( yypParser->yytos >= &yypParser->yystack + && yymx != YYERRORSYMBOL + && (yyact = yy_find_reduce_action( + yypParser->yytos->stateno, YYERRORSYMBOL)) >= YY_MIN_REDUCE ){ yy_pop_parser_stack(yypParser); } - if( yypParser->yyidx < 0 || yymajor==0 ){ + if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); yymajor = YYNOCODE; @@ -914,14 +921,16 @@ void Parse( yymajor = YYNOCODE; #endif } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); + }while( yymajor!=YYNOCODE && yypParser->yytos>=yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ - int i; + yyStackEntry *i; + char cDiv = '['; fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ', - yyTokenName[yypParser->yystack[i].major]); + for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){ + fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]); + cDiv = ' '; + } fprintf(yyTraceFILE,"]\n"); } #endif From abecc0b883a6afb48a14a0299dd76f39deff60f3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 May 2016 00:40:54 +0000 Subject: [PATCH 095/302] Improvements to the initialization of the push-down automoton for the Lemon-generated parser. Smaller and faster. FossilOrigin-Name: 3b28b68e232060f8b2fe2fe6fa478280da2006ff --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 41 +++++++++++++---------------------------- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index 8f4a53f747..2f83cec788 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\spointer\sto\sthe\stop\sof\sthe\sstack\srather\sthan\san\sindex\sinto\sthe\sstack\nin\sthe\sLemon-generated\sparser\stemplate,\sfor\sabout\s6.6%\sparser\sperformance\sgain. -D 2016-05-23T21:56:24.427 +C Improvements\sto\sthe\sinitialization\sof\sthe\spush-down\sautomoton\sfor\sthe\nLemon-generated\sparser.\s\sSmaller\sand\sfaster. +D 2016-05-24T00:40:54.799 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1422,7 +1422,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39 -F tool/lempar.c 872383ebf36c13fdaff0f3692d4ff60e64ec49e2 +F tool/lempar.c 8569dd3e4c22831e08e441ab7a0eb6bbefa1d38a F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 @@ -1493,7 +1493,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 276e92f5b4c1ee49eabb738b24d73d7af90fb13c -R f3a217ca3fc6adf56f5cf5443069e03b +P 3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68 +R f0cfba4e984837df73820e425fc5291f U drh -Z babb89b922e84c6e93d4048989d7622c +Z 2da99ff99cbfd3def15eb678236b100e diff --git a/manifest.uuid b/manifest.uuid index 9a4a91d8af..0635c8e250 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68 \ No newline at end of file +3b28b68e232060f8b2fe2fe6fa478280da2006ff \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index b02fd21b77..7fb5fe2d0c 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -275,12 +275,15 @@ static const char *const yyRuleName[] = { */ static void yyGrowStack(yyParser *p){ int newSize; + int idx; yyStackEntry *pNew; newSize = p->yystksz*2 + 100; + idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); if( pNew ){ p->yystack = pNew; + p->yytos = &p->yystack[idx]; p->yystksz = newSize; #ifndef NDEBUG if( yyTraceFILE ){ @@ -317,15 +320,18 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( pParser ){ - pParser->yytos = 0; #ifdef YYTRACKMAXSTACKDEPTH pParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 + pParser->yytos = NULL; pParser->yystack = NULL; pParser->yystksz = 0; yyGrowStack(pParser); #endif + pParser->yytos = pParser->yystack; + pParser->yystack[0].stateno = 0; + pParser->yystack[0].major = 0; } return pParser; } @@ -397,7 +403,7 @@ void ParseFree( #ifndef YYPARSEFREENEVERNULL if( pParser==0 ) return; #endif - while( pParser->yytos>=pParser->yystack ) yy_pop_parser_stack(pParser); + while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 free(pParser->yystack); #endif @@ -522,7 +528,7 @@ static void yyStackOverflow(yyParser *yypParser){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif - while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); + while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ @@ -695,8 +701,7 @@ static void yy_parse_failed( fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); } #endif - while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); - yypParser->yytos = 0; + while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ @@ -734,8 +739,7 @@ static void yy_accept( fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif - while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); - yypParser->yytos = 0; + while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ @@ -781,26 +785,7 @@ void Parse( /* (re)initialize the parser, if necessary */ yypParser = (yyParser*)yyp; - if( yypParser->yytos==0 ){ -#if YYSTACKDEPTH<=0 - if( yypParser->yystksz <=0 ){ - yyStackOverflow(yypParser); - return; - } -#endif - yypParser->yytos = yypParser->yystack; -#ifndef YYNOERRORRECOVERY - yypParser->yyerrcnt = -1; -#endif - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n", - yyTracePrompt); - } -#endif - } + assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif @@ -921,7 +906,7 @@ void Parse( yymajor = YYNOCODE; #endif } - }while( yymajor!=YYNOCODE && yypParser->yytos>=yypParser->yystack ); + }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; From fe912510ea1f383574f06919047884617e2d517c Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 24 May 2016 16:20:51 +0000 Subject: [PATCH 096/302] Fix an obscure problem with transactions written in "PRAGMA synchronous=full" mode on systems that do not support POWERSAFE_OVERWRITE causing an xSync() call to be omitted if the last frame written by a transaction is aligned to a sector boundary. This means that if a power failure or OS crash occurs very soon after such a transaction is committed, it may be lost following system recovery. FossilOrigin-Name: 37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80 --- manifest | 17 +++++----- manifest.uuid | 2 +- src/test6.c | 26 +++++++++++++++- src/wal.c | 7 ++++- test/walcrash4.test | 75 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 test/walcrash4.test diff --git a/manifest b/manifest index 2f83cec788..f15691dac1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sinitialization\sof\sthe\spush-down\sautomoton\sfor\sthe\nLemon-generated\sparser.\s\sSmaller\sand\sfaster. -D 2016-05-24T00:40:54.799 +C Fix\san\sobscure\sproblem\swith\stransactions\swritten\sin\s"PRAGMA\ssynchronous=full"\smode\son\ssystems\sthat\sdo\snot\ssupport\sPOWERSAFE_OVERWRITE\scausing\san\sxSync()\scall\sto\sbe\somitted\sif\sthe\slast\sframe\swritten\sby\sa\stransaction\sis\saligned\sto\sa\ssector\sboundary.\sThis\smeans\sthat\sif\sa\spower\sfailure\sor\sOS\scrash\soccurs\svery\ssoon\safter\ssuch\sa\stransaction\sis\scommitted,\sit\smay\sbe\slost\sfollowing\ssystem\srecovery. +D 2016-05-24T16:20:51.379 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -394,7 +394,7 @@ F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c d2c9efd2985ff8f5502ffd3253156984778d77d8 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 -F src/test6.c 2c014d4977efd6107ec9eef3dfdec56ac516f824 +F src/test6.c a684b7abd01352ab50cb79c0bf727e6b3f381a3d F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 F src/test8.c fa262391d3edea6490a71bfaa8fed477ccbbac75 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -456,7 +456,7 @@ F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 F src/vtab.c ce0f2ebb589b459b32c640b33af64bfa5b29aaf8 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 -F src/wal.c 4db22ed7e77bcf672b1a685d6ddeffba8d5be302 +F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 0e54a03d11d4e99ad25528f42ff4c9a6fa7a23da @@ -1356,6 +1356,7 @@ F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af +F test/walcrash4.test 2907eaa670156daf41bb865c30a08ad13088262c F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c @@ -1493,7 +1494,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68 -R f0cfba4e984837df73820e425fc5291f -U drh -Z 2da99ff99cbfd3def15eb678236b100e +P 3b28b68e232060f8b2fe2fe6fa478280da2006ff +R 517787a46c326083f1c71f4f2bce6c10 +U dan +Z 8b1bf46b6e26241c0a55d35f24f797fc diff --git a/manifest.uuid b/manifest.uuid index 0635c8e250..374fcadf94 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b28b68e232060f8b2fe2fe6fa478280da2006ff \ No newline at end of file +37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80 \ No newline at end of file diff --git a/src/test6.c b/src/test6.c index 2a09122c6c..24fe725f78 100644 --- a/src/test6.c +++ b/src/test6.c @@ -215,7 +215,9 @@ static int writeListSync(CrashFile *pFile, int isCrash){ } #ifdef TRACE_CRASHTEST - printf("Sync %s (is %s crash)\n", pFile->zName, (isCrash?"a":"not a")); + if( pFile ){ + printf("Sync %s (is %s crash)\n", pFile->zName, (isCrash?"a":"not a")); + } #endif ppPtr = &g.pWriteList; @@ -799,6 +801,27 @@ static int processDevSymArgs( return TCL_OK; } +/* +** tclcmd: sqlite3_crash_now +** +** Simulate a crash immediately. This function does not return +** (writeListSync() calls exit(-1)). +*/ +static int crashNowCmd( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + if( objc!=1 ){ + Tcl_WrongNumArgs(interp, 1, objv, ""); + return TCL_ERROR; + } + writeListSync(0, 1); + assert( 0 ); + return TCL_OK; +} + /* ** tclcmd: sqlite_crash_enable ENABLE ** @@ -1034,6 +1057,7 @@ int Sqlitetest6_Init(Tcl_Interp *interp){ #ifndef SQLITE_OMIT_DISKIO Tcl_CreateObjCommand(interp, "sqlite3_crash_enable", crashEnableCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0); + Tcl_CreateObjCommand(interp, "sqlite3_crash_now", crashNowCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_simulate_device", devSymObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "unregister_devsim", dsUnregisterObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "register_jt_vfs", jtObjCmd, 0, 0); diff --git a/src/wal.c b/src/wal.c index 98b46be801..235d383e1a 100644 --- a/src/wal.c +++ b/src/wal.c @@ -3109,16 +3109,21 @@ int sqlite3WalFrames( ** past the sector boundary is written after the sync. */ if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){ + int bSync = 1; if( pWal->padToSectorBoundary ){ int sectorSize = sqlite3SectorSize(pWal->pWalFd); w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize; + bSync = (w.iSyncPoint==iOffset); + testcase( bSync ); while( iOffset@stdout } msg] + list $r $msg + } {1 {child process exited abnormally}} + + do_execsql_test 1.nExtra=$nExtra.i=$i.2 { + SELECT count(*) FROM t1; + PRAGMA integrity_check; + } {1 ok} + } +} + + +finish_test From f34a25a23bbf51a57c2ccbb6126eba77ecf4ae63 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 May 2016 18:50:41 +0000 Subject: [PATCH 097/302] Minor change to the walcrash4.test module so that it works when SQLITE_DEFAULT_WAL_SYNCHRONOUS is set to something other than 2. FossilOrigin-Name: 61e239bc4310eff172e1e50d51522ecc75dd997e --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/walcrash4.test | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f15691dac1..8b597e7bf2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobscure\sproblem\swith\stransactions\swritten\sin\s"PRAGMA\ssynchronous=full"\smode\son\ssystems\sthat\sdo\snot\ssupport\sPOWERSAFE_OVERWRITE\scausing\san\sxSync()\scall\sto\sbe\somitted\sif\sthe\slast\sframe\swritten\sby\sa\stransaction\sis\saligned\sto\sa\ssector\sboundary.\sThis\smeans\sthat\sif\sa\spower\sfailure\sor\sOS\scrash\soccurs\svery\ssoon\safter\ssuch\sa\stransaction\sis\scommitted,\sit\smay\sbe\slost\sfollowing\ssystem\srecovery. -D 2016-05-24T16:20:51.379 +C Minor\schange\sto\sthe\swalcrash4.test\smodule\sso\sthat\sit\sworks\swhen\nSQLITE_DEFAULT_WAL_SYNCHRONOUS\sis\sset\sto\ssomething\sother\sthan\s2. +D 2016-05-24T18:50:41.162 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1356,7 +1356,7 @@ F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af -F test/walcrash4.test 2907eaa670156daf41bb865c30a08ad13088262c +F test/walcrash4.test fa7d92ab84fe3ff409e1cda88a622545e2bc2b66 F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c @@ -1494,7 +1494,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3b28b68e232060f8b2fe2fe6fa478280da2006ff -R 517787a46c326083f1c71f4f2bce6c10 -U dan -Z 8b1bf46b6e26241c0a55d35f24f797fc +P 37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80 +R a85ab0cafd821231f355609347ddd044 +U drh +Z c6593df9e63293d2b7fb6ab3cfe0f9b0 diff --git a/manifest.uuid b/manifest.uuid index 374fcadf94..0dbb5b2cbc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80 \ No newline at end of file +61e239bc4310eff172e1e50d51522ecc75dd997e \ No newline at end of file diff --git a/test/walcrash4.test b/test/walcrash4.test index df0f12b510..d2f07730a0 100644 --- a/test/walcrash4.test +++ b/test/walcrash4.test @@ -46,6 +46,7 @@ for {set nExtra 0} {$nExtra < 10} {incr nExtra} { sqlite3_test_control_pending_byte $::sqlite_pending_byte sqlite3 db test.db -vfs crash db eval { + PRAGMA main.synchronous=FULL; BEGIN; CREATE TABLE t1(x UNIQUE); } From 756b41ebd47e2db4dab5de5ba5f57568829e0c31 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 May 2016 18:55:08 +0000 Subject: [PATCH 098/302] Enhance Lemon and the parser template so that it can once again build parsers that have no unreachable branches. FossilOrigin-Name: 41fd46e2962ba9a1e1f6867567499d1f6f5b8372 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lemon.c | 21 ++++++++++++++++++++- tool/lempar.c | 2 +- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8b597e7bf2..a229ea4a91 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\schange\sto\sthe\swalcrash4.test\smodule\sso\sthat\sit\sworks\swhen\nSQLITE_DEFAULT_WAL_SYNCHRONOUS\sis\sset\sto\ssomething\sother\sthan\s2. -D 2016-05-24T18:50:41.162 +C Enhance\sLemon\sand\sthe\sparser\stemplate\sso\sthat\sit\scan\sonce\sagain\sbuild\sparsers\nthat\shave\sno\sunreachable\sbranches. +D 2016-05-24T18:55:08.844 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1422,8 +1422,8 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39 -F tool/lempar.c 8569dd3e4c22831e08e441ab7a0eb6bbefa1d38a +F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 +F tool/lempar.c 1f69ad7531e39612915570a3d2c67a3cc1e9bbf0 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 @@ -1494,7 +1494,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 37de3eab67f12ae1ce5bc8d5e541c64fc6b1fd80 -R a85ab0cafd821231f355609347ddd044 +P 61e239bc4310eff172e1e50d51522ecc75dd997e +R 871f96c4fa63421d837cdbce37a6939a U drh -Z c6593df9e63293d2b7fb6ab3cfe0f9b0 +Z 9f1d9f44ca67035c6f1f764382efebdf diff --git a/manifest.uuid b/manifest.uuid index 0dbb5b2cbc..b7546cc298 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61e239bc4310eff172e1e50d51522ecc75dd997e \ No newline at end of file +41fd46e2962ba9a1e1f6867567499d1f6f5b8372 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index d643b341e4..5f124601db 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -294,6 +294,7 @@ struct rule { int index; /* An index number for this rule */ int iRule; /* Rule number as used in the generated tables */ Boolean canReduce; /* True if this rule is ever reduced */ + Boolean doesReduce; /* Reduce actions occur after optimization */ struct rule *nextlhs; /* Next rule with the same LHS */ struct rule *next; /* Next rule in the global list */ }; @@ -4152,6 +4153,19 @@ void ReportTable( } free(ax); + /* Mark rules that are actually used for reduce actions after all + ** optimizations have been applied + */ + for(rp=lemp->rule; rp; rp=rp->next) rp->doesReduce = LEMON_FALSE; + for(i=0; inxstate; i++){ + struct action *ap; + for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){ + if( ap->type==REDUCE || ap->type==SHIFTREDUCE ){ + ap->x.rp->doesReduce = i; + } + } + } + /* Finish rendering the constants now that the action table has ** been computed */ fprintf(out,"#define YYNSTATE %d\n",lemp->nxstate); lineno++; @@ -4443,7 +4457,12 @@ void ReportTable( assert( rp->noCode ); fprintf(out," /* (%d) ", rp->iRule); writeRuleText(out, rp); - fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++; + if( rp->doesReduce ){ + fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++; + }else{ + fprintf(out, " (OPTIMIZED OUT) */ assert(yyruleno!=%d);\n", + rp->iRule); lineno++; + } } fprintf(out," break;\n"); lineno++; tplt_xfer(lemp->name,in,out,&lineno); diff --git a/tool/lempar.c b/tool/lempar.c index 7fb5fe2d0c..91f3549f31 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -739,7 +739,7 @@ static void yy_accept( fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif - while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); + assert( yypParser->yytos==yypParser->yystack ); /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ From ce3c5011d9325adf3546505c45d40243db6e7eee Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 May 2016 18:53:39 +0000 Subject: [PATCH 099/302] Add the libvers.c tool in the tool/ subdirectory. FossilOrigin-Name: 2a41f098b2f0523b3d7e6eba6ae91cc0d30752df --- manifest | 11 ++++++----- manifest.uuid | 2 +- tool/libvers.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 tool/libvers.c diff --git a/manifest b/manifest index a229ea4a91..6e33cdaa4b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sLemon\sand\sthe\sparser\stemplate\sso\sthat\sit\scan\sonce\sagain\sbuild\sparsers\nthat\shave\sno\sunreachable\sbranches. -D 2016-05-24T18:55:08.844 +C Add\sthe\slibvers.c\stool\sin\sthe\stool/\ssubdirectory. +D 2016-05-25T18:53:39.049 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1424,6 +1424,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 F tool/lempar.c 1f69ad7531e39612915570a3d2c67a3cc1e9bbf0 +F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 @@ -1494,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 61e239bc4310eff172e1e50d51522ecc75dd997e -R 871f96c4fa63421d837cdbce37a6939a +P 41fd46e2962ba9a1e1f6867567499d1f6f5b8372 +R 871df33bb708dea5ddc1c61eb4854aa7 U drh -Z 9f1d9f44ca67035c6f1f764382efebdf +Z b20c30dd356053a2351766a3c882aef8 diff --git a/manifest.uuid b/manifest.uuid index b7546cc298..b182bd8e82 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -41fd46e2962ba9a1e1f6867567499d1f6f5b8372 \ No newline at end of file +2a41f098b2f0523b3d7e6eba6ae91cc0d30752df \ No newline at end of file diff --git a/tool/libvers.c b/tool/libvers.c new file mode 100644 index 0000000000..6911dbd07e --- /dev/null +++ b/tool/libvers.c @@ -0,0 +1,15 @@ +/* +** Compile this program against an SQLite library of unknown version +** and then run this program, and it will print out the SQLite version +** information. +*/ +#include + +extern const char *sqlite3_libversion(void); +extern const char *sqlite3_sourceid(void); + +int main(int argc, char **argv){ + printf("SQLite version %s\n", sqlite3_libversion()); + printf("SQLite source %s\n", sqlite3_sourceid()); + return 0; +} From eeb9565a3e3397340a4dc79a8b693e35cdecfb7c Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 May 2016 20:56:38 +0000 Subject: [PATCH 100/302] Add a new OP_SeekRowid opcode, that combines the functions of OP_MustBeInt and OP_NotExists. This makes the code slightly smaller and faster. FossilOrigin-Name: ffe80a1bfa014943a614fc6993c1749b9bfec4c1 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/expr.c | 3 +-- src/pragma.c | 4 +--- src/vdbe.c | 50 +++++++++++++++++++++++++++++++++++++++++++------ src/wherecode.c | 3 +-- 6 files changed, 57 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 6e33cdaa4b..88f7d0cd56 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\slibvers.c\stool\sin\sthe\stool/\ssubdirectory. -D 2016-05-25T18:53:39.049 +C Add\sa\snew\sOP_SeekRowid\sopcode,\sthat\scombines\sthe\sfunctions\sof\sOP_MustBeInt\nand\sOP_NotExists.\s\sThis\smakes\sthe\scode\sslightly\ssmaller\sand\sfaster. +D 2016-05-26T20:56:38.450 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -333,7 +333,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c 8796c0739b2ad091e6779253f62aad6e767e2be1 +F src/expr.c 81bd7d87985746313770211183e900ed1ad28381 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb F src/func.c ef4c18c8a66143413ce41a58d582d2c14ddf78e1 @@ -372,7 +372,7 @@ F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d -F src/pragma.c 9fdce031ddcb57f0f56e4a8b421b7e7a77de73b0 +F src/pragma.c d98039af2deb5a4990f6635462b3f61f325a6c75 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 @@ -445,7 +445,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c f2706d5564d2b2887a27c909e8e1575250029503 +F src/vdbe.c 45e4da739187028281e342f79fae0f4145055bec F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c @@ -461,7 +461,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 0e54a03d11d4e99ad25528f42ff4c9a6fa7a23da F src/whereInt.h 6e18240be400bef8e4dbafea605251707c5dbf49 -F src/wherecode.c e3f18fcda2d7f8218a09dc33cf495dca0efa6e3e +F src/wherecode.c ba71a4e4bada29aa9842200e6299714bf18c812c F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 41fd46e2962ba9a1e1f6867567499d1f6f5b8372 -R 871df33bb708dea5ddc1c61eb4854aa7 +P 2a41f098b2f0523b3d7e6eba6ae91cc0d30752df +R 810bd747b437c6e4e76eef1099520866 U drh -Z b20c30dd356053a2351766a3c882aef8 +Z 73ea989f24641ac606e6e6c2f5b60872 diff --git a/manifest.uuid b/manifest.uuid index b182bd8e82..9a103ac06c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a41f098b2f0523b3d7e6eba6ae91cc0d30752df \ No newline at end of file +ffe80a1bfa014943a614fc6993c1749b9bfec4c1 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 9e3b664e8d..156db96fa1 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2222,8 +2222,7 @@ static void sqlite3ExprCodeIN( if( eType==IN_INDEX_ROWID ){ /* In this case, the RHS is the ROWID of table b-tree */ - sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); VdbeCoverage(v); - sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1); + sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1); VdbeCoverage(v); }else{ /* In this case, the RHS is an index b-tree. diff --git a/src/pragma.c b/src/pragma.c index 330e999090..56823c7243 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1334,12 +1334,10 @@ void sqlite3Pragma( sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); sqlite3ColumnDefault(v, pTab, iKey, regRow); sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v); - sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow, - sqlite3VdbeCurrentAddr(v)+3); VdbeCoverage(v); }else{ sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); } - sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v); + sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v); sqlite3VdbeGoto(v, addrOk); sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); }else{ diff --git a/src/vdbe.c b/src/vdbe.c index d512c0bc74..d4392a89d9 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4023,6 +4023,30 @@ case OP_Found: { /* jump, in3 */ break; } +/* Opcode: SeekRowid P1 P2 P3 * * +** Synopsis: intkey=r[P3] +** +** P1 is the index of a cursor open on an SQL table btree (with integer +** keys). If register P3 does not contain an integer or if P1 does not +** contain a record with rowid P3 then jump immediately to P2. +** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain +** a record with rowid P3 then +** leave the cursor pointing at that record and fall through to the next +** instruction. +** +** The OP_NotExists opcode performs the same operation, but with OP_NotExists +** the P3 register must be guaranteed to contain an integer value. With this +** opcode, register P3 might not contain an integer. +** +** The OP_NotFound opcode performs the same operation on index btrees +** (with arbitrary multi-value keys). +** +** This opcode leaves the cursor in a state where it cannot be advanced +** in either direction. In other words, the Next and Prev opcodes will +** not work following this opcode. +** +** See also: Found, NotFound, NoConflict, SeekRowid +*/ /* Opcode: NotExists P1 P2 P3 * * ** Synopsis: intkey=r[P3] ** @@ -4033,6 +4057,10 @@ case OP_Found: { /* jump, in3 */ ** leave the cursor pointing at that record and fall through to the next ** instruction. ** +** The OP_SeekRowid opcode performs the same operation but also allows the +** P3 register to contain a non-integer value, in which case the jump is +** always taken. This opcode requires that P3 always contain an integer. +** ** The OP_NotFound opcode performs the same operation on index btrees ** (with arbitrary multi-value keys). ** @@ -4040,14 +4068,21 @@ case OP_Found: { /* jump, in3 */ ** in either direction. In other words, the Next and Prev opcodes will ** not work following this opcode. ** -** See also: Found, NotFound, NoConflict +** See also: Found, NotFound, NoConflict, SeekRowid */ -case OP_NotExists: { /* jump, in3 */ +case OP_SeekRowid: { /* jump, in3 */ VdbeCursor *pC; BtCursor *pCrsr; int res; u64 iKey; + pIn3 = &aMem[pOp->p3]; + if( (pIn3->flags & MEM_Int)==0 ){ + applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding); + if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2; + } + /* Fall through into OP_NotExists */ +case OP_NotExists: /* jump, in3 */ pIn3 = &aMem[pOp->p3]; assert( pIn3->flags & MEM_Int ); assert( pOp->p1>=0 && pOp->p1nCursor ); @@ -4250,10 +4285,12 @@ case OP_NewRowid: { /* out2 */ ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). ** ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of -** the last seek operation (OP_NotExists) was a success, then this +** the last seek operation (OP_NotExists or OP_SeekRowid) was a success, +** then this ** operation will not attempt to find the appropriate row before doing ** the insert but will instead overwrite the row that the cursor is -** currently pointing to. Presumably, the prior OP_NotExists opcode +** currently pointing to. Presumably, the prior OP_NotExists or +** OP_SeekRowid opcode ** has already positioned the cursor correctly. This is an optimization ** that boosts performance by avoiding redundant seeks. ** @@ -4611,8 +4648,9 @@ case OP_RowData: { pCrsr = pC->uc.pCursor; /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or - ** OP_Rewind/Op_Next with no intervening instructions that might invalidate - ** the cursor. If this where not the case, on of the following assert()s + ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions + ** that might invalidate the cursor. + ** If this where not the case, on of the following assert()s ** would fail. Should this ever change (because of changes in the code ** generator) then the fix would be to insert a call to ** sqlite3VdbeCursorMoveto(). diff --git a/src/wherecode.c b/src/wherecode.c index 054b1b1078..83ee48ac66 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -971,8 +971,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg); if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg); addrNxt = pLevel->addrNxt; - sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); VdbeCoverage(v); - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); + sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg); VdbeCoverage(v); sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); From baf254aef9bc88bc152f99422939c7482e83e1c6 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 27 May 2016 01:07:18 +0000 Subject: [PATCH 101/302] Fix the Lemon-generated parser so that it compiles with -DYYSTACKDEPTH=0. It does compile now, but there are subtle issues still. FossilOrigin-Name: 28d439f816d2fa5263e1c4ddecf3bf1ac2dd6549 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 88f7d0cd56..cfe2236da5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\sOP_SeekRowid\sopcode,\sthat\scombines\sthe\sfunctions\sof\sOP_MustBeInt\nand\sOP_NotExists.\s\sThis\smakes\sthe\scode\sslightly\ssmaller\sand\sfaster. -D 2016-05-26T20:56:38.450 +C Fix\sthe\sLemon-generated\sparser\sso\sthat\sit\scompiles\swith\s-DYYSTACKDEPTH=0.\nIt\sdoes\scompile\snow,\sbut\sthere\sare\ssubtle\sissues\sstill. +D 2016-05-27T01:07:18.565 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -1423,7 +1423,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 1f69ad7531e39612915570a3d2c67a3cc1e9bbf0 +F tool/lempar.c 7689ddc408a54f9c23e7f9e17e597752b71fa537 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2a41f098b2f0523b3d7e6eba6ae91cc0d30752df -R 810bd747b437c6e4e76eef1099520866 +P ffe80a1bfa014943a614fc6993c1749b9bfec4c1 +R 8a7f49776364e838d9d2230beef644f3 U drh -Z 73ea989f24641ac606e6e6c2f5b60872 +Z 81291c1e83b5b57f970177cd78c139d0 diff --git a/manifest.uuid b/manifest.uuid index 9a103ac06c..c2da443b16 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ffe80a1bfa014943a614fc6993c1749b9bfec4c1 \ No newline at end of file +28d439f816d2fa5263e1c4ddecf3bf1ac2dd6549 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 91f3549f31..e96d6c9e7f 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -582,7 +582,7 @@ static void yy_shift( #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ yyGrowStack(yypParser); - if( yypParser->yytos>=&yypParser->yystach[yypParser->yystksz] ){ + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ yyStackOverflow(yypParser); return; } From 8dc8247eabe32d2b866dc19e8490f04723c9f8ca Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 27 May 2016 04:10:47 +0000 Subject: [PATCH 102/302] Fix Lemon so that it actually works with -DYYSTACKDEPTH=0. FossilOrigin-Name: a9be4c2d56d08fea2cd1aab20b19092a45ef7620 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/misc5.test | 2 ++ tool/lempar.c | 34 ++++++++++++++++++++++------------ 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index cfe2236da5..fac75fe3b2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sLemon-generated\sparser\sso\sthat\sit\scompiles\swith\s-DYYSTACKDEPTH=0.\nIt\sdoes\scompile\snow,\sbut\sthere\sare\ssubtle\sissues\sstill. -D 2016-05-27T01:07:18.565 +C Fix\sLemon\sso\sthat\sit\sactually\sworks\swith\s-DYYSTACKDEPTH=0. +D 2016-05-27T04:10:47.610 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -929,7 +929,7 @@ F test/misc1.test 6430dabfb4b4fa480633590118964201f94d3ccc F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 0d8be3466adf123a7791a66ba2bc8e8d229e87f3 -F test/misc5.test f96428ea95b3820aafc6f1c50cf48a09e4597ee1 +F test/misc5.test fff0f75e834bc09a39f6079320dd8c37de956f4f F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test edd0b63e2ee29a256900b0514f6fff27e19e9bb2 F test/misc8.test 21ac9d35a5e110279ae9e1588b8914f54de1c60b @@ -1423,7 +1423,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 7689ddc408a54f9c23e7f9e17e597752b71fa537 +F tool/lempar.c f06b7e98a6b7efb404375b6f4a0c71c85faa1512 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ffe80a1bfa014943a614fc6993c1749b9bfec4c1 -R 8a7f49776364e838d9d2230beef644f3 +P 28d439f816d2fa5263e1c4ddecf3bf1ac2dd6549 +R 8847199d288118b0d192a3b11dedaea9 U drh -Z 81291c1e83b5b57f970177cd78c139d0 +Z bc76551811bb8ec7ccdce96ef01b993f diff --git a/manifest.uuid b/manifest.uuid index c2da443b16..9f517dff20 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -28d439f816d2fa5263e1c4ddecf3bf1ac2dd6549 \ No newline at end of file +a9be4c2d56d08fea2cd1aab20b19092a45ef7620 \ No newline at end of file diff --git a/test/misc5.test b/test/misc5.test index 30176b8082..0e7e34dd16 100644 --- a/test/misc5.test +++ b/test/misc5.test @@ -571,6 +571,8 @@ ifcapable subquery&&compound { # Overflow the lemon parser stack by providing an overly complex # expression. Make sure that the overflow is detected and reported. # +# This test fails when building with -DYYSTACKDEPTH=0 +# do_test misc5-7.1 { execsql {CREATE TABLE t1(x)} set sql "INSERT INTO t1 VALUES(" diff --git a/tool/lempar.c b/tool/lempar.c index e96d6c9e7f..1258c549de 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -214,6 +214,7 @@ struct yyParser { #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ + yyStackEntry yystk0; /* First stack entry */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ #endif @@ -271,27 +272,34 @@ static const char *const yyRuleName[] = { #if YYSTACKDEPTH<=0 /* -** Try to increase the size of the parser stack. +** Try to increase the size of the parser stack. Return the number +** of errors. Return 0 on success. */ -static void yyGrowStack(yyParser *p){ +static int yyGrowStack(yyParser *p){ int newSize; int idx; yyStackEntry *pNew; newSize = p->yystksz*2 + 100; idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); + if( p->yystack==&p->yystk0 ){ + pNew = malloc(newSize*sizeof(pNew[0])); + if( pNew ) pNew[0] = p->yystk0; + }else{ + pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); + } if( pNew ){ p->yystack = pNew; p->yytos = &p->yystack[idx]; - p->yystksz = newSize; #ifndef NDEBUG if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); + fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", + yyTracePrompt, p->yystksz, newSize); } #endif + p->yystksz = newSize; } + return pNew==0; } #endif @@ -327,7 +335,10 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ pParser->yytos = NULL; pParser->yystack = NULL; pParser->yystksz = 0; - yyGrowStack(pParser); + if( yyGrowStack(pParser) ){ + pParser->yystack = &pParser->yystk0; + pParser->yystksz = 1; + } #endif pParser->yytos = pParser->yystack; pParser->yystack[0].stateno = 0; @@ -405,7 +416,7 @@ void ParseFree( #endif while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 - free(pParser->yystack); + if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); #endif (*freeProc)((void*)pParser); } @@ -581,8 +592,7 @@ static void yy_shift( } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ - yyGrowStack(yypParser); - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ + if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); return; } @@ -646,11 +656,11 @@ static void yy_reduce( } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - yyGrowStack(yypParser); - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); return; } + yymsp = yypParser->yytos; } #endif } From c84a4020efa68962c186aec680f41607fe87e4bd Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 27 May 2016 12:30:20 +0000 Subject: [PATCH 103/302] Improvements to WHERE-clause debug tracing. Show TK_MATCH expressions and show more details on WhereTerm traces. FossilOrigin-Name: 71087c12bc75a82f5d1051600a442ef6efc5e899 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/treeview.c | 6 ++++++ src/where.c | 35 ++++++++++++++++++++++++++--------- src/whereInt.h | 3 +++ 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index fac75fe3b2..8c4974db29 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sLemon\sso\sthat\sit\sactually\sworks\swith\s-DYYSTACKDEPTH=0. -D 2016-05-27T04:10:47.610 +C Improvements\sto\sWHERE-clause\sdebug\stracing.\s\sShow\sTK_MATCH\sexpressions\sand\nshow\smore\sdetails\son\sWhereTerm\straces. +D 2016-05-27T12:30:20.162 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -439,7 +439,7 @@ F src/test_windirent.h b12055cab6227f7be10f5c19296f67c60cc5e2a5 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 3b29883b0ce4a6c6f643965b66b5ca6613178e59 -F src/treeview.c e4b41a37530a191579d3c53142cc44ee2eb99373 +F src/treeview.c c56d6ddbed564efda746236b35bcbb8238daac4b F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c @@ -459,8 +459,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 0e54a03d11d4e99ad25528f42ff4c9a6fa7a23da -F src/whereInt.h 6e18240be400bef8e4dbafea605251707c5dbf49 +F src/where.c b9f5b0ddb14c3827e70b5379e659cf4cfd524c4d +F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c ba71a4e4bada29aa9842200e6299714bf18c812c F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28d439f816d2fa5263e1c4ddecf3bf1ac2dd6549 -R 8847199d288118b0d192a3b11dedaea9 +P a9be4c2d56d08fea2cd1aab20b19092a45ef7620 +R 2beba98fee0a4944905820065cc75fbf U drh -Z bc76551811bb8ec7ccdce96ef01b993f +Z 8d7a3e9d02c8c2b09e27f05110ad65d3 diff --git a/manifest.uuid b/manifest.uuid index 9f517dff20..2f2802b83d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9be4c2d56d08fea2cd1aab20b19092a45ef7620 \ No newline at end of file +71087c12bc75a82f5d1051600a442ef6efc5e899 \ No newline at end of file diff --git a/src/treeview.c b/src/treeview.c index 907159c06d..27996d46d7 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -445,6 +445,12 @@ void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){ break; } #endif + case TK_MATCH: { + sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s", + pExpr->iTable, pExpr->iColumn, zFlgs); + sqlite3TreeViewExpr(pView, pExpr->pRight, 0); + break; + } default: { sqlite3TreeViewLine(pView, "op=%d", pExpr->op); break; diff --git a/src/where.c b/src/where.c index cb008b7df4..04d0b0190c 100644 --- a/src/where.c +++ b/src/where.c @@ -1648,19 +1648,41 @@ static void whereTermPrint(WhereTerm *pTerm, int iTerm){ sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm); }else{ char zType[4]; + char zLeft[50]; memcpy(zType, "...", 4); if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V'; if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E'; if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; + if( pTerm->eOperator & WO_SINGLE ){ + sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}", + pTerm->leftCursor, pTerm->u.leftColumn); + }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){ + sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld", + pTerm->u.pOrInfo->indexable); + }else{ + sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor); + } sqlite3DebugPrintf( - "TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x wtFlags=0x%04x\n", - iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb, + "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n", + iTerm, pTerm, zType, zLeft, pTerm->truthProb, pTerm->eOperator, pTerm->wtFlags); sqlite3TreeViewExpr(0, pTerm->pExpr, 0); } } #endif +#ifdef WHERETRACE_ENABLED +/* +** Show the complete content of a WhereClause +*/ +void sqlite3WhereClausePrint(WhereClause *pWC){ + int i; + for(i=0; inTerm; i++){ + whereTermPrint(&pWC->a[i], i); + } +} +#endif + #ifdef WHERETRACE_ENABLED /* ** Print a WhereLoop object for debugging purposes @@ -3124,9 +3146,7 @@ static int whereLoopAddOr( WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n", (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm)); if( sqlite3WhereTrace & 0x400 ){ - for(i=0; inTerm; i++){ - whereTermPrint(&sSubBuild.pWC->a[i], i); - } + sqlite3WhereClausePrint(sSubBuild.pWC); } #endif #ifndef SQLITE_OMIT_VIRTUALTABLE @@ -4310,10 +4330,7 @@ WhereInfo *sqlite3WhereBegin( sqlite3DebugPrintf(")\n"); } if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ - int i; - for(i=0; inTerm; i++){ - whereTermPrint(&sWLB.pWC->a[i], i); - } + sqlite3WhereClausePrint(sWLB.pWC); } #endif diff --git a/src/whereInt.h b/src/whereInt.h index ed6b198e4b..075c04e5e5 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -437,6 +437,9 @@ struct WhereInfo { ** where.c: */ Bitmask sqlite3WhereGetMask(WhereMaskSet*,int); +#ifdef WHERETRACE_ENABLED +void sqlite3WhereClausePrint(WhereClause *pWC); +#endif WhereTerm *sqlite3WhereFindTerm( WhereClause *pWC, /* The WHERE clause to be searched */ int iCur, /* Cursor number of LHS */ From 15e2ddeab3c81cbe20c43cdb9643a2e1ca62b874 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 May 2016 18:09:45 +0000 Subject: [PATCH 104/302] Add basic compiler information to the results of 'PRAGMA compile_options'. FossilOrigin-Name: d734e2df40d95da74ce0c8dd2da1c14033cad8bb --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/ctime.c | 7 +++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8c4974db29..970b987929 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sWHERE-clause\sdebug\stracing.\s\sShow\sTK_MATCH\sexpressions\sand\nshow\smore\sdetails\son\sWhereTerm\straces. -D 2016-05-27T12:30:20.162 +C Add\sbasic\scompiler\sinformation\sto\sthe\sresults\sof\s'PRAGMA\scompile_options'. +D 2016-05-27T18:09:45.039 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -329,7 +329,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 +F src/ctime.c dc03a31584045e0d7ee62659416c557bc35c679e F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1495,7 +1495,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a9be4c2d56d08fea2cd1aab20b19092a45ef7620 -R 2beba98fee0a4944905820065cc75fbf -U drh -Z 8d7a3e9d02c8c2b09e27f05110ad65d3 +P 71087c12bc75a82f5d1051600a442ef6efc5e899 +R 5414a76b2e5839d41b19cee14a1187ef +T *branch * ctimeCompiler +T *sym-ctimeCompiler * +T -sym-trunk * +U mistachkin +Z 2c1781ffb1db3ba053f96360f37bbb14 diff --git a/manifest.uuid b/manifest.uuid index 2f2802b83d..bf8c366494 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -71087c12bc75a82f5d1051600a442ef6efc5e899 \ No newline at end of file +d734e2df40d95da74ce0c8dd2da1c14033cad8bb \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index f1bb69c16a..f91615f44a 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -45,6 +45,13 @@ static const char * const azCompileOpt[] = { #if SQLITE_CHECK_PAGES "CHECK_PAGES", #endif +#if defined(_MSC_VER) + "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), +#elif defined(__GNUC__) && defined(__VERSION__) + "COMPILER=gcc-" CTIMEOPT_VAL(__VERSION__), +#elif defined(__clang__) && defined(__clang_version__) + "COMPILER=clang-" CTIMEOPT_VAL(__clang_version__), +#endif #if SQLITE_COVERAGE_TEST "COVERAGE_TEST", #endif From 2b9672e998099c1c7fd96e8b0f621f61cd85cc31 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 27 May 2016 19:34:29 +0000 Subject: [PATCH 105/302] Remove surplus quotation marks from the COMPILER= compile_options setting for GCC. FossilOrigin-Name: 664c132dabe4a871d5c39c11b339f871ca3a5d31 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/ctime.c | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 970b987929..6dcca4db34 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sbasic\scompiler\sinformation\sto\sthe\sresults\sof\s'PRAGMA\scompile_options'. -D 2016-05-27T18:09:45.039 +C Remove\ssurplus\squotation\smarks\sfrom\sthe\sCOMPILER=\scompile_options\ssetting\nfor\sGCC. +D 2016-05-27T19:34:29.738 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -329,7 +329,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c dc03a31584045e0d7ee62659416c557bc35c679e +F src/ctime.c 7d735d9700670e61f415f0874cee3888515b94db F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1495,10 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71087c12bc75a82f5d1051600a442ef6efc5e899 -R 5414a76b2e5839d41b19cee14a1187ef -T *branch * ctimeCompiler -T *sym-ctimeCompiler * -T -sym-trunk * -U mistachkin -Z 2c1781ffb1db3ba053f96360f37bbb14 +P d734e2df40d95da74ce0c8dd2da1c14033cad8bb +R ee122ac8c0e3fee0c343c143c0eaf533 +U drh +Z 748a461f334251e4f63154f77f6b9c4a diff --git a/manifest.uuid b/manifest.uuid index bf8c366494..3464a2a6e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d734e2df40d95da74ce0c8dd2da1c14033cad8bb \ No newline at end of file +664c132dabe4a871d5c39c11b339f871ca3a5d31 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index f91615f44a..0fc1c4cd0c 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -48,7 +48,7 @@ static const char * const azCompileOpt[] = { #if defined(_MSC_VER) "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), #elif defined(__GNUC__) && defined(__VERSION__) - "COMPILER=gcc-" CTIMEOPT_VAL(__VERSION__), + "COMPILER=gcc-" __VERSION__, #elif defined(__clang__) && defined(__clang_version__) "COMPILER=clang-" CTIMEOPT_VAL(__clang_version__), #endif From 756e09c338a73c807506ce4b4c4e391cb5b69b1e Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 May 2016 20:30:02 +0000 Subject: [PATCH 106/302] Remove surplus quotation marks from the COMPILER= compile_options setting for Clang. FossilOrigin-Name: 5c966f200018043f5258eb03e043bb25c7766131 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/ctime.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6dcca4db34..6b25a7bcf8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssurplus\squotation\smarks\sfrom\sthe\sCOMPILER=\scompile_options\ssetting\nfor\sGCC. -D 2016-05-27T19:34:29.738 +C Remove\ssurplus\squotation\smarks\sfrom\sthe\sCOMPILER=\scompile_options\ssetting\sfor\sClang. +D 2016-05-27T20:30:02.032 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -329,7 +329,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 7d735d9700670e61f415f0874cee3888515b94db +F src/ctime.c 5fffce9c220c2694bdefcc5297d77f14266370b8 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d734e2df40d95da74ce0c8dd2da1c14033cad8bb -R ee122ac8c0e3fee0c343c143c0eaf533 -U drh -Z 748a461f334251e4f63154f77f6b9c4a +P 664c132dabe4a871d5c39c11b339f871ca3a5d31 +R c95d80b350856738e8dbac827a63287b +U mistachkin +Z 5ee041c65db3cfb46a182fca07281d4b diff --git a/manifest.uuid b/manifest.uuid index 3464a2a6e1..aeff037a85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -664c132dabe4a871d5c39c11b339f871ca3a5d31 \ No newline at end of file +5c966f200018043f5258eb03e043bb25c7766131 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 0fc1c4cd0c..a39917af99 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -50,7 +50,7 @@ static const char * const azCompileOpt[] = { #elif defined(__GNUC__) && defined(__VERSION__) "COMPILER=gcc-" __VERSION__, #elif defined(__clang__) && defined(__clang_version__) - "COMPILER=clang-" CTIMEOPT_VAL(__clang_version__), + "COMPILER=clang-" __clang_version__, #endif #if SQLITE_COVERAGE_TEST "COVERAGE_TEST", From 7ce6cdd51511feeaa45b02451424f64bfabadd50 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 May 2016 21:13:43 +0000 Subject: [PATCH 107/302] Check for Clang before GCC. FossilOrigin-Name: 7c2cd4b05f88a759bdf72d3a249db5984fd7105d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/ctime.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6b25a7bcf8..43de9fbb03 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\ssurplus\squotation\smarks\sfrom\sthe\sCOMPILER=\scompile_options\ssetting\sfor\sClang. -D 2016-05-27T20:30:02.032 +C Check\sfor\sClang\sbefore\sGCC. +D 2016-05-27T21:13:43.995 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -329,7 +329,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 5fffce9c220c2694bdefcc5297d77f14266370b8 +F src/ctime.c 89ae9d9959010022a14bb36dea1b360da760b092 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 664c132dabe4a871d5c39c11b339f871ca3a5d31 -R c95d80b350856738e8dbac827a63287b +P 5c966f200018043f5258eb03e043bb25c7766131 +R f374868f610dd3d0429b813be905b071 U mistachkin -Z 5ee041c65db3cfb46a182fca07281d4b +Z 313307f37a580f7772d82428c7123b20 diff --git a/manifest.uuid b/manifest.uuid index aeff037a85..41c0c8e659 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5c966f200018043f5258eb03e043bb25c7766131 \ No newline at end of file +7c2cd4b05f88a759bdf72d3a249db5984fd7105d \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index a39917af99..b33d803ba2 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -47,10 +47,10 @@ static const char * const azCompileOpt[] = { #endif #if defined(_MSC_VER) "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), -#elif defined(__GNUC__) && defined(__VERSION__) - "COMPILER=gcc-" __VERSION__, #elif defined(__clang__) && defined(__clang_version__) "COMPILER=clang-" __clang_version__, +#elif defined(__GNUC__) && defined(__VERSION__) + "COMPILER=gcc-" __VERSION__, #endif #if SQLITE_COVERAGE_TEST "COVERAGE_TEST", From f35b8f83697d5dfbaab607f1cef7be738fdbaec0 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 28 May 2016 00:13:21 +0000 Subject: [PATCH 108/302] Clang can define _MSC_VER in some circumstances; therefore, check for Clang first. FossilOrigin-Name: 3f710bc3617691fa7432a24f1410d4651ca181b6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/ctime.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 43de9fbb03..b6da3f6920 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Check\sfor\sClang\sbefore\sGCC. -D 2016-05-27T21:13:43.995 +C Clang\scan\sdefine\s_MSC_VER\sin\ssome\scircumstances;\stherefore,\scheck\sfor\sClang\sfirst. +D 2016-05-28T00:13:21.036 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -329,7 +329,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 89ae9d9959010022a14bb36dea1b360da760b092 +F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1495,7 +1495,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5c966f200018043f5258eb03e043bb25c7766131 -R f374868f610dd3d0429b813be905b071 +P 7c2cd4b05f88a759bdf72d3a249db5984fd7105d +R 49f2ff6c03dd42bcf8b96859a75667c2 U mistachkin -Z 313307f37a580f7772d82428c7123b20 +Z 7fd0da57a78dfad092dddeef636c580c diff --git a/manifest.uuid b/manifest.uuid index 41c0c8e659..5f707fe176 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c2cd4b05f88a759bdf72d3a249db5984fd7105d \ No newline at end of file +3f710bc3617691fa7432a24f1410d4651ca181b6 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index b33d803ba2..589cabc1ab 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -45,10 +45,10 @@ static const char * const azCompileOpt[] = { #if SQLITE_CHECK_PAGES "CHECK_PAGES", #endif -#if defined(_MSC_VER) - "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), -#elif defined(__clang__) && defined(__clang_version__) +#if defined(__clang__) && defined(__clang_version__) "COMPILER=clang-" __clang_version__, +#elif defined(_MSC_VER) + "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), #elif defined(__GNUC__) && defined(__VERSION__) "COMPILER=gcc-" __VERSION__, #endif From 3c40ae7d3aa982d7f389be43ce11263219dfe1ea Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 May 2016 14:53:48 +0000 Subject: [PATCH 109/302] Add the vfsstat.c loadable extension - a VFS shim that measures the amount of I/O, and an eponymous virtual table that is used to extract and view the measurements. FossilOrigin-Name: 0987487dd4ebfcf66ddeec8ceca47775216a0887 --- ext/misc/vfsstat.c | 819 +++++++++++++++++++++++++++++++++++++++++++++ manifest | 11 +- manifest.uuid | 2 +- 3 files changed, 826 insertions(+), 6 deletions(-) create mode 100644 ext/misc/vfsstat.c diff --git a/ext/misc/vfsstat.c b/ext/misc/vfsstat.c new file mode 100644 index 0000000000..e519de6341 --- /dev/null +++ b/ext/misc/vfsstat.c @@ -0,0 +1,819 @@ +/* +** 2016-05-27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains the implementation of an SQLite vfs shim that +** tracks I/O. Access to the accumulated status counts is provided using +** an eponymous virtual table. +*/ +#include +SQLITE_EXTENSION_INIT1 + +/* +** This module contains code for a wrapper VFS that cause stats for +** most VFS calls to be recorded. +** +** To use this module, first compile it as a loadable extension. See +** https://www.sqlite.org/loadext.html#build for compilations instructions. +** +** After compliing, load this extension, then open database connections to be +** measured. Query usages status using the vfsstat virtual table: +** +** SELECT * FROM vfsstat; +** +** Reset counters using UPDATE statements against vfsstat: +** +** UPDATE vfsstat SET count=0; +** +** EXAMPLE SCRIPT: +** +** .load ./vfsstat +** .open test.db +** DROP TABLE IF EXISTS t1; +** CREATE TABLE t1(x,y); +** INSERT INTO t1 VALUES(123, randomblob(5000)); +** CREATE INDEX t1x ON t1(x); +** DROP TABLE t1; +** VACUUM; +** SELECT * FROM vfsstat WHERE count>0; +** +** LIMITATIONS: +** +** This module increments counters without using mutex protection. So if +** two or more threads try to use this module at the same time, race conditions +** may occur which mess up the counts. This is harmless, other than giving +** incorrect statistics. +*/ +#include +#include +#include + +/* +** File types +*/ +#define VFSSTAT_MAIN 0 /* Main database file */ +#define VFSSTAT_JOURNAL 1 /* Rollback journal */ +#define VFSSTAT_WAL 2 /* Write-ahead log file */ +#define VFSSTAT_MASTERJRNL 3 /* Master journal */ +#define VFSSTAT_SUBJRNL 4 /* Subjournal */ +#define VFSSTAT_TEMPDB 5 /* TEMP database */ +#define VFSSTAT_TEMPJRNL 6 /* Journal for TEMP database */ +#define VFSSTAT_TRANSIENT 7 /* Transient database */ +#define VFSSTAT_ANY 8 /* Unspecified file type */ +#define VFSSTAT_nFile 9 /* This many file types */ + +/* Names of the file types. These are allowed values for the +** first column of the vfsstat virtual table. +*/ +static const char *azFile[] = { + "database", "journal", "wal", "master-journal", "sub-journal", + "temp-database", "temp-journal", "transient-db", "*" +}; + +/* +** Stat types +*/ +#define VFSSTAT_BYTESIN 0 /* Bytes read in */ +#define VFSSTAT_BYTESOUT 1 /* Bytes written out */ +#define VFSSTAT_READ 2 /* Read requests */ +#define VFSSTAT_WRITE 3 /* Write requests */ +#define VFSSTAT_SYNC 4 /* Syncs */ +#define VFSSTAT_OPEN 5 /* File opens */ +#define VFSSTAT_LOCK 6 /* Lock requests */ +#define VFSSTAT_ACCESS 0 /* xAccess calls. filetype==ANY only */ +#define VFSSTAT_DELETE 1 /* xDelete calls. filetype==ANY only */ +#define VFSSTAT_FULLPATH 2 /* xFullPathname calls. ANY only */ +#define VFSSTAT_RANDOM 3 /* xRandomness calls. ANY only */ +#define VFSSTAT_SLEEP 4 /* xSleep calls. ANY only */ +#define VFSSTAT_CURTIME 5 /* xCurrentTime calls. ANY only */ +#define VFSSTAT_nStat 7 /* This many stat types */ + + +/* Names for the second column of the vfsstat virtual table for all +** cases except when the first column is "*" or VFSSTAT_ANY. */ +static const char *azStat[] = { + "bytes-in", "bytes-out", "read", "write", "sync", "open", "lock", +}; +static const char *azStatAny[] = { + "access", "delete", "fullpathname", "randomness", "sleep", "currenttimestamp", + "not-used" +}; + +/* Total number of counters */ +#define VFSSTAT_MXCNT (VFSSTAT_nStat*VFSSTAT_nFile) + +/* +** Performance stats are collected in an instance of the following +** global array. +*/ +static sqlite3_uint64 aVfsCnt[VFSSTAT_MXCNT]; + +/* +** Access to a specific counter +*/ +#define STATCNT(filetype,stat) (aVfsCnt[(filetype)*VFSSTAT_nStat+(stat)]) + +/* +** Forward declaration of objects used by this utility +*/ +typedef struct VStatVfs VStatVfs; +typedef struct VStatFile VStatFile; + +/* An instance of the VFS */ +struct VStatVfs { + sqlite3_vfs base; /* VFS methods */ + sqlite3_vfs *pVfs; /* Parent VFS */ +}; + +/* An open file */ +struct VStatFile { + sqlite3_file base; /* IO methods */ + sqlite3_file *pReal; /* Underlying file handle */ + unsigned char eFiletype; /* What type of file is this */ +}; + +#define REALVFS(p) (((VStatVfs*)(p))->pVfs) + +/* +** Methods for VStatFile +*/ +static int vstatClose(sqlite3_file*); +static int vstatRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); +static int vstatWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst); +static int vstatTruncate(sqlite3_file*, sqlite3_int64 size); +static int vstatSync(sqlite3_file*, int flags); +static int vstatFileSize(sqlite3_file*, sqlite3_int64 *pSize); +static int vstatLock(sqlite3_file*, int); +static int vstatUnlock(sqlite3_file*, int); +static int vstatCheckReservedLock(sqlite3_file*, int *pResOut); +static int vstatFileControl(sqlite3_file*, int op, void *pArg); +static int vstatSectorSize(sqlite3_file*); +static int vstatDeviceCharacteristics(sqlite3_file*); +static int vstatShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**); +static int vstatShmLock(sqlite3_file*, int offset, int n, int flags); +static void vstatShmBarrier(sqlite3_file*); +static int vstatShmUnmap(sqlite3_file*, int deleteFlag); +static int vstatFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); +static int vstatUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p); + +/* +** Methods for VStatVfs +*/ +static int vstatOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *); +static int vstatDelete(sqlite3_vfs*, const char *zName, int syncDir); +static int vstatAccess(sqlite3_vfs*, const char *zName, int flags, int *); +static int vstatFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut); +static void *vstatDlOpen(sqlite3_vfs*, const char *zFilename); +static void vstatDlError(sqlite3_vfs*, int nByte, char *zErrMsg); +static void (*vstatDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void); +static void vstatDlClose(sqlite3_vfs*, void*); +static int vstatRandomness(sqlite3_vfs*, int nByte, char *zOut); +static int vstatSleep(sqlite3_vfs*, int microseconds); +static int vstatCurrentTime(sqlite3_vfs*, double*); +static int vstatGetLastError(sqlite3_vfs*, int, char *); +static int vstatCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); + +static VStatVfs vstat_vfs = { + { + 2, /* iVersion */ + 0, /* szOsFile (set by register_vstat()) */ + 1024, /* mxPathname */ + 0, /* pNext */ + "vfslog", /* zName */ + 0, /* pAppData */ + vstatOpen, /* xOpen */ + vstatDelete, /* xDelete */ + vstatAccess, /* xAccess */ + vstatFullPathname, /* xFullPathname */ + vstatDlOpen, /* xDlOpen */ + vstatDlError, /* xDlError */ + vstatDlSym, /* xDlSym */ + vstatDlClose, /* xDlClose */ + vstatRandomness, /* xRandomness */ + vstatSleep, /* xSleep */ + vstatCurrentTime, /* xCurrentTime */ + vstatGetLastError, /* xGetLastError */ + vstatCurrentTimeInt64 /* xCurrentTimeInt64 */ + }, + 0 +}; + +static const sqlite3_io_methods vstat_io_methods = { + 3, /* iVersion */ + vstatClose, /* xClose */ + vstatRead, /* xRead */ + vstatWrite, /* xWrite */ + vstatTruncate, /* xTruncate */ + vstatSync, /* xSync */ + vstatFileSize, /* xFileSize */ + vstatLock, /* xLock */ + vstatUnlock, /* xUnlock */ + vstatCheckReservedLock, /* xCheckReservedLock */ + vstatFileControl, /* xFileControl */ + vstatSectorSize, /* xSectorSize */ + vstatDeviceCharacteristics, /* xDeviceCharacteristics */ + vstatShmMap, /* xShmMap */ + vstatShmLock, /* xShmLock */ + vstatShmBarrier, /* xShmBarrier */ + vstatShmUnmap, /* xShmUnmap */ + vstatFetch, /* xFetch */ + vstatUnfetch /* xUnfetch */ +}; + + + +/* +** Close an vstat-file. +*/ +static int vstatClose(sqlite3_file *pFile){ + VStatFile *p = (VStatFile *)pFile; + int rc = SQLITE_OK; + + if( p->pReal->pMethods ){ + rc = p->pReal->pMethods->xClose(p->pReal); + } + return rc; +} + + +/* +** Read data from an vstat-file. +*/ +static int vstatRead( + sqlite3_file *pFile, + void *zBuf, + int iAmt, + sqlite_int64 iOfst +){ + int rc; + VStatFile *p = (VStatFile *)pFile; + + rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst); + STATCNT(p->eFiletype,VFSSTAT_READ)++; + if( rc==SQLITE_OK ){ + STATCNT(p->eFiletype,VFSSTAT_BYTESIN) += iAmt; + } + return rc; +} + +/* +** Write data to an vstat-file. +*/ +static int vstatWrite( + sqlite3_file *pFile, + const void *z, + int iAmt, + sqlite_int64 iOfst +){ + int rc; + VStatFile *p = (VStatFile *)pFile; + + rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst); + STATCNT(p->eFiletype,VFSSTAT_WRITE)++; + if( rc==SQLITE_OK ){ + STATCNT(p->eFiletype,VFSSTAT_BYTESOUT) += iAmt; + } + return rc; +} + +/* +** Truncate an vstat-file. +*/ +static int vstatTruncate(sqlite3_file *pFile, sqlite_int64 size){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xTruncate(p->pReal, size); + return rc; +} + +/* +** Sync an vstat-file. +*/ +static int vstatSync(sqlite3_file *pFile, int flags){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xSync(p->pReal, flags); + STATCNT(p->eFiletype,VFSSTAT_SYNC)++; + return rc; +} + +/* +** Return the current file-size of an vstat-file. +*/ +static int vstatFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xFileSize(p->pReal, pSize); + return rc; +} + +/* +** Lock an vstat-file. +*/ +static int vstatLock(sqlite3_file *pFile, int eLock){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xLock(p->pReal, eLock); + STATCNT(p->eFiletype,VFSSTAT_LOCK)++; + return rc; +} + +/* +** Unlock an vstat-file. +*/ +static int vstatUnlock(sqlite3_file *pFile, int eLock){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xUnlock(p->pReal, eLock); + STATCNT(p->eFiletype,VFSSTAT_LOCK)++; + return rc; +} + +/* +** Check if another file-handle holds a RESERVED lock on an vstat-file. +*/ +static int vstatCheckReservedLock(sqlite3_file *pFile, int *pResOut){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut); + STATCNT(p->eFiletype,VFSSTAT_LOCK)++; + return rc; +} + +/* +** File control method. For custom operations on an vstat-file. +*/ +static int vstatFileControl(sqlite3_file *pFile, int op, void *pArg){ + VStatFile *p = (VStatFile *)pFile; + int rc; + rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg); + if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){ + *(char**)pArg = sqlite3_mprintf("vstat/%z", *(char**)pArg); + } + return rc; +} + +/* +** Return the sector-size in bytes for an vstat-file. +*/ +static int vstatSectorSize(sqlite3_file *pFile){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xSectorSize(p->pReal); + return rc; +} + +/* +** Return the device characteristic flags supported by an vstat-file. +*/ +static int vstatDeviceCharacteristics(sqlite3_file *pFile){ + int rc; + VStatFile *p = (VStatFile *)pFile; + rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal); + return rc; +} + +/* Create a shared memory file mapping */ +static int vstatShmMap( + sqlite3_file *pFile, + int iPg, + int pgsz, + int bExtend, + void volatile **pp +){ + VStatFile *p = (VStatFile *)pFile; + return p->pReal->pMethods->xShmMap(p->pReal, iPg, pgsz, bExtend, pp); +} + +/* Perform locking on a shared-memory segment */ +static int vstatShmLock(sqlite3_file *pFile, int offset, int n, int flags){ + VStatFile *p = (VStatFile *)pFile; + return p->pReal->pMethods->xShmLock(p->pReal, offset, n, flags); +} + +/* Memory barrier operation on shared memory */ +static void vstatShmBarrier(sqlite3_file *pFile){ + VStatFile *p = (VStatFile *)pFile; + return p->pReal->pMethods->xShmBarrier(p->pReal); +} + +/* Unmap a shared memory segment */ +static int vstatShmUnmap(sqlite3_file *pFile, int deleteFlag){ + VStatFile *p = (VStatFile *)pFile; + return p->pReal->pMethods->xShmUnmap(p->pReal, deleteFlag); +} + +/* Fetch a page of a memory-mapped file */ +static int vstatFetch( + sqlite3_file *pFile, + sqlite3_int64 iOfst, + int iAmt, + void **pp +){ + VStatFile *p = (VStatFile *)pFile; + return p->pReal->pMethods->xFetch(p->pReal, iOfst, iAmt, pp); +} + +/* Release a memory-mapped page */ +static int vstatUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ + VStatFile *p = (VStatFile *)pFile; + return p->pReal->pMethods->xUnfetch(p->pReal, iOfst, pPage); +} + +/* +** Open an vstat file handle. +*/ +static int vstatOpen( + sqlite3_vfs *pVfs, + const char *zName, + sqlite3_file *pFile, + int flags, + int *pOutFlags +){ + int rc; + VStatFile *p = (VStatFile*)pFile; + + p->pReal = (sqlite3_file*)&p[1]; + rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags); + if( flags & SQLITE_OPEN_MAIN_DB ){ + p->eFiletype = VFSSTAT_MAIN; + }else if( flags & SQLITE_OPEN_MAIN_JOURNAL ){ + p->eFiletype = VFSSTAT_JOURNAL; + }else if( flags & SQLITE_OPEN_WAL ){ + p->eFiletype = VFSSTAT_WAL; + }else if( flags & SQLITE_OPEN_MASTER_JOURNAL ){ + p->eFiletype = VFSSTAT_MASTERJRNL; + }else if( flags & SQLITE_OPEN_SUBJOURNAL ){ + p->eFiletype = VFSSTAT_SUBJRNL; + }else if( flags & SQLITE_OPEN_TEMP_DB ){ + p->eFiletype = VFSSTAT_TEMPDB; + }else if( flags & SQLITE_OPEN_TEMP_JOURNAL ){ + p->eFiletype = VFSSTAT_TEMPJRNL; + }else{ + p->eFiletype = VFSSTAT_TRANSIENT; + } + STATCNT(p->eFiletype,VFSSTAT_OPEN)++; + pFile->pMethods = rc ? 0 : &vstat_io_methods; + return rc; +} + +/* +** Delete the file located at zPath. If the dirSync argument is true, +** ensure the file-system modifications are synced to disk before +** returning. +*/ +static int vstatDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ + int rc; + rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync); + STATCNT(VFSSTAT_ANY,VFSSTAT_DELETE)++; + return rc; +} + +/* +** Test for access permissions. Return true if the requested permission +** is available, or false otherwise. +*/ +static int vstatAccess( + sqlite3_vfs *pVfs, + const char *zPath, + int flags, + int *pResOut +){ + int rc; + rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut); + STATCNT(VFSSTAT_ANY,VFSSTAT_ACCESS)++; + return rc; +} + +/* +** Populate buffer zOut with the full canonical pathname corresponding +** to the pathname in zPath. zOut is guaranteed to point to a buffer +** of at least (INST_MAX_PATHNAME+1) bytes. +*/ +static int vstatFullPathname( + sqlite3_vfs *pVfs, + const char *zPath, + int nOut, + char *zOut +){ + STATCNT(VFSSTAT_ANY,VFSSTAT_FULLPATH)++; + return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut); +} + +/* +** Open the dynamic library located at zPath and return a handle. +*/ +static void *vstatDlOpen(sqlite3_vfs *pVfs, const char *zPath){ + return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath); +} + +/* +** Populate the buffer zErrMsg (size nByte bytes) with a human readable +** utf-8 string describing the most recent error encountered associated +** with dynamic libraries. +*/ +static void vstatDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){ + REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg); +} + +/* +** Return a pointer to the symbol zSymbol in the dynamic library pHandle. +*/ +static void (*vstatDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){ + return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym); +} + +/* +** Close the dynamic library handle pHandle. +*/ +static void vstatDlClose(sqlite3_vfs *pVfs, void *pHandle){ + REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle); +} + +/* +** Populate the buffer pointed to by zBufOut with nByte bytes of +** random data. +*/ +static int vstatRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ + STATCNT(VFSSTAT_ANY,VFSSTAT_RANDOM)++; + return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut); +} + +/* +** Sleep for nMicro microseconds. Return the number of microseconds +** actually slept. +*/ +static int vstatSleep(sqlite3_vfs *pVfs, int nMicro){ + STATCNT(VFSSTAT_ANY,VFSSTAT_SLEEP)++; + return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro); +} + +/* +** Return the current time as a Julian Day number in *pTimeOut. +*/ +static int vstatCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ + STATCNT(VFSSTAT_ANY,VFSSTAT_CURTIME)++; + return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut); +} + +static int vstatGetLastError(sqlite3_vfs *pVfs, int a, char *b){ + return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b); +} +static int vstatCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){ + STATCNT(VFSSTAT_ANY,VFSSTAT_CURTIME)++; + return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p); +} + +/* +** A virtual table for accessing the stats collected by this VFS shim +*/ +static int vstattabConnect(sqlite3*, void*, int, const char*const*, + sqlite3_vtab**,char**); +static int vstattabBestIndex(sqlite3_vtab*,sqlite3_index_info*); +static int vstattabDisconnect(sqlite3_vtab*); +static int vstattabOpen(sqlite3_vtab*, sqlite3_vtab_cursor**); +static int vstattabClose(sqlite3_vtab_cursor*); +static int vstattabFilter(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, + int argc, sqlite3_value **argv); +static int vstattabNext(sqlite3_vtab_cursor*); +static int vstattabEof(sqlite3_vtab_cursor*); +static int vstattabColumn(sqlite3_vtab_cursor*,sqlite3_context*,int); +static int vstattabRowid(sqlite3_vtab_cursor*,sqlite3_int64*); +static int vstattabUpdate(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*); + +/* A cursor for the vfsstat virtual table */ +typedef struct VfsStatCursor { + sqlite3_vtab_cursor base; /* Base class. Must be first */ + int i; /* Pointing to this aVfsCnt[] value */ +} VfsStatCursor; + + +static int vstattabConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + sqlite3_vtab *pNew; + int rc; + +/* Column numbers */ +#define VSTAT_COLUMN_FILE 0 +#define VSTAT_COLUMN_STAT 1 +#define VSTAT_COLUMN_COUNT 2 + + rc = sqlite3_declare_vtab(db,"CREATE TABLE x(file,stat,count)"); + if( rc==SQLITE_OK ){ + pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + } + return rc; +} + +/* +** This method is the destructor for vstat table object. +*/ +static int vstattabDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** Constructor for a new vstat table cursor object. +*/ +static int vstattabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + VfsStatCursor *pCur; + pCur = sqlite3_malloc( sizeof(*pCur) ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur)); + *ppCursor = &pCur->base; + return SQLITE_OK; +} + + +/* +** Destructor for a VfsStatCursor. +*/ +static int vstattabClose(sqlite3_vtab_cursor *cur){ + sqlite3_free(cur); + return SQLITE_OK; +} + + +/* +** Advance a VfsStatCursor to its next row of output. +*/ +static int vstattabNext(sqlite3_vtab_cursor *cur){ + ((VfsStatCursor*)cur)->i++; + return SQLITE_OK; +} + +/* +** Return values of columns for the row at which the VfsStatCursor +** is currently pointing. +*/ +static int vstattabColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + VfsStatCursor *pCur = (VfsStatCursor*)cur; + switch( i ){ + case VSTAT_COLUMN_FILE: { + sqlite3_result_text(ctx, azFile[pCur->i/VFSSTAT_nStat], -1, SQLITE_STATIC); + break; + } + case VSTAT_COLUMN_STAT: { + const char **az; + az = (pCur->i/VFSSTAT_nStat)==VFSSTAT_ANY ? azStatAny : azStat; + sqlite3_result_text(ctx, az[pCur->i%VFSSTAT_nStat], -1, SQLITE_STATIC); + break; + } + case VSTAT_COLUMN_COUNT: { + sqlite3_result_int64(ctx, aVfsCnt[pCur->i]); + break; + } + } + return SQLITE_OK; +} + +/* +** Return the rowid for the current row. +*/ +static int vstattabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + VfsStatCursor *pCur = (VfsStatCursor*)cur; + *pRowid = pCur->i; + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int vstattabEof(sqlite3_vtab_cursor *cur){ + VfsStatCursor *pCur = (VfsStatCursor*)cur; + return pCur->i >= VFSSTAT_MXCNT; +} + +/* +** Only a full table scan is supported. So xFilter simply rewinds to +** the beginning. +*/ +static int vstattabFilter( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + VfsStatCursor *pCur = (VfsStatCursor*)pVtabCursor; + pCur->i = 0; + return SQLITE_OK; +} + +/* +** Only a forwards full table scan is supported. xBestIndex is a no-op. +*/ +static int vstattabBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + return SQLITE_OK; +} + +/* +** Any VSTAT_COLUMN_COUNT can be changed to a positive integer. +** No deletions or insertions are allowed. No changes to other +** columns are allowed. +*/ +static int vstattabUpdate( + sqlite3_vtab *tab, + int argc, sqlite3_value **argv, + sqlite3_int64 *pRowid +){ + sqlite3_int64 iRowid, x; + if( argc==1 ) return SQLITE_ERROR; + if( sqlite3_value_type(argv[0])!=SQLITE_INTEGER ) return SQLITE_ERROR; + iRowid = sqlite3_value_int64(argv[0]); + if( iRowid!=sqlite3_value_int64(argv[1]) ) return SQLITE_ERROR; + if( iRowid<0 || iRowid>=VFSSTAT_MXCNT ) return SQLITE_ERROR; + if( sqlite3_value_type(argv[VSTAT_COLUMN_COUNT+2])!=SQLITE_INTEGER ){ + return SQLITE_ERROR; + } + x = sqlite3_value_int64(argv[VSTAT_COLUMN_COUNT+2]); + if( x<0 ) return SQLITE_ERROR; + aVfsCnt[iRowid] = x; + return SQLITE_OK; +} + +static sqlite3_module VfsStatModule = { + 0, /* iVersion */ + 0, /* xCreate */ + vstattabConnect, /* xConnect */ + vstattabBestIndex, /* xBestIndex */ + vstattabDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + vstattabOpen, /* xOpen - open a cursor */ + vstattabClose, /* xClose - close a cursor */ + vstattabFilter, /* xFilter - configure scan constraints */ + vstattabNext, /* xNext - advance a cursor */ + vstattabEof, /* xEof - check for end of scan */ + vstattabColumn, /* xColumn - read data */ + vstattabRowid, /* xRowid - read data */ + vstattabUpdate, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; + +/* +** This routine is an sqlite3_auto_extension() callback, invoked to register +** the vfsstat virtual table for all new database connections. +*/ +static int vstatRegister( + sqlite3 *db, + const char **pzErrMsg, + const struct sqlite3_api_routines *pThunk +){ + return sqlite3_create_module(db, "vfsstat", &VfsStatModule, 0); +} + +#ifdef _WIN32 +__declspec(dllexport) +#endif +/* +** This routine is called when the extension is loaded. +** +** Register the new VFS. Make arrangement to register the virtual table +** for each new database connection. +*/ +int sqlite3_vfsstat_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + VStatVfs *pNew; + SQLITE_EXTENSION_INIT2(pApi); + pNew = sqlite3_malloc(sizeof(vstat_vfs)); + if( pNew==0 ) return SQLITE_NOMEM; + memcpy(&pNew->base, &vstat_vfs, sizeof(vstat_vfs)); + pNew->pVfs = sqlite3_vfs_find(0); + pNew->base.szOsFile = sizeof(VStatFile) + pNew->pVfs->szOsFile; + rc = sqlite3_vfs_register(&pNew->base, 1); + if( rc==SQLITE_OK ){ + rc = sqlite3_auto_extension((void(*)(void))vstatRegister); + } + return rc; +} diff --git a/manifest b/manifest index 8c4974db29..98076dc0c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sWHERE-clause\sdebug\stracing.\s\sShow\sTK_MATCH\sexpressions\sand\nshow\smore\sdetails\son\sWhereTerm\straces. -D 2016-05-27T12:30:20.162 +C Add\sthe\svfsstat.c\sloadable\sextension\s-\sa\sVFS\sshim\sthat\smeasures\sthe\samount\nof\sI/O,\sand\san\seponymous\svirtual\stable\sthat\sis\sused\sto\sextract\sand\sview\nthe\smeasurements. +D 2016-05-28T14:53:48.676 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -221,6 +221,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 +F ext/misc/vfsstat.c 318bb69270291bfff3d5bb58b46397ed7b507589 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4 @@ -1495,7 +1496,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a9be4c2d56d08fea2cd1aab20b19092a45ef7620 -R 2beba98fee0a4944905820065cc75fbf +P 71087c12bc75a82f5d1051600a442ef6efc5e899 +R 3d452eed48a36d85ceafabad1e13a1b0 U drh -Z 8d7a3e9d02c8c2b09e27f05110ad65d3 +Z 226f41fb99617919dc67fcf97f9a5431 diff --git a/manifest.uuid b/manifest.uuid index 2f2802b83d..4270f95914 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -71087c12bc75a82f5d1051600a442ef6efc5e899 \ No newline at end of file +0987487dd4ebfcf66ddeec8ceca47775216a0887 \ No newline at end of file From 00dae0a3ca0764565d4b3ddb6f336f478bdf517e Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 May 2016 15:09:35 +0000 Subject: [PATCH 110/302] Update the amalgamation-tarball configure script so that it can use header file "readline/readline.h" with library file "libedit". FossilOrigin-Name: cbf72b04bb0650b62336d86b22ef59315ccdc183 --- autoconf/configure.ac | 74 +++++++++++++++++++++++++------------------ manifest | 14 ++++---- manifest.uuid | 2 +- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 01f8b0d03d..b9a11aac8f 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -30,40 +30,52 @@ AC_FUNC_STRERROR_R AC_CONFIG_FILES([Makefile sqlite3.pc]) AC_SUBST(BUILD_CFLAGS) -#----------------------------------------------------------------------- +#------------------------------------------------------------------------- +# Two options to enable readline compatible libraries: +# # --enable-editline # --enable-readline # -AC_ARG_ENABLE(editline, [AS_HELP_STRING( - [--enable-editline], - [use BSD libedit])], - [], [enable_editline=yes]) -AC_ARG_ENABLE(readline, [AS_HELP_STRING( - [--enable-readline], - [use readline])], - [], [enable_readline=yes]) -if test x"$enable_editline" != xno ; then - sLIBS=$LIBS - LIBS="" - AC_SEARCH_LIBS([readline],[edit],[enable_readline=no],[enable_editline=no]) - READLINE_LIBS=$LIBS - if test x"$LIBS" != "x"; then - AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) - enable_readline=no - else - unset ac_cv_search_readline - fi - LIBS=$sLIBS -fi -if test x"$enable_readline" != xno ; then - sLIBS=$LIBS - LIBS="" - AC_SEARCH_LIBS(tgetent, curses ncurses ncursesw, [], []) - AC_SEARCH_LIBS(readline, readline, [], [enable_readline=no]) - AC_CHECK_FUNCS(readline, [], []) - READLINE_LIBS=$LIBS - LIBS=$sLIBS -fi +# Both are enabled by default. If, after command line processing both are +# still enabled, the script searches for editline first and automatically +# disables readline if it is found. So, to use readline explicitly, the +# user must pass "--disable-editline". To disable command line editing +# support altogether, "--disable-editline --disable-readline". +# +# When searching for either library, check for headers before libraries +# as some distros supply packages that contain libraries but not header +# files, which come as a separate development package. +# +AC_ARG_ENABLE(editline, [AS_HELP_STRING([--enable-editline],[use BSD libedit])]) +AC_ARG_ENABLE(readline, [AS_HELP_STRING([--enable-readline],[use readline])]) + +AS_IF([ test x"$enable_editline" != xno ],[ + AC_CHECK_HEADERS([editline/readline.h],[ + sLIBS=$LIBS + LIBS="" + AC_SEARCH_LIBS([readline],[edit],[ + AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) + READLINE_LIBS=$LIBS + enable_readline=no + ]) + AS_UNSET(ac_cv_search_readline) + LIBS=$sLIBS + ]) +]) + +AS_IF([ test x"$enable_readline" != xno ],[ + AC_CHECK_HEADERS([readline/readline.h],[ + sLIBS=$LIBS + LIBS="" + AC_SEARCH_LIBS(tgetent, termcap curses ncurses ncursesw, [], []) + AC_SEARCH_LIBS(readline,[readline edit], [ + AC_DEFINE([HAVE_READLINE],1,Define to use readline or wrapper) + READLINE_LIBS=$LIBS + ]) + LIBS=$sLIBS + ]) +]) + AC_SUBST(READLINE_LIBS) #----------------------------------------------------------------------- diff --git a/manifest b/manifest index 98076dc0c3..777de8ed6c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\svfsstat.c\sloadable\sextension\s-\sa\sVFS\sshim\sthat\smeasures\sthe\samount\nof\sI/O,\sand\san\seponymous\svirtual\stable\sthat\sis\sused\sto\sextract\sand\sview\nthe\smeasurements. -D 2016-05-28T14:53:48.676 +C Update\sthe\samalgamation-tarball\sconfigure\sscript\sso\sthat\sit\scan\suse\sheader\sfile\s"readline/readline.h"\swith\slibrary\sfile\s"libedit". +D 2016-05-28T15:09:35.313 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -14,7 +14,7 @@ F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 F autoconf/Makefile.msc 0eca137c12542bd76c253a2d24380f29ade59b95 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 -F autoconf/configure.ac 7754404e955900cfdeba08862cdfa802eca5b0af +F autoconf/configure.ac cacf2616abf6e4a569bde2ef365c143caeec40bc F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1496,7 +1496,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 71087c12bc75a82f5d1051600a442ef6efc5e899 -R 3d452eed48a36d85ceafabad1e13a1b0 -U drh -Z 226f41fb99617919dc67fcf97f9a5431 +P 0987487dd4ebfcf66ddeec8ceca47775216a0887 +R 3c226086b91b471db1b9e5c3998de4c9 +U dan +Z 4323e6121ccb1a6dc1ad24e971c3fe39 diff --git a/manifest.uuid b/manifest.uuid index 4270f95914..e4dcde7a36 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0987487dd4ebfcf66ddeec8ceca47775216a0887 \ No newline at end of file +cbf72b04bb0650b62336d86b22ef59315ccdc183 \ No newline at end of file From c1502e2f4ff34628e7e8bb0a0d8b7c0af3cb51ad Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 May 2016 17:23:08 +0000 Subject: [PATCH 111/302] Enhance the sqlite3_load_extension() interface to permit extensions to return SQLITE_OK_LOAD_PERMANENTLY which will prevent the extensions from unloading when the database connection closes. FossilOrigin-Name: d3f99a5e8d0486d0917dfe96987c179a6f63b850 --- ext/misc/vfsstat.c | 1 + manifest | 20 +++++++++++--------- manifest.uuid | 2 +- src/loadext.c | 5 ++++- src/sqlite.h.in | 1 + 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ext/misc/vfsstat.c b/ext/misc/vfsstat.c index e519de6341..71bea16bd9 100644 --- a/ext/misc/vfsstat.c +++ b/ext/misc/vfsstat.c @@ -815,5 +815,6 @@ int sqlite3_vfsstat_init( if( rc==SQLITE_OK ){ rc = sqlite3_auto_extension((void(*)(void))vstatRegister); } + if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY; return rc; } diff --git a/manifest b/manifest index d2efa14e2d..eb178318cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\s"PRAGMA\scompile_options"\sso\sthat\sit\sshows\sthe\sversion\sof\sthe\scompiler\nused\sto\sgenerate\sthe\sexecutable,\sfor\scommon\scompilers. -D 2016-05-28T15:22:33.400 +C Enhance\sthe\ssqlite3_load_extension()\sinterface\sto\spermit\sextensions\sto\nreturn\sSQLITE_OK_LOAD_PERMANENTLY\swhich\swill\sprevent\sthe\sextensions\sfrom\nunloading\swhen\sthe\sdatabase\sconnection\scloses. +D 2016-05-28T17:23:08.946 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -221,7 +221,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 -F ext/misc/vfsstat.c 318bb69270291bfff3d5bb58b46397ed7b507589 +F ext/misc/vfsstat.c 9b41dd28f523f56f688529db12b9a6895a3e6896 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4 @@ -344,7 +344,7 @@ F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c 8b3a73f0624c5f7cadbd5cb89940783bee1d39a6 +F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 F src/main.c 405d13e3a4f7c5add9fb27702ae70ed0a6e32cca F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -382,7 +382,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c a0c4abf54bc6bd3a9c77a36ef3d1676045706cb2 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 -F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 +F src/sqlite.h.in 5f8113dbec74c6c093ead9930afb8c9fbd9f643d F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 F src/sqliteInt.h 09621b4b7dba808b24262c2480ea75b045001853 @@ -1496,8 +1496,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cbf72b04bb0650b62336d86b22ef59315ccdc183 3f710bc3617691fa7432a24f1410d4651ca181b6 -R b8a29334efa74a5834e7230ac30a1859 -T +closed 3f710bc3617691fa7432a24f1410d4651ca181b6 +P 6a0f200957ea294a2ae06c0b039a10ac838925f2 +R 6ce9b533604a3edd0071ae2a75774cc3 +T *branch * load-permanently +T *sym-load-permanently * +T -sym-trunk * U drh -Z e6aad793d53e0a92b777c64d70afe184 +Z 6a4e05708813f8abe1e82b227d71ac00 diff --git a/manifest.uuid b/manifest.uuid index ad8620c28e..8814600fda 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a0f200957ea294a2ae06c0b039a10ac838925f2 \ No newline at end of file +d3f99a5e8d0486d0917dfe96987c179a6f63b850 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index f881d99710..718dae5777 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -446,6 +446,7 @@ static int sqlite3LoadExtension( void **aHandle; u64 nMsg = 300 + sqlite3Strlen30(zFile); int ii; + int rc; /* Shared library endings to try if zFile cannot be loaded as written */ static const char *azEndings[] = { @@ -548,7 +549,9 @@ static int sqlite3LoadExtension( return SQLITE_ERROR; } sqlite3_free(zAltEntry); - if( xInit(db, &zErrmsg, &sqlite3Apis) ){ + rc = xInit(db, &zErrmsg, &sqlite3Apis); + if( rc ){ + if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK; if( pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 795236f587..4865f18132 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -506,6 +506,7 @@ int sqlite3_exec( #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) +#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) /* ** CAPI3REF: Flags For File Open Operations From 66bf810467d1734cb7d86552c57fcdefa5a00247 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 May 2016 17:45:15 +0000 Subject: [PATCH 112/302] Remove an unnecessary malloc from the vfsstat extension. FossilOrigin-Name: 24f258c2392290168cf34622b89a4a406a3dd853 --- ext/misc/vfsstat.c | 10 +++------- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ext/misc/vfsstat.c b/ext/misc/vfsstat.c index e519de6341..eefa6ea62b 100644 --- a/ext/misc/vfsstat.c +++ b/ext/misc/vfsstat.c @@ -804,14 +804,10 @@ int sqlite3_vfsstat_init( const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; - VStatVfs *pNew; SQLITE_EXTENSION_INIT2(pApi); - pNew = sqlite3_malloc(sizeof(vstat_vfs)); - if( pNew==0 ) return SQLITE_NOMEM; - memcpy(&pNew->base, &vstat_vfs, sizeof(vstat_vfs)); - pNew->pVfs = sqlite3_vfs_find(0); - pNew->base.szOsFile = sizeof(VStatFile) + pNew->pVfs->szOsFile; - rc = sqlite3_vfs_register(&pNew->base, 1); + vstat_vfs.pVfs = sqlite3_vfs_find(0); + vstat_vfs.base.szOsFile = sizeof(VStatFile) + pNew->pVfs->szOsFile; + rc = sqlite3_vfs_register(&vstat_vfs.base, 1); if( rc==SQLITE_OK ){ rc = sqlite3_auto_extension((void(*)(void))vstatRegister); } diff --git a/manifest b/manifest index d2efa14e2d..9cfe44a4b4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\s"PRAGMA\scompile_options"\sso\sthat\sit\sshows\sthe\sversion\sof\sthe\scompiler\nused\sto\sgenerate\sthe\sexecutable,\sfor\scommon\scompilers. -D 2016-05-28T15:22:33.400 +C Remove\san\sunnecessary\smalloc\sfrom\sthe\svfsstat\sextension. +D 2016-05-28T17:45:15.304 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -221,7 +221,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 -F ext/misc/vfsstat.c 318bb69270291bfff3d5bb58b46397ed7b507589 +F ext/misc/vfsstat.c 20f206b6d38911dfac4b4db88171204d0373f7df F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4 @@ -1496,8 +1496,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cbf72b04bb0650b62336d86b22ef59315ccdc183 3f710bc3617691fa7432a24f1410d4651ca181b6 -R b8a29334efa74a5834e7230ac30a1859 -T +closed 3f710bc3617691fa7432a24f1410d4651ca181b6 +P 6a0f200957ea294a2ae06c0b039a10ac838925f2 +R 829320b2f280fbfaceb9a39efce4a03a U drh -Z e6aad793d53e0a92b777c64d70afe184 +Z aae9a2c9c9808c4a6dec915905c542ff diff --git a/manifest.uuid b/manifest.uuid index ad8620c28e..c667abe35c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a0f200957ea294a2ae06c0b039a10ac838925f2 \ No newline at end of file +24f258c2392290168cf34622b89a4a406a3dd853 \ No newline at end of file From dbd2dcbd5ec86a795a3af633e4cd16dc26f929a0 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 May 2016 18:53:55 +0000 Subject: [PATCH 113/302] Experimental change to allow virtual tables to take advantage of LIKE, REGEXP and GLOB terms that are part of OR expressions within WHERE clauses. FossilOrigin-Name: 242507b4ff96bc4c7c7844dbe1c2b8508dbf1d01 --- manifest | 18 +++-- manifest.uuid | 2 +- src/whereexpr.c | 6 +- test/bestindex3.test | 170 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+), 10 deletions(-) create mode 100644 test/bestindex3.test diff --git a/manifest b/manifest index 9cfe44a4b4..fc8ac69d1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\smalloc\sfrom\sthe\svfsstat\sextension. -D 2016-05-28T17:45:15.304 +C Experimental\schange\sto\sallow\svirtual\stables\sto\stake\sadvantage\sof\sLIKE,\sREGEXP\sand\sGLOB\sterms\sthat\sare\spart\sof\sOR\sexpressions\swithin\sWHERE\sclauses. +D 2016-05-28T18:53:55.546 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -463,7 +463,7 @@ F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c b9f5b0ddb14c3827e70b5379e659cf4cfd524c4d F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c ba71a4e4bada29aa9842200e6299714bf18c812c -F src/whereexpr.c eacc0e60d029a082b4fc0cc42ea98544add1319e +F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -526,6 +526,7 @@ F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f F test/bc_common.tcl b5e42d80305be95697e6370e015af571e5333a1c F test/bestindex1.test 0cf1bd2d7b97d3a3a8c10736125274f64765c4ee F test/bestindex2.test 4a06b8922ab2fd09434870da8d1cdf525aaf7060 +F test/bestindex3.test b80da904d23581d233a7ceee7d6bbad2b23a8133 F test/between.test 34d375fb5ce1ae283ffe82b6b233e9f38e84fc6c F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -1496,7 +1497,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a0f200957ea294a2ae06c0b039a10ac838925f2 -R 829320b2f280fbfaceb9a39efce4a03a -U drh -Z aae9a2c9c9808c4a6dec915905c542ff +P 24f258c2392290168cf34622b89a4a406a3dd853 +R 983129af8245564f55ecb1fc34584518 +T *branch * vtab-experimental +T *sym-vtab-experimental * +T -sym-trunk * +U dan +Z 81d42b1213db363a99013be9cf2ad43d diff --git a/manifest.uuid b/manifest.uuid index c667abe35c..7e28d7946f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24f258c2392290168cf34622b89a4a406a3dd853 \ No newline at end of file +242507b4ff96bc4c7c7844dbe1c2b8508dbf1d01 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index ff012281b1..90c4c45965 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -568,7 +568,9 @@ static void exprAnalyzeOrTerm( if( !db->mallocFailed ){ for(j=0, pAndTerm=pAndWC->a; jnTerm; j++, pAndTerm++){ assert( pAndTerm->pExpr ); - if( allowedOp(pAndTerm->pExpr->op) ){ + if( allowedOp(pAndTerm->pExpr->op) + || pAndTerm->eOperator==WO_MATCH + ){ b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor); } } @@ -1122,7 +1124,7 @@ static void exprAnalyze( ** virtual tables. The native query optimizer does not attempt ** to do anything with MATCH functions. */ - if( isMatchOfColumn(pExpr, &eOp2) ){ + if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){ int idxNew; Expr *pRight, *pLeft; WhereTerm *pNewTerm; diff --git a/test/bestindex3.test b/test/bestindex3.test new file mode 100644 index 0000000000..bb6d5cefd1 --- /dev/null +++ b/test/bestindex3.test @@ -0,0 +1,170 @@ +# 2016 May 29 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix bestindex3 + +ifcapable !vtab { + finish_test + return +} + +#------------------------------------------------------------------------- +# Virtual table callback for a virtual table named $tbl. +# +# The table created is: +# +# "CREATE TABLE t1 (a, b, c)" +# +# This virtual table supports both LIKE and = operators on all columns. +# +proc vtab_cmd {bOmit method args} { + switch -- $method { + xConnect { + return "CREATE TABLE t1(a, b, c)" + } + + xBestIndex { + foreach {clist orderby mask} $args {} + + set ret [list] + set use use + if {$bOmit} {set use omit} + + for {set i 0} {$i < [llength $clist]} {incr i} { + array unset C + array set C [lindex $clist $i] + if {$C(usable) && ($C(op)=="like" || $C(op)=="eq")} { + lappend ret $use $i + lappend ret idxstr + lappend ret "[lindex {a b c} $C(column)] [string toupper $C(op)] ?" + break + } + } + + if {$ret==""} { + lappend ret cost 1000000 rows 1000000 + } else { + lappend ret cost 100 rows 10 + } + return $ret + } + + xFilter { + foreach {idxnum idxstr param} $args {} + set where "" + if {$bOmit && $idxstr != ""} { + set where " WHERE [string map [list ? '$param' EQ =] $idxstr]" + } + return [list sql "SELECT rowid, * FROM ttt$where"] + } + } + return "" +} + +register_tcl_module db + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING tcl("vtab_cmd 0"); +} + +do_eqp_test 1.1 { + SELECT * FROM t1 WHERE a LIKE 'abc'; +} { + 0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a LIKE ?} +} + +do_eqp_test 1.2 { + SELECT * FROM t1 WHERE a = 'abc'; +} { + 0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a EQ ?} +} + +do_eqp_test 1.3 { + SELECT * FROM t1 WHERE a = 'abc' OR b = 'def'; +} { + 0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a EQ ?} + 0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:b EQ ?} +} + +do_eqp_test 1.4 { + SELECT * FROM t1 WHERE a LIKE 'abc%' OR b = 'def'; +} { + 0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a LIKE ?} + 0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:b EQ ?} +} + +do_execsql_test 1.5 { + CREATE TABLE ttt(a, b, c); + + INSERT INTO ttt VALUES(1, 'two', 'three'); + INSERT INTO ttt VALUES(2, 'one', 'two'); + INSERT INTO ttt VALUES(3, 'three', 'one'); + INSERT INTO ttt VALUES(4, 'y', 'one'); + INSERT INTO ttt VALUES(5, 'x', 'two'); + INSERT INTO ttt VALUES(6, 'y', 'three'); +} + +foreach omit {0 1} { + do_execsql_test 1.6.$omit.0 " + DROP TABLE t1; + CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd $omit'); + " + do_execsql_test 1.6.$omit.1 { + SELECT rowid FROM t1 WHERE c LIKE 'o%' + } {3 4} + + do_execsql_test 1.6.$omit.2 { + SELECT rowid FROM t1 WHERE c LIKE 'o%' OR b='y' + } {3 4 6} + + do_execsql_test 1.6.$omit.3 { + SELECT rowid FROM t1 WHERE c = 'three' OR c LIKE 'o%' + } {1 6 3 4} +} + +#------------------------------------------------------------------------- +# Test the same pattern works with ordinary tables. +# +do_execsql_test 2.1 { + CREATE TABLE t2(x TEXT COLLATE nocase, y TEXT); + CREATE INDEX t2x ON t2(x COLLATE nocase); + CREATE INDEX t2y ON t2(y); +} + +do_eqp_test 2.2 { + SELECT * FROM t2 WHERE x LIKE 'abc%' OR y = 'def' +} { + 0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x>? AND x Date: Mon, 30 May 2016 08:28:21 +0000 Subject: [PATCH 114/302] Fix an FTS5 problem (segfault or incorrect query results) with "... MATCH 'x OR y' ORDER BY rank" queries when either token 'x' or 'y' is completely absent from the dataset. FossilOrigin-Name: 64ca1a835a89fd211078d2cd8f9b649e89be528d --- ext/fts5/fts5Int.h | 1 - ext/fts5/fts5_expr.c | 11 ----------- ext/fts5/fts5_main.c | 1 - ext/fts5/test/fts5rank.test | 29 +++++++++++++++++++++++++++++ manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index c4e7506fb1..c7169a113b 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -686,7 +686,6 @@ int sqlite3Fts5ExprPopulatePoslists( Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int ); void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); -void sqlite3Fts5ExprClearEof(Fts5Expr*); int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index a48fa6e9d0..9119813c85 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2617,17 +2617,6 @@ void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){ fts5ExprCheckPoslists(pExpr->pRoot, iRowid); } -static void fts5ExprClearEof(Fts5ExprNode *pNode){ - int i; - for(i=0; inChild; i++){ - fts5ExprClearEof(pNode->apChild[i]); - } - pNode->bEof = 0; -} -void sqlite3Fts5ExprClearEof(Fts5Expr *pExpr){ - fts5ExprClearEof(pExpr->pRoot); -} - /* ** This function is only called for detail=columns tables. */ diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 4feb3e1a2f..384d3dd8f7 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1186,7 +1186,6 @@ static int fts5FilterMethod( pCsr->ePlan = FTS5_PLAN_SOURCE; pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); - sqlite3Fts5ExprClearEof(pCsr->pExpr); }else if( pMatch ){ const char *zExpr = (const char*)sqlite3_value_text(apVal[0]); if( zExpr==0 ) zExpr = ""; diff --git a/ext/fts5/test/fts5rank.test b/ext/fts5/test/fts5rank.test index 4961b42605..e958aea15b 100644 --- a/ext/fts5/test/fts5rank.test +++ b/ext/fts5/test/fts5rank.test @@ -91,9 +91,38 @@ do_test 2.7 { } {1 3 2} +#-------------------------------------------------------------------------- +# At one point there was a problem with queries such as: +# +# ... MATCH 'x OR y' ORDER BY rank; +# +# if there were zero occurrences of token 'y' in the dataset. The +# following tests verify that that problem has been addressed. +# +foreach_detail_mode $::testprefix { + do_execsql_test 3.0 { + CREATE VIRTUAL TABLE y1 USING fts5(z, detail=%DETAIL%); + INSERT INTO y1 VALUES('test xyz'); + INSERT INTO y1 VALUES('test test xyz test'); + INSERT INTO y1 VALUES('test test xyz'); + } + do_execsql_test 3.1 { + SELECT rowid FROM y1('test OR tset'); + } {1 2 3} + do_execsql_test 3.2 { + SELECT rowid FROM y1('test OR tset') ORDER BY bm25(y1) + } {2 3 1} + do_execsql_test 3.3 { + SELECT rowid FROM y1('test OR tset') ORDER BY +rank + } {2 3 1} + + do_execsql_test 3.4 { + SELECT rowid FROM y1('test OR tset') ORDER BY rank + } {2 3 1} +} finish_test diff --git a/manifest b/manifest index 9cfe44a4b4..ce51d87c84 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\smalloc\sfrom\sthe\svfsstat\sextension. -D 2016-05-28T17:45:15.304 +C Fix\san\sFTS5\sproblem\s(segfault\sor\sincorrect\squery\sresults)\swith\s"...\sMATCH\s'x\sOR\sy'\sORDER\sBY\srank"\squeries\swhen\seither\stoken\s'x'\sor\s'y'\sis\scompletely\sabsent\sfrom\sthe\sdataset. +D 2016-05-30T08:28:21.370 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -98,14 +98,14 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h b770c5e0a8d2ee071ddffc7ab722dbf3474a8abe -F ext/fts5/fts5Int.h 3677076aecbf645a7f2a019115c6a4ec3272dd78 +F ext/fts5/fts5Int.h 9bd0c7c64285b5b368eca0ac63613185c5ad24ba F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 -F ext/fts5/fts5_expr.c da2b33c2aac91e96641c0a7cf2bbaa36eb2667f7 +F ext/fts5/fts5_expr.c bcb238ee4ac1164302ab528487520488516bd030 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 -F ext/fts5/fts5_main.c b4a0fc5bf17f2f1f056ee76cdd7d2af08b360f55 +F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c 3309c6a8e34b974513016fd1ef47c83f5898f94c F ext/fts5/fts5_tcl.c f8731e0508299bd43f1a2eff7dbeaac870768966 F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc @@ -176,7 +176,7 @@ F ext/fts5/test/fts5porter.test 7cdc07bef301d70eebbfa75dcaf45c3680e1d0e1 F ext/fts5/test/fts5porter2.test 2e65633d58a1c525d5af0f6c01e5a59155bb3487 F ext/fts5/test/fts5prefix.test efd42e00bb8e8a36383f25c838185508681c093f F ext/fts5/test/fts5query.test f5ec25f5f2fbb70033424113cdffc101b1985a40 -F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab +F ext/fts5/test/fts5rank.test 3e55e7eeb4c98728e4a3171c9e994e1a2f24eb99 F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 16908a99d6efc9ba21081b4f2b86b3fc699839a6 @@ -1496,7 +1496,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a0f200957ea294a2ae06c0b039a10ac838925f2 -R 829320b2f280fbfaceb9a39efce4a03a -U drh -Z aae9a2c9c9808c4a6dec915905c542ff +P 24f258c2392290168cf34622b89a4a406a3dd853 +R 09bf6149ab89919173c2bf6834d1442a +U dan +Z 067d36e8e3bb6a90972bf218c0cabd70 diff --git a/manifest.uuid b/manifest.uuid index c667abe35c..15daff8194 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24f258c2392290168cf34622b89a4a406a3dd853 \ No newline at end of file +64ca1a835a89fd211078d2cd8f9b649e89be528d \ No newline at end of file From 724b18966deb18ae6b1559c31de419e13fea465d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 May 2016 16:22:48 +0000 Subject: [PATCH 115/302] Add the "csv" virtual table for reading CSV files, as an extension in the ext/misc/ subfolder. FossilOrigin-Name: 00d3570c8bb96469c984903e20de589e998d4636 --- ext/misc/csv.c | 622 +++++++++++++++++++++++++++++++++++++++++++++++++ manifest | 13 +- manifest.uuid | 2 +- 3 files changed, 630 insertions(+), 7 deletions(-) create mode 100644 ext/misc/csv.c diff --git a/ext/misc/csv.c b/ext/misc/csv.c new file mode 100644 index 0000000000..62521d81f7 --- /dev/null +++ b/ext/misc/csv.c @@ -0,0 +1,622 @@ +/* +** 2016-05-28 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains the implementation of an SQLite virtual table for +** reading CSV files. +** +** Usage: +** +** .load ./csv +** CREATE VIRTUAL TABLE temp.csv USING csv(filename=FILENAME); +** SELECT * FROM csv; +** +** The columns are named "c1", "c2", "c3", ... by default. But the +** application can define its own CREATE TABLE statement as an additional +** parameter. For example: +** +** CREATE VIRTUAL TABLE temp.csv2 USING csv( +** filename = "../http.log", +** schema = "CREATE TABLE x(date,ipaddr,url,referrer,userAgent)" +** ); +*/ +#include +SQLITE_EXTENSION_INIT1 +#include +#include +#include +#include +#include +#include + +/* +** A macro to hint to the compiler that a function should not be +** inlined. +*/ +#if defined(__GNUC__) +# define CSV_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) && _MSC_VER>=1310 +# define CSV_NOINLINE __declspec(noinline) +#else +# define CSV_NOINLINE +#endif + + +/* Max size of the error message in a CsvReader */ +#define CSV_MXERR 200 + +/* A context object used when read a CSV file. */ +typedef struct CsvReader CsvReader; +struct CsvReader { + FILE *in; /* Read the CSV text from this input stream */ + char *z; /* Accumulated text for a field */ + int n; /* Number of bytes in z */ + int nAlloc; /* Space allocated for z[] */ + int nLine; /* Current line number */ + int cTerm; /* Character that terminated the most recent field */ + char zErr[CSV_MXERR]; /* Error message */ +}; + +/* Initialize a CsvReader object */ +static void csv_reader_init(CsvReader *p){ + memset(p, 0, sizeof(*p)); +} + +/* Close and reset a CsvReader object */ +static void csv_reader_reset(CsvReader *p){ + if( p->in ) fclose(p->in); + sqlite3_free(p->z); + csv_reader_init(p); +} + +/* Report an error on a CsvReader */ +static void csv_errmsg(CsvReader *p, const char *zFormat, ...){ + va_list ap; + va_start(ap, zFormat); + sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap); + va_end(ap); +} + +/* Open the file associated with a CsvReader +** Return the number of errors. +*/ +static int csv_reader_open(CsvReader *p, const char *zFilename){ + p->in = fopen(zFilename, "rb"); + if( p->in==0 ){ + csv_errmsg(p, "cannot open '%s' for reading", zFilename); + return 1; + } + return 0; +} + +/* Increase the size of p->z and append character c to the end. +** Return 0 on success and non-zero if there is an OOM error */ +static CSV_NOINLINE int csv_resize_and_append(CsvReader *p, char c){ + char *zNew; + int nNew = p->nAlloc*2 + 100; + zNew = sqlite3_realloc64(p->z, nNew); + if( zNew ){ + p->z = zNew; + p->nAlloc = nNew; + p->z[p->n++] = c; + return 0; + }else{ + csv_errmsg(p, "out of memory"); + return 1; + } +} + +/* Append a single character to the CsvReader.z[] array. +** Return 0 on success and non-zero if there is an OOM error */ +static int csv_append(CsvReader *p, char c){ + if( p->n>=p->nAlloc-1 ) return csv_resize_and_append(p, c); + p->z[p->n++] = c; + return 0; +} + +/* Read a single field of CSV text. Compatible with rfc4180 and extended +** with the option of having a separator other than ",". +** +** + Input comes from p->in. +** + Store results in p->z of length p->n. Space to hold p->z comes +** from sqlite3_malloc64(). +** + Keep track of the line number in p->nLine. +** + Store the character that terminates the field in p->cTerm. Store +** EOF on end-of-file. +** +** Return "" at EOF. Return 0 on an OOM error. +*/ +static char *csv_read_one_field(CsvReader *p){ + int c; + p->n = 0; + c = fgetc(p->in); + if( c==EOF ){ + p->cTerm = EOF; + return ""; + } + if( c=='"' ){ + int pc, ppc; + int startLine = p->nLine; + int cQuote = c; + pc = ppc = 0; + while( 1 ){ + c = fgetc(p->in); + if( c=='\n' ) p->nLine++; + if( c==cQuote ){ + if( pc==cQuote ){ + pc = 0; + continue; + } + } + if( (c==',' && pc==cQuote) + || (c=='\n' && pc==cQuote) + || (c=='\n' && pc=='\r' && ppc==cQuote) + || (c==EOF && pc==cQuote) + ){ + do{ p->n--; }while( p->z[p->n]!=cQuote ); + p->cTerm = c; + break; + } + if( pc==cQuote && c!='\r' ){ + csv_errmsg(p, "line %d: unescaped %c character", p->nLine, cQuote); + break; + } + if( c==EOF ){ + csv_errmsg(p, "line %d: unterminated %c-quoted field\n", + startLine, cQuote); + p->cTerm = c; + break; + } + if( csv_append(p, (char)c) ) return 0; + ppc = pc; + pc = c; + } + }else{ + while( c!=EOF && c!=',' && c!='\n' ){ + if( csv_append(p, (char)c) ) return 0; + c = fgetc(p->in); + } + if( c=='\n' ){ + p->nLine++; + if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--; + } + p->cTerm = c; + } + if( p->z ) p->z[p->n] = 0; + return p->z; +} + + +/* Forward references to the various virtual table methods implemented +** in this file. */ +static int csvtabCreate(sqlite3*, void*, int, const char*const*, + sqlite3_vtab**,char**); +static int csvtabConnect(sqlite3*, void*, int, const char*const*, + sqlite3_vtab**,char**); +static int csvtabBestIndex(sqlite3_vtab*,sqlite3_index_info*); +static int csvtabDisconnect(sqlite3_vtab*); +static int csvtabOpen(sqlite3_vtab*, sqlite3_vtab_cursor**); +static int csvtabClose(sqlite3_vtab_cursor*); +static int csvtabFilter(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, + int argc, sqlite3_value **argv); +static int csvtabNext(sqlite3_vtab_cursor*); +static int csvtabEof(sqlite3_vtab_cursor*); +static int csvtabColumn(sqlite3_vtab_cursor*,sqlite3_context*,int); +static int csvtabRowid(sqlite3_vtab_cursor*,sqlite3_int64*); + +/* An instance of the CSV virtual table */ +typedef struct CsvTable { + sqlite3_vtab base; /* Base class. Must be first */ + char *zFilename; /* Name of the CSV file */ + long iStart; /* Offset to start of data in zFilename */ + int nCol; /* Number of columns in the CSV file */ +} CsvTable; + +/* A cursor for the CSV virtual table */ +typedef struct CsvCursor { + sqlite3_vtab_cursor base; /* Base class. Must be first */ + CsvReader rdr; /* The CsvReader object */ + char **azVal; /* Value of the current row */ + sqlite3_int64 iRowid; /* The current rowid. Negative for EOF */ +} CsvCursor; + +/* Transfer error message text from a reader into a CsvTable */ +static void csv_xfer_error(CsvTable *pTab, CsvReader *pRdr){ + sqlite3_free(pTab->base.zErrMsg); + pTab->base.zErrMsg = sqlite3_mprintf("%s", pRdr->zErr); +} + +/* +** This method is the destructor fo a CsvTable object. +*/ +static int csvtabDisconnect(sqlite3_vtab *pVtab){ + CsvTable *p = (CsvTable*)pVtab; + sqlite3_free(p->zFilename); + sqlite3_free(p); + return SQLITE_OK; +} + +/* Skip leading whitespace. Return a pointer to the first non-whitespace +** character, or to the zero terminator if the string has only whitespace */ +static const char *csv_skip_whitespace(const char *z){ + while( isspace((unsigned char)z[0]) ) z++; + return z; +} + +/* Remove trailing whitespace from the end of string z[] */ +static void csv_trim_whitespace(char *z){ + size_t n = strlen(z); + while( n>0 && isspace((unsigned char)z[n]) ) n--; + z[n] = 0; +} + +/* Dequote the string */ +static void csv_dequote(char *z){ + int i, j; + char cQuote = z[0]; + size_t n; + + if( cQuote!='\'' && cQuote!='"' ) return; + n = strlen(z); + if( n<2 || z[n-1]!=z[0] ) return; + for(i=1, j=0; i=0 ){ + csv_errmsg(&sRdr, "more than one 'header' parameter"); + goto csvtab_connect_error; + } + x = csv_boolean(zValue); + if( x==1 ){ + bHeader = 1; + }else if( x==0 ){ + bHeader = 0; + }else{ + csv_errmsg(&sRdr, "unrecognized argument to 'header': %s", zValue); + goto csvtab_connect_error; + } + }else + { + csv_errmsg(&sRdr, "unrecognized parameter '%s'", z); + goto csvtab_connect_error; + } + } + if( zFilename==0 ){ + csv_errmsg(&sRdr, "missing 'filename' parameter"); + goto csvtab_connect_error; + } + if( csv_reader_open(&sRdr, zFilename) ){ + goto csvtab_connect_error; + } + pNew = sqlite3_malloc( sizeof(*pNew) ); + *ppVtab = (sqlite3_vtab*)pNew; + if( pNew==0 ) goto csvtab_connect_oom; + memset(pNew, 0, sizeof(*pNew)); + do{ + const char *z = csv_read_one_field(&sRdr); + if( z==0 ) goto csvtab_connect_oom; + pNew->nCol++; + }while( sRdr.cTerm==',' ); + pNew->zFilename = zFilename; + zFilename = 0; + pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0; + csv_reader_reset(&sRdr); + if( zSchema==0 ){ + char *zSep = ""; + zSchema = sqlite3_mprintf("CREATE TABLE x("); + if( zSchema==0 ) goto csvtab_connect_oom; + for(i=0; inCol; i++){ + zSchema = sqlite3_mprintf("%z%sc%d TEXT",zSchema, zSep, i); + zSep = ","; + } + zSchema = sqlite3_mprintf("%z);", zSchema); + } + rc = sqlite3_declare_vtab(db, zSchema); + if( rc ) goto csvtab_connect_error; + sqlite3_free(zSchema); + return SQLITE_OK; + +csvtab_connect_oom: + rc = SQLITE_NOMEM; + csv_errmsg(&sRdr, "out of memory"); + +csvtab_connect_error: + if( pNew ) csvtabDisconnect(&pNew->base); + sqlite3_free(zFilename); + sqlite3_free(zSchema); + if( sRdr.zErr[0] ){ + sqlite3_free(*pzErr); + *pzErr = sqlite3_mprintf("%s", sRdr.zErr); + } + csv_reader_reset(&sRdr); + return rc; +} + +/* +** Reset the current row content held by a CsvCursor. +*/ +static void csvtabCursorRowReset(CsvCursor *pCur){ + CsvTable *pTab = (CsvTable*)pCur->base.pVtab; + int i; + for(i=0; inCol; i++){ + sqlite3_free(pCur->azVal[i]); + pCur->azVal[i] = 0; + } +} + +/* +** The xConnect and xCreate methods do the same thing, but they must be +** different so that the virtual table is not an eponymous virtual table. +*/ +static int csvtabCreate( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + return csvtabConnect(db, pAux, argc, argv, ppVtab, pzErr); +} + +/* +** Destructor for a CsvCursor. +*/ +static int csvtabClose(sqlite3_vtab_cursor *cur){ + CsvCursor *pCur = (CsvCursor*)cur; + csvtabCursorRowReset(pCur); + csv_reader_reset(&pCur->rdr); + sqlite3_free(cur); + return SQLITE_OK; +} + +/* +** Constructor for a new CsvTable cursor object. +*/ +static int csvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + CsvTable *pTab = (CsvTable*)p; + CsvCursor *pCur; + pCur = sqlite3_malloc( sizeof(*pCur) * sizeof(char*)*pTab->nCol ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur) + sizeof(char*)*pTab->nCol ); + pCur->azVal = (char**)&pCur[1]; + *ppCursor = &pCur->base; + if( csv_reader_open(&pCur->rdr, pTab->zFilename) ){ + csv_xfer_error(pTab, &pCur->rdr); + return SQLITE_ERROR; + } + return SQLITE_OK; +} + + +/* +** Advance a CsvCursor to its next row of input. +** Set the EOF marker if we reach the end of input. +*/ +static int csvtabNext(sqlite3_vtab_cursor *cur){ + CsvCursor *pCur = (CsvCursor*)cur; + CsvTable *pTab = (CsvTable*)cur->pVtab; + int i = 0; + char *z; + csvtabCursorRowReset(pCur); + do{ + z = csv_read_one_field(&pCur->rdr); + if( z==0 ){ + csv_xfer_error(pTab, &pCur->rdr); + break; + } + z = sqlite3_mprintf("%s", z); + if( z==0 ){ + csv_errmsg(&pCur->rdr, "out of memory"); + csv_xfer_error(pTab, &pCur->rdr); + break; + } + if( inCol ){ + pCur->azVal[i++] = z; + } + }while( z!=0 && pCur->rdr.cTerm==',' ); + if( z==0 || pCur->rdr.cTerm==EOF ){ + pCur->iRowid = -1; + }else{ + pCur->iRowid++; + } + return SQLITE_OK; +} + +/* +** Return values of columns for the row at which the CsvCursor +** is currently pointing. +*/ +static int csvtabColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + CsvCursor *pCur = (CsvCursor*)cur; + CsvTable *pTab = (CsvTable*)cur->pVtab; + if( i>=0 && inCol && pCur->azVal[i]!=0 ){ + sqlite3_result_text(ctx, pCur->azVal[i], -1, SQLITE_STATIC); + } + return SQLITE_OK; +} + +/* +** Return the rowid for the current row. +*/ +static int csvtabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + CsvCursor *pCur = (CsvCursor*)cur; + *pRowid = pCur->iRowid; + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int csvtabEof(sqlite3_vtab_cursor *cur){ + CsvCursor *pCur = (CsvCursor*)cur; + return pCur->iRowid<0; +} + +/* +** Only a full table scan is supported. So xFilter simply rewinds to +** the beginning. +*/ +static int csvtabFilter( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + CsvCursor *pCur = (CsvCursor*)pVtabCursor; + CsvTable *pTab = (CsvTable*)pVtabCursor->pVtab; + pCur->iRowid = 0; + fseek(pCur->rdr.in, pTab->iStart, SEEK_SET); + return csvtabNext(pVtabCursor); +} + +/* +** Only a forwards full table scan is supported. xBestIndex is a no-op. +*/ +static int csvtabBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + return SQLITE_OK; +} + + +static sqlite3_module CsvModule = { + 0, /* iVersion */ + csvtabCreate, /* xCreate */ + csvtabConnect, /* xConnect */ + csvtabBestIndex, /* xBestIndex */ + csvtabDisconnect, /* xDisconnect */ + csvtabDisconnect, /* xDestroy */ + csvtabOpen, /* xOpen - open a cursor */ + csvtabClose, /* xClose - close a cursor */ + csvtabFilter, /* xFilter - configure scan constraints */ + csvtabNext, /* xNext - advance a cursor */ + csvtabEof, /* xEof - check for end of scan */ + csvtabColumn, /* xColumn - read data */ + csvtabRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; + +#ifdef _WIN32 +__declspec(dllexport) +#endif +/* +** This routine is called when the extension is loaded. The new +** CSV virtual table module is registered with the calling database +** connection. +*/ +int sqlite3_csv_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + SQLITE_EXTENSION_INIT2(pApi); + return sqlite3_create_module(db, "csv", &CsvModule, 0); +} diff --git a/manifest b/manifest index ce51d87c84..e2d03ea381 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sFTS5\sproblem\s(segfault\sor\sincorrect\squery\sresults)\swith\s"...\sMATCH\s'x\sOR\sy'\sORDER\sBY\srank"\squeries\swhen\seither\stoken\s'x'\sor\s'y'\sis\scompletely\sabsent\sfrom\sthe\sdataset. -D 2016-05-30T08:28:21.370 +C Add\sthe\s"csv"\svirtual\stable\sfor\sreading\sCSV\sfiles,\sas\san\sextension\sin\nthe\sext/misc/\ssubfolder. +D 2016-05-31T16:22:48.849 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -206,6 +206,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 +F ext/misc/csv.c 386ea82a7eeac9850000b43913a20453bc816a70 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1496,7 +1497,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 24f258c2392290168cf34622b89a4a406a3dd853 -R 09bf6149ab89919173c2bf6834d1442a -U dan -Z 067d36e8e3bb6a90972bf218c0cabd70 +P 64ca1a835a89fd211078d2cd8f9b649e89be528d +R b775d969691f2ff7971a8ef71faf9f8c +U drh +Z 58655b63021cdf0ee9fb657659454c01 diff --git a/manifest.uuid b/manifest.uuid index 15daff8194..649908c68d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -64ca1a835a89fd211078d2cd8f9b649e89be528d \ No newline at end of file +00d3570c8bb96469c984903e20de589e998d4636 \ No newline at end of file From abfd272b599c4c4acd1c193822755f0d195dd3f8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 May 2016 18:08:35 +0000 Subject: [PATCH 116/302] Add the testflags parameter to the csv extension. FossilOrigin-Name: b93fb2fe0df1b3bea2bc2a4e1528da74ab290593 --- ext/misc/csv.c | 29 ++++++++++++++++++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index 62521d81f7..d8087664fa 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -218,8 +218,12 @@ typedef struct CsvTable { char *zFilename; /* Name of the CSV file */ long iStart; /* Offset to start of data in zFilename */ int nCol; /* Number of columns in the CSV file */ + unsigned int tstFlags; /* Bit values used for testing */ } CsvTable; +/* Allowed values for tstFlags */ +#define CSVTEST_FIDX 0x0001 /* Pretend that constrained searchs cost less*/ + /* A cursor for the CSV virtual table */ typedef struct CsvCursor { sqlite3_vtab_cursor base; /* Base class. Must be first */ @@ -314,6 +318,7 @@ static int csv_boolean(const char *z){ ** schema=SCHEMA Optional ** header=YES|NO First row of CSV defines the names of ** columns if "yes". Default "no". +** testflags=N Bitmask of test flags. Optional ** ** If header=no and not columns are listed, then the columns are named ** "c0", "c1", "c2", and so forth. @@ -331,6 +336,7 @@ static int csvtabConnect( int i; char *zFilename = 0; char *zSchema = 0; + int tstFlags = 0; CsvReader sRdr; memset(&sRdr, 0, sizeof(sRdr)); @@ -373,6 +379,9 @@ static int csvtabConnect( goto csvtab_connect_error; } }else + if( (zValue = csv_parameter("testflags",9,z))!=0 ){ + tstFlags = (unsigned int)atoi(zValue); + }else { csv_errmsg(&sRdr, "unrecognized parameter '%s'", z); goto csvtab_connect_error; @@ -395,6 +404,7 @@ static int csvtabConnect( pNew->nCol++; }while( sRdr.cTerm==',' ); pNew->zFilename = zFilename; + pNew->tstFlags = tstFlags; zFilename = 0; pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0; csv_reader_reset(&sRdr); @@ -426,6 +436,7 @@ csvtab_connect_error: *pzErr = sqlite3_mprintf("%s", sRdr.zErr); } csv_reader_reset(&sRdr); + if( rc==SQLITE_OK ) rc = SQLITE_ERROR; return rc; } @@ -571,12 +582,28 @@ static int csvtabFilter( } /* -** Only a forwards full table scan is supported. xBestIndex is a no-op. +** Only a forwards full table scan is supported. xBestIndex is mostly +** a no-op. If CSVTEST_FIDX is set, then the presence of equality +** constraints lowers the estimated cost, which is fiction, but is useful +** for testing certain kinds of virtual table behavior. */ static int csvtabBestIndex( sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo ){ + CsvTable *pTab = (CsvTable*)tab; + int i; + pIdxInfo->estimatedCost = 1000000; + if( (pTab->tstFlags & CSVTEST_FIDX)==0 ){ + return SQLITE_OK; + } + for(i=0; inConstraint; i++){ + if( pIdxInfo->aConstraint[i].usable==0 ) continue; + if( pIdxInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ ){ + pIdxInfo->estimatedCost = 10; + break; + } + } return SQLITE_OK; } diff --git a/manifest b/manifest index e2d03ea381..6ea00aab63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"csv"\svirtual\stable\sfor\sreading\sCSV\sfiles,\sas\san\sextension\sin\nthe\sext/misc/\ssubfolder. -D 2016-05-31T16:22:48.849 +C Add\sthe\stestflags\sparameter\sto\sthe\scsv\sextension. +D 2016-05-31T18:08:35.263 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -206,7 +206,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c 386ea82a7eeac9850000b43913a20453bc816a70 +F ext/misc/csv.c d9b1dac6e43891174560abdd7d1d68bac20a2277 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1497,7 +1497,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 64ca1a835a89fd211078d2cd8f9b649e89be528d -R b775d969691f2ff7971a8ef71faf9f8c +P 00d3570c8bb96469c984903e20de589e998d4636 +R 7c1772dc60b41e0b51f7bd702d450189 U drh -Z 58655b63021cdf0ee9fb657659454c01 +Z ed250383d88d82f9f9e7a2529e3cc23c diff --git a/manifest.uuid b/manifest.uuid index 649908c68d..52e6a805d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00d3570c8bb96469c984903e20de589e998d4636 \ No newline at end of file +b93fb2fe0df1b3bea2bc2a4e1528da74ab290593 \ No newline at end of file From 1fc1a0f280e949736d10debf308c79494b16fe77 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 May 2016 18:44:33 +0000 Subject: [PATCH 117/302] Add the columns=N parameter to the CSV extension. FossilOrigin-Name: 28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac --- ext/misc/csv.c | 69 ++++++++++++++++++++++++++++++++++++-------------- manifest | 12 ++++----- manifest.uuid | 2 +- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index d8087664fa..81a1d9ff63 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -315,13 +315,16 @@ static int csv_boolean(const char *z){ /* ** Parameters: ** filename=FILENAME Required -** schema=SCHEMA Optional +** schema=SCHEMA Alternative CSV schema. ** header=YES|NO First row of CSV defines the names of ** columns if "yes". Default "no". +** columns=N Assum the CSV file contains N columns. ** testflags=N Bitmask of test flags. Optional ** -** If header=no and not columns are listed, then the columns are named -** "c0", "c1", "c2", and so forth. +** If schema= is omitted, then the columns are named "c0", "c1", "c2", +** and so forth. If columns=N is omitted, then the file is opened and +** the number of columns in the first row is counted to determine the +** column count. If header=YES, then the first row is skipped. */ static int csvtabConnect( sqlite3 *db, @@ -330,14 +333,16 @@ static int csvtabConnect( sqlite3_vtab **ppVtab, char **pzErr ){ - CsvTable *pNew = 0; - int bHeader = -1; - int rc = SQLITE_OK; - int i; - char *zFilename = 0; - char *zSchema = 0; - int tstFlags = 0; - CsvReader sRdr; + CsvTable *pNew = 0; /* The CsvTable object to construct */ + int bHeader = -1; /* header= flags. -1 means not seen yet */ + int rc = SQLITE_OK; /* Result code from this routine */ + int i; /* Loop counter */ + char *zFilename = 0; /* Value of the filename= parameter */ + char *zSchema = 0; /* Value of the schema= parameter */ + int tstFlags = 0; /* Value of the testflags= parameter */ + int nCol = -99; /* Value of the columns= parameter */ + CsvReader sRdr; /* A CSV file reader used to store an error + ** message and/or to count the number of columns */ memset(&sRdr, 0, sizeof(sRdr)); for(i=3; i0 ){ + csv_errmsg(&sRdr, "more than one 'columns' parameter"); + goto csvtab_connect_error; + } + nCol = atoi(zValue); + if( nCol<=0 ){ + csv_errmsg(&sRdr, "must have at least one column"); + goto csvtab_connect_error; + } + }else { csv_errmsg(&sRdr, "unrecognized parameter '%s'", z); goto csvtab_connect_error; @@ -391,18 +407,22 @@ static int csvtabConnect( csv_errmsg(&sRdr, "missing 'filename' parameter"); goto csvtab_connect_error; } - if( csv_reader_open(&sRdr, zFilename) ){ + if( nCol<=0 && csv_reader_open(&sRdr, zFilename) ){ goto csvtab_connect_error; } pNew = sqlite3_malloc( sizeof(*pNew) ); *ppVtab = (sqlite3_vtab*)pNew; if( pNew==0 ) goto csvtab_connect_oom; memset(pNew, 0, sizeof(*pNew)); - do{ - const char *z = csv_read_one_field(&sRdr); - if( z==0 ) goto csvtab_connect_oom; - pNew->nCol++; - }while( sRdr.cTerm==',' ); + if( nCol>0 ){ + pNew->nCol = nCol; + }else{ + do{ + const char *z = csv_read_one_field(&sRdr); + if( z==0 ) goto csvtab_connect_oom; + pNew->nCol++; + }while( sRdr.cTerm==',' ); + } pNew->zFilename = zFilename; pNew->tstFlags = tstFlags; zFilename = 0; @@ -593,15 +613,26 @@ static int csvtabBestIndex( ){ CsvTable *pTab = (CsvTable*)tab; int i; + int nConst = 0; pIdxInfo->estimatedCost = 1000000; if( (pTab->tstFlags & CSVTEST_FIDX)==0 ){ return SQLITE_OK; } + /* The usual (an sensible) case is to take the "return SQLITE_OK" above. + ** The code below only runs when testflags=1. The following code + ** generates an artifical and unrealistic plan which is useful + ** for testing virtual table logic but is useless for real applications. */ for(i=0; inConstraint; i++){ + unsigned char op; if( pIdxInfo->aConstraint[i].usable==0 ) continue; - if( pIdxInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ ){ + op = pIdxInfo->aConstraint[i].op; + if( op==SQLITE_INDEX_CONSTRAINT_EQ + || op==SQLITE_INDEX_CONSTRAINT_LIKE + || op==SQLITE_INDEX_CONSTRAINT_GLOB + ){ pIdxInfo->estimatedCost = 10; - break; + pIdxInfo->aConstraintUsage[nConst].argvIndex = nConst+1; + nConst++; } } return SQLITE_OK; diff --git a/manifest b/manifest index 6ea00aab63..db47b84b3f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\stestflags\sparameter\sto\sthe\scsv\sextension. -D 2016-05-31T18:08:35.263 +C Add\sthe\scolumns=N\sparameter\sto\sthe\sCSV\sextension. +D 2016-05-31T18:44:33.835 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -206,7 +206,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c d9b1dac6e43891174560abdd7d1d68bac20a2277 +F ext/misc/csv.c 39060a352f43e43df575484cc0f23ab61091dac3 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1497,7 +1497,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 00d3570c8bb96469c984903e20de589e998d4636 -R 7c1772dc60b41e0b51f7bd702d450189 +P b93fb2fe0df1b3bea2bc2a4e1528da74ab290593 +R 65e8595850caa2b47ebf66d47e8638e5 U drh -Z ed250383d88d82f9f9e7a2529e3cc23c +Z b14790ed4c9841c10d8b6970f4ae5ca1 diff --git a/manifest.uuid b/manifest.uuid index 52e6a805d6..bc70991975 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b93fb2fe0df1b3bea2bc2a4e1528da74ab290593 \ No newline at end of file +28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac \ No newline at end of file From 62340f849859258cf7ec778d9edd7391f450af62 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 May 2016 21:18:15 +0000 Subject: [PATCH 118/302] An experimental branch with code that allows virtual tables to be declared as WITHOUT ROWID tables. This might be useful for virtual tables that model external data sources that do not have a convenient way of computing a unique rowid. The current check-in almost works, but there are still serious issues. FossilOrigin-Name: 49638f180e26477974cacc69b79e0be0a5e18b29 --- manifest | 21 +++++++------ manifest.uuid | 2 +- src/build.c | 83 ++++++++++++++++++++++++------------------------- src/parse.y | 8 +++-- src/sqliteInt.h | 4 +-- src/vtab.c | 12 ++++--- 6 files changed, 69 insertions(+), 61 deletions(-) diff --git a/manifest b/manifest index db47b84b3f..d3f3735698 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\scolumns=N\sparameter\sto\sthe\sCSV\sextension. -D 2016-05-31T18:44:33.835 +C An\sexperimental\sbranch\swith\scode\sthat\sallows\svirtual\stables\sto\sbe\sdeclared\nas\sWITHOUT\sROWID\stables.\sThis\smight\sbe\suseful\sfor\svirtual\stables\sthat\smodel\nexternal\sdata\ssources\sthat\sdo\snot\shave\sa\sconvenient\sway\sof\scomputing\sa\sunique\nrowid.\s\sThe\scurrent\scheck-in\salmost\sworks,\sbut\sthere\sare\sstill\sserious\sissues. +D 2016-05-31T21:18:15.834 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -328,7 +328,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2128172fc1c420a6fa6878827fa595407795069a F src/btree.h 1342a9b2cc2089e3534d3ef00204786783f6aea6 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 785fa789319d93c6ae20efbd01d4da9ce8f8a793 +F src/build.c 7acc29d0944bd9995864148286e9daeb0cbce742 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 @@ -370,7 +370,7 @@ F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 -F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e +F src/parse.y 01b9f37c4c7009ab56fda98bc7db4c42643cecfe F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d @@ -386,7 +386,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 9984129d86243424b765fcb3f147c697bd20bb54 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 09621b4b7dba808b24262c2480ea75b045001853 +F src/sqliteInt.h 801e2a569ea79b09b87d045cd6f00ec88205f1f6 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -456,7 +456,7 @@ F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 -F src/vtab.c ce0f2ebb589b459b32c640b33af64bfa5b29aaf8 +F src/vtab.c 694e444986746b7e3bb9bd3d74e3284dd7209990 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -1497,7 +1497,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b93fb2fe0df1b3bea2bc2a4e1528da74ab290593 -R 65e8595850caa2b47ebf66d47e8638e5 +P 28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac +R f4a0fccb57a153a0ab74e7b69ae020b2 +T *branch * without-rowid-vtab +T *sym-without-rowid-vtab * +T -sym-trunk * U drh -Z b14790ed4c9841c10d8b6970f4ae5ca1 +Z 938f365203a268d591e6d60732902516 diff --git a/manifest.uuid b/manifest.uuid index bc70991975..06965e9c56 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac \ No newline at end of file +49638f180e26477974cacc69b79e0be0a5e18b29 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 565101356a..5afc32bd5e 100644 --- a/src/build.c +++ b/src/build.c @@ -605,8 +605,11 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){ /* Delete all indices associated with this table. */ for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ pNext = pIndex->pNext; - assert( pIndex->pSchema==pTable->pSchema ); - if( !db || db->pnBytesFreed==0 ){ + assert( pIndex->pSchema==pTable->pSchema + || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) ); + if( pIndex->idxType==SQLITE_IDXTYPE_APPDEF + && (!db || db->pnBytesFreed==0) + ){ char *zName = pIndex->zName; TESTONLY ( Index *pOld = ) sqlite3HashInsert( &pIndex->pSchema->idxHash, zName, 0 @@ -1288,7 +1291,7 @@ void sqlite3AddPrimaryKey( Column *pCol = 0; int iCol = -1, i; int nTerm; - if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; + if( pTab==0 ) goto primary_key_exit; if( pTab->tabFlags & TF_HasPrimaryKey ){ sqlite3ErrorMsg(pParse, "table \"%s\" has more than one primary key", pTab->zName); @@ -1334,12 +1337,8 @@ void sqlite3AddPrimaryKey( "INTEGER PRIMARY KEY"); #endif }else{ - Index *p; - p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, - 0, sortOrder, 0); - if( p ){ - p->idxType = SQLITE_IDXTYPE_PRIMARYKEY; - } + sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, + 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY); pList = 0; } @@ -1656,21 +1655,23 @@ static int hasColumn(const i16 *aiCol, int nCol, int x){ ** are appropriate for a WITHOUT ROWID table instead of a rowid table. ** Changes include: ** -** (1) Convert the OP_CreateTable into an OP_CreateIndex. There is +** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL. +** (2) Convert the OP_CreateTable into an OP_CreateIndex. There is ** no rowid btree for a WITHOUT ROWID. Instead, the canonical ** data storage is a covering index btree. -** (2) Bypass the creation of the sqlite_master table entry +** (3) Bypass the creation of the sqlite_master table entry ** for the PRIMARY KEY as the primary key index is now ** identified by the sqlite_master table entry of the table itself. -** (3) Set the Index.tnum of the PRIMARY KEY Index object in the +** (4) Set the Index.tnum of the PRIMARY KEY Index object in the ** schema to the rootpage from the main table. -** (4) Set all columns of the PRIMARY KEY schema object to be NOT NULL. ** (5) Add all table columns to the PRIMARY KEY Index object ** so that the PRIMARY KEY is a covering index. The surplus ** columns are part of KeyInfo.nXField and are not used for ** sorting or lookup or uniqueness checks. ** (6) Replace the rowid tail on all automatically generated UNIQUE ** indices with the PRIMARY KEY columns. +** +** For virtual tables, only (1) is performed. */ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ Index *pIdx; @@ -1680,6 +1681,20 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ sqlite3 *db = pParse->db; Vdbe *v = pParse->pVdbe; + /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables) + */ + if( !db->init.imposterTable ){ + for(i=0; inCol; i++){ + if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){ + pTab->aCol[i].notNull = OE_Abort; + } + } + } + + /* The remaining transformations only apply to b-tree tables, not to + ** virtual tables */ + if( IN_DECLARE_VTAB ) return; + /* Convert the OP_CreateTable opcode that would normally create the ** root-page for the table into an OP_CreateIndex opcode. The index ** created will become the PRIMARY KEY index. @@ -1701,9 +1716,9 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ if( pList==0 ) return; pList->a[0].sortOrder = pParse->iPkSortOrder; assert( pParse->pNewTable==pTab ); - pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0); - if( pPk==0 ) return; - pPk->idxType = SQLITE_IDXTYPE_PRIMARYKEY; + sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, + SQLITE_IDXTYPE_PRIMARYKEY); + pPk = sqlite3PrimaryKeyIndex(pTab); pTab->iPKey = -1; }else{ pPk = sqlite3PrimaryKeyIndex(pTab); @@ -1731,19 +1746,11 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ } pPk->nKeyCol = j; } - pPk->isCovering = 1; assert( pPk!=0 ); + pPk->isCovering = 1; + if( !db->init.imposterTable ) pPk->uniqNotNull = 1; nPk = pPk->nKeyCol; - /* Make sure every column of the PRIMARY KEY is NOT NULL. (Except, - ** do not enforce this for imposter tables.) */ - if( !db->init.imposterTable ){ - for(i=0; iaCol[pPk->aiColumn[i]].notNull = OE_Abort; - } - pPk->uniqNotNull = 1; - } - /* The root page of the PRIMARY KEY is the table root page */ pPk->tnum = pTab->tnum; @@ -2868,12 +2875,8 @@ Index *sqlite3AllocateIndexObject( ** pList is a list of columns to be indexed. pList will be NULL if this ** is a primary key or unique-constraint on the most recent column added ** to the table currently under construction. -** -** If the index is created successfully, return a pointer to the new Index -** structure. This is used by sqlite3AddPrimaryKey() to mark the index -** as the tables primary key (Index.idxType==SQLITE_IDXTYPE_PRIMARYKEY) */ -Index *sqlite3CreateIndex( +void sqlite3CreateIndex( Parse *pParse, /* All information about this parse */ Token *pName1, /* First part of index name. May be NULL */ Token *pName2, /* Second part of index name. May be NULL */ @@ -2883,9 +2886,9 @@ Index *sqlite3CreateIndex( Token *pStart, /* The CREATE token that begins this statement */ Expr *pPIWhere, /* WHERE clause for partial indices */ int sortOrder, /* Sort order of primary key when pList==NULL */ - int ifNotExist /* Omit error if index already exists */ + int ifNotExist, /* Omit error if index already exists */ + u8 idxType /* The index type */ ){ - Index *pRet = 0; /* Pointer to return */ Table *pTab = 0; /* Table to be indexed */ Index *pIndex = 0; /* The index to be created */ char *zName = 0; /* Name of the index */ @@ -2903,7 +2906,10 @@ Index *sqlite3CreateIndex( char *zExtra = 0; /* Extra space after the Index object */ Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */ - if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){ + if( db->mallocFailed || pParse->nErr>0 ){ + goto exit_create_index; + } + if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){ goto exit_create_index; } if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ @@ -3092,7 +3098,7 @@ Index *sqlite3CreateIndex( pIndex->pTable = pTab; pIndex->onError = (u8)onError; pIndex->uniqNotNull = onError!=OE_None; - pIndex->idxType = pName ? SQLITE_IDXTYPE_APPDEF : SQLITE_IDXTYPE_UNIQUE; + pIndex->idxType = idxType; pIndex->pSchema = db->aDb[iDb].pSchema; pIndex->nKeyCol = pList->nExpr; if( pPIWhere ){ @@ -3272,7 +3278,6 @@ Index *sqlite3CreateIndex( pIdx->onError = pIndex->onError; } } - pRet = pIdx; goto exit_create_index; } } @@ -3390,7 +3395,6 @@ Index *sqlite3CreateIndex( pIndex->pNext = pOther->pNext; pOther->pNext = pIndex; } - pRet = pIndex; pIndex = 0; } @@ -3401,7 +3405,6 @@ exit_create_index: sqlite3ExprListDelete(db, pList); sqlite3SrcListDelete(db, pTblName); sqlite3DbFree(db, zName); - return pRet; } /* @@ -4315,10 +4318,6 @@ void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){ /* ** Return a KeyInfo structure that is appropriate for the given Index. ** -** The KeyInfo structure for an index is cached in the Index object. -** So there might be multiple references to the returned pointer. The -** caller should not try to modify the KeyInfo object. -** ** The caller should invoke sqlite3KeyInfoUnref() on the returned object ** when it has finished using it. */ diff --git a/src/parse.y b/src/parse.y index ae763e46d6..9294a30428 100644 --- a/src/parse.y +++ b/src/parse.y @@ -300,7 +300,8 @@ ccons ::= NULL onconf. ccons ::= NOT NULL onconf(R). {sqlite3AddNotNull(pParse, R);} ccons ::= PRIMARY KEY sortorder(Z) onconf(R) autoinc(I). {sqlite3AddPrimaryKey(pParse,0,R,I,Z);} -ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0);} +ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0, + SQLITE_IDXTYPE_UNIQUE);} ccons ::= CHECK LP expr(X) RP. {sqlite3AddCheckConstraint(pParse,X.pExpr);} ccons ::= REFERENCES nm(T) eidlist_opt(TA) refargs(R). {sqlite3CreateForeignKey(pParse,0,&T,TA,R);} @@ -349,7 +350,8 @@ tcons ::= CONSTRAINT nm(X). {pParse->constraintName = X;} tcons ::= PRIMARY KEY LP sortlist(X) autoinc(I) RP onconf(R). {sqlite3AddPrimaryKey(pParse,X,R,I,0);} tcons ::= UNIQUE LP sortlist(X) RP onconf(R). - {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0);} + {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0, + SQLITE_IDXTYPE_UNIQUE);} tcons ::= CHECK LP expr(E) RP onconf. {sqlite3AddCheckConstraint(pParse,E.pExpr);} tcons ::= FOREIGN KEY LP eidlist(FA) RP @@ -1198,7 +1200,7 @@ cmd ::= createkw(S) uniqueflag(U) INDEX ifnotexists(NE) nm(X) dbnm(D) ON nm(Y) LP sortlist(Z) RP where_opt(W). { sqlite3CreateIndex(pParse, &X, &D, sqlite3SrcListAppend(pParse->db,0,&Y,0), Z, U, - &S, W, SQLITE_SO_ASC, NE); + &S, W, SQLITE_SO_ASC, NE, SQLITE_IDXTYPE_APPDEF); } %type uniqueflag {int} diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b15d788093..024003afb0 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3617,8 +3617,8 @@ void sqlite3SrcListAssignCursors(Parse*, SrcList*); void sqlite3IdListDelete(sqlite3*, IdList*); void sqlite3SrcListDelete(sqlite3*, SrcList*); Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**); -Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, - Expr*, int, int); +void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, + Expr*, int, int, u8); void sqlite3DropIndex(Parse*, SrcList*, int); int sqlite3Select(Parse*, Select*, SelectDest*); Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, diff --git a/src/vtab.c b/src/vtab.c index 2fe105a296..01ea9750f5 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -754,10 +754,14 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ && (pParse->pNewTable->tabFlags & TF_Virtual)==0 ){ if( !pTab->aCol ){ - pTab->aCol = pParse->pNewTable->aCol; - pTab->nCol = pParse->pNewTable->nCol; - pParse->pNewTable->nCol = 0; - pParse->pNewTable->aCol = 0; + Table *pNew = pParse->pNewTable; + pTab->aCol = pNew->aCol; + pTab->nCol = pNew->nCol; + pTab->tabFlags |= pNew->tabFlags & TF_WithoutRowid; + pTab->pIndex = pNew->pIndex; + pNew->nCol = 0; + pNew->aCol = 0; + pNew->pIndex = 0; } pCtx->bDeclared = 1; }else{ From 9f6e686f59fff4b7413182980cc3dfa898986ddf Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 1 Jun 2016 05:02:05 +0000 Subject: [PATCH 119/302] Fix compilation issues with the VFS stat extension. FossilOrigin-Name: f6e956525b03fa07190e5521edac4758c386cc80 --- ext/misc/vfsstat.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/misc/vfsstat.c b/ext/misc/vfsstat.c index eefa6ea62b..30d4514113 100644 --- a/ext/misc/vfsstat.c +++ b/ext/misc/vfsstat.c @@ -402,7 +402,7 @@ static int vstatShmLock(sqlite3_file *pFile, int offset, int n, int flags){ /* Memory barrier operation on shared memory */ static void vstatShmBarrier(sqlite3_file *pFile){ VStatFile *p = (VStatFile *)pFile; - return p->pReal->pMethods->xShmBarrier(p->pReal); + p->pReal->pMethods->xShmBarrier(p->pReal); } /* Unmap a shared memory segment */ @@ -806,7 +806,7 @@ int sqlite3_vfsstat_init( int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); vstat_vfs.pVfs = sqlite3_vfs_find(0); - vstat_vfs.base.szOsFile = sizeof(VStatFile) + pNew->pVfs->szOsFile; + vstat_vfs.base.szOsFile = sizeof(VStatFile) + vstat_vfs.pVfs->szOsFile; rc = sqlite3_vfs_register(&vstat_vfs.base, 1); if( rc==SQLITE_OK ){ rc = sqlite3_auto_extension((void(*)(void))vstatRegister); diff --git a/manifest b/manifest index db47b84b3f..35df2a424c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\scolumns=N\sparameter\sto\sthe\sCSV\sextension. -D 2016-05-31T18:44:33.835 +C Fix\scompilation\sissues\swith\sthe\sVFS\sstat\sextension. +D 2016-06-01T05:02:05.387 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -222,7 +222,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 -F ext/misc/vfsstat.c 20f206b6d38911dfac4b4db88171204d0373f7df +F ext/misc/vfsstat.c aed1f11904f07487d71015c8826885f57e4644b3 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4 @@ -1497,7 +1497,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b93fb2fe0df1b3bea2bc2a4e1528da74ab290593 -R 65e8595850caa2b47ebf66d47e8638e5 -U drh -Z b14790ed4c9841c10d8b6970f4ae5ca1 +P 28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac +R 439a7441f751d5eee3dcb1d6f6a64d80 +U mistachkin +Z fb90ffd16972fce7722c3409e726b839 diff --git a/manifest.uuid b/manifest.uuid index bc70991975..f309668697 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac \ No newline at end of file +f6e956525b03fa07190e5521edac4758c386cc80 \ No newline at end of file From 82a1c0e5bb94704c27cd50eddb6a10bc4b8b677d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 1 Jun 2016 10:37:50 +0000 Subject: [PATCH 120/302] Fix an issue preventing RBU vacuum from working with virtual tables. FossilOrigin-Name: 3bd85fa5a9a489fd505c973e37c33a76c1b0e957 --- ext/rbu/rbu_common.tcl | 17 +++++ ext/rbu/rbuvacuum.test | 18 ----- ext/rbu/rbuvacuum2.test | 162 ++++++++++++++++++++++++++++++++++++++++ ext/rbu/sqlite3rbu.c | 6 +- manifest | 19 ++--- manifest.uuid | 2 +- 6 files changed, 194 insertions(+), 30 deletions(-) create mode 100644 ext/rbu/rbuvacuum2.test diff --git a/ext/rbu/rbu_common.tcl b/ext/rbu/rbu_common.tcl index 8190021baf..4a8c5cba9f 100644 --- a/ext/rbu/rbu_common.tcl +++ b/ext/rbu/rbu_common.tcl @@ -36,3 +36,20 @@ proc step_rbu {target rbu} { set rc } +proc do_rbu_vacuum_test {tn step} { + uplevel [list do_test $tn.1 { + if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db } + while 1 { + if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db } + set rc [rbu step] + if {$rc!="SQLITE_OK"} break + if {$step==1} { rbu close } + } + rbu close + } {SQLITE_DONE}] + + uplevel [list do_execsql_test $tn.2 { + PRAGMA integrity_check + } ok] +} + diff --git a/ext/rbu/rbuvacuum.test b/ext/rbu/rbuvacuum.test index 7d82e380d6..86f4aa770e 100644 --- a/ext/rbu/rbuvacuum.test +++ b/ext/rbu/rbuvacuum.test @@ -17,23 +17,6 @@ source [file join [file dirname [info script]] rbu_common.tcl] set ::testprefix rbuvacuum -proc do_rbu_vacuum_test {tn step} { - uplevel [list do_test $tn.1 { - if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db } - while 1 { - if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db } - set rc [rbu step] - if {$rc!="SQLITE_OK"} break - if {$step==1} { rbu close } - } - rbu close - } {SQLITE_DONE}] - - uplevel [list do_execsql_test $tn.2 { - PRAGMA integrity_check - } ok] -} - foreach step {0 1} { set ::testprefix rbuvacuum-step=$step @@ -404,7 +387,6 @@ do_test 3.5 { list [catch { rbu close } msg] $msg } {0 SQLITE_DONE} - catch { db close } finish_test diff --git a/ext/rbu/rbuvacuum2.test b/ext/rbu/rbuvacuum2.test new file mode 100644 index 0000000000..6397751836 --- /dev/null +++ b/ext/rbu/rbuvacuum2.test @@ -0,0 +1,162 @@ +# 2016 June 1 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# This file contains tests for the RBU module. More specifically, it +# contains tests to ensure that the sqlite3rbu_vacuum() API works as +# expected. +# + +source [file join [file dirname [info script]] rbu_common.tcl] + +foreach step {0 1} { + set ::testprefix rbuvacuum2-$step + + #------------------------------------------------------------------------- + # Test that a database that contains fts3 tables can be vacuumed. + # + ifcapable fts3 { + reset_db + do_execsql_test 1.1 { + CREATE VIRTUAL TABLE t1 USING fts3(z, y); + INSERT INTO t1 VALUES('fix this issue', 'at some point'); + } + + do_rbu_vacuum_test 1.2 $step + + do_execsql_test 1.3 { + SELECT * FROM t1; + } {{fix this issue} {at some point}} + + do_execsql_test 1.4 { + SELECT rowid FROM t1 WHERE t1 MATCH 'fix'; + } {1} + + do_execsql_test 1.5 { + INSERT INTO t1 VALUES('a b c', 'd e f'); + INSERT INTO t1 VALUES('l h i', 'd e f'); + DELETE FROM t1 WHERE docid = 2; + INSERT INTO t1 VALUES('a b c', 'x y z'); + } + + do_rbu_vacuum_test 1.6 $step + do_execsql_test 1.7 { + INSERT INTO t1(t1) VALUES('integrity-check'); + SELECT * FROM t1; + } { + {fix this issue} {at some point} + {l h i} {d e f} + {a b c} {x y z} + } + } + + #------------------------------------------------------------------------- + # Test that a database that contains fts5 tables can be vacuumed. + # + ifcapable fts5 { + reset_db + do_execsql_test 2.1 { + CREATE VIRTUAL TABLE t1 USING fts5(z, y); + INSERT INTO t1 VALUES('fix this issue', 'at some point'); + } + + do_rbu_vacuum_test 2.2 $step + + do_execsql_test 2.3 { + SELECT * FROM t1; + } {{fix this issue} {at some point}} + + do_execsql_test 2.4 { + SELECT rowid FROM t1 ('fix'); + } {1} + + do_execsql_test 2.5 { + INSERT INTO t1 VALUES('a b c', 'd e f'); + INSERT INTO t1 VALUES('l h i', 'd e f'); + DELETE FROM t1 WHERE rowid = 2; + INSERT INTO t1 VALUES('a b c', 'x y z'); + } + + do_rbu_vacuum_test 2.6 $step + do_execsql_test 2.7 { + INSERT INTO t1(t1) VALUES('integrity-check'); + SELECT * FROM t1; + } { + {fix this issue} {at some point} + {l h i} {d e f} + {a b c} {x y z} + } + } + + #------------------------------------------------------------------------- + # Test that a database that contains an rtree table can be vacuumed. + # + ifcapable rtree { + reset_db + do_execsql_test 3.1 { + CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2); + INSERT INTO rt VALUES(1, 45, 55); + INSERT INTO rt VALUES(2, 50, 60); + INSERT INTO rt VALUES(3, 55, 65); + } + + do_rbu_vacuum_test 3.2 $step + + do_execsql_test 3.3 { + SELECT * FROM rt; + } {1 45.0 55.0 2 50.0 60.0 3 55.0 65.0} + + do_execsql_test 3.4.1 { + SELECT rowid FROM rt WHERE x2>51 AND x1 < 51 + } {1 2} + do_execsql_test 3.4.2 { + SELECT rowid FROM rt WHERE x2>59 AND x1 < 59 + } {2 3} + + do_rbu_vacuum_test 3.5 $step + + do_execsql_test 3.6.1 { + SELECT rowid FROM rt WHERE x2>51 AND x1 < 51 + } {1 2} + do_execsql_test 3.6.2 { + SELECT rowid FROM rt WHERE x2>59 AND x1 < 59 + } {2 3} + } + + ifcapable trigger { + reset_db + do_execsql_test 4.1 { + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + CREATE VIEW v1 AS SELECT * FROM t1; + CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END; + } + + do_execsql_test 4.2 { + SELECT * FROM sqlite_master; + } { + table t1 t1 2 {CREATE TABLE t1(a, b, c)} + view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t1} + trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END} + } + + do_rbu_vacuum_test 4.3 $step + do_execsql_test 4.4 { + SELECT * FROM sqlite_master; + } { + table t1 t1 2 {CREATE TABLE t1(a, b, c)} + view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t1} + trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END} + } + } + +} + +finish_test diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index dc80935ecf..39d31935cb 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -921,12 +921,14 @@ static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){ int rc; memset(pIter, 0, sizeof(RbuObjIter)); - rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, + rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, + sqlite3_mprintf( "SELECT rbu_target_name(name, type='view') AS target, name " "FROM sqlite_master " "WHERE type IN ('table', 'view') AND target IS NOT NULL " + " %s " "ORDER BY name" - ); + , rbuIsVacuum(p) ? "AND rootpage!=0 AND rootpage IS NOT NULL" : "")); if( rc==SQLITE_OK ){ rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg, diff --git a/manifest b/manifest index 35df2a424c..28d7551f5d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\sissues\swith\sthe\sVFS\sstat\sextension. -D 2016-06-01T05:02:05.387 +C Fix\san\sissue\spreventing\sRBU\svacuum\sfrom\sworking\swith\svirtual\stables. +D 2016-06-01T10:37:50.553 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -241,7 +241,7 @@ F ext/rbu/rbu9.test 0806d1772c9f4981774ff028de6656e4183082af F ext/rbu/rbuA.test c1a7b3e2d926b8f8448bb3b4ae787e314ee4b2b3 F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2 F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831 -F ext/rbu/rbu_common.tcl 0398545fed614f807d5f0ba55a85a51f08ba8f1a +F ext/rbu/rbu_common.tcl 3a4b916b6f5dca9c9da9a30863e272fe5ea4414f F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695 F ext/rbu/rbudiff.test 2df0a8a7d998ecf81764c21eeda3cde5611c5091 F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 @@ -250,8 +250,9 @@ F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda F ext/rbu/rbuprogress.test 2023a7df2c523e3df1cb532eff811cda385a789a F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 -F ext/rbu/rbuvacuum.test 66e02cf299836770e718e95c36686be0b26dbda3 -F ext/rbu/sqlite3rbu.c bf36625990c6865ecf08bd844d8097ed2d0a6958 +F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 +F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab +F ext/rbu/sqlite3rbu.c a37a7dfb225c497171aa60120e81b884954361c7 F ext/rbu/sqlite3rbu.h 2acd0a6344a6079de15c8dc9d84d3df83a665930 F ext/rbu/test_rbu.c 9bbdf6bd8efd58fbc4f192698df50569598fbb9e F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 @@ -1497,7 +1498,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac -R 439a7441f751d5eee3dcb1d6f6a64d80 -U mistachkin -Z fb90ffd16972fce7722c3409e726b839 +P f6e956525b03fa07190e5521edac4758c386cc80 +R e1810942aeafbc52047febcf823bcd33 +U dan +Z 9391b61c89a105fa8d99de95f920a23b diff --git a/manifest.uuid b/manifest.uuid index f309668697..86876cd341 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f6e956525b03fa07190e5521edac4758c386cc80 \ No newline at end of file +3bd85fa5a9a489fd505c973e37c33a76c1b0e957 \ No newline at end of file From 273bfe9f204415a222ece75889dca8c1c17fb8af Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Jun 2016 16:22:53 +0000 Subject: [PATCH 121/302] Fix corner cases in the WITHOUT ROWID virtual table logic. FossilOrigin-Name: a393bbb972660c1ffcdda923d0f3564ecfcd2f0a --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/build.c | 8 ++++---- src/vtab.c | 11 +++++++++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index d3f3735698..3c0483e6d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\sexperimental\sbranch\swith\scode\sthat\sallows\svirtual\stables\sto\sbe\sdeclared\nas\sWITHOUT\sROWID\stables.\sThis\smight\sbe\suseful\sfor\svirtual\stables\sthat\smodel\nexternal\sdata\ssources\sthat\sdo\snot\shave\sa\sconvenient\sway\sof\scomputing\sa\sunique\nrowid.\s\sThe\scurrent\scheck-in\salmost\sworks,\sbut\sthere\sare\sstill\sserious\sissues. -D 2016-05-31T21:18:15.834 +C Fix\scorner\scases\sin\sthe\sWITHOUT\sROWID\svirtual\stable\slogic. +D 2016-06-02T16:22:53.508 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -328,7 +328,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2128172fc1c420a6fa6878827fa595407795069a F src/btree.h 1342a9b2cc2089e3534d3ef00204786783f6aea6 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 7acc29d0944bd9995864148286e9daeb0cbce742 +F src/build.c 555b459d1f25fba6c56266e60bbbdc93bdf5f66a F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 @@ -456,7 +456,7 @@ F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 -F src/vtab.c 694e444986746b7e3bb9bd3d74e3284dd7209990 +F src/vtab.c a80b4e40ed8687daa3303e970d938b1f613a3eeb F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -1497,10 +1497,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28ebeadd6a4c9ff2ce9fc86a0f0fe2f6cf94d3ac -R f4a0fccb57a153a0ab74e7b69ae020b2 -T *branch * without-rowid-vtab -T *sym-without-rowid-vtab * -T -sym-trunk * +P 49638f180e26477974cacc69b79e0be0a5e18b29 +R cf24c2970498f36ff11e1ac85a33493a U drh -Z 938f365203a268d591e6d60732902516 +Z 5a84619c2e2d24987b3ea5aba48efb6c diff --git a/manifest.uuid b/manifest.uuid index 06965e9c56..154b8a6067 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -49638f180e26477974cacc69b79e0be0a5e18b29 \ No newline at end of file +a393bbb972660c1ffcdda923d0f3564ecfcd2f0a \ No newline at end of file diff --git a/src/build.c b/src/build.c index 5afc32bd5e..092a9973b3 100644 --- a/src/build.c +++ b/src/build.c @@ -607,9 +607,7 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){ pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) ); - if( pIndex->idxType==SQLITE_IDXTYPE_APPDEF - && (!db || db->pnBytesFreed==0) - ){ + if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){ char *zName = pIndex->zName; TESTONLY ( Index *pOld = ) sqlite3HashInsert( &pIndex->pSchema->idxHash, zName, 0 @@ -1718,6 +1716,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ assert( pParse->pNewTable==pTab ); sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, SQLITE_IDXTYPE_PRIMARYKEY); + if( db->mallocFailed ) return; pPk = sqlite3PrimaryKeyIndex(pTab); pTab->iPKey = -1; }else{ @@ -3278,6 +3277,7 @@ void sqlite3CreateIndex( pIdx->onError = pIndex->onError; } } + if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType; goto exit_create_index; } } @@ -3287,7 +3287,7 @@ void sqlite3CreateIndex( ** in-memory database structures. */ assert( pParse->nErr==0 ); - if( db->init.busy ){ + if( db->init.busy && !IN_DECLARE_VTAB ){ Index *p; assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); p = sqlite3HashInsert(&pIndex->pSchema->idxHash, diff --git a/src/vtab.c b/src/vtab.c index 01ea9750f5..b4268536a0 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -755,13 +755,20 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ ){ if( !pTab->aCol ){ Table *pNew = pParse->pNewTable; + Index *pIdx; pTab->aCol = pNew->aCol; pTab->nCol = pNew->nCol; pTab->tabFlags |= pNew->tabFlags & TF_WithoutRowid; - pTab->pIndex = pNew->pIndex; pNew->nCol = 0; pNew->aCol = 0; - pNew->pIndex = 0; + assert( pTab->pIndex==0 ); + pIdx = pNew->pIndex; + if( pIdx ){ + assert( pIdx->pNext==0 ); + pTab->pIndex = pIdx; + pNew->pIndex = 0; + pIdx->pTable = pTab; + } } pCtx->bDeclared = 1; }else{ From adcba64df4f5475e62146f483d53b6d687ef7103 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Jun 2016 17:44:24 +0000 Subject: [PATCH 122/302] Add the data= parameter to the CSV virtual table extension. FossilOrigin-Name: 769191042aa14e6eccdfe2391fc1011171d5c9ad --- ext/misc/csv.c | 214 ++++++++++++++++++++++++++++++++++++------------- manifest | 12 +-- manifest.uuid | 2 +- 3 files changed, 165 insertions(+), 63 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index 81a1d9ff63..1b19631772 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -53,6 +53,9 @@ SQLITE_EXTENSION_INIT1 /* Max size of the error message in a CsvReader */ #define CSV_MXERR 200 +/* Size of the CsvReader input buffer */ +#define CSV_INBUFSZ 1024 + /* A context object used when read a CSV file. */ typedef struct CsvReader CsvReader; struct CsvReader { @@ -61,18 +64,31 @@ struct CsvReader { int n; /* Number of bytes in z */ int nAlloc; /* Space allocated for z[] */ int nLine; /* Current line number */ - int cTerm; /* Character that terminated the most recent field */ + char cTerm; /* Character that terminated the most recent field */ + size_t iIn; /* Next unread character in the input buffer */ + size_t nIn; /* Number of characters in the input buffer */ + char *zIn; /* The input buffer */ char zErr[CSV_MXERR]; /* Error message */ }; /* Initialize a CsvReader object */ static void csv_reader_init(CsvReader *p){ - memset(p, 0, sizeof(*p)); + p->in = 0; + p->z = 0; + p->n = 0; + p->nAlloc = 0; + p->nLine = 0; + p->nIn = 0; + p->zIn = 0; + p->zErr[0] = 0; } /* Close and reset a CsvReader object */ static void csv_reader_reset(CsvReader *p){ - if( p->in ) fclose(p->in); + if( p->in ){ + fclose(p->in); + sqlite3_free(p->zIn); + } sqlite3_free(p->z); csv_reader_init(p); } @@ -88,15 +104,56 @@ static void csv_errmsg(CsvReader *p, const char *zFormat, ...){ /* Open the file associated with a CsvReader ** Return the number of errors. */ -static int csv_reader_open(CsvReader *p, const char *zFilename){ - p->in = fopen(zFilename, "rb"); - if( p->in==0 ){ - csv_errmsg(p, "cannot open '%s' for reading", zFilename); - return 1; +static int csv_reader_open( + CsvReader *p, /* The reader to open */ + const char *zFilename, /* Read from this filename */ + const char *zData /* ... or use this data */ +){ + if( zFilename ){ + p->zIn = sqlite3_malloc( CSV_INBUFSZ ); + if( p->zIn==0 ){ + csv_errmsg(p, "out of memory"); + return 1; + } + p->in = fopen(zFilename, "rb"); + if( p->in==0 ){ + csv_reader_reset(p); + csv_errmsg(p, "cannot open '%s' for reading", zFilename); + return 1; + } + }else{ + assert( p->in==0 ); + p->zIn = (char*)zData; + p->nIn = strlen(zData); } return 0; } +/* The input buffer has overflowed. Refill the input buffer, then +** return the next character +*/ +static CSV_NOINLINE int csv_getc_refill(CsvReader *p){ + size_t got; + + assert( p->iIn>=p->nIn ); /* Only called on an empty input buffer */ + assert( p->in!=0 ); /* Only called if reading froma file */ + + got = fread(p->zIn, 1, CSV_INBUFSZ, p->in); + if( got==0 ) return EOF; + p->nIn = got; + p->iIn = 1; + return p->zIn[0]; +} + +/* Return the next character of input. Return EOF at end of input. */ +static int csv_getc(CsvReader *p){ + if( p->iIn >= p->nIn ){ + if( p->in!=0 ) return csv_getc_refill(p); + return EOF; + } + return p->zIn[p->iIn++]; +} + /* Increase the size of p->z and append character c to the end. ** Return 0 on success and non-zero if there is an OOM error */ static CSV_NOINLINE int csv_resize_and_append(CsvReader *p, char c){ @@ -137,7 +194,7 @@ static int csv_append(CsvReader *p, char c){ static char *csv_read_one_field(CsvReader *p){ int c; p->n = 0; - c = fgetc(p->in); + c = csv_getc(p); if( c==EOF ){ p->cTerm = EOF; return ""; @@ -148,7 +205,7 @@ static char *csv_read_one_field(CsvReader *p){ int cQuote = c; pc = ppc = 0; while( 1 ){ - c = fgetc(p->in); + c = csv_getc(p); if( c=='\n' ) p->nLine++; if( c==cQuote ){ if( pc==cQuote ){ @@ -182,7 +239,7 @@ static char *csv_read_one_field(CsvReader *p){ }else{ while( c!=EOF && c!=',' && c!='\n' ){ if( csv_append(p, (char)c) ) return 0; - c = fgetc(p->in); + c = csv_getc(p); } if( c=='\n' ){ p->nLine++; @@ -216,6 +273,7 @@ static int csvtabRowid(sqlite3_vtab_cursor*,sqlite3_int64*); typedef struct CsvTable { sqlite3_vtab base; /* Base class. Must be first */ char *zFilename; /* Name of the CSV file */ + char *zData; /* Raw CSV data in lieu of zFilename */ long iStart; /* Offset to start of data in zFilename */ int nCol; /* Number of columns in the CSV file */ unsigned int tstFlags; /* Bit values used for testing */ @@ -290,6 +348,37 @@ static const char *csv_parameter(const char *zTag, int nTag, const char *z){ return csv_skip_whitespace(z+1); } +/* Decode a parameter that requires a dequoted string. +** +** Return 1 if the parameter is seen, or 0 if not. 1 is returned +** even if there is an error. If an error occurs, then an error message +** is left in p->zErr. If there are no errors, p->zErr[0]==0. +*/ +static int csv_string_parameter( + CsvReader *p, /* Leave the error message here, if there is one */ + const char *zParam, /* Parameter we are checking for */ + const char *zArg, /* Raw text of the virtual table argment */ + char **pzVal /* Write the dequoted string value here */ +){ + const char *zValue; + zValue = csv_parameter(zParam,strlen(zParam),zArg); + if( zValue==0 ) return 0; + p->zErr[0] = 0; + if( *pzVal ){ + csv_errmsg(p, "more than one '%s' parameter", zParam); + return 1; + } + *pzVal = sqlite3_mprintf("%s", zValue); + if( *pzVal==0 ){ + csv_errmsg(p, "out of memory"); + return 1; + } + csv_trim_whitespace(*pzVal); + csv_dequote(*pzVal); + return 1; +} + + /* Return 0 if the argument is false and 1 if it is true. Return -1 if ** we cannot really tell. */ @@ -314,11 +403,12 @@ static int csv_boolean(const char *z){ /* ** Parameters: -** filename=FILENAME Required +** filename=FILENAME Name of file containing CSV content +** data=TEXT Direct CSV content. ** schema=SCHEMA Alternative CSV schema. ** header=YES|NO First row of CSV defines the names of ** columns if "yes". Default "no". -** columns=N Assum the CSV file contains N columns. +** columns=N Assume the CSV file contains N columns. ** testflags=N Bitmask of test flags. Optional ** ** If schema= is omitted, then the columns are named "c0", "c1", "c2", @@ -336,37 +426,31 @@ static int csvtabConnect( CsvTable *pNew = 0; /* The CsvTable object to construct */ int bHeader = -1; /* header= flags. -1 means not seen yet */ int rc = SQLITE_OK; /* Result code from this routine */ - int i; /* Loop counter */ - char *zFilename = 0; /* Value of the filename= parameter */ - char *zSchema = 0; /* Value of the schema= parameter */ - int tstFlags = 0; /* Value of the testflags= parameter */ + int i, j; /* Loop counters */ + int tstFlags = 0; /* Value for testflags=N parameter */ int nCol = -99; /* Value of the columns= parameter */ CsvReader sRdr; /* A CSV file reader used to store an error ** message and/or to count the number of columns */ + static const char *azParam[] = { + "filename", "data", "schema", + }; + char *azPValue[3]; /* Parameter values */ +# define CSV_FILENAME (azPValue[0]) +# define CSV_DATA (azPValue[1]) +# define CSV_SCHEMA (azPValue[2]) + + assert( sizeof(azPValue)==sizeof(azParam) ); memset(&sRdr, 0, sizeof(sRdr)); + memset(azPValue, 0, sizeof(azPValue)); for(i=3; inCol++; }while( sRdr.cTerm==',' ); } - pNew->zFilename = zFilename; + pNew->zFilename = CSV_FILENAME; CSV_FILENAME = 0; + pNew->zData = CSV_DATA; CSV_DATA = 0; pNew->tstFlags = tstFlags; - zFilename = 0; pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0; csv_reader_reset(&sRdr); - if( zSchema==0 ){ + if( CSV_SCHEMA==0 ){ char *zSep = ""; - zSchema = sqlite3_mprintf("CREATE TABLE x("); - if( zSchema==0 ) goto csvtab_connect_oom; + CSV_SCHEMA = sqlite3_mprintf("CREATE TABLE x("); + if( CSV_SCHEMA==0 ) goto csvtab_connect_oom; for(i=0; inCol; i++){ - zSchema = sqlite3_mprintf("%z%sc%d TEXT",zSchema, zSep, i); + CSV_SCHEMA = sqlite3_mprintf("%z%sc%d TEXT",CSV_SCHEMA, zSep, i); zSep = ","; } - zSchema = sqlite3_mprintf("%z);", zSchema); + CSV_SCHEMA = sqlite3_mprintf("%z);", CSV_SCHEMA); } - rc = sqlite3_declare_vtab(db, zSchema); + rc = sqlite3_declare_vtab(db, CSV_SCHEMA); if( rc ) goto csvtab_connect_error; - sqlite3_free(zSchema); + for(i=0; ibase); - sqlite3_free(zFilename); - sqlite3_free(zSchema); + for(i=0; inCol ); pCur->azVal = (char**)&pCur[1]; *ppCursor = &pCur->base; - if( csv_reader_open(&pCur->rdr, pTab->zFilename) ){ + if( csv_reader_open(&pCur->rdr, pTab->zFilename, pTab->zData) ){ csv_xfer_error(pTab, &pCur->rdr); return SQLITE_ERROR; } @@ -597,12 +684,20 @@ static int csvtabFilter( CsvCursor *pCur = (CsvCursor*)pVtabCursor; CsvTable *pTab = (CsvTable*)pVtabCursor->pVtab; pCur->iRowid = 0; - fseek(pCur->rdr.in, pTab->iStart, SEEK_SET); + if( pCur->rdr.in==0 ){ + assert( pCur->rdr.zIn==pTab->zData ); + assert( pTab->iStart<=pCur->rdr.nIn ); + pCur->rdr.iIn = pTab->iStart; + }else{ + fseek(pCur->rdr.in, pTab->iStart, SEEK_SET); + pCur->rdr.iIn = 0; + pCur->rdr.nIn = 0; + } return csvtabNext(pVtabCursor); } /* -** Only a forwards full table scan is supported. xBestIndex is mostly +** Only a forward full table scan is supported. xBestIndex is mostly ** a no-op. If CSVTEST_FIDX is set, then the presence of equality ** constraints lowers the estimated cost, which is fiction, but is useful ** for testing certain kinds of virtual table behavior. @@ -618,10 +713,17 @@ static int csvtabBestIndex( if( (pTab->tstFlags & CSVTEST_FIDX)==0 ){ return SQLITE_OK; } - /* The usual (an sensible) case is to take the "return SQLITE_OK" above. - ** The code below only runs when testflags=1. The following code + /* The usual (and sensible) case is to take the "return SQLITE_OK" above. + ** The code below only runs when testflags=1. The code below ** generates an artifical and unrealistic plan which is useful - ** for testing virtual table logic but is useless for real applications. */ + ** for testing virtual table logic but is not helpfulto real applications. + ** + ** Any ==, LIKE, or GLOB constraint is marked as usable by the virtual + ** table (even though it is not) and the cost of running the virtual table + ** is reduced from 1 million to just 10. The constraints are *not* marked + ** as omittable, however, so the query planner should still generate a + ** plan that gives a correct answer, even if they plan is not optimal. + */ for(i=0; inConstraint; i++){ unsigned char op; if( pIdxInfo->aConstraint[i].usable==0 ) continue; diff --git a/manifest b/manifest index 3c0483e6d0..e986c301dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scorner\scases\sin\sthe\sWITHOUT\sROWID\svirtual\stable\slogic. -D 2016-06-02T16:22:53.508 +C Add\sthe\sdata=\sparameter\sto\sthe\sCSV\svirtual\stable\sextension. +D 2016-06-02T17:44:24.492 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 @@ -206,7 +206,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c 39060a352f43e43df575484cc0f23ab61091dac3 +F ext/misc/csv.c d4f6f0776bcaaed7929d6ef1e1261287b856e0da F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1497,7 +1497,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 49638f180e26477974cacc69b79e0be0a5e18b29 -R cf24c2970498f36ff11e1ac85a33493a +P a393bbb972660c1ffcdda923d0f3564ecfcd2f0a +R 47b04ec69529b5020af652ca946943fd U drh -Z 5a84619c2e2d24987b3ea5aba48efb6c +Z ea4616a356c99262b96b6fda702a53cc diff --git a/manifest.uuid b/manifest.uuid index 154b8a6067..61b0d4ac01 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a393bbb972660c1ffcdda923d0f3564ecfcd2f0a \ No newline at end of file +769191042aa14e6eccdfe2391fc1011171d5c9ad \ No newline at end of file From 35db31b24b3ec27f741da5c8916c5e9dadee4727 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Jun 2016 23:13:21 +0000 Subject: [PATCH 123/302] Add the CSV extension to the test fixture. Fix a memory leak in the CSV extension. Add test cases for the CSV extension, including one that uses a WITHOUT ROWID virtual table participating in the OR optimization. FossilOrigin-Name: 95f483e86e30ae68108904400e18ed41d389446b --- Makefile.in | 1 + Makefile.msc | 1 + ext/misc/csv.c | 1 + main.mk | 1 + manifest | 23 +++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- src/test1.c | 2 ++ test/csv01.test | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 test/csv01.test diff --git a/Makefile.in b/Makefile.in index 4e10d4e231..115cfac58f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -417,6 +417,7 @@ TESTSRC = \ TESTSRC += \ $(TOP)/ext/misc/amatch.c \ $(TOP)/ext/misc/closure.c \ + $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/eval.c \ $(TOP)/ext/misc/fileio.c \ $(TOP)/ext/misc/fuzzer.c \ diff --git a/Makefile.msc b/Makefile.msc index 408a516364..9bf1e4f8fe 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1293,6 +1293,7 @@ TESTSRC = \ TESTEXT = \ $(TOP)\ext\misc\amatch.c \ $(TOP)\ext\misc\closure.c \ + $(TOP)\ext\misc\csv.c \ $(TOP)\ext\misc\eval.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\fuzzer.c \ diff --git a/ext/misc/csv.c b/ext/misc/csv.c index 1b19631772..343c866c95 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -302,6 +302,7 @@ static void csv_xfer_error(CsvTable *pTab, CsvReader *pRdr){ static int csvtabDisconnect(sqlite3_vtab *pVtab){ CsvTable *p = (CsvTable*)pVtab; sqlite3_free(p->zFilename); + sqlite3_free(p->zData); sqlite3_free(p); return SQLITE_OK; } diff --git a/main.mk b/main.mk index e193729b8a..624bf77a06 100644 --- a/main.mk +++ b/main.mk @@ -325,6 +325,7 @@ TESTSRC = \ TESTSRC += \ $(TOP)/ext/misc/amatch.c \ $(TOP)/ext/misc/closure.c \ + $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/eval.c \ $(TOP)/ext/misc/fileio.c \ $(TOP)/ext/misc/fuzzer.c \ diff --git a/manifest b/manifest index e986c301dd..2da7d447f7 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Add\sthe\sdata=\sparameter\sto\sthe\sCSV\svirtual\stable\sextension. -D 2016-06-02T17:44:24.492 -F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 +C Add\sthe\sCSV\sextension\sto\sthe\stest\sfixture.\s\sFix\sa\smemory\sleak\sin\sthe\sCSV\nextension.\s\sAdd\stest\scases\sfor\sthe\sCSV\sextension,\sincluding\sone\sthat\suses\na\sWITHOUT\sROWID\svirtual\stable\sparticipating\sin\sthe\sOR\soptimization. +D 2016-06-02T23:13:21.510 +F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 +F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -206,7 +206,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c d4f6f0776bcaaed7929d6ef1e1261287b856e0da +F ext/misc/csv.c 58ad4e9eb25310a2712e0cb78592dc15924f0379 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -306,7 +306,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk eab7db27ac2a32b1172a85aa850c0b9c3a00524c +F main.mk 2b90646ca027cc21dbae209a0fee68dfedfe0e83 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -335,7 +335,7 @@ F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c 81bd7d87985746313770211183e900ed1ad28381 +F src/expr.c 798146ea4c87d723e8a157d88450ac9c43256998 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb F src/func.c ef4c18c8a66143413ce41a58d582d2c14ddf78e1 @@ -391,7 +391,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 -F src/test1.c c0e5b69f99e95a2c9f55fdb6e46b44f1a15292d8 +F src/test1.c 43b37ab2b7338fd3313e74902f0d6c821eae843b F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c d2c9efd2985ff8f5502ffd3253156984778d77d8 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -612,6 +612,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c +F test/csv01.test 44a9786f6cb4dcf40f3d5d59844dbb88d2265e5d F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 @@ -1497,7 +1498,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a393bbb972660c1ffcdda923d0f3564ecfcd2f0a -R 47b04ec69529b5020af652ca946943fd +P 769191042aa14e6eccdfe2391fc1011171d5c9ad +R 7cb009be35227902926fe0d852282f91 U drh -Z ea4616a356c99262b96b6fda702a53cc +Z 7f2a8b3dbd34984ea991a68c56b4587b diff --git a/manifest.uuid b/manifest.uuid index 61b0d4ac01..816aa44fdf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -769191042aa14e6eccdfe2391fc1011171d5c9ad \ No newline at end of file +95f483e86e30ae68108904400e18ed41d389446b \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 156db96fa1..c6a09d9d9d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2535,7 +2535,7 @@ void sqlite3ExprCodeGetColumnOfTable( }else{ int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; int x = iCol; - if( !HasRowid(pTab) ){ + if( !HasRowid(pTab) && !IsVirtual(pTab) ){ x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol); } sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); diff --git a/src/test1.c b/src/test1.c index ee71b854b9..0f16d62d85 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6584,6 +6584,7 @@ static int tclLoadStaticExtensionCmd( ){ extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); + extern int sqlite3_csv_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_eval_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*); @@ -6601,6 +6602,7 @@ static int tclLoadStaticExtensionCmd( } aExtension[] = { { "amatch", sqlite3_amatch_init }, { "closure", sqlite3_closure_init }, + { "csv", sqlite3_csv_init }, { "eval", sqlite3_eval_init }, { "fileio", sqlite3_fileio_init }, { "fuzzer", sqlite3_fuzzer_init }, diff --git a/test/csv01.test b/test/csv01.test new file mode 100644 index 0000000000..aaec857992 --- /dev/null +++ b/test/csv01.test @@ -0,0 +1,91 @@ +# 2016-06-02 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Test cases for CSV virtual table. + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix closure01 + +ifcapable !vtab||!cte { finish_test ; return } + +load_static_extension db csv + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE temp.t1 USING csv( + data= +'1,2,3,4 +5,6,7,8 +9,10,11,12 +13,14,15,16 +', + columns=4 + ); + SELECT * FROM t1 WHERE c1=10; +} {9 10 11 12} +do_execsql_test 1.1 { + SELECT * FROM t1 WHERE c1='10'; +} {9 10 11 12} +do_execsql_test 1.2 { + SELECT rowid FROM t1; +} {1 2 3 4} + +do_execsql_test 2.0 { + DROP TABLE t1; + CREATE VIRTUAL TABLE temp.t2 USING csv( + data= +'1,2,3,4 +5,6,7,8 +9,10,11,12 +13,14,15,16 +', + columns=4, + schema='CREATE TABLE t2(a INT, b TEXT, c REAL, d BLOB)' + ); + SELECT * FROM t2 WHERE a=9; +} {9 10 11 12} +do_execsql_test 2.1 { + SELECT * FROM t2 WHERE b=10; +} {9 10 11 12} +do_execsql_test 2.2 { + SELECT * FROM t2 WHERE c=11; +} {9 10 11 12} +do_execsql_test 2.3 { + SELECT * FROM t2 WHERE d=12; +} {} +do_execsql_test 2.4 { + SELECT * FROM t2 WHERE d='12'; +} {9 10 11 12} +do_execsql_test 2.5 { + SELECT * FROM t2 WHERE a='9'; +} {9 10 11 12} + +do_execsql_test 3.0 { + DROP TABLE t2; + CREATE VIRTUAL TABLE temp.t3 USING csv( + data= +'1,2,3,4 +5,6,7,8 +9,10,11,12 +13,14,15,16 +', + columns=4, + schema= + 'CREATE TABLE t3(a PRIMARY KEY,b TEXT,c TEXT,d TEXT) WITHOUT ROWID', + testflags=1 + ); + SELECT a FROM t3 WHERE b=6 OR c=7 OR d=12 ORDER BY +a; +} {5 9} +do_execsql_test 3.1 { + SELECT a FROM t3 WHERE +b=6 OR c=7 OR d=12 ORDER BY +a; +} {5 9} + +finish_test From ac9c3d2c1805e7266fe53b9dcb4d75a22fec0335 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 3 Jun 2016 01:01:57 +0000 Subject: [PATCH 124/302] Performance optimizations on the CSV virtual table. Disallow WITHOUT ROWID virtual tables that have an xUpdate method, for now. FossilOrigin-Name: 3134b3266c36c9d018e8d365ef46ef638c0792f4 --- ext/misc/csv.c | 210 +++++++++++++++++++++++++++++++++--------------- manifest | 16 ++-- manifest.uuid | 2 +- src/vtab.c | 3 + test/csv01.test | 16 ++++ 5 files changed, 172 insertions(+), 75 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index 343c866c95..c0d8ecd3fc 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -27,6 +27,17 @@ ** filename = "../http.log", ** schema = "CREATE TABLE x(date,ipaddr,url,referrer,userAgent)" ** ); +** +** Instead of specifying a file, the text of the CSV can be loaded using +** the data= parameter. +** +** If the columns=N parameter is supplied, then the CSV file is assumed to have +** N columns. If the columns parameter is omitted, the CSV file is opened +** as soon as the virtual table is constructed and the first row of the CSV +** is read in order to count the tables. +** +** Some extra debugging features (used for testing virtual tables) are available +** if this module is compiled with -DSQLITE_TEST. */ #include SQLITE_EXTENSION_INIT1 @@ -202,42 +213,43 @@ static char *csv_read_one_field(CsvReader *p){ if( c=='"' ){ int pc, ppc; int startLine = p->nLine; - int cQuote = c; pc = ppc = 0; while( 1 ){ c = csv_getc(p); - if( c=='\n' ) p->nLine++; - if( c==cQuote ){ - if( pc==cQuote ){ - pc = 0; - continue; + if( c<='"' || pc=='"' ){ + if( c=='\n' ) p->nLine++; + if( c=='"' ){ + if( pc=='"' ){ + pc = 0; + continue; + } + } + if( (c==',' && pc=='"') + || (c=='\n' && pc=='"') + || (c=='\n' && pc=='\r' && ppc=='"') + || (c==EOF && pc=='"') + ){ + do{ p->n--; }while( p->z[p->n]!='"' ); + p->cTerm = c; + break; + } + if( pc=='"' && c!='\r' ){ + csv_errmsg(p, "line %d: unescaped %c character", p->nLine, '"'); + break; + } + if( c==EOF ){ + csv_errmsg(p, "line %d: unterminated %c-quoted field\n", + startLine, '"'); + p->cTerm = c; + break; } - } - if( (c==',' && pc==cQuote) - || (c=='\n' && pc==cQuote) - || (c=='\n' && pc=='\r' && ppc==cQuote) - || (c==EOF && pc==cQuote) - ){ - do{ p->n--; }while( p->z[p->n]!=cQuote ); - p->cTerm = c; - break; - } - if( pc==cQuote && c!='\r' ){ - csv_errmsg(p, "line %d: unescaped %c character", p->nLine, cQuote); - break; - } - if( c==EOF ){ - csv_errmsg(p, "line %d: unterminated %c-quoted field\n", - startLine, cQuote); - p->cTerm = c; - break; } if( csv_append(p, (char)c) ) return 0; ppc = pc; pc = c; } }else{ - while( c!=EOF && c!=',' && c!='\n' ){ + while( c>',' || (c!=EOF && c!=',' && c!='\n') ){ if( csv_append(p, (char)c) ) return 0; c = csv_getc(p); } @@ -287,6 +299,7 @@ typedef struct CsvCursor { sqlite3_vtab_cursor base; /* Base class. Must be first */ CsvReader rdr; /* The CsvReader object */ char **azVal; /* Value of the current row */ + int *aLen; /* Length of each entry */ sqlite3_int64 iRowid; /* The current rowid. Negative for EOF */ } CsvCursor; @@ -410,6 +423,9 @@ static int csv_boolean(const char *z){ ** header=YES|NO First row of CSV defines the names of ** columns if "yes". Default "no". ** columns=N Assume the CSV file contains N columns. +** +** Only available if compiled with SQLITE_TEST: +** ** testflags=N Bitmask of test flags. Optional ** ** If schema= is omitted, then the columns are named "c0", "c1", "c2", @@ -428,7 +444,9 @@ static int csvtabConnect( int bHeader = -1; /* header= flags. -1 means not seen yet */ int rc = SQLITE_OK; /* Result code from this routine */ int i, j; /* Loop counters */ +#ifdef SQLITE_TEST int tstFlags = 0; /* Value for testflags=N parameter */ +#endif int nCol = -99; /* Value of the columns= parameter */ CsvReader sRdr; /* A CSV file reader used to store an error ** message and/or to count the number of columns */ @@ -469,9 +487,11 @@ static int csvtabConnect( goto csvtab_connect_error; } }else +#ifdef SQLITE_TEST if( (zValue = csv_parameter("testflags",9,z))!=0 ){ tstFlags = (unsigned int)atoi(zValue); }else +#endif if( (zValue = csv_parameter("columns",7,z))!=0 ){ if( nCol>0 ){ csv_errmsg(&sRdr, "more than one 'columns' parameter"); @@ -510,7 +530,9 @@ static int csvtabConnect( } pNew->zFilename = CSV_FILENAME; CSV_FILENAME = 0; pNew->zData = CSV_DATA; CSV_DATA = 0; +#ifdef SQLITE_TEST pNew->tstFlags = tstFlags; +#endif pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0; csv_reader_reset(&sRdr); if( CSV_SCHEMA==0 ){ @@ -557,6 +579,7 @@ static void csvtabCursorRowReset(CsvCursor *pCur){ for(i=0; inCol; i++){ sqlite3_free(pCur->azVal[i]); pCur->azVal[i] = 0; + pCur->aLen[i] = 0; } } @@ -591,10 +614,13 @@ static int csvtabClose(sqlite3_vtab_cursor *cur){ static int csvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ CsvTable *pTab = (CsvTable*)p; CsvCursor *pCur; - pCur = sqlite3_malloc( sizeof(*pCur) * sizeof(char*)*pTab->nCol ); + size_t nByte; + nByte = sizeof(*pCur) + (sizeof(char*)+sizeof(int))*pTab->nCol; + pCur = sqlite3_malloc( nByte ); if( pCur==0 ) return SQLITE_NOMEM; - memset(pCur, 0, sizeof(*pCur) + sizeof(char*)*pTab->nCol ); + memset(pCur, 0, nByte); pCur->azVal = (char**)&pCur[1]; + pCur->aLen = (int*)&pCur->azVal[pTab->nCol]; *ppCursor = &pCur->base; if( csv_reader_open(&pCur->rdr, pTab->zFilename, pTab->zData) ){ csv_xfer_error(pTab, &pCur->rdr); @@ -613,23 +639,33 @@ static int csvtabNext(sqlite3_vtab_cursor *cur){ CsvTable *pTab = (CsvTable*)cur->pVtab; int i = 0; char *z; - csvtabCursorRowReset(pCur); do{ z = csv_read_one_field(&pCur->rdr); if( z==0 ){ csv_xfer_error(pTab, &pCur->rdr); break; } - z = sqlite3_mprintf("%s", z); - if( z==0 ){ - csv_errmsg(&pCur->rdr, "out of memory"); - csv_xfer_error(pTab, &pCur->rdr); - break; - } if( inCol ){ - pCur->azVal[i++] = z; + if( pCur->aLen[i] < pCur->rdr.n+1 ){ + char *zNew = sqlite3_realloc(pCur->azVal[i], pCur->rdr.n+1); + if( zNew==0 ){ + csv_errmsg(&pCur->rdr, "out of memory"); + csv_xfer_error(pTab, &pCur->rdr); + break; + } + pCur->azVal[i] = zNew; + pCur->aLen[i] = pCur->rdr.n+1; + } + memcpy(pCur->azVal[i], z, pCur->rdr.n+1); + i++; } - }while( z!=0 && pCur->rdr.cTerm==',' ); + }while( pCur->rdr.cTerm==',' ); + while( inCol ){ + sqlite3_free(pCur->azVal[i]); + pCur->azVal[i] = 0; + pCur->aLen[i] = 0; + i++; + } if( z==0 || pCur->rdr.cTerm==EOF ){ pCur->iRowid = -1; }else{ @@ -707,37 +743,37 @@ static int csvtabBestIndex( sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo ){ - CsvTable *pTab = (CsvTable*)tab; - int i; - int nConst = 0; pIdxInfo->estimatedCost = 1000000; - if( (pTab->tstFlags & CSVTEST_FIDX)==0 ){ - return SQLITE_OK; - } - /* The usual (and sensible) case is to take the "return SQLITE_OK" above. - ** The code below only runs when testflags=1. The code below - ** generates an artifical and unrealistic plan which is useful - ** for testing virtual table logic but is not helpfulto real applications. - ** - ** Any ==, LIKE, or GLOB constraint is marked as usable by the virtual - ** table (even though it is not) and the cost of running the virtual table - ** is reduced from 1 million to just 10. The constraints are *not* marked - ** as omittable, however, so the query planner should still generate a - ** plan that gives a correct answer, even if they plan is not optimal. - */ - for(i=0; inConstraint; i++){ - unsigned char op; - if( pIdxInfo->aConstraint[i].usable==0 ) continue; - op = pIdxInfo->aConstraint[i].op; - if( op==SQLITE_INDEX_CONSTRAINT_EQ - || op==SQLITE_INDEX_CONSTRAINT_LIKE - || op==SQLITE_INDEX_CONSTRAINT_GLOB - ){ - pIdxInfo->estimatedCost = 10; - pIdxInfo->aConstraintUsage[nConst].argvIndex = nConst+1; - nConst++; +#ifdef SQLITE_TEST + if( (((CsvTable*)tab)->tstFlags & CSVTEST_FIDX)!=0 ){ + /* The usual (and sensible) case is to always do a full table scan. + ** The code in this branch only runs when testflags=1. This code + ** generates an artifical and unrealistic plan which is useful + ** for testing virtual table logic but is not helpful to real applications. + ** + ** Any ==, LIKE, or GLOB constraint is marked as usable by the virtual + ** table (even though it is not) and the cost of running the virtual table + ** is reduced from 1 million to just 10. The constraints are *not* marked + ** as omittable, however, so the query planner should still generate a + ** plan that gives a correct answer, even if they plan is not optimal. + */ + int i; + int nConst = 0; + for(i=0; inConstraint; i++){ + unsigned char op; + if( pIdxInfo->aConstraint[i].usable==0 ) continue; + op = pIdxInfo->aConstraint[i].op; + if( op==SQLITE_INDEX_CONSTRAINT_EQ + || op==SQLITE_INDEX_CONSTRAINT_LIKE + || op==SQLITE_INDEX_CONSTRAINT_GLOB + ){ + pIdxInfo->estimatedCost = 10; + pIdxInfo->aConstraintUsage[nConst].argvIndex = nConst+1; + nConst++; + } } } +#endif return SQLITE_OK; } @@ -765,6 +801,41 @@ static sqlite3_module CsvModule = { 0, /* xRename */ }; +#ifdef SQLITE_TEST +/* +** For virtual table testing, make a version of the CSV virtual table +** available that has an xUpdate function. But the xUpdate always returns +** SQLITE_READONLY since the CSV file is not really writable. +*/ +static int csvtabUpdate(sqlite3_vtab *p,int n,sqlite3_value**v,sqlite3_int64*x){ + return SQLITE_READONLY; +} +static sqlite3_module CsvModuleFauxWrite = { + 0, /* iVersion */ + csvtabCreate, /* xCreate */ + csvtabConnect, /* xConnect */ + csvtabBestIndex, /* xBestIndex */ + csvtabDisconnect, /* xDisconnect */ + csvtabDisconnect, /* xDestroy */ + csvtabOpen, /* xOpen - open a cursor */ + csvtabClose, /* xClose - close a cursor */ + csvtabFilter, /* xFilter - configure scan constraints */ + csvtabNext, /* xNext - advance a cursor */ + csvtabEof, /* xEof - check for end of scan */ + csvtabColumn, /* xColumn - read data */ + csvtabRowid, /* xRowid - read data */ + csvtabUpdate, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; +#endif /* SQLITE_TEST */ + + + #ifdef _WIN32 __declspec(dllexport) #endif @@ -778,6 +849,13 @@ int sqlite3_csv_init( char **pzErrMsg, const sqlite3_api_routines *pApi ){ + int rc; SQLITE_EXTENSION_INIT2(pApi); - return sqlite3_create_module(db, "csv", &CsvModule, 0); + rc = sqlite3_create_module(db, "csv", &CsvModule, 0); +#ifdef SQLITE_TEST + if( rc==SQLITE_OK ){ + rc = sqlite3_create_module(db, "csv_wr", &CsvModuleFauxWrite, 0); + } +#endif + return rc; } diff --git a/manifest b/manifest index 2da7d447f7..21eb765e24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sCSV\sextension\sto\sthe\stest\sfixture.\s\sFix\sa\smemory\sleak\sin\sthe\sCSV\nextension.\s\sAdd\stest\scases\sfor\sthe\sCSV\sextension,\sincluding\sone\sthat\suses\na\sWITHOUT\sROWID\svirtual\stable\sparticipating\sin\sthe\sOR\soptimization. -D 2016-06-02T23:13:21.510 +C Performance\soptimizations\son\sthe\sCSV\svirtual\stable.\s\sDisallow\sWITHOUT\sROWID\nvirtual\stables\sthat\shave\san\sxUpdate\smethod,\sfor\snow. +D 2016-06-03T01:01:57.592 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -206,7 +206,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c 58ad4e9eb25310a2712e0cb78592dc15924f0379 +F ext/misc/csv.c f01126ba170fd4ef7c752b156568a80c912d4441 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -456,7 +456,7 @@ F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 -F src/vtab.c a80b4e40ed8687daa3303e970d938b1f613a3eeb +F src/vtab.c a9e8175477539660814a4704e8eaba6df3678651 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -612,7 +612,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c -F test/csv01.test 44a9786f6cb4dcf40f3d5d59844dbb88d2265e5d +F test/csv01.test 69aecc17f11f597390b47700aec8d748b8364140 F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 @@ -1498,7 +1498,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 769191042aa14e6eccdfe2391fc1011171d5c9ad -R 7cb009be35227902926fe0d852282f91 +P 95f483e86e30ae68108904400e18ed41d389446b +R 110a9ed97c9cb7052ae396116c46b04d U drh -Z 7f2a8b3dbd34984ea991a68c56b4587b +Z 863bf523824cd922d795a07ca8451a6d diff --git a/manifest.uuid b/manifest.uuid index 816aa44fdf..935a081c06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95f483e86e30ae68108904400e18ed41d389446b \ No newline at end of file +3134b3266c36c9d018e8d365ef46ef638c0792f4 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index b4268536a0..30cdd43e4b 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -762,6 +762,9 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ pNew->nCol = 0; pNew->aCol = 0; assert( pTab->pIndex==0 ); + if( !HasRowid(pNew) && pCtx->pVTable->pMod->pModule->xUpdate!=0 ){ + rc = SQLITE_ERROR; + } pIdx = pNew->pIndex; if( pIdx ){ assert( pIdx->pNext==0 ); diff --git a/test/csv01.test b/test/csv01.test index aaec857992..ba3a947dfc 100644 --- a/test/csv01.test +++ b/test/csv01.test @@ -88,4 +88,20 @@ do_execsql_test 3.1 { SELECT a FROM t3 WHERE +b=6 OR c=7 OR d=12 ORDER BY +a; } {5 9} +do_catchsql_test 4.0 { + DROP TABLE t3; + CREATE VIRTUAL TABLE temp.t4 USING csv_wr( + data= +'1,2,3,4 +5,6,7,8 +9,10,11,12 +13,14,15,16 +', + columns=4, + schema= + 'CREATE TABLE t3(a PRIMARY KEY,b TEXT,c TEXT,d TEXT) WITHOUT ROWID', + testflags=1 + ); +} {1 {vtable constructor failed: t4}} + finish_test From 7edcf627af2b62cd0914cd25299d704a9751f617 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 3 Jun 2016 17:27:14 +0000 Subject: [PATCH 125/302] Disallow access to the rowid column on WITHOUT ROWID virtual tables. FossilOrigin-Name: d31c25972bfb6d04caad05534505698776e7e6d5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vtab.c | 2 +- test/csv01.test | 5 +++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 21eb765e24..14b0bedf9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimizations\son\sthe\sCSV\svirtual\stable.\s\sDisallow\sWITHOUT\sROWID\nvirtual\stables\sthat\shave\san\sxUpdate\smethod,\sfor\snow. -D 2016-06-03T01:01:57.592 +C Disallow\saccess\sto\sthe\srowid\scolumn\son\sWITHOUT\sROWID\svirtual\stables. +D 2016-06-03T17:27:14.741 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -456,7 +456,7 @@ F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 -F src/vtab.c a9e8175477539660814a4704e8eaba6df3678651 +F src/vtab.c 7a143175f5586d99f78f61b43a563caa03eb4d63 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -612,7 +612,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c -F test/csv01.test 69aecc17f11f597390b47700aec8d748b8364140 +F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 @@ -1498,7 +1498,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 95f483e86e30ae68108904400e18ed41d389446b -R 110a9ed97c9cb7052ae396116c46b04d +P 3134b3266c36c9d018e8d365ef46ef638c0792f4 +R 6bd90244b320ac429cd2120cdab002d9 U drh -Z 863bf523824cd922d795a07ca8451a6d +Z 5fa00a97540dd1b5ac1a6e73a3f78ebc diff --git a/manifest.uuid b/manifest.uuid index 935a081c06..0f61bc8586 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3134b3266c36c9d018e8d365ef46ef638c0792f4 \ No newline at end of file +d31c25972bfb6d04caad05534505698776e7e6d5 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index 30cdd43e4b..eeef64c67a 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -758,7 +758,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ Index *pIdx; pTab->aCol = pNew->aCol; pTab->nCol = pNew->nCol; - pTab->tabFlags |= pNew->tabFlags & TF_WithoutRowid; + pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid); pNew->nCol = 0; pNew->aCol = 0; assert( pTab->pIndex==0 ); diff --git a/test/csv01.test b/test/csv01.test index ba3a947dfc..a6fff81c3f 100644 --- a/test/csv01.test +++ b/test/csv01.test @@ -88,6 +88,11 @@ do_execsql_test 3.1 { SELECT a FROM t3 WHERE +b=6 OR c=7 OR d=12 ORDER BY +a; } {5 9} +# The rowid column is not visible on a WITHOUT ROWID virtual table +do_catchsql_test 3.2 { + SELECT rowid, a FROM t3; +} {1 {no such column: rowid}} + do_catchsql_test 4.0 { DROP TABLE t3; CREATE VIRTUAL TABLE temp.t4 USING csv_wr( From 0b2c140a4d9a12784d2501cc223931a82208a161 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 3 Jun 2016 18:21:04 +0000 Subject: [PATCH 126/302] Fix a memory leak when a WITHOUT ROWID eponymous virtual table is used. FossilOrigin-Name: 31b83a7d7e553163eb186fc966a885f237554ec2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/fkey.c | 3 ++- src/vtab.c | 21 ++++++++++++--------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 14b0bedf9c..b320ac31b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disallow\saccess\sto\sthe\srowid\scolumn\son\sWITHOUT\sROWID\svirtual\stables. -D 2016-06-03T17:27:14.741 +C Fix\sa\smemory\sleak\swhen\sa\sWITHOUT\sROWID\seponymous\svirtual\stable\sis\sused. +D 2016-06-03T18:21:04.549 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -337,7 +337,7 @@ F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f F src/expr.c 798146ea4c87d723e8a157d88450ac9c43256998 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 4c0bd09e602b8ae8d36d81e31e4872d0b53c87bb +F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 F src/func.c ef4c18c8a66143413ce41a58d582d2c14ddf78e1 F src/global.c c45ea22aff29334f6a9ec549235ac3357c970015 F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36 @@ -456,7 +456,7 @@ F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 -F src/vtab.c 7a143175f5586d99f78f61b43a563caa03eb4d63 +F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -1498,7 +1498,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3134b3266c36c9d018e8d365ef46ef638c0792f4 -R 6bd90244b320ac429cd2120cdab002d9 +P d31c25972bfb6d04caad05534505698776e7e6d5 +R 531a893078b3c566412693ad918cbea6 U drh -Z 5fa00a97540dd1b5ac1a6e73a3f78ebc +Z 4ddeb8f309e9f433c6376653796d4760 diff --git a/manifest.uuid b/manifest.uuid index 0f61bc8586..8dbe108de4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d31c25972bfb6d04caad05534505698776e7e6d5 \ No newline at end of file +31b83a7d7e553163eb186fc966a885f237554ec2 \ No newline at end of file diff --git a/src/fkey.c b/src/fkey.c index fa19fbc1ce..25d9f84917 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1372,7 +1372,8 @@ void sqlite3FkDelete(sqlite3 *db, Table *pTab){ FKey *pFKey; /* Iterator variable */ FKey *pNext; /* Copy of pFKey->pNextFrom */ - assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); + assert( db==0 || IsVirtual(pTab) + || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){ /* Remove the FK from the fkeyHash hash table. */ diff --git a/src/vtab.c b/src/vtab.c index eeef64c67a..e81079a050 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -1101,7 +1101,7 @@ void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){ } /* -** Check to see if virtual tale module pMod can be have an eponymous +** Check to see if virtual table module pMod can be have an eponymous ** virtual table instance. If it can, create one if one does not already ** exist. Return non-zero if the eponymous virtual table instance exists ** when this routine returns, and return zero if it does not exist. @@ -1118,17 +1118,18 @@ int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ const sqlite3_module *pModule = pMod->pModule; Table *pTab; char *zErr = 0; - int nName; int rc; sqlite3 *db = pParse->db; if( pMod->pEpoTab ) return 1; if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0; - nName = sqlite3Strlen30(pMod->zName) + 1; - pTab = sqlite3DbMallocZero(db, sizeof(Table) + nName); + pTab = sqlite3DbMallocZero(db, sizeof(Table)); if( pTab==0 ) return 0; + pTab->zName = sqlite3DbStrDup(db, pMod->zName); + if( pTab->zName==0 ){ + sqlite3DbFree(db, pTab); + return 0; + } pMod->pEpoTab = pTab; - pTab->zName = (char*)&pTab[1]; - memcpy(pTab->zName, pMod->zName, nName); pTab->nRef = 1; pTab->pSchema = db->aDb[0].pSchema; pTab->tabFlags |= TF_Virtual; @@ -1154,9 +1155,11 @@ int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){ Table *pTab = pMod->pEpoTab; if( pTab!=0 ){ - sqlite3DeleteColumnNames(db, pTab); - sqlite3VtabClear(db, pTab); - sqlite3DbFree(db, pTab); + /* Mark the table as Ephemeral prior to deleting it, so that the + ** sqlite3DeleteTable() routine will know that it is not stored in + ** the schema. */ + pTab->tabFlags |= TF_Ephemeral; + sqlite3DeleteTable(db, pTab); pMod->pEpoTab = 0; } } From cc9717381075e58c9d2197b1924d7a77ae4372a4 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Jun 2016 13:57:41 +0000 Subject: [PATCH 127/302] Remove an unreachable branch in the UNIQUE constraint parsing. FossilOrigin-Name: 313e990c741d7db082f1d9b9f3f4c65fdd91b812 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/build.c | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d7eafa6187..b04a4479b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sOR\soptimization\sis\susable\son\svirtual\stables\swith\sLIKE,\sREGEXP\sand/or\sGLOB\nterms\sin\sthe\sWHERE\sclause. -D 2016-06-03T18:59:37.684 +C Remove\san\sunreachable\sbranch\sin\sthe\sUNIQUE\sconstraint\sparsing. +D 2016-06-04T13:57:41.807 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -329,7 +329,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2128172fc1c420a6fa6878827fa595407795069a F src/btree.h 1342a9b2cc2089e3534d3ef00204786783f6aea6 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 555b459d1f25fba6c56266e60bbbdc93bdf5f66a +F src/build.c e827e57e4a29c00e8429c5fd4d9d4572cb1b32a4 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 @@ -1500,8 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aa7e9d0cc15c050205b09d5a50f985e4ade571d0 242507b4ff96bc4c7c7844dbe1c2b8508dbf1d01 -R dfe54e67ed3ff0c24bd7773ed3ea50c6 -T +closed 242507b4ff96bc4c7c7844dbe1c2b8508dbf1d01 +P fa3a89fc0b88d5ad7f5c232198847b3483eef611 +R 792813b3b416caa613200f5d3538ce28 U drh -Z 465e32629738d03f290a2446a78a1b88 +Z d457dbe5f31dc59ad0f374dbed05972f diff --git a/manifest.uuid b/manifest.uuid index 0bd0a43bf5..2ef42a0dcf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa3a89fc0b88d5ad7f5c232198847b3483eef611 \ No newline at end of file +313e990c741d7db082f1d9b9f3f4c65fdd91b812 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 092a9973b3..a5931954ad 100644 --- a/src/build.c +++ b/src/build.c @@ -3287,8 +3287,9 @@ void sqlite3CreateIndex( ** in-memory database structures. */ assert( pParse->nErr==0 ); - if( db->init.busy && !IN_DECLARE_VTAB ){ + if( db->init.busy ){ Index *p; + assert( !IN_DECLARE_VTAB ); assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); p = sqlite3HashInsert(&pIndex->pSchema->idxHash, pIndex->zName, pIndex); From 30e3fdf0ee42a94b4932dee03a69845d62f50da3 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Jun 2016 16:33:48 +0000 Subject: [PATCH 128/302] Fix up speedtest1.c so that it will compile and run on SQLite versions prior to 3.6.18 (circa 2009-09-11). FossilOrigin-Name: 9583c0fb39f357a76e0c99ea03b034aea3e03c75 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index b04a4479b5..64889ef359 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\sbranch\sin\sthe\sUNIQUE\sconstraint\sparsing. -D 2016-06-04T13:57:41.807 +C Fix\sup\sspeedtest1.c\sso\sthat\sit\swill\scompile\sand\srun\son\sSQLite\sversions\sprior\nto\s3.6.18\s(circa\s2009-09-11). +D 2016-06-04T16:33:48.064 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -1093,7 +1093,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c 4476f7030775507f060d27b789e1f4123c5a5866 +F test/speedtest1.c 28221f433d358dd3fcf2ca504ed51409aa66ffaf F test/spellfix.test f9c1f431e2c096c8775fec032952320c0e4700db F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa3a89fc0b88d5ad7f5c232198847b3483eef611 -R 792813b3b416caa613200f5d3538ce28 +P 313e990c741d7db082f1d9b9f3f4c65fdd91b812 +R 0ccf0692aa5b1e3235a74f8650fcfe4f U drh -Z d457dbe5f31dc59ad0f374dbed05972f +Z a2bd3a06dcb83b470b97f0c6e2306afd diff --git a/manifest.uuid b/manifest.uuid index 2ef42a0dcf..12c744c1c5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -313e990c741d7db082f1d9b9f3f4c65fdd91b812 \ No newline at end of file +9583c0fb39f357a76e0c99ea03b034aea3e03c75 \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index 2d337d4705..c69c6d5fc5 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -1216,6 +1216,10 @@ static void displayLinuxIoStats(FILE *out){ } #endif +#if SQLITE_VERSION_NUMBER<3006018 +# define sqlite3_sourceid(X) "(before 3.6.18)" +#endif + int main(int argc, char **argv){ int doAutovac = 0; /* True for --autovacuum */ int cacheSize = 0; /* Desired cache size. 0 means default */ From f94fdd832cc7f7ec1764af518edf746cba6a3687 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Jun 2016 17:12:26 +0000 Subject: [PATCH 129/302] Allocate KeyInfo objects from lookaside if possible. FossilOrigin-Name: b411107a3609d53af4e147f01e311b858b78420b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 64889ef359..5cfb3e8240 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sup\sspeedtest1.c\sso\sthat\sit\swill\scompile\sand\srun\son\sSQLite\sversions\sprior\nto\s3.6.18\s(circa\s2009-09-11). -D 2016-06-04T16:33:48.064 +C Allocate\sKeyInfo\sobjects\sfrom\slookaside\sif\spossible. +D 2016-06-04T17:12:26.466 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -382,7 +382,7 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c a0c4abf54bc6bd3a9c77a36ef3d1676045706cb2 +F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 5f8113dbec74c6c093ead9930afb8c9fbd9f643d F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 313e990c741d7db082f1d9b9f3f4c65fdd91b812 -R 0ccf0692aa5b1e3235a74f8650fcfe4f +P 9583c0fb39f357a76e0c99ea03b034aea3e03c75 +R 065fce549d6916be91d3267449fff27c U drh -Z a2bd3a06dcb83b470b97f0c6e2306afd +Z 36eef125b8bc40e49e28e0447e72ab1c diff --git a/manifest.uuid b/manifest.uuid index 12c744c1c5..b10b2154c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9583c0fb39f357a76e0c99ea03b034aea3e03c75 \ No newline at end of file +b411107a3609d53af4e147f01e311b858b78420b \ No newline at end of file diff --git a/src/select.c b/src/select.c index 495d47e20b..e21ac57dc5 100644 --- a/src/select.c +++ b/src/select.c @@ -1028,7 +1028,7 @@ static void selectInnerLoop( */ KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ int nExtra = (N+X)*(sizeof(CollSeq*)+1); - KeyInfo *p = sqlite3Malloc(sizeof(KeyInfo) + nExtra); + KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra); if( p ){ p->aSortOrder = (u8*)&p->aColl[N+X]; p->nField = (u16)N; @@ -1050,7 +1050,7 @@ void sqlite3KeyInfoUnref(KeyInfo *p){ if( p ){ assert( p->nRef>0 ); p->nRef--; - if( p->nRef==0 ) sqlite3DbFree(0, p); + if( p->nRef==0 ) sqlite3DbFree(p->db, p); } } From a7c90c42eaf1badd141ca21bd64669e03de9830c Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Jun 2016 20:37:10 +0000 Subject: [PATCH 130/302] Change the sqlite3BtreeKeySize() interface into sqlite3BtreeIntegerKey() and make it only work for table btrees. Change sqlite3BtreeDataSize() into sqlite3BtreePayloadSize() and make it work for all btrees. Combine sqlite3BtreeDataFetch() and sqlite3BtreeKeyFetch() into a single sqlite3BtreePayloadFetch() routine. These changes seem to make the b-tree interface more rational and they reduce both binary size and CPU usage. FossilOrigin-Name: bef35e18dd19732f7859287b097feeb593e5900f --- manifest | 29 +++++++++++++----------- manifest.uuid | 2 +- src/btree.c | 61 +++++++++++++++++--------------------------------- src/btree.h | 7 +++--- src/test3.c | 15 +++---------- src/vdbe.c | 49 +++++++++------------------------------- src/vdbeapi.c | 3 +-- src/vdbeaux.c | 6 ++--- src/vdbeblob.c | 2 +- src/vdbemem.c | 6 +---- 10 files changed, 59 insertions(+), 121 deletions(-) diff --git a/manifest b/manifest index 5cfb3e8240..f5cc249751 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allocate\sKeyInfo\sobjects\sfrom\slookaside\sif\spossible. -D 2016-06-04T17:12:26.466 +C Change\sthe\ssqlite3BtreeKeySize()\sinterface\sinto\ssqlite3BtreeIntegerKey()\sand\nmake\sit\sonly\swork\sfor\stable\sbtrees.\s\sChange\ssqlite3BtreeDataSize()\sinto\nsqlite3BtreePayloadSize()\sand\smake\sit\swork\sfor\sall\sbtrees.\s\sCombine\nsqlite3BtreeDataFetch()\sand\ssqlite3BtreeKeyFetch()\sinto\sa\ssingle\nsqlite3BtreePayloadFetch()\sroutine.\s\sThese\schanges\sseem\sto\smake\sthe\nb-tree\sinterface\smore\srational\sand\sthey\sreduce\sboth\sbinary\ssize\sand\nCPU\susage. +D 2016-06-04T20:37:10.186 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -326,8 +326,8 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 2128172fc1c420a6fa6878827fa595407795069a -F src/btree.h 1342a9b2cc2089e3534d3ef00204786783f6aea6 +F src/btree.c b55e96857e89734ae0ef2e77ed07b5e55314f1d9 +F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c e827e57e4a29c00e8429c5fd4d9d4572cb1b32a4 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 @@ -394,7 +394,7 @@ F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 F src/test1.c 43b37ab2b7338fd3313e74902f0d6c821eae843b F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b -F src/test3.c d2c9efd2985ff8f5502ffd3253156984778d77d8 +F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 F src/test6.c a684b7abd01352ab50cb79c0bf727e6b3f381a3d @@ -448,13 +448,13 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 45e4da739187028281e342f79fae0f4145055bec +F src/vdbe.c f6d37b366fe426637708ad6ad21d93e8b52512e2 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd -F src/vdbeapi.c ba85b78fe08dc4a9ce747e62c89a2b4a4547e74c -F src/vdbeaux.c 1d6b9a979d1036db7bc39990e9e683f19520bc5c -F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77 -F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb +F src/vdbeapi.c 02bcbc2ca5d2004b029088b05b468b394881e103 +F src/vdbeaux.c c90275b0e55a2b32c03dc09314194fe46f2429d8 +F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b +F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e @@ -1500,7 +1500,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9583c0fb39f357a76e0c99ea03b034aea3e03c75 -R 065fce549d6916be91d3267449fff27c +P b411107a3609d53af4e147f01e311b858b78420b +R 80a60ad5ffc5ad6e753a2a298aeee05c +T *branch * btree-refactor +T *sym-btree-refactor * +T -sym-trunk * U drh -Z 36eef125b8bc40e49e28e0447e72ab1c +Z 4c3d5b0be019f44c3e1bc23daff07019 diff --git a/manifest.uuid b/manifest.uuid index b10b2154c9..2fca7ce9d8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b411107a3609d53af4e147f01e311b858b78420b \ No newline at end of file +bef35e18dd19732f7859287b097feeb593e5900f \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7a2b80c23b..4003352a5e 100644 --- a/src/btree.c +++ b/src/btree.c @@ -609,20 +609,17 @@ static void btreeReleaseAllCursorPages(BtCursor *pCur){ ** the key. */ static int saveCursorKey(BtCursor *pCur){ - int rc; + int rc = SQLITE_OK; assert( CURSOR_VALID==pCur->eState ); assert( 0==pCur->pKey ); assert( cursorHoldsMutex(pCur) ); - rc = sqlite3BtreeKeySize(pCur, &pCur->nKey); - assert( rc==SQLITE_OK ); /* KeySize() cannot fail */ - - /* If this is an intKey table, then the above call to BtreeKeySize() - ** stores the integer key in pCur->nKey. In this case this value is - ** all that is required. Otherwise, if pCur is not open on an intKey - ** table, then malloc space for and store the pCur->nKey bytes of key - ** data. */ - if( 0==pCur->curIntKey ){ + if( pCur->curIntKey ){ + /* Only the rowid is required for a table btree */ + pCur->nKey = sqlite3BtreeIntegerKey(pCur); + }else{ + /* For an index btree, save the complete key content */ + pCur->nKey = sqlite3BtreePayloadSize(pCur); void *pKey = sqlite3Malloc( pCur->nKey ); if( pKey ){ rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey); @@ -4262,46 +4259,33 @@ int sqlite3BtreeCursorIsValid(BtCursor *pCur){ #endif /* NDEBUG */ /* -** Set *pSize to the size of the buffer needed to hold the value of -** the key for the current entry. If the cursor is not pointing -** to a valid entry, *pSize is set to 0. -** -** For a table with the INTKEY flag set, this routine returns the key -** itself, not the number of bytes in the key. -** -** The caller must position the cursor prior to invoking this routine. -** -** This routine cannot fail. It always returns SQLITE_OK. +** Return the value of the integer key or "rowid" for a table btree. +** This routine is only valid for a cursor that is pointing into a +** ordinary table btree. If the cursor points to an index btree or +** is invalid, the result of this routine is undefined. */ -int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){ +i64 sqlite3BtreeIntegerKey(BtCursor *pCur){ assert( cursorHoldsMutex(pCur) ); assert( pCur->eState==CURSOR_VALID ); + assert( pCur->curIntKey ); getCellInfo(pCur); - *pSize = pCur->info.nKey; - return SQLITE_OK; + return pCur->info.nKey; } /* -** Set *pSize to the number of bytes of data in the entry the -** cursor currently points to. +** Return the number of bytes of payload for the entry that pCur is +** currently pointing to. For table btrees, this will be the amount +** of data. For index btrees, this will be the size of the key. ** ** The caller must guarantee that the cursor is pointing to a non-NULL ** valid entry. In other words, the calling procedure must guarantee ** that the cursor has Cursor.eState==CURSOR_VALID. -** -** Failure is not possible. This function always returns SQLITE_OK. -** It might just as well be a procedure (returning void) but we continue -** to return an integer result code for historical reasons. */ -int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){ - assert( cursorOwnsBtShared(pCur) ); +u32 sqlite3BtreePayloadSize(BtCursor *pCur){ + assert( cursorHoldsMutex(pCur) ); assert( pCur->eState==CURSOR_VALID ); - assert( pCur->iPage>=0 ); - assert( pCur->iPageapPage[pCur->iPage]->intKeyLeaf==1 ); getCellInfo(pCur); - *pSize = pCur->info.nPayload; - return SQLITE_OK; + return pCur->info.nPayload; } /* @@ -4743,10 +4727,7 @@ static const void *fetchPayload( ** These routines is used to get quick access to key and data ** in the common case where no overflow pages are used. */ -const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){ - return fetchPayload(pCur, pAmt); -} -const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){ +const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){ return fetchPayload(pCur, pAmt); } diff --git a/src/btree.h b/src/btree.h index 5ac119c40a..5720df90f7 100644 --- a/src/btree.h +++ b/src/btree.h @@ -284,11 +284,10 @@ int sqlite3BtreeLast(BtCursor*, int *pRes); int sqlite3BtreeNext(BtCursor*, int *pRes); int sqlite3BtreeEof(BtCursor*); int sqlite3BtreePrevious(BtCursor*, int *pRes); -int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); +i64 sqlite3BtreeIntegerKey(BtCursor*); int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); -const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt); -const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt); -int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); +const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); +u32 sqlite3BtreePayloadSize(BtCursor*); int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); diff --git a/src/test3.c b/src/test3.c index 1e4baf7577..bfd7c30b65 100644 --- a/src/test3.c +++ b/src/test3.c @@ -385,8 +385,7 @@ static int btree_payload_size( const char **argv /* Text of each argument */ ){ BtCursor *pCur; - int n2; - u64 n1; + u32 n; char zBuf[50]; if( argc!=2 ){ @@ -396,17 +395,9 @@ static int btree_payload_size( } pCur = sqlite3TestTextToPtr(argv[1]); sqlite3BtreeEnter(pCur->pBtree); - - /* The cursor may be in "require-seek" state. If this is the case, the - ** call to BtreeDataSize() will fix it. */ - sqlite3BtreeDataSize(pCur, (u32*)&n2); - if( pCur->apPage[pCur->iPage]->intKey ){ - n1 = 0; - }else{ - sqlite3BtreeKeySize(pCur, (i64*)&n1); - } + n = sqlite3BtreePayloadSize(pCur); sqlite3BtreeLeave(pCur->pBtree); - sqlite3_snprintf(sizeof(zBuf),zBuf, "%d", (int)(n1+n2)); + sqlite3_snprintf(sizeof(zBuf),zBuf, "%u", n); Tcl_AppendResult(interp, zBuf, 0); return SQLITE_OK; } diff --git a/src/vdbe.c b/src/vdbe.c index d4392a89d9..356cf52f01 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2380,7 +2380,6 @@ case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ ** skipped for length() and all content loading can be skipped for typeof(). */ case OP_Column: { - i64 payloadSize64; /* Number of bytes in the record */ int p2; /* column number to retrieve */ VdbeCursor *pC; /* The VDBE cursor */ BtCursor *pCrsr; /* The BTree cursor */ @@ -2433,22 +2432,9 @@ case OP_Column: { }else{ assert( pC->eCurType==CURTYPE_BTREE ); assert( pCrsr ); - if( pC->isTable==0 ){ - assert( sqlite3BtreeCursorIsValid(pCrsr) ); - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &payloadSize64); - assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ - /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the - ** payload size, so it is impossible for payloadSize64 to be - ** larger than 32 bits. */ - assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 ); - pC->aRow = sqlite3BtreeKeyFetch(pCrsr, &avail); - pC->payloadSize = (u32)payloadSize64; - }else{ - assert( sqlite3BtreeCursorIsValid(pCrsr) ); - VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &pC->payloadSize); - assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ - pC->aRow = sqlite3BtreeDataFetch(pCrsr, &avail); - } + assert( sqlite3BtreeCursorIsValid(pCrsr) ); + pC->payloadSize = sqlite3BtreePayloadSize(pCrsr); + pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail); assert( avail<=65536 ); /* Maximum page size is 64KiB */ if( pC->payloadSize <= (u32)avail ){ pC->szRow = pC->payloadSize; @@ -4201,8 +4187,7 @@ case OP_NewRowid: { /* out2 */ v = 1; /* IMP: R-61914-48074 */ }else{ assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) ); - rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v); - assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */ + v = sqlite3BtreeIntegerKey(pC->uc.pCursor); if( v>=MAX_ROWID ){ pC->useRandomRowid = 1; }else{ @@ -4459,8 +4444,7 @@ case OP_Delete: { /* If p5 is zero, the seek operation that positioned the cursor prior to ** OP_Delete will have also set the pC->movetoTarget field to the rowid of ** the row that is being deleted */ - i64 iKey = 0; - sqlite3BtreeKeySize(pC->uc.pCursor, &iKey); + i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor); assert( pC->movetoTarget==iKey ); } #endif @@ -4476,7 +4460,7 @@ case OP_Delete: { zDb = db->aDb[pC->iDb].zName; pTab = pOp->p4.pTab; if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){ - sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget); + pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor); } }else{ zDb = 0; /* Not needed. Silence a compiler warning. */ @@ -4630,7 +4614,6 @@ case OP_RowData: { VdbeCursor *pC; BtCursor *pCrsr; u32 n; - i64 n64; pOut = &aMem[pOp->p2]; memAboutToChange(p, pOut); @@ -4662,20 +4645,9 @@ case OP_RowData: { if( rc!=SQLITE_OK ) goto abort_due_to_error; #endif - if( pC->isTable==0 ){ - assert( !pC->isTable ); - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &n64); - assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ - if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){ - goto too_big; - } - n = (u32)n64; - }else{ - VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &n); - assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ - if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ - goto too_big; - } + n = sqlite3BtreePayloadSize(pCrsr); + if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){ + goto too_big; } testcase( n==0 ); if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){ @@ -4740,8 +4712,7 @@ case OP_Rowid: { /* out2 */ pOut->flags = MEM_Null; break; } - rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v); - assert( rc==SQLITE_OK ); /* Always so because of CursorRestore() above */ + v = sqlite3BtreeIntegerKey(pC->uc.pCursor); } pOut->u.i = v; break; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 1feecb3e11..83718eae39 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1650,8 +1650,7 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ u32 nRec; u8 *aRec; - rc = sqlite3BtreeDataSize(p->pCsr->uc.pCursor, &nRec); - if( rc!=SQLITE_OK ) goto preupdate_old_out; + nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor); aRec = sqlite3DbMallocRaw(db, nRec); if( !aRec ) goto preupdate_old_out; rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index bce676f10c..63609d72dd 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4315,8 +4315,7 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){ ** this code can safely assume that nCellKey is 32-bits */ assert( sqlite3BtreeCursorIsValid(pCur) ); - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); - assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ + nCellKey = sqlite3BtreePayloadSize(pCur); assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey ); /* Read in the complete content of the index entry */ @@ -4393,8 +4392,7 @@ int sqlite3VdbeIdxKeyCompare( assert( pC->eCurType==CURTYPE_BTREE ); pCur = pC->uc.pCursor; assert( sqlite3BtreeCursorIsValid(pCur) ); - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); - assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ + nCellKey = sqlite3BtreePayloadSize(pCur); /* nCellKey will always be between 0 and 0xffffffff because of the way ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ if( nCellKey<=0 || nCellKey>0x7fffffff ){ diff --git a/src/vdbeblob.c b/src/vdbeblob.c index f2b3ffef2b..01827f94d0 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -415,7 +415,7 @@ static int blobReadWrite( ** anyhow. */ sqlite3_int64 iKey; - sqlite3BtreeKeySize(p->pCsr, &iKey); + iKey = sqlite3BtreeIntegerKey(p->pCsr); sqlite3VdbePreUpdateHook( v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1 ); diff --git a/src/vdbemem.c b/src/vdbemem.c index f9396e570c..04cb9c5c63 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -991,11 +991,7 @@ int sqlite3VdbeMemFromBtree( /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() ** that both the BtShared and database handle mutexes are held. */ assert( (pMem->flags & MEM_RowSet)==0 ); - if( key ){ - zData = (char *)sqlite3BtreeKeyFetch(pCur, &available); - }else{ - zData = (char *)sqlite3BtreeDataFetch(pCur, &available); - } + zData = (char *)sqlite3BtreePayloadFetch(pCur, &available); assert( zData!=0 ); if( offset+amt<=available ){ From d66c4f809d3677d935f5b0c218585457289c2ff6 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Jun 2016 20:58:35 +0000 Subject: [PATCH 131/302] Fix a C99-ism and a compiler warning for MSVC. FossilOrigin-Name: aa53a36ea2eb90cc4939e37e6ad320b4211692fd --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/btree.c | 3 ++- src/vdbe.c | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index f5cc249751..f8c32841be 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\ssqlite3BtreeKeySize()\sinterface\sinto\ssqlite3BtreeIntegerKey()\sand\nmake\sit\sonly\swork\sfor\stable\sbtrees.\s\sChange\ssqlite3BtreeDataSize()\sinto\nsqlite3BtreePayloadSize()\sand\smake\sit\swork\sfor\sall\sbtrees.\s\sCombine\nsqlite3BtreeDataFetch()\sand\ssqlite3BtreeKeyFetch()\sinto\sa\ssingle\nsqlite3BtreePayloadFetch()\sroutine.\s\sThese\schanges\sseem\sto\smake\sthe\nb-tree\sinterface\smore\srational\sand\sthey\sreduce\sboth\sbinary\ssize\sand\nCPU\susage. -D 2016-06-04T20:37:10.186 +C Fix\sa\sC99-ism\sand\sa\scompiler\swarning\sfor\sMSVC. +D 2016-06-04T20:58:35.587 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -326,7 +326,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c b55e96857e89734ae0ef2e77ed07b5e55314f1d9 +F src/btree.c 579a8160f57db168425ef940276319bed48a95d3 F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c e827e57e4a29c00e8429c5fd4d9d4572cb1b32a4 @@ -448,7 +448,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c f6d37b366fe426637708ad6ad21d93e8b52512e2 +F src/vdbe.c e23a15d352e63b51cf08af8052e678e67c54ec09 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c 02bcbc2ca5d2004b029088b05b468b394881e103 @@ -1500,10 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b411107a3609d53af4e147f01e311b858b78420b -R 80a60ad5ffc5ad6e753a2a298aeee05c -T *branch * btree-refactor -T *sym-btree-refactor * -T -sym-trunk * +P bef35e18dd19732f7859287b097feeb593e5900f +R 7b13c2762e2abdaed13574cfe801f7ea U drh -Z 4c3d5b0be019f44c3e1bc23daff07019 +Z c33407f01f615b8db559b27222022193 diff --git a/manifest.uuid b/manifest.uuid index 2fca7ce9d8..0b98334436 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bef35e18dd19732f7859287b097feeb593e5900f \ No newline at end of file +aa53a36ea2eb90cc4939e37e6ad320b4211692fd \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 4003352a5e..550beb38aa 100644 --- a/src/btree.c +++ b/src/btree.c @@ -619,8 +619,9 @@ static int saveCursorKey(BtCursor *pCur){ pCur->nKey = sqlite3BtreeIntegerKey(pCur); }else{ /* For an index btree, save the complete key content */ + void *pKey; pCur->nKey = sqlite3BtreePayloadSize(pCur); - void *pKey = sqlite3Malloc( pCur->nKey ); + pKey = sqlite3Malloc( pCur->nKey ); if( pKey ){ rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey); if( rc==SQLITE_OK ){ diff --git a/src/vdbe.c b/src/vdbe.c index 356cf52f01..245c5beb6c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4646,7 +4646,7 @@ case OP_RowData: { #endif n = sqlite3BtreePayloadSize(pCrsr); - if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){ + if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ goto too_big; } testcase( n==0 ); From 5e08d0fcb6574735f2f02803117e7094136856ce Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Jun 2016 21:05:54 +0000 Subject: [PATCH 132/302] Improved comment on cursorOwnsBtShared(). No changes to code. FossilOrigin-Name: 5e269c2d2667df65592a32d6bc2fa388fd7eb181 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f8c32841be..3a383881e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sC99-ism\sand\sa\scompiler\swarning\sfor\sMSVC. -D 2016-06-04T20:58:35.587 +C Improved\scomment\son\scursorOwnsBtShared().\s\sNo\schanges\sto\scode. +D 2016-06-04T21:05:54.667 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -326,7 +326,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 579a8160f57db168425ef940276319bed48a95d3 +F src/btree.c b8875cff2d98d662a7e25d73483bccc2374d8bdb F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c e827e57e4a29c00e8429c5fd4d9d4572cb1b32a4 @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bef35e18dd19732f7859287b097feeb593e5900f -R 7b13c2762e2abdaed13574cfe801f7ea +P aa53a36ea2eb90cc4939e37e6ad320b4211692fd +R 31679baf828d6d3e0ee835dac82e6874 U drh -Z c33407f01f615b8db559b27222022193 +Z bd564a0c26801286c1f95fad1a35ec86 diff --git a/manifest.uuid b/manifest.uuid index 0b98334436..6568d401a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aa53a36ea2eb90cc4939e37e6ad320b4211692fd \ No newline at end of file +5e269c2d2667df65592a32d6bc2fa388fd7eb181 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 550beb38aa..5fbd6c4173 100644 --- a/src/btree.c +++ b/src/btree.c @@ -450,6 +450,15 @@ static void releasePage(MemPage *pPage); /* Forward reference */ static int cursorHoldsMutex(BtCursor *p){ return sqlite3_mutex_held(p->pBt->mutex); } + +/* Verify that the cursor and the BtShared agree about what is the current +** database connetion. This is important in shared-cache mode. If the database +** connection pointers get out-of-sync, it is possible for routines like +** btreeInitPage() to reference an stale connection pointer that references a +** a connection that has already closed. This routine is used inside assert() +** statements only and for the purpose of double-checking that the btree code +** does keep the database connection pointers up-to-date. +*/ static int cursorOwnsBtShared(BtCursor *p){ assert( cursorHoldsMutex(p) ); return (p->pBtree->db==p->pBt->db); From c80937a5f5ec900d898603dfd2d3bc7c47af10fe Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 6 Jun 2016 01:48:14 +0000 Subject: [PATCH 133/302] Small performance improvement in the LIKE function. FossilOrigin-Name: 5fb0c35459cf7a8662bf8cd84ac345f6fafda6cc --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/func.c | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f32e69180f..c43382d993 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Btree\sinterface\srefactoring:\n(1)\sThe\ssqlite3BtreeKeySize()\sinterface\sis\srenamed\sto\ssqlite3BtreeIntegerKey()\nand\smodified\sto\swork\sonly\sfor\stable\sbtrees\swith\sa\srowid.\n(2)\sThe\ssqlite3BtreeDataSize()\sinterface\sis\srenamed\sto\ssqlite3BtreePayloadSize()\nand\smodified\sto\swork\swith\sany\sbtree.\n(3)\sThe\ssqlite3BtreeDataFetch()\sand\ssqlite3BtreeKeyFetch()\sroutines\sare\ncombined\sinto\sa\ssingle\ssqlite3BtreePayloadFetch()\sroutine.\nThe\sresult\sof\sthese\schanges\sis\sa\ssmaller\sbinary\sand\sfewer\sCPU\scycles\sneeded\nto\srun\squeries. -D 2016-06-06T01:14:08.809 +C Small\sperformance\simprovement\sin\sthe\sLIKE\sfunction. +D 2016-06-06T01:48:14.262 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -339,7 +339,7 @@ F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f F src/expr.c 798146ea4c87d723e8a157d88450ac9c43256998 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 -F src/func.c ef4c18c8a66143413ce41a58d582d2c14ddf78e1 +F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 F src/global.c c45ea22aff29334f6a9ec549235ac3357c970015 F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -1500,8 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b411107a3609d53af4e147f01e311b858b78420b 5e269c2d2667df65592a32d6bc2fa388fd7eb181 -R 31679baf828d6d3e0ee835dac82e6874 -T +closed 5e269c2d2667df65592a32d6bc2fa388fd7eb181 +P 2d831074cf730dce47de5880d7b4570d04d15fee +R 55f60418d6dcbf8aee4f5a82499e5642 U drh -Z e9c5ee5d96d9c9f1da27014117e66fa4 +Z 55a25f2496cfdeb6e61ef11536fc4f7e diff --git a/manifest.uuid b/manifest.uuid index e4a8777eb9..8076fd6a9e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2d831074cf730dce47de5880d7b4570d04d15fee \ No newline at end of file +5fb0c35459cf7a8662bf8cd84ac345f6fafda6cc \ No newline at end of file diff --git a/src/func.c b/src/func.c index 4feedc7440..78c8806456 100644 --- a/src/func.c +++ b/src/func.c @@ -740,7 +740,7 @@ static int patternCompare( } c2 = Utf8Read(zString); if( c==c2 ) continue; - if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ + if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){ continue; } if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue; From 05a360913d38e3685a5cc994c4394fe54c131eb0 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 6 Jun 2016 01:54:20 +0000 Subject: [PATCH 134/302] Small performance boost and size decrease in sqlite3BtreeMovetoUnpacked(). FossilOrigin-Name: e106a77d85c20ae23ebe49a5acceeaffecb40fc2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c43382d993..eca2ed0fc6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\simprovement\sin\sthe\sLIKE\sfunction. -D 2016-06-06T01:48:14.262 +C Small\sperformance\sboost\sand\ssize\sdecrease\sin\ssqlite3BtreeMovetoUnpacked(). +D 2016-06-06T01:54:20.047 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -326,7 +326,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c b8875cff2d98d662a7e25d73483bccc2374d8bdb +F src/btree.c 2781fb1db1e46390a9c27a2162395f371577ac66 F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c e827e57e4a29c00e8429c5fd4d9d4572cb1b32a4 @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2d831074cf730dce47de5880d7b4570d04d15fee -R 55f60418d6dcbf8aee4f5a82499e5642 +P 5fb0c35459cf7a8662bf8cd84ac345f6fafda6cc +R 6c89b96783c3d80d21140f4fa1e28558 U drh -Z 55a25f2496cfdeb6e61ef11536fc4f7e +Z fcd58109b062d41d087b764fb431a88f diff --git a/manifest.uuid b/manifest.uuid index 8076fd6a9e..41857ac25e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fb0c35459cf7a8662bf8cd84ac345f6fafda6cc \ No newline at end of file +e106a77d85c20ae23ebe49a5acceeaffecb40fc2 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 5fbd6c4173..3a95edf007 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5070,11 +5070,12 @@ int sqlite3BtreeMovetoUnpacked( assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); assert( pRes ); assert( (pIdxKey==0)==(pCur->pKeyInfo==0) ); + assert( (pIdxKey==0)==(pCur->curIntKey!=0) || pCur->eState!=CURSOR_VALID ); /* If the cursor is already positioned at the point we are trying ** to move to, then just return without doing any work */ - if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 - && pCur->curIntKey + if( pIdxKey==0 + && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 ){ if( pCur->info.nKey==intKey ){ *pRes = 0; From 4335ad05b893cc3ab48796e746dee309a823a7d8 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 6 Jun 2016 13:24:57 +0000 Subject: [PATCH 135/302] Initialize the yyerrcnt variable in the lemon parser template. This has no effect on SQLite itself. FossilOrigin-Name: 45531654f7f5be3a08e9ee8598f14efe028245d8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index eca2ed0fc6..e299eaa5ba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\sboost\sand\ssize\sdecrease\sin\ssqlite3BtreeMovetoUnpacked(). -D 2016-06-06T01:54:20.047 +C Initialize\sthe\syyerrcnt\svariable\sin\sthe\slemon\sparser\stemplate.\s\sThis\shas\sno\neffect\son\sSQLite\sitself. +D 2016-06-06T13:24:57.848 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -1428,7 +1428,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c f06b7e98a6b7efb404375b6f4a0c71c85faa1512 +F tool/lempar.c 66a16b5e00fefff278b9e6e3aae14037c0246427 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5fb0c35459cf7a8662bf8cd84ac345f6fafda6cc -R 6c89b96783c3d80d21140f4fa1e28558 +P e106a77d85c20ae23ebe49a5acceeaffecb40fc2 +R 44ddd09e002da6e14637db41834f8d1e U drh -Z fcd58109b062d41d087b764fb431a88f +Z 4d4207228c1d0bca23b591b2a4bc29d5 diff --git a/manifest.uuid b/manifest.uuid index 41857ac25e..a22289fa3a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e106a77d85c20ae23ebe49a5acceeaffecb40fc2 \ No newline at end of file +45531654f7f5be3a08e9ee8598f14efe028245d8 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 1258c549de..5b6e6d77d3 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -339,6 +339,9 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ pParser->yystack = &pParser->yystk0; pParser->yystksz = 1; } +#endif +#ifndef YYNOERRORRECOVERY + pParser->yyerrcnt = -1; #endif pParser->yytos = pParser->yystack; pParser->yystack[0].stateno = 0; From 0efd37f28b2918655de43acc8a32d6e75a3f2735 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 6 Jun 2016 18:17:36 +0000 Subject: [PATCH 136/302] Fix lempar.c so that the shift-reduce optimization works for error processing. This is a Lemon issue only and has no impact on SQLite. FossilOrigin-Name: 3665a2f554e5b8d2717d952dbaf325a39c637c31 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e299eaa5ba..7b75e3ac80 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initialize\sthe\syyerrcnt\svariable\sin\sthe\slemon\sparser\stemplate.\s\sThis\shas\sno\neffect\son\sSQLite\sitself. -D 2016-06-06T13:24:57.848 +C Fix\slempar.c\sso\sthat\sthe\sshift-reduce\soptimization\sworks\sfor\serror\sprocessing.\nThis\sis\sa\sLemon\sissue\sonly\sand\shas\sno\simpact\son\sSQLite. +D 2016-06-06T18:17:36.269 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -1428,7 +1428,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 66a16b5e00fefff278b9e6e3aae14037c0246427 +F tool/lempar.c 8c4e9d8517e50da391f1d89a519e743dd4afbc09 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e106a77d85c20ae23ebe49a5acceeaffecb40fc2 -R 44ddd09e002da6e14637db41834f8d1e +P 45531654f7f5be3a08e9ee8598f14efe028245d8 +R ca88b1e538e49deb8a0ada7b00edb9b6 U drh -Z 4d4207228c1d0bca23b591b2a4bc29d5 +Z 8cae88ab86923e6f759f4ae6a119c6f0 diff --git a/manifest.uuid b/manifest.uuid index a22289fa3a..589f699701 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45531654f7f5be3a08e9ee8598f14efe028245d8 \ No newline at end of file +3665a2f554e5b8d2717d952dbaf325a39c637c31 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 5b6e6d77d3..9b76d6e3c5 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -601,6 +601,9 @@ static void yy_shift( } } #endif + if( yyNewState > YY_MAX_SHIFT ){ + yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; + } yytos = yypParser->yytos; yytos->stateno = (YYACTIONTYPE)yyNewState; yytos->major = (YYCODETYPE)yyMajor; @@ -813,9 +816,6 @@ void Parse( do{ yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyact <= YY_MAX_SHIFTREDUCE ){ - if( yyact > YY_MAX_SHIFT ){ - yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; - } yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; From 8a5fd2611686c62c06ac8b5f0bad9c2db2ac5dce Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 6 Jun 2016 20:27:15 +0000 Subject: [PATCH 137/302] Translate filenames of the form "/c:/*" into just "c:/*" on WinRT and Cygwin. (SQLite has long done this for Win32/WinNT.) FossilOrigin-Name: f8470ffc49918099820cc0008b9089e5fe8a7dff --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 7b75e3ac80..f4ea0d3997 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\slempar.c\sso\sthat\sthe\sshift-reduce\soptimization\sworks\sfor\serror\sprocessing.\nThis\sis\sa\sLemon\sissue\sonly\sand\shas\sno\simpact\son\sSQLite. -D 2016-06-06T18:17:36.269 +C Translate\sfilenames\sof\sthe\sform\s"/c:/*"\sinto\sjust\s"c:/*"\son\sWinRT\sand\sCygwin.\n(SQLite\shas\slong\sdone\sthis\sfor\sWin32/WinNT.) +D 2016-06-06T20:27:15.051 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -367,7 +367,7 @@ F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 -F src/os_win.c 852fc2ff6084296348ed3739c548b2cf32df394e +F src/os_win.c 59ccd6a22c90c7eb06721060a881484664f67487 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 45531654f7f5be3a08e9ee8598f14efe028245d8 -R ca88b1e538e49deb8a0ada7b00edb9b6 +P 3665a2f554e5b8d2717d952dbaf325a39c637c31 +R 1ce06fe2980795cbe08c14d88bf14c86 U drh -Z 8cae88ab86923e6f759f4ae6a119c6f0 +Z b8067fa7fb955f58e26e08c4eb3e1ea5 diff --git a/manifest.uuid b/manifest.uuid index 589f699701..06742e2e7b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3665a2f554e5b8d2717d952dbaf325a39c637c31 \ No newline at end of file +f8470ffc49918099820cc0008b9089e5fe8a7dff \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 9a34d9a106..6458d283c8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5274,6 +5274,13 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); assert( nFull>=pVfs->mxPathname ); + /* If this path name begins with "/X:", where "X" is any alphabetic + ** character, discard the initial "/" from the pathname. + */ + if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ + zRelative++; + } + if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5329,6 +5336,13 @@ static int winFullPathname( #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) SimulateIOError( return SQLITE_ERROR ); + /* If this path name begins with "/X:", where "X" is any alphabetic + ** character, discard the initial "/" from the pathname. + */ + if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ + zRelative++; + } + /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ From 4a58d5fdf5a298a0b020c7cdd57586220622dc3f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 6 Jun 2016 20:36:26 +0000 Subject: [PATCH 138/302] In winFullPathname, translate '/X:' to 'X:' before doing anything else. FossilOrigin-Name: e404ad705d0e2d96025d05cc88348ffcd0703533 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 31 +++++++++---------------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index f4ea0d3997..a8641b80ec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Translate\sfilenames\sof\sthe\sform\s"/c:/*"\sinto\sjust\s"c:/*"\son\sWinRT\sand\sCygwin.\n(SQLite\shas\slong\sdone\sthis\sfor\sWin32/WinNT.) -D 2016-06-06T20:27:15.051 +C In\swinFullPathname,\stranslate\s'/X:'\sto\s'X:'\sbefore\sdoing\sanything\selse. +D 2016-06-06T20:36:26.843 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -367,7 +367,7 @@ F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 -F src/os_win.c 59ccd6a22c90c7eb06721060a881484664f67487 +F src/os_win.c d4b8faf8896b65818e67070711fdd00d8e620bd6 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3665a2f554e5b8d2717d952dbaf325a39c637c31 -R 1ce06fe2980795cbe08c14d88bf14c86 -U drh -Z b8067fa7fb955f58e26e08c4eb3e1ea5 +P f8470ffc49918099820cc0008b9089e5fe8a7dff +R c81f8bc1e79df8beab98e4603e5f0a7e +U mistachkin +Z 376528e39cb88246cfc2bf50694a3c28 diff --git a/manifest.uuid b/manifest.uuid index 06742e2e7b..785cf6ce09 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f8470ffc49918099820cc0008b9089e5fe8a7dff \ No newline at end of file +e404ad705d0e2d96025d05cc88348ffcd0703533 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 6458d283c8..edc182a017 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5269,11 +5269,12 @@ static int winFullPathname( int nFull, /* Size of output buffer in bytes */ char *zFull /* Output buffer */ ){ +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) + DWORD nByte; + void *zConverted; + char *zOut; +#endif -#if defined(__CYGWIN__) - SimulateIOError( return SQLITE_ERROR ); - UNUSED_PARAMETER(nFull); - assert( nFull>=pVfs->mxPathname ); /* If this path name begins with "/X:", where "X" is any alphabetic ** character, discard the initial "/" from the pathname. */ @@ -5281,6 +5282,10 @@ static int winFullPathname( zRelative++; } +#if defined(__CYGWIN__) + SimulateIOError( return SQLITE_ERROR ); + UNUSED_PARAMETER(nFull); + assert( nFull>=pVfs->mxPathname ); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5336,13 +5341,6 @@ static int winFullPathname( #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) SimulateIOError( return SQLITE_ERROR ); - /* If this path name begins with "/X:", where "X" is any alphabetic - ** character, discard the initial "/" from the pathname. - */ - if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ - zRelative++; - } - /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ @@ -5361,17 +5359,6 @@ static int winFullPathname( #endif #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) - DWORD nByte; - void *zConverted; - char *zOut; - - /* If this path name begins with "/X:", where "X" is any alphabetic - ** character, discard the initial "/" from the pathname. - */ - if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ - zRelative++; - } - /* It's odd to simulate an io-error here, but really this is just ** using the io-error infrastructure to test that SQLite handles this ** function failing. This function could fail if, for example, the From a83a5c3fbcef8b408a5dbfd212ed67950c116d3d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 7 Jun 2016 20:25:19 +0000 Subject: [PATCH 139/302] Fix the walcrash4.test test module so that it works on windows. FossilOrigin-Name: 2091a4c9231c7871f27661adc27dd7df26500f6c --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/walcrash4.test | 10 +++++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index a8641b80ec..36bb44109e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\swinFullPathname,\stranslate\s'/X:'\sto\s'X:'\sbefore\sdoing\sanything\selse. -D 2016-06-06T20:36:26.843 +C Fix\sthe\swalcrash4.test\stest\smodule\sso\sthat\sit\sworks\son\swindows. +D 2016-06-07T20:25:19.931 F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e @@ -1361,7 +1361,7 @@ F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af -F test/walcrash4.test fa7d92ab84fe3ff409e1cda88a622545e2bc2b66 +F test/walcrash4.test 3374d6a0813bfe9d841a973958e0552b545a6423 F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c @@ -1500,7 +1500,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f8470ffc49918099820cc0008b9089e5fe8a7dff -R c81f8bc1e79df8beab98e4603e5f0a7e -U mistachkin -Z 376528e39cb88246cfc2bf50694a3c28 +P e404ad705d0e2d96025d05cc88348ffcd0703533 +R 17828d50ca8a72aedc66939901a97177 +U drh +Z c43be01e1ddab6118f1ee2a4247dca79 diff --git a/manifest.uuid b/manifest.uuid index 785cf6ce09..459a559a5d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e404ad705d0e2d96025d05cc88348ffcd0703533 \ No newline at end of file +2091a4c9231c7871f27661adc27dd7df26500f6c \ No newline at end of file diff --git a/test/walcrash4.test b/test/walcrash4.test index d2f07730a0..3abc16d1eb 100644 --- a/test/walcrash4.test +++ b/test/walcrash4.test @@ -35,6 +35,14 @@ do_execsql_test 1.0 { faultsim_save_and_close +# The error message is different on unix and windows +# +if {$::tcl_platform(platform)=="windows"} { + set msg "child killed: unknown signal" +} else { + set msg "child process exited abnormally" +} + for {set nExtra 0} {$nExtra < 10} {incr nExtra} { for {set i 0} {$i < 10} {incr i} { do_test 1.nExtra=$nExtra.i=$i.1 { @@ -63,7 +71,7 @@ for {set nExtra 0} {$nExtra < 10} {incr nExtra} { set r [catch { exec [info nameofexec] crash.tcl >@stdout } msg] list $r $msg - } {1 {child process exited abnormally}} + } "1 {$msg}" do_execsql_test 1.nExtra=$nExtra.i=$i.2 { SELECT count(*) FROM t1; From 290fcaa2d130bc488c22e615d37c240186714260 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 8 Jun 2016 01:03:05 +0000 Subject: [PATCH 140/302] An initial attempt at a "dbhash" command-line utility. FossilOrigin-Name: 2247649ca215c06205b33b2250eb809baf39263a --- Makefile.in | 7 +- Makefile.msc | 8 +- main.mk | 7 +- manifest | 20 ++- manifest.uuid | 2 +- tool/dbhash.c | 424 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 455 insertions(+), 13 deletions(-) create mode 100644 tool/dbhash.c diff --git a/Makefile.in b/Makefile.in index 115cfac58f..29c9174afa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -539,7 +539,8 @@ TESTPROGS = \ testfixture$(TEXE) \ sqlite3$(TEXE) \ sqlite3_analyzer$(TEXE) \ - sqldiff$(TEXE) + sqldiff$(TEXE) \ + dbhash$(TEXE) # Databases containing fuzzer test cases # @@ -590,6 +591,9 @@ sqlite3$(TEXE): $(TOP)/src/shell.c sqlite3.c sqldiff$(TEXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) +dbhash$(TEXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h + $(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.c $(TLIBS) + scrub$(TEXE): $(TOP)/ext/misc/scrub.c sqlite3.o $(LTLINK) -o $@ -I. -DSCRUB_STANDALONE \ $(TOP)/ext/misc/scrub.c sqlite3.o $(TLIBS) @@ -1251,6 +1255,7 @@ clean: rm -f fuzzershell fuzzershell.exe rm -f fuzzcheck fuzzcheck.exe rm -f sqldiff sqldiff.exe + rm -f dbhash dbhash.exe rm -f fts5.* fts5parse.* distclean: clean diff --git a/Makefile.msc b/Makefile.msc index 9bf1e4f8fe..93116cd0dc 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1378,7 +1378,8 @@ TESTPROGS = \ testfixture.exe \ $(SQLITE3EXE) \ sqlite3_analyzer.exe \ - sqldiff.exe + sqldiff.exe \ + dbhash.exe # Databases containing fuzzer test cases # @@ -1456,6 +1457,9 @@ $(SQLITE3EXE): $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_S sqldiff.exe: $(TOP)\tool\sqldiff.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) $(TOP)\tool\sqldiff.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) +dbhash.exe: $(TOP)\tool\dbhash.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) $(TOP)\tool\dbhash.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) + scrub.exe: $(TOP)\ext\misc\scrub.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) $(TOP)\ext\misc\scrub.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) @@ -2105,6 +2109,6 @@ clean: del /Q shell.c sqlite3ext.h sqlite3session.h 2>NUL del /Q sqlite3_analyzer.exe sqlite3_analyzer.c 2>NUL del /Q sqlite-*-output.vsix 2>NUL - del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe 2>NUL + del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe dbhash.exe 2>NUL del /Q fts5.* fts5parse.* 2>NUL # <> diff --git a/main.mk b/main.mk index 624bf77a06..ba710bfa46 100644 --- a/main.mk +++ b/main.mk @@ -451,7 +451,8 @@ TESTPROGS = \ testfixture$(EXE) \ sqlite3$(EXE) \ sqlite3_analyzer$(EXE) \ - sqldiff$(EXE) + sqldiff$(EXE) \ + dbhash$(EXE) # Databases containing fuzzer test cases # @@ -488,6 +489,10 @@ sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) $(THREADLIB) +dbhash$(EXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h + $(TCCX) -o dbhash$(EXE) -DSQLITE_THREADSAFE=0 \ + $(TOP)/tool/dbhash.c sqlite3.c $(TLIBS) $(THREADLIB) + scrub$(EXE): $(TOP)/ext/misc/scrub.c sqlite3.o $(TCC) -I. -DSCRUB_STANDALONE -o scrub$(EXE) $(TOP)/ext/misc/scrub.c sqlite3.o $(THREADLIB) diff --git a/manifest b/manifest index 36bb44109e..7d7f2a3501 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Fix\sthe\swalcrash4.test\stest\smodule\sso\sthat\sit\sworks\son\swindows. -D 2016-06-07T20:25:19.931 -F Makefile.in 7321ef0b584224781ec7731408857fa8962c32cc +C An\sinitial\sattempt\sat\sa\s"dbhash"\scommand-line\sutility. +D 2016-06-08T01:03:05.100 +F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 831503fc4e988f571590af1405645fff121b5f1e +F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -307,7 +307,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 2b90646ca027cc21dbae209a0fee68dfedfe0e83 +F main.mk 3f669c06db5c4a53ff21dda639247c6310497180 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1420,6 +1420,7 @@ F tool/build-all-msvc.bat 3e4e4043b53f1aede4308e0d2567bbd773614630 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 +F tool/dbhash.c 11ae59057c1ebbd54ac10bdc59c8fc7e0a43a156 F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 @@ -1500,7 +1501,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e404ad705d0e2d96025d05cc88348ffcd0703533 -R 17828d50ca8a72aedc66939901a97177 +P 2091a4c9231c7871f27661adc27dd7df26500f6c +R 2cb484710443ce45b289f472a9c90e73 +T *branch * dbhash +T *sym-dbhash * +T -sym-trunk * U drh -Z c43be01e1ddab6118f1ee2a4247dca79 +Z 1329a111dd8194eb5ec209c8b1ad3288 diff --git a/manifest.uuid b/manifest.uuid index 459a559a5d..ca0df0561c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2091a4c9231c7871f27661adc27dd7df26500f6c \ No newline at end of file +2247649ca215c06205b33b2250eb809baf39263a \ No newline at end of file diff --git a/tool/dbhash.c b/tool/dbhash.c new file mode 100644 index 0000000000..0e1b02b673 --- /dev/null +++ b/tool/dbhash.c @@ -0,0 +1,424 @@ +/* +** 2016-06-07 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This is a utility program that computes a hash on the content +** of an SQLite database. +** +** The hash is computed over just the content of the database. Free +** space inside of the database file, and alternative on-disk representations +** of the same content (ex: UTF8 vs UTF16) do not affect the hash. So, +** for example, the database file page size, encoding, and auto_vacuum setting +** can all be changed without changing the hash. +*/ +#include +#include +#include +#include +#include +#include +#include "sqlite3.h" + +/* Context for the SHA1 hash */ +typedef struct SHA1Context SHA1Context; +struct SHA1Context { + unsigned int state[5]; + unsigned int count[2]; + unsigned char buffer[64]; +}; + +/* +** All global variables are gathered into the "g" singleton. +*/ +struct GlobalVars { + const char *zArgv0; /* Name of program */ + int bSchemaPK; /* Use the schema-defined PK, not the true PK */ + unsigned fDebug; /* Debug flags */ + sqlite3 *db; /* The database connection */ + SHA1Context cx; /* SHA1 hash context */ +} g; + +/****************************************************************************** +** The Hash Engine +** +** Modify these routines (and appropriate state fields in global variable 'g') +** in order to compute a different (better?) hash of the database. +*/ +/* + * blk0() and blk() perform the initial expand. + * I got the idea of expanding during the round function from SSLeay + * + * blk0le() for little-endian and blk0be() for big-endian. + */ +#if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) +/* + * GCC by itself only generates left rotates. Use right rotates if + * possible to be kinder to dinky implementations with iterative rotate + * instructions. + */ +#define SHA_ROT(op, x, k) \ + ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) +#define rol(x,k) SHA_ROT("roll", x, k) +#define ror(x,k) SHA_ROT("rorl", x, k) + +#else +/* Generic C equivalent */ +#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) +#define rol(x,k) SHA_ROT(x,k,32-(k)) +#define ror(x,k) SHA_ROT(x,32-(k),k) +#endif + + +#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ + |(rol(block[i],8)&0x00FF00FF)) +#define blk0be(i) block[i] +#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ + ^block[(i+2)&15]^block[i&15],1)) + +/* + * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 + * + * Rl0() for little-endian and Rb0() for big-endian. Endianness is + * determined at run-time. + */ +#define Rl0(v,w,x,y,z,i) \ + z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); +#define Rb0(v,w,x,y,z,i) \ + z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); +#define R1(v,w,x,y,z,i) \ + z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); +#define R2(v,w,x,y,z,i) \ + z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); +#define R3(v,w,x,y,z,i) \ + z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); +#define R4(v,w,x,y,z,i) \ + z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); + +/* + * Hash a single 512-bit block. This is the core of the algorithm. + */ +#define a qq[0] +#define b qq[1] +#define c qq[2] +#define d qq[3] +#define e qq[4] + +void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){ + unsigned int qq[5]; /* a, b, c, d, e; */ + static int one = 1; + unsigned int block[16]; + memcpy(block, buffer, 64); + memcpy(qq,state,5*sizeof(unsigned int)); + + /* Copy g.cx.state[] to working vars */ + /* + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + */ + + /* 4 rounds of 20 operations each. Loop unrolled. */ + if( 1 == *(unsigned char*)&one ){ + Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); + Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); + Rl0(c,d,e,a,b, 8); Rl0(b,c,d,e,a, 9); Rl0(a,b,c,d,e,10); Rl0(e,a,b,c,d,11); + Rl0(d,e,a,b,c,12); Rl0(c,d,e,a,b,13); Rl0(b,c,d,e,a,14); Rl0(a,b,c,d,e,15); + }else{ + Rb0(a,b,c,d,e, 0); Rb0(e,a,b,c,d, 1); Rb0(d,e,a,b,c, 2); Rb0(c,d,e,a,b, 3); + Rb0(b,c,d,e,a, 4); Rb0(a,b,c,d,e, 5); Rb0(e,a,b,c,d, 6); Rb0(d,e,a,b,c, 7); + Rb0(c,d,e,a,b, 8); Rb0(b,c,d,e,a, 9); Rb0(a,b,c,d,e,10); Rb0(e,a,b,c,d,11); + Rb0(d,e,a,b,c,12); Rb0(c,d,e,a,b,13); Rb0(b,c,d,e,a,14); Rb0(a,b,c,d,e,15); + } + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; +} + + +/* Initialize the SHA1 hash */ +static void hash_init(void){ + /* SHA1 initialization constants */ + g.cx.state[0] = 0x67452301; + g.cx.state[1] = 0xEFCDAB89; + g.cx.state[2] = 0x98BADCFE; + g.cx.state[3] = 0x10325476; + g.cx.state[4] = 0xC3D2E1F0; + g.cx.count[0] = g.cx.count[1] = 0; +} + +/* Add new content to the SHA1 hash */ +static void hash_step(const unsigned char *data, unsigned int len){ + unsigned int i, j; + + j = g.cx.count[0]; + if( (g.cx.count[0] += len << 3) < j ){ + g.cx.count[1] += (len>>29)+1; + } + j = (j >> 3) & 63; + if( (j + len) > 63 ){ + (void)memcpy(&g.cx.buffer[j], data, (i = 64-j)); + SHA1Transform(g.cx.state, g.cx.buffer); + for(; i + 63 < len; i += 64){ + SHA1Transform(g.cx.state, &data[i]); + } + j = 0; + }else{ + i = 0; + } + (void)memcpy(&g.cx.buffer[j], &data[i], len - i); +} + + +/* Add padding and compute and output the message digest. */ +static void hash_finish(void){ + unsigned int i; + unsigned char finalcount[8]; + unsigned char digest[20]; + static const char zEncode[] = "0123456789abcdef"; + char zOut[40]; + + for (i = 0; i < 8; i++){ + finalcount[i] = (unsigned char)((g.cx.count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + hash_step((const unsigned char *)"\200", 1); + while ((g.cx.count[0] & 504) != 448){ + hash_step((const unsigned char *)"\0", 1); + } + hash_step(finalcount, 8); /* Should cause a SHA1Transform() */ + for (i = 0; i < 20; i++){ + digest[i] = (unsigned char)((g.cx.state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + for(i=0; i<20; i++){ + zOut[i*2] = zEncode[(digest[i]>>4)&0xf]; + zOut[i*2+1] = zEncode[digest[i] & 0xf]; + } + zOut[i*2]= 0; + printf("%s\n", zOut); +} +/* End of the hashing logic +*******************************************************************************/ + +/* +** Print an error resulting from faulting command-line arguments and +** abort the program. +*/ +static void cmdlineError(const char *zFormat, ...){ + va_list ap; + fprintf(stderr, "%s: ", g.zArgv0); + va_start(ap, zFormat); + vfprintf(stderr, zFormat, ap); + va_end(ap); + fprintf(stderr, "\n\"%s --help\" for more help\n", g.zArgv0); + exit(1); +} + +/* +** Print an error message for an error that occurs at runtime, then +** abort the program. +*/ +static void runtimeError(const char *zFormat, ...){ + va_list ap; + fprintf(stderr, "%s: ", g.zArgv0); + va_start(ap, zFormat); + vfprintf(stderr, zFormat, ap); + va_end(ap); + fprintf(stderr, "\n"); + exit(1); +} + +/* +** Prepare a new SQL statement. Print an error and abort if anything +** goes wrong. +*/ +static sqlite3_stmt *db_vprepare(const char *zFormat, va_list ap){ + char *zSql; + int rc; + sqlite3_stmt *pStmt; + + zSql = sqlite3_vmprintf(zFormat, ap); + if( zSql==0 ) runtimeError("out of memory"); + rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, 0); + if( rc ){ + runtimeError("SQL statement error: %s\n\"%s\"", sqlite3_errmsg(g.db), + zSql); + } + sqlite3_free(zSql); + return pStmt; +} +static sqlite3_stmt *db_prepare(const char *zFormat, ...){ + va_list ap; + sqlite3_stmt *pStmt; + va_start(ap, zFormat); + pStmt = db_vprepare(zFormat, ap); + va_end(ap); + return pStmt; +} + +/* +** Compute the hash for a single table named zTab +*/ +static void hash_one_table(const char *zTab){ + sqlite3_stmt *pStmt; + int nCol; + int i; + pStmt = db_prepare("SELECT * FROM \"%w\";", zTab); + nCol = sqlite3_column_count(pStmt); + while( SQLITE_ROW==sqlite3_step(pStmt) ){ + for(i=0; i=0; j--){ + x[j] = u & 0xff; + u >>= 8; + } + hash_step((const unsigned char*)"1",1); + hash_step(x,8); + break; + } + case SQLITE_FLOAT: { + sqlite3_uint64 u; + int j; + unsigned char x[8]; + double r = sqlite3_column_double(pStmt,i); + memcpy(&u, &r, 8); + for(j=7; j>=0; j--){ + x[j] = u & 0xff; + u >>= 8; + } + hash_step((const unsigned char*)"2",1); + hash_step(x,8); + break; + } + case SQLITE_TEXT: { + int n = sqlite3_column_bytes(pStmt, i); + const unsigned char *z = sqlite3_column_text(pStmt, i); + hash_step((const unsigned char*)"3", 1); + hash_step(z, n); + break; + } + case SQLITE_BLOB: { + int n = sqlite3_column_bytes(pStmt, i); + const unsigned char *z = sqlite3_column_blob(pStmt, i); + hash_step((const unsigned char*)"4", 1); + hash_step(z, n); + break; + } + } + } + } + sqlite3_finalize(pStmt); +} + + +/* +** Print sketchy documentation for this utility program +*/ +static void showHelp(void){ + printf("Usage: %s DB\n", g.zArgv0); + printf( +"Compute a hash on the content of database DB\n" + ); +} + +int main(int argc, char **argv){ + const char *zDb = 0; + int i; + int rc; + char *zErrMsg; + sqlite3_stmt *pStmt; + + g.zArgv0 = argv[0]; + sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); + for(i=1; i Date: Wed, 8 Jun 2016 13:49:28 +0000 Subject: [PATCH 141/302] Fix the dbhash utility so that it ignores the root page number when hashing the sqlite_master table. Add new command-line options. Add the ability to hash multiple databases with a single command. FossilOrigin-Name: 44f157e0f0d5a76ef9002b2592164c4fdae89e34 --- manifest | 15 ++--- manifest.uuid | 2 +- tool/dbhash.c | 170 +++++++++++++++++++++++++++++++++++++------------- 3 files changed, 133 insertions(+), 54 deletions(-) diff --git a/manifest b/manifest index 7d7f2a3501..efda9daef2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\sinitial\sattempt\sat\sa\s"dbhash"\scommand-line\sutility. -D 2016-06-08T01:03:05.100 +C Fix\sthe\sdbhash\sutility\sso\sthat\sit\signores\sthe\sroot\spage\snumber\swhen\shashing\nthe\ssqlite_master\stable.\s\sAdd\snew\scommand-line\soptions.\s\sAdd\sthe\sability\sto\nhash\smultiple\sdatabases\swith\sa\ssingle\scommand. +D 2016-06-08T13:49:28.865 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -1420,7 +1420,7 @@ F tool/build-all-msvc.bat 3e4e4043b53f1aede4308e0d2567bbd773614630 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 -F tool/dbhash.c 11ae59057c1ebbd54ac10bdc59c8fc7e0a43a156 +F tool/dbhash.c 3e7a97ebdaff842f99ee1eab3787717582d665b8 F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 @@ -1501,10 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2091a4c9231c7871f27661adc27dd7df26500f6c -R 2cb484710443ce45b289f472a9c90e73 -T *branch * dbhash -T *sym-dbhash * -T -sym-trunk * +P 2247649ca215c06205b33b2250eb809baf39263a +R 8393151ede059e20b861d67944f07343 U drh -Z 1329a111dd8194eb5ec209c8b1ad3288 +Z e6c66d0412cbc063d2ea74dc380f683a diff --git a/manifest.uuid b/manifest.uuid index ca0df0561c..8a0b15bbb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2247649ca215c06205b33b2250eb809baf39263a \ No newline at end of file +44f157e0f0d5a76ef9002b2592164c4fdae89e34 \ No newline at end of file diff --git a/tool/dbhash.c b/tool/dbhash.c index 0e1b02b673..8873c39c2a 100644 --- a/tool/dbhash.c +++ b/tool/dbhash.c @@ -10,7 +10,7 @@ ** ************************************************************************* ** -** This is a utility program that computes a hash on the content +** This is a utility program that computes an SHA1 hash on the content ** of an SQLite database. ** ** The hash is computed over just the content of the database. Free @@ -40,12 +40,16 @@ struct SHA1Context { */ struct GlobalVars { const char *zArgv0; /* Name of program */ - int bSchemaPK; /* Use the schema-defined PK, not the true PK */ unsigned fDebug; /* Debug flags */ sqlite3 *db; /* The database connection */ SHA1Context cx; /* SHA1 hash context */ } g; +/* +** Debugging flags +*/ +#define DEBUG_FULLTRACE 0x00000001 /* Trace hash to stderr */ + /****************************************************************************** ** The Hash Engine ** @@ -200,7 +204,7 @@ static void hash_step(const unsigned char *data, unsigned int len){ /* Add padding and compute and output the message digest. */ -static void hash_finish(void){ +static void hash_finish(const char *zName){ unsigned int i; unsigned char finalcount[8]; unsigned char digest[20]; @@ -224,7 +228,7 @@ static void hash_finish(void){ zOut[i*2+1] = zEncode[digest[i] & 0xf]; } zOut[i*2]= 0; - printf("%s\n", zOut); + printf("%s %s\n", zOut, zName); } /* End of the hashing logic *******************************************************************************/ @@ -286,19 +290,28 @@ static sqlite3_stmt *db_prepare(const char *zFormat, ...){ } /* -** Compute the hash for a single table named zTab +** Compute the hash for all rows of the query formed from the printf-style +** zFormat and its argument. */ -static void hash_one_table(const char *zTab){ - sqlite3_stmt *pStmt; - int nCol; - int i; - pStmt = db_prepare("SELECT * FROM \"%w\";", zTab); +static void hash_one_query(const char *zFormat, ...){ + va_list ap; + sqlite3_stmt *pStmt; /* The query defined by zFormat and "..." */ + int nCol; /* Number of columns in the result set */ + int i; /* Loop counter */ + + /* Prepare the query defined by zFormat and "..." */ + va_start(ap, zFormat); + pStmt = db_vprepare(zFormat, ap); + va_end(ap); nCol = sqlite3_column_count(pStmt); + + /* Compute a hash over the result of the query */ while( SQLITE_ROW==sqlite3_step(pStmt) ){ for(i=0; i Date: Wed, 8 Jun 2016 13:59:35 +0000 Subject: [PATCH 142/302] Fix an undersized buffer in the SHA1 implementation. FossilOrigin-Name: fb2768154c513881886e89801e906bea959197b3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/dbhash.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index efda9daef2..c020071d16 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sdbhash\sutility\sso\sthat\sit\signores\sthe\sroot\spage\snumber\swhen\shashing\nthe\ssqlite_master\stable.\s\sAdd\snew\scommand-line\soptions.\s\sAdd\sthe\sability\sto\nhash\smultiple\sdatabases\swith\sa\ssingle\scommand. -D 2016-06-08T13:49:28.865 +C Fix\san\sundersized\sbuffer\sin\sthe\sSHA1\simplementation. +D 2016-06-08T13:59:35.817 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -1420,7 +1420,7 @@ F tool/build-all-msvc.bat 3e4e4043b53f1aede4308e0d2567bbd773614630 x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 -F tool/dbhash.c 3e7a97ebdaff842f99ee1eab3787717582d665b8 +F tool/dbhash.c a06228aa21ebc4e6ea8daa486601d938499238a5 F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2247649ca215c06205b33b2250eb809baf39263a -R 8393151ede059e20b861d67944f07343 +P 44f157e0f0d5a76ef9002b2592164c4fdae89e34 +R 654981991ade95156b7aa25e1b0590de U drh -Z e6c66d0412cbc063d2ea74dc380f683a +Z 0f8b86024c43c03c854a2dd32c154497 diff --git a/manifest.uuid b/manifest.uuid index 8a0b15bbb6..4f4dd55a84 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -44f157e0f0d5a76ef9002b2592164c4fdae89e34 \ No newline at end of file +fb2768154c513881886e89801e906bea959197b3 \ No newline at end of file diff --git a/tool/dbhash.c b/tool/dbhash.c index 8873c39c2a..b1c72b3e36 100644 --- a/tool/dbhash.c +++ b/tool/dbhash.c @@ -209,7 +209,7 @@ static void hash_finish(const char *zName){ unsigned char finalcount[8]; unsigned char digest[20]; static const char zEncode[] = "0123456789abcdef"; - char zOut[40]; + char zOut[41]; for (i = 0; i < 8; i++){ finalcount[i] = (unsigned char)((g.cx.count[(i >= 4 ? 0 : 1)] From 8dc570b6afac593f029a67640ab916278af1ca65 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 8 Jun 2016 18:07:21 +0000 Subject: [PATCH 143/302] Prefer to use partial indexes for full table scans when that is possible. FossilOrigin-Name: fe1874321ba31cec9ae65387920c33d8d0178ed8 --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/build.c | 7 ++++--- src/where.c | 1 + test/index6.test | 11 +++++++++++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index b9ef6e83ef..718d324c20 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"dbhash.exe"\sutility\sprogram\sthat\scomputes\sa\sSHA1\shash\sover\sthe\ninvariant\scontent\sof\san\sSQLite\sdatabase\sfile.\s\sFree\sspace\sin\sthe\sfile,\sthe\npage\ssize,\sauto_vacuum\sstatus,\stext\sencoding,\sand\sso\sforth\sdo\snot\schange\sthe\nhash.\s\sOnly\sthe\scontent\smatters. -D 2016-06-08T14:04:50.483 +C Prefer\sto\suse\spartial\sindexes\sfor\sfull\stable\sscans\swhen\sthat\sis\spossible. +D 2016-06-08T18:07:21.900 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -329,7 +329,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2781fb1db1e46390a9c27a2162395f371577ac66 F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c e827e57e4a29c00e8429c5fd4d9d4572cb1b32a4 +F src/build.c 535879738a9f9e351624ebe827bdfb6ef16475ae F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 @@ -462,7 +462,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c b9f5b0ddb14c3827e70b5379e659cf4cfd524c4d +F src/where.c 74f0798525b6306682d7234f230ea93f86959b9b F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c ba71a4e4bada29aa9842200e6299714bf18c812c F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 @@ -840,7 +840,7 @@ F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407 F test/index3.test 81bc47890b8abfb181bc35f8d10b56c069803386 F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6 F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7 -F test/index6.test 7102ec371414c42dfb1d5ca37eb4519aa9edc23a +F test/index6.test 43b4e29258b978fcdab84fc61df4f5212119dd09 F test/index7.test 9c6765a74fc3fcde7aebc5b3bd40d98df14a527c F test/indexedby.test 9c4cd331224e57f79fbf411ae245e6272d415985 F test/indexexpr1.test cb71b6586177b840e28110dd952178bb2bdfedc2 @@ -1501,8 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2091a4c9231c7871f27661adc27dd7df26500f6c fb2768154c513881886e89801e906bea959197b3 -R 654981991ade95156b7aa25e1b0590de -T +closed fb2768154c513881886e89801e906bea959197b3 +P f48a4ad33ecd4a86f5529596ff11829ba38b0875 +R f8f1ecf8d68a5747b29b0c8ae33faacb U drh -Z 4625be77e802d56f2b1c496e15a4bd85 +Z bc2339201021198d1e3ee60eab532825 diff --git a/manifest.uuid b/manifest.uuid index 7e4bb144b7..e6930e8d09 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f48a4ad33ecd4a86f5529596ff11829ba38b0875 \ No newline at end of file +fe1874321ba31cec9ae65387920c33d8d0178ed8 \ No newline at end of file diff --git a/src/build.c b/src/build.c index a5931954ad..c32195f655 100644 --- a/src/build.c +++ b/src/build.c @@ -3434,10 +3434,11 @@ void sqlite3DefaultRowEst(Index *pIdx){ int i; /* Set the first entry (number of rows in the index) to the estimated - ** number of rows in the table. Or 10, if the estimated number of rows - ** in the table is less than that. */ + ** number of rows in the table, or half the number of rows in the table + ** for a partial index. But do not let the estimate drop below 10. */ a[0] = pIdx->pTable->nRowLogEst; - if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) ); + if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) ); + if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) ); /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is ** 6 and each subsequent value (if any) is 5. */ diff --git a/src/where.c b/src/where.c index 04d0b0190c..e5a476c00a 100644 --- a/src/where.c +++ b/src/where.c @@ -2761,6 +2761,7 @@ static int whereLoopAddBtree( /* Full scan via index */ if( b || !HasRowid(pTab) + || pProbe->pPartIdxWhere!=0 || ( m==0 && pProbe->bUnordered==0 && (pProbe->szIdxRowszTabRow) diff --git a/test/index6.test b/test/index6.test index 33ae3d1cb1..9501a6c864 100644 --- a/test/index6.test +++ b/test/index6.test @@ -376,4 +376,15 @@ do_execsql_test index6-10.3eqp { SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC; } {~/USING INDEX t10x/} +# A partial index will be used for a full table scan, where possible +do_execsql_test index6-11.1 { + CREATE TABLE t11(a,b,c); + CREATE INDEX t11x ON t11(a) WHERE b<>99; + EXPLAIN QUERY PLAN SELECT a FROM t11 WHERE b<>99; +} {/USING INDEX t11x/} +do_execsql_test index6-11.2 { + EXPLAIN QUERY PLAN SELECT a FROM t11 WHERE b<>99 AND c<>98; +} {/USING INDEX t11x/} + + finish_test From 4d249e61289c76b41a880126ceb44bf97e14fb8b Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 10 Jun 2016 22:49:01 +0000 Subject: [PATCH 144/302] Enhance "PRAGMA table_info" to that it provides information about eponymous virtual tables. FossilOrigin-Name: 53a1e5d51304cb3de700c1807a2c945a40240576 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/build.c | 21 ++++++++++++--------- src/pragma.c | 2 +- src/sqliteInt.h | 6 ++++-- test/stat.test | 3 +++ 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 718d324c20..3aa1a8ed67 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prefer\sto\suse\spartial\sindexes\sfor\sfull\stable\sscans\swhen\sthat\sis\spossible. -D 2016-06-08T18:07:21.900 +C Enhance\s"PRAGMA\stable_info"\sto\sthat\sit\sprovides\sinformation\sabout\seponymous\nvirtual\stables. +D 2016-06-10T22:49:01.448 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -329,7 +329,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2781fb1db1e46390a9c27a2162395f371577ac66 F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 535879738a9f9e351624ebe827bdfb6ef16475ae +F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 @@ -375,7 +375,7 @@ F src/parse.y 01b9f37c4c7009ab56fda98bc7db4c42643cecfe F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d -F src/pragma.c d98039af2deb5a4990f6635462b3f61f325a6c75 +F src/pragma.c c8b499756658cb8b82cfdbb5845c22cf11f297aa F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 @@ -387,7 +387,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 5f8113dbec74c6c093ead9930afb8c9fbd9f643d F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 801e2a569ea79b09b87d045cd6f00ec88205f1f6 +F src/sqliteInt.h b425bb606c14c078b1c9feb7cf72f2f3a35be188 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1100,7 +1100,7 @@ F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 F test/sqldiff1.test 28cd737cf1b0078b1ec1bbf425e674c47785835e F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142 F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a -F test/stat.test 66e95f97b9f724f9ab921d054ee0db3c2689f1ee +F test/stat.test 8544f219694807400c8fd1830e4ad858f5b1b23f F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f48a4ad33ecd4a86f5529596ff11829ba38b0875 -R f8f1ecf8d68a5747b29b0c8ae33faacb +P fe1874321ba31cec9ae65387920c33d8d0178ed8 +R bcb028582306bc8630ca7310032e2582 U drh -Z bc2339201021198d1e3ee60eab532825 +Z 24931a2c89ab34cc35408cff5c484569 diff --git a/manifest.uuid b/manifest.uuid index e6930e8d09..d22ea35143 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe1874321ba31cec9ae65387920c33d8d0178ed8 \ No newline at end of file +53a1e5d51304cb3de700c1807a2c945a40240576 \ No newline at end of file diff --git a/src/build.c b/src/build.c index c32195f655..52f6f200f8 100644 --- a/src/build.c +++ b/src/build.c @@ -338,7 +338,7 @@ Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){ */ Table *sqlite3LocateTable( Parse *pParse, /* context in which to report errors */ - int isView, /* True if looking for a VIEW rather than a TABLE */ + u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */ const char *zName, /* Name of the table we are looking for */ const char *zDbase /* Name of the database. Might be NULL */ ){ @@ -352,7 +352,7 @@ Table *sqlite3LocateTable( p = sqlite3FindTable(pParse->db, zName, zDbase); if( p==0 ){ - const char *zMsg = isView ? "no such view" : "no such table"; + const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table"; #ifndef SQLITE_OMIT_VIRTUALTABLE if( sqlite3FindDbName(pParse->db, zDbase)<1 ){ /* If zName is the not the name of a table in the schema created using @@ -364,12 +364,14 @@ Table *sqlite3LocateTable( } } #endif - if( zDbase ){ - sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); - }else{ - sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); + if( (flags & LOCATE_NOERR)==0 ){ + if( zDbase ){ + sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); + }else{ + sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); + } + pParse->checkSchema = 1; } - pParse->checkSchema = 1; } return p; @@ -386,7 +388,7 @@ Table *sqlite3LocateTable( */ Table *sqlite3LocateTableItem( Parse *pParse, - int isView, + u32 flags, struct SrcList_item *p ){ const char *zDb; @@ -397,7 +399,7 @@ Table *sqlite3LocateTableItem( }else{ zDb = p->zDatabase; } - return sqlite3LocateTable(pParse, isView, p->zName, zDb); + return sqlite3LocateTable(pParse, flags, p->zName, zDb); } /* @@ -2504,6 +2506,7 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ assert( pName->nSrc==1 ); if( sqlite3ReadSchema(pParse) ) goto exit_drop_table; if( noErr ) db->suppressErr++; + assert( isView==0 || isView==LOCATE_VIEW ); pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]); if( noErr ) db->suppressErr--; diff --git a/src/pragma.c b/src/pragma.c index 56823c7243..1ee08fbec0 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1052,7 +1052,7 @@ void sqlite3Pragma( */ case PragTyp_TABLE_INFO: if( zRight ){ Table *pTab; - pTab = sqlite3FindTable(db, zRight, zDb); + pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb); if( pTab ){ static const char *azCol[] = { "cid", "name", "type", "notnull", "dflt_value", "pk" diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 024003afb0..798523bd1e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3671,8 +3671,10 @@ void sqlite3ExprIfTrue(Parse*, Expr*, int, int); void sqlite3ExprIfFalse(Parse*, Expr*, int, int); void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int); Table *sqlite3FindTable(sqlite3*,const char*, const char*); -Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*); -Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *); +#define LOCATE_VIEW 0x01 +#define LOCATE_NOERR 0x02 +Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); +Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *); Index *sqlite3FindIndex(sqlite3*,const char*, const char*); void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); diff --git a/test/stat.test b/test/stat.test index d106894d71..f77e4d24a3 100644 --- a/test/stat.test +++ b/test/stat.test @@ -32,6 +32,9 @@ db func a_string a_string register_dbstat_vtab db do_execsql_test stat-0.0 { + PRAGMA table_info(dbstat); +} {/0 name STRING .* 1 path INTEGER .* 9 pgsize INTEGER/} +do_execsql_test stat-0.1 { PRAGMA auto_vacuum = OFF; CREATE VIRTUAL TABLE temp.stat USING dbstat; SELECT * FROM stat; From edc4024b9da4374f78d5dfb8e108144415e7467e Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Jun 2016 12:34:38 +0000 Subject: [PATCH 145/302] Fix the "onecolumn" and "exists" methods of the TCL interface so that they work in combination with the "profile" callback. FossilOrigin-Name: d362ba157f993fc74a590cf15a9a2fa589278dd7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 6 ++++-- test/tclsqlite.test | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 3aa1a8ed67..b15af5f081 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\s"PRAGMA\stable_info"\sto\sthat\sit\sprovides\sinformation\sabout\seponymous\nvirtual\stables. -D 2016-06-10T22:49:01.448 +C Fix\sthe\s"onecolumn"\sand\s"exists"\smethods\sof\sthe\sTCL\sinterface\sso\sthat\sthey\nwork\sin\scombination\swith\sthe\s"profile"\scallback. +D 2016-06-13T12:34:38.095 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -391,7 +391,7 @@ F src/sqliteInt.h b425bb606c14c078b1c9feb7cf72f2f3a35be188 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060 +F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 F src/test1.c 43b37ab2b7338fd3313e74902f0d6c821eae843b F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1117,7 +1117,7 @@ F test/tabfunc01.test f977868fa8bb7beb4b2072883190411653473906 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 -F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa +F test/tclsqlite.test cf0d0a3fd03d64892cec2d48aae9fb2f148680a5 F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 F test/tempdb2.test 4fc92055f2a3f7626c0f2eabbb637dc021b311d5 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fe1874321ba31cec9ae65387920c33d8d0178ed8 -R bcb028582306bc8630ca7310032e2582 +P 53a1e5d51304cb3de700c1807a2c945a40240576 +R 728aa3483f448a04bb6de7c432f92c81 U drh -Z 24931a2c89ab34cc35408cff5c484569 +Z f275382679f329597f4cef7fe1c1d3e9 diff --git a/manifest.uuid b/manifest.uuid index d22ea35143..17751de4e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -53a1e5d51304cb3de700c1807a2c945a40240576 \ No newline at end of file +d362ba157f993fc74a590cf15a9a2fa589278dd7 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index d6a36118c4..476bdf235e 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2325,6 +2325,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ */ case DB_EXISTS: case DB_ONECOLUMN: { + Tcl_Obj *pResult = 0; DbEvalContext sEval; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "SQL"); @@ -2335,14 +2336,15 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ rc = dbEvalStep(&sEval); if( choice==DB_ONECOLUMN ){ if( rc==TCL_OK ){ - Tcl_SetObjResult(interp, dbEvalColumnValue(&sEval, 0)); + pResult = dbEvalColumnValue(&sEval, 0); }else if( rc==TCL_BREAK ){ Tcl_ResetResult(interp); } }else if( rc==TCL_BREAK || rc==TCL_OK ){ - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc==TCL_OK)); + pResult = Tcl_NewBooleanObj(rc==TCL_OK); } dbEvalFinalize(&sEval); + if( pResult ) Tcl_SetObjResult(interp, pResult); if( rc==TCL_BREAK ){ rc = TCL_OK; diff --git a/test/tclsqlite.test b/test/tclsqlite.test index 44d5c5634b..767dd01be2 100644 --- a/test/tclsqlite.test +++ b/test/tclsqlite.test @@ -635,6 +635,39 @@ do_test tcl-14.2 { db one {SELECT x FROM t6 WHERE xCall()!='value'} } {} +# Verify that the "exists" and "onecolumn" methods work when +# a "profile" is registered. +# +catch {db close} +sqlite3 db :memory: +proc noop-profile {args} { + return +} +do_test tcl-15.0 { + db eval {CREATE TABLE t1(a); INSERT INTO t1 VALUES(1),(2),(3);} + db onecolumn {SELECT a FROM t1 WHERE a>2} +} {3} +do_test tcl-15.1 { + db exists {SELECT a FROM t1 WHERE a>2} +} {1} +do_test tcl-15.2 { + db exists {SELECT a FROM t1 WHERE a>3} +} {0} +db profile noop-profile +do_test tcl-15.3 { + db onecolumn {SELECT a FROM t1 WHERE a>2} +} {3} +do_test tcl-15.4 { + db exists {SELECT a FROM t1 WHERE a>2} +} {1} +do_test tcl-15.5 { + db exists {SELECT a FROM t1 WHERE a>3} +} {0} + + + + + finish_test From debaa86c1c3b73de2b1fe4dad5009c717de5b980 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Jun 2016 12:51:20 +0000 Subject: [PATCH 146/302] Fix an incorrect assert() in the btree logic. FossilOrigin-Name: fcf6114be94b260641e7c78a58db16a31ac5ab35 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b15af5f081..87f091e147 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s"onecolumn"\sand\s"exists"\smethods\sof\sthe\sTCL\sinterface\sso\sthat\sthey\nwork\sin\scombination\swith\sthe\s"profile"\scallback. -D 2016-06-13T12:34:38.095 +C Fix\san\sincorrect\sassert()\sin\sthe\sbtree\slogic. +D 2016-06-13T12:51:20.365 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -326,7 +326,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 2781fb1db1e46390a9c27a2162395f371577ac66 +F src/btree.c 0621247619df15790f7ed5f14926cfb3925c10b1 F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 53a1e5d51304cb3de700c1807a2c945a40240576 -R 728aa3483f448a04bb6de7c432f92c81 +P d362ba157f993fc74a590cf15a9a2fa589278dd7 +R 8b591288ef08b6290802dd112ec0668a U drh -Z f275382679f329597f4cef7fe1c1d3e9 +Z 9ef02259ea1748db703c32ac6cd57aa7 diff --git a/manifest.uuid b/manifest.uuid index 17751de4e1..16b994508c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d362ba157f993fc74a590cf15a9a2fa589278dd7 \ No newline at end of file +fcf6114be94b260641e7c78a58db16a31ac5ab35 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 3a95edf007..f37199276f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5070,7 +5070,7 @@ int sqlite3BtreeMovetoUnpacked( assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); assert( pRes ); assert( (pIdxKey==0)==(pCur->pKeyInfo==0) ); - assert( (pIdxKey==0)==(pCur->curIntKey!=0) || pCur->eState!=CURSOR_VALID ); + assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) ); /* If the cursor is already positioned at the point we are trying ** to move to, then just return without doing any work */ From 6c0e41b951ba5bf71bd9e4e4230a82e95f39f8a0 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Jun 2016 15:59:37 +0000 Subject: [PATCH 147/302] Fix the declaration of the table implemented by DBSTAT so that it uses correct datatypes. FossilOrigin-Name: a1e1cdc51d1c68502f43ac72c28ba87cb1916a0d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/dbstat.c | 6 +++--- test/stat.test | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 87f091e147..400a0f60d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\sassert()\sin\sthe\sbtree\slogic. -D 2016-06-13T12:51:20.365 +C Fix\sthe\sdeclaration\sof\sthe\stable\simplemented\sby\sDBSTAT\sso\sthat\sit\suses\ncorrect\sdatatypes. +D 2016-06-13T15:59:37.932 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -334,7 +334,7 @@ F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 -F src/dbstat.c c845548d4346e606e2f2b7d2e714ace2b8a7dd1b +F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f F src/expr.c 798146ea4c87d723e8a157d88450ac9c43256998 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -1100,7 +1100,7 @@ F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 F test/sqldiff1.test 28cd737cf1b0078b1ec1bbf425e674c47785835e F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142 F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a -F test/stat.test 8544f219694807400c8fd1830e4ad858f5b1b23f +F test/stat.test ab95d28503d0f6d98ffd8ce204643c9da090ebf1 F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d362ba157f993fc74a590cf15a9a2fa589278dd7 -R 8b591288ef08b6290802dd112ec0668a +P fcf6114be94b260641e7c78a58db16a31ac5ab35 +R 39b9428988b60189530e38dc24c060de U drh -Z 9ef02259ea1748db703c32ac6cd57aa7 +Z 57ee65d1a2a24e95107b0a8e8a3984a2 diff --git a/manifest.uuid b/manifest.uuid index 16b994508c..102fffd27e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fcf6114be94b260641e7c78a58db16a31ac5ab35 \ No newline at end of file +a1e1cdc51d1c68502f43ac72c28ba87cb1916a0d \ No newline at end of file diff --git a/src/dbstat.c b/src/dbstat.c index b8e79b0864..92ce650df1 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -58,10 +58,10 @@ */ #define VTAB_SCHEMA \ "CREATE TABLE xx( " \ - " name STRING, /* Name of table or index */" \ - " path INTEGER, /* Path to page from root */" \ + " name TEXT, /* Name of table or index */" \ + " path TEXT, /* Path to page from root */" \ " pageno INTEGER, /* Page number */" \ - " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \ + " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \ " ncell INTEGER, /* Cells on page (0 for overflow) */" \ " payload INTEGER, /* Bytes of payload on this page */" \ " unused INTEGER, /* Bytes of unused space on this page */" \ diff --git a/test/stat.test b/test/stat.test index f77e4d24a3..6a87a629b9 100644 --- a/test/stat.test +++ b/test/stat.test @@ -33,7 +33,7 @@ db func a_string a_string register_dbstat_vtab db do_execsql_test stat-0.0 { PRAGMA table_info(dbstat); -} {/0 name STRING .* 1 path INTEGER .* 9 pgsize INTEGER/} +} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/} do_execsql_test stat-0.1 { PRAGMA auto_vacuum = OFF; CREATE VIRTUAL TABLE temp.stat USING dbstat; From c14566aff3cdd0cb0a6acf0e6526a3238b9bbd0c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 13 Jun 2016 19:58:46 +0000 Subject: [PATCH 148/302] Fix RBU so that it builds with -DSQLITE_ENABLE_8_3_NAMES. Fix "PRAGMA compile_options" for SQLITE_ENABLE_8_3_NAMES such that it reports the numeric setting: "1" or "2". FossilOrigin-Name: 0230ca17ba20ecd3d213788ad6891973d52a7b72 --- ext/rbu/sqlite3rbu.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- src/ctime.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 39d31935cb..1cfb71384f 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -2507,9 +2507,9 @@ static void rbuFileSuffix3(const char *zBase, char *z){ #endif { int i, sz; - sz = sqlite3Strlen30(z); + sz = (int)strlen(z)&0xffffff; for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} - if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4); + if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4); } #endif } diff --git a/manifest b/manifest index 400a0f60d3..4f19e2712a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sdeclaration\sof\sthe\stable\simplemented\sby\sDBSTAT\sso\sthat\sit\suses\ncorrect\sdatatypes. -D 2016-06-13T15:59:37.932 +C Fix\sRBU\sso\sthat\sit\sbuilds\swith\s-DSQLITE_ENABLE_8_3_NAMES.\nFix\s"PRAGMA\scompile_options"\sfor\sSQLITE_ENABLE_8_3_NAMES\ssuch\sthat\sit\sreports\nthe\snumeric\ssetting:\s"1"\sor\s"2". +D 2016-06-13T19:58:46.382 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -252,7 +252,7 @@ F ext/rbu/rbuprogress.test 2023a7df2c523e3df1cb532eff811cda385a789a F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab -F ext/rbu/sqlite3rbu.c a37a7dfb225c497171aa60120e81b884954361c7 +F ext/rbu/sqlite3rbu.c 3d35b1dc46f5ca0f0f59db8e6163fe7627ea107c F ext/rbu/sqlite3rbu.h 2acd0a6344a6079de15c8dc9d84d3df83a665930 F ext/rbu/test_rbu.c 9bbdf6bd8efd58fbc4f192698df50569598fbb9e F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 @@ -332,7 +332,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 999a828425b35b8092a8cde25690e71c20906344 +F src/ctime.c 61949e83c4c36e37195a8398ebc752780b534d95 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fcf6114be94b260641e7c78a58db16a31ac5ab35 -R 39b9428988b60189530e38dc24c060de +P a1e1cdc51d1c68502f43ac72c28ba87cb1916a0d +R c278a2e099b6be15733b154091fd5a26 U drh -Z 57ee65d1a2a24e95107b0a8e8a3984a2 +Z 0e8cfd82e8662e22b8b1a31845a5f102 diff --git a/manifest.uuid b/manifest.uuid index 102fffd27e..731f5db73f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a1e1cdc51d1c68502f43ac72c28ba87cb1916a0d \ No newline at end of file +0230ca17ba20ecd3d213788ad6891973d52a7b72 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 589cabc1ab..1a7c69f3bf 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -71,7 +71,7 @@ static const char * const azCompileOpt[] = { "DISABLE_LFS", #endif #if SQLITE_ENABLE_8_3_NAMES - "ENABLE_8_3_NAMES", + "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES), #endif #if SQLITE_ENABLE_API_ARMOR "ENABLE_API_ARMOR", From 6b922881198683f958227ca2c5682251dab9cb2a Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 16 Jun 2016 11:16:53 +0000 Subject: [PATCH 149/302] Fix a typo in a comment on the SrcList object. FossilOrigin-Name: 48b555c42de1cbc031fb6c2c93ef170e491c7d76 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4f19e2712a..086230a5e9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sRBU\sso\sthat\sit\sbuilds\swith\s-DSQLITE_ENABLE_8_3_NAMES.\nFix\s"PRAGMA\scompile_options"\sfor\sSQLITE_ENABLE_8_3_NAMES\ssuch\sthat\sit\sreports\nthe\snumeric\ssetting:\s"1"\sor\s"2". -D 2016-06-13T19:58:46.382 +C Fix\sa\stypo\sin\sa\scomment\son\sthe\sSrcList\sobject. +D 2016-06-16T11:16:53.415 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -387,7 +387,7 @@ F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 F src/sqlite.h.in 5f8113dbec74c6c093ead9930afb8c9fbd9f643d F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h b425bb606c14c078b1c9feb7cf72f2f3a35be188 +F src/sqliteInt.h 2ac73e9fdd138f4607139d9bd6a1e6dcd01837dc F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a1e1cdc51d1c68502f43ac72c28ba87cb1916a0d -R c278a2e099b6be15733b154091fd5a26 +P 0230ca17ba20ecd3d213788ad6891973d52a7b72 +R 1a1c29c9329c6a84a9521e4c335dbb95 U drh -Z 0e8cfd82e8662e22b8b1a31845a5f102 +Z 2cdcc0a9545b2084d273426178a84d04 diff --git a/manifest.uuid b/manifest.uuid index 731f5db73f..7714859290 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0230ca17ba20ecd3d213788ad6891973d52a7b72 \ No newline at end of file +48b555c42de1cbc031fb6c2c93ef170e491c7d76 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 798523bd1e..c52cd29927 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2485,7 +2485,7 @@ struct SrcList { int regReturn; /* Register holding return address of addrFillSub */ int regResult; /* Registers holding results of a co-routine */ struct { - u8 jointype; /* Type of join between this able and the previous */ + u8 jointype; /* Type of join between this table and the previous */ unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ unsigned isTabFunc :1; /* True if table-valued-function syntax */ From 3480bfdae9523d3b2e67c4b594e79bab6ca7776b Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 16 Jun 2016 17:14:02 +0000 Subject: [PATCH 150/302] Add a missing OP_ColumnsUsed opcode to code for expressions like "? IN (SELECT ...)" in cases where expression can use an index that may contain NULL values. FossilOrigin-Name: 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 086230a5e9..b6450cc841 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sa\scomment\son\sthe\sSrcList\sobject. -D 2016-06-16T11:16:53.415 +C Add\sa\smissing\sOP_ColumnsUsed\sopcode\sto\scode\sfor\sexpressions\slike\s"?\sIN\s(SELECT\s...)"\sin\scases\swhere\sexpression\scan\suse\san\sindex\sthat\smay\scontain\sNULL\svalues. +D 2016-06-16T17:14:02.375 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -336,7 +336,7 @@ F src/ctime.c 61949e83c4c36e37195a8398ebc752780b534d95 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c 798146ea4c87d723e8a157d88450ac9c43256998 +F src/expr.c 523a5b1db2b6d88c6eefb224877bf635a3bcfc92 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 @@ -1501,7 +1501,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0230ca17ba20ecd3d213788ad6891973d52a7b72 -R 1a1c29c9329c6a84a9521e4c335dbb95 -U drh -Z 2cdcc0a9545b2084d273426178a84d04 +P 48b555c42de1cbc031fb6c2c93ef170e491c7d76 +R 7c056b92500e212b6fa7144618e1e6e0 +U dan +Z 6cf13efbb72ea4474e244da36e8952f1 diff --git a/manifest.uuid b/manifest.uuid index 7714859290..6347d15d5f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48b555c42de1cbc031fb6c2c93ef170e491c7d76 \ No newline at end of file +0b1579caf06a2c42433b8bc9dc28c9ad381aa07c \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index c6a09d9d9d..ce3a476561 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1818,6 +1818,11 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFlags, int *prRhsHasNull){ eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0]; if( prRhsHasNull && !pTab->aCol[iCol].notNull ){ +#ifdef SQLITE_ENABLE_COLUMN_USED_MASK + const i64 sOne = 1; + sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, + iTab, 0, 0, (u8*)&sOne, P4_INT64); +#endif *prRhsHasNull = ++pParse->nMem; sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull); } From 2ad96f5880fd77919571477dc0302cf763e527ff Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 17 Jun 2016 13:01:51 +0000 Subject: [PATCH 151/302] Add the json_quote() function to the JSON1 extension. FossilOrigin-Name: 2c3714aebf5e40e3728877a235b3c1f93defa33e --- ext/misc/json1.c | 20 ++++++++++++++++++++ manifest | 19 +++++++++++-------- manifest.uuid | 2 +- test/json101.test | 29 +++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 99d299c29c..a9452b0191 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1211,6 +1211,25 @@ static void jsonTest1Func( ** Scalar SQL function implementations ****************************************************************************/ +/* +** Implementation of the json_QUOTE(VALUE) function. Return a JSON value +** corresponding to the SQL value input. Mostly this means putting +** double-quotes around strings and returning the unquoted string "null" +** when given a NULL input. +*/ +static void jsonQuoteFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString jx; + + jsonInit(&jx, ctx); + jsonAppendValue(&jx, argv[0]); + jsonResult(&jx); + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + /* ** Implementation of the json_array(VALUE,...) function. Return a JSON ** array that contains all values given in arguments. Or if any argument @@ -2124,6 +2143,7 @@ int sqlite3Json1Init(sqlite3 *db){ { "json_extract", -1, 0, jsonExtractFunc }, { "json_insert", -1, 0, jsonSetFunc }, { "json_object", -1, 0, jsonObjectFunc }, + { "json_quote", 1, 0, jsonQuoteFunc }, { "json_remove", -1, 0, jsonRemoveFunc }, { "json_replace", -1, 0, jsonReplaceFunc }, { "json_set", -1, 1, jsonSetFunc }, diff --git a/manifest b/manifest index b6450cc841..cfd0f94004 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\sOP_ColumnsUsed\sopcode\sto\scode\sfor\sexpressions\slike\s"?\sIN\s(SELECT\s...)"\sin\scases\swhere\sexpression\scan\suse\san\sindex\sthat\smay\scontain\sNULL\svalues. -D 2016-06-16T17:14:02.375 +C Add\sthe\sjson_quote()\sfunction\sto\sthe\sJSON1\sextension. +D 2016-06-17T13:01:51.782 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -211,7 +211,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c -F ext/misc/json1.c b9c88d5c3b6ecd8c731ffdd7f5b3d902857f8c96 +F ext/misc/json1.c d51a764ba43a49e191bc3536238bfab3def258ca F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 @@ -874,7 +874,7 @@ F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307 F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa -F test/json101.test ef42283f0b60d8bacbc2243448e7c84988578e52 +F test/json101.test 865776ed8580703e1684fe4b8ee2e473333bb121 F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff @@ -1501,7 +1501,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48b555c42de1cbc031fb6c2c93ef170e491c7d76 -R 7c056b92500e212b6fa7144618e1e6e0 -U dan -Z 6cf13efbb72ea4474e244da36e8952f1 +P 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c +R d87f9b42ae99ac8ed32dd707e5951481 +T *branch * json_quote +T *sym-json_quote * +T -sym-trunk * +U drh +Z f05f5d0cd323376080196dc4fc41462d diff --git a/manifest.uuid b/manifest.uuid index 6347d15d5f..8de647c48f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b1579caf06a2c42433b8bc9dc28c9ad381aa07c \ No newline at end of file +2c3714aebf5e40e3728877a235b3c1f93defa33e \ No newline at end of file diff --git a/test/json101.test b/test/json101.test index 9b780a379b..3ee007c1cb 100644 --- a/test/json101.test +++ b/test/json101.test @@ -356,5 +356,34 @@ do_execsql_test json-8.2 { SELECT a=json_extract(b,'$[0]') FROM t8; } {1} +# The json_quote() function transforms an SQL value into a JSON value. +# String values are quoted and interior quotes are escaped. NULL values +# are rendered as the unquoted string "null". +# +do_execsql_test json-9.1 { + SELECT json_quote('abc"xyz'); +} {{"abc\"xyz"}} +do_execsql_test json-9.2 { + SELECT json_quote(3.14159); +} {3.14159} +do_execsql_test json-9.3 { + SELECT json_quote(12345); +} {12345} +do_execsql_test json-9.4 { + SELECT json_quote(null); +} {"null"} +do_catchsql_test json-9.5 { + SELECT json_quote(x'30313233'); +} {1 {JSON cannot hold BLOB values}} +do_catchsql_test json-9.6 { + SELECT json_quote(123,456) +} {1 {wrong number of arguments to function json_quote()}} +do_catchsql_test json-9.7 { + SELECT json_quote() +} {1 {wrong number of arguments to function json_quote()}} + + + + finish_test From b324cf756ea0622b43fb64687223a22451d697f7 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 17 Jun 2016 14:33:32 +0000 Subject: [PATCH 152/302] If a table is on the rhs of a LEFT JOIN, include only terms from the joins ON(...) clause in the cursor-hint passed via OP_CursorHint. FossilOrigin-Name: 2a2346b04235c6d0b7a8e64c92ee31018285c29f --- manifest | 16 ++++--- manifest.uuid | 2 +- src/wherecode.c | 35 ++++++++++++--- test/cursorhint2.test | 101 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 12 deletions(-) create mode 100644 test/cursorhint2.test diff --git a/manifest b/manifest index b6450cc841..9af4d76b72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\sOP_ColumnsUsed\sopcode\sto\scode\sfor\sexpressions\slike\s"?\sIN\s(SELECT\s...)"\sin\scases\swhere\sexpression\scan\suse\san\sindex\sthat\smay\scontain\sNULL\svalues. -D 2016-06-16T17:14:02.375 +C If\sa\stable\sis\son\sthe\srhs\sof\sa\sLEFT\sJOIN,\sinclude\sonly\sterms\sfrom\sthe\sjoins\sON(...)\sclause\sin\sthe\scursor-hint\spassed\svia\sOP_CursorHint. +D 2016-06-17T14:33:32.727 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -464,7 +464,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 74f0798525b6306682d7234f230ea93f86959b9b F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 -F src/wherecode.c ba71a4e4bada29aa9842200e6299714bf18c812c +F src/wherecode.c b9d5f7d8ebed2e09376fd785a111ffd9dfd59ffc F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -617,6 +617,7 @@ F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 +F test/cursorhint2.test 532fdc678653f73e30770b59af0a47f9af0124ee F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab @@ -1501,7 +1502,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48b555c42de1cbc031fb6c2c93ef170e491c7d76 -R 7c056b92500e212b6fa7144618e1e6e0 +P 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c +R 2d1831333befb414525bf922ba35c127 +T *branch * cursor-hints +T *sym-cursor-hints * +T -sym-trunk * U dan -Z 6cf13efbb72ea4474e244da36e8952f1 +Z b45fbbd37d7e68d5f1357e6143b6a1f1 diff --git a/manifest.uuid b/manifest.uuid index 6347d15d5f..4e6e68e3f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b1579caf06a2c42433b8bc9dc28c9ad381aa07c \ No newline at end of file +2a2346b04235c6d0b7a8e64c92ee31018285c29f \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 83ee48ac66..94139b6543 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -678,6 +678,7 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){ ** Insert an OP_CursorHint instruction if it is appropriate to do so. */ static void codeCursorHint( + struct SrcList_item *pTabItem, /* FROM clause item */ WhereInfo *pWInfo, /* The where clause */ WhereLevel *pLevel, /* Which loop to provide hints for */ WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */ @@ -708,7 +709,31 @@ static void codeCursorHint( pTerm = &pWC->a[i]; if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; if( pTerm->prereqAll & pLevel->notReady ) continue; - if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue; + + /* Any terms specified as part of the ON(...) clause for any LEFT + ** JOIN for which the current table is not the rhs are omitted + ** from the cursor-hint. + ** + ** If this table is the rhs of a LEFT JOIN, only terms that were + ** specified as part of the ON(...) clause may be included in the + ** hint. This is to address the following: + ** + ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL; + ** + ** If the (t2.c IS NULL) constraint is pushed down to the cursor, it + ** might filter out all rows that match (t1.a=t2.b), causing SQLite + ** to add a row of NULL values to the output that should not be + ** present (since the ON clause does actually match rows within t2). + */ + if( pTabItem->fg.jointype & JT_LEFT ){ + if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin) + || pTerm->pExpr->iRightJoinTable!=pTabItem->iCursor + ){ + continue; + } + }else{ + if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue; + } /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize ** the cursor. These terms are not needed as hints for a pure range @@ -742,7 +767,7 @@ static void codeCursorHint( } } #else -# define codeCursorHint(A,B,C) /* No-op */ +# define codeCursorHint(A,B,C,D) /* No-op */ #endif /* SQLITE_ENABLE_CURSOR_HINTS */ /* @@ -998,7 +1023,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( pStart = pEnd; pEnd = pTerm; } - codeCursorHint(pWInfo, pLevel, pEnd); + codeCursorHint(pTabItem, pWInfo, pLevel, pEnd); if( pStart ){ Expr *pX; /* The expression that defines the start bound */ int r1, rTemp; /* Registers for holding the start boundary */ @@ -1212,7 +1237,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** and store the values of those terms in an array of registers ** starting at regBase. */ - codeCursorHint(pWInfo, pLevel, pRangeEnd); + codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd); regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff); assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq ); if( zStartAff ) cEndAff = zStartAff[nEq]; @@ -1660,7 +1685,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** a pseudo-cursor. No need to Rewind or Next such cursors. */ pLevel->op = OP_Noop; }else{ - codeCursorHint(pWInfo, pLevel, 0); + codeCursorHint(pTabItem, pWInfo, pLevel, 0); pLevel->op = aStep[bRev]; pLevel->p1 = iCur; pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk); diff --git a/test/cursorhint2.test b/test/cursorhint2.test new file mode 100644 index 0000000000..3909678802 --- /dev/null +++ b/test/cursorhint2.test @@ -0,0 +1,101 @@ +# 2016 June 17 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus is on testing that cursor-hints are correct for queries +# involving LEFT JOIN. +# + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix cursorhint2 + +ifcapable !cursorhints { + finish_test + return +} + +proc extract_hints {sql} { + + db eval "SELECT tbl_name, rootpage FROM sqlite_master where rootpage" { + set lookup($rootpage) $tbl_name + } + + set ret [list] + db eval "EXPLAIN $sql" a { + switch -- $a(opcode) { + OpenRead { + set csr($a(p1)) $lookup($a(p2)) + } + CursorHint { + lappend ret $csr($a(p1)) $a(p4) + } + } + } + + set ret +} + +proc do_extract_hints_test {tn sql ret} { + uplevel [list do_test $tn [list extract_hints $sql] [list {*}$ret]] +} + +do_execsql_test 1.0 { + PRAGMA automatic_index = 0; + CREATE TABLE t1(a, b); + CREATE TABLE t2(c, d); + CREATE TABLE t3(e, f); +} + +do_extract_hints_test $tn.1.1 { + SELECT * FROM t1 WHERE a=1; +} { + t1 EQ(c0,1) +} + +do_extract_hints_test $tn.1.2 { + SELECT * FROM t1 CROSS JOIN t2 ON (a=c) WHERE d IS NULL; +} { + t2 {AND(ISNULL(c1),EQ(r[1],c0))} +} + +do_extract_hints_test $tn.1.3 { + SELECT * FROM t1 LEFT JOIN t2 ON (a=c) WHERE d IS NULL; +} { + t2 {EQ(r[2],c0)} +} + +do_extract_hints_test $tn.1.4 { + SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND a=10) WHERE d IS NULL; +} { + t2 {AND(EQ(r[2],c0),EQ(r[3],10))} +} + +do_extract_hints_test $tn.1.5 { + SELECT * FROM t1 CROSS JOIN t2 ON (a=c AND a=10) WHERE d IS NULL; +} { + t1 EQ(c0,10) t2 {AND(ISNULL(c1),EQ(r[3],c0))} +} + +do_extract_hints_test $tn.1.6 { + SELECT * FROM t1 LEFT JOIN t2 ON (a=c) LEFT JOIN t3 ON (d=f); +} { + t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} +} + +do_extract_hints_test $tn.1.6 { + SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND d=e) LEFT JOIN t3 ON (d=f); +} { + t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} +} + +finish_test + From 419b03c1bbd30e455c709d9a16d9512a99d9544f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 17 Jun 2016 14:47:37 +0000 Subject: [PATCH 153/302] Fix a typo in the cursorhint2.test script. FossilOrigin-Name: c1a5a57cf10dca91082963dcbd3e3ffebc3707ef --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/cursorhint2.test | 14 +++++++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 9af4d76b72..627ec4af45 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\stable\sis\son\sthe\srhs\sof\sa\sLEFT\sJOIN,\sinclude\sonly\sterms\sfrom\sthe\sjoins\sON(...)\sclause\sin\sthe\scursor-hint\spassed\svia\sOP_CursorHint. -D 2016-06-17T14:33:32.727 +C Fix\sa\stypo\sin\sthe\scursorhint2.test\sscript. +D 2016-06-17T14:47:37.300 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -617,7 +617,7 @@ F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 -F test/cursorhint2.test 532fdc678653f73e30770b59af0a47f9af0124ee +F test/cursorhint2.test c4c49b4b34eabc3d61ff111d477113f5c901d7fa F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab @@ -1502,10 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c -R 2d1831333befb414525bf922ba35c127 -T *branch * cursor-hints -T *sym-cursor-hints * -T -sym-trunk * +P 2a2346b04235c6d0b7a8e64c92ee31018285c29f +R f8aa0cb7edf61b31b26c82b3f234b1ab U dan -Z b45fbbd37d7e68d5f1357e6143b6a1f1 +Z ac8df9edec12a135c248b7ca97a78998 diff --git a/manifest.uuid b/manifest.uuid index 4e6e68e3f9..bbdc3674bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a2346b04235c6d0b7a8e64c92ee31018285c29f \ No newline at end of file +c1a5a57cf10dca91082963dcbd3e3ffebc3707ef \ No newline at end of file diff --git a/test/cursorhint2.test b/test/cursorhint2.test index 3909678802..3a79596036 100644 --- a/test/cursorhint2.test +++ b/test/cursorhint2.test @@ -55,43 +55,43 @@ do_execsql_test 1.0 { CREATE TABLE t3(e, f); } -do_extract_hints_test $tn.1.1 { +do_extract_hints_test 1.1 { SELECT * FROM t1 WHERE a=1; } { t1 EQ(c0,1) } -do_extract_hints_test $tn.1.2 { +do_extract_hints_test 1.2 { SELECT * FROM t1 CROSS JOIN t2 ON (a=c) WHERE d IS NULL; } { t2 {AND(ISNULL(c1),EQ(r[1],c0))} } -do_extract_hints_test $tn.1.3 { +do_extract_hints_test 1.3 { SELECT * FROM t1 LEFT JOIN t2 ON (a=c) WHERE d IS NULL; } { t2 {EQ(r[2],c0)} } -do_extract_hints_test $tn.1.4 { +do_extract_hints_test 1.4 { SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND a=10) WHERE d IS NULL; } { t2 {AND(EQ(r[2],c0),EQ(r[3],10))} } -do_extract_hints_test $tn.1.5 { +do_extract_hints_test 1.5 { SELECT * FROM t1 CROSS JOIN t2 ON (a=c AND a=10) WHERE d IS NULL; } { t1 EQ(c0,10) t2 {AND(ISNULL(c1),EQ(r[3],c0))} } -do_extract_hints_test $tn.1.6 { +do_extract_hints_test 1.6 { SELECT * FROM t1 LEFT JOIN t2 ON (a=c) LEFT JOIN t3 ON (d=f); } { t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} } -do_extract_hints_test $tn.1.6 { +do_extract_hints_test 1.6 { SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND d=e) LEFT JOIN t3 ON (d=f); } { t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} From c4974414061f90e2ed8184eefc573e557109df8f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 17 Jun 2016 14:59:40 +0000 Subject: [PATCH 154/302] Fix a duplicate test name in cursorhint2.test. FossilOrigin-Name: fcd12b69cee1335224a65aa6d22c4e302b889398 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/cursorhint2.test | 2 +- test/where3.test | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 627ec4af45..788c218d3b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sthe\scursorhint2.test\sscript. -D 2016-06-17T14:47:37.300 +C Fix\sa\sduplicate\stest\sname\sin\scursorhint2.test. +D 2016-06-17T14:59:40.619 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -617,7 +617,7 @@ F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 -F test/cursorhint2.test c4c49b4b34eabc3d61ff111d477113f5c901d7fa +F test/cursorhint2.test aa52c25d84366531af871f0bed91a7147b2b37e8 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab @@ -1376,7 +1376,7 @@ F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e F test/where.test f0c325563acde44f2c4ea6ba348e9e29f7121757 F test/where2.test 478d2170637b9211f593120648858593bf2445a1 -F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e +F test/where3.test 54cdeb02157acc979de41530b804ae7b09552bf1 F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b @@ -1502,7 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2a2346b04235c6d0b7a8e64c92ee31018285c29f -R f8aa0cb7edf61b31b26c82b3f234b1ab +P c1a5a57cf10dca91082963dcbd3e3ffebc3707ef +R ae6a6e72981ae73e95b7048747b6cd4f U dan -Z ac8df9edec12a135c248b7ca97a78998 +Z 130058fba07c74a7ae7dc91c3a4fa1a9 diff --git a/manifest.uuid b/manifest.uuid index bbdc3674bd..8c6ce154cd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c1a5a57cf10dca91082963dcbd3e3ffebc3707ef \ No newline at end of file +fcd12b69cee1335224a65aa6d22c4e302b889398 \ No newline at end of file diff --git a/test/cursorhint2.test b/test/cursorhint2.test index 3a79596036..b6ebda2244 100644 --- a/test/cursorhint2.test +++ b/test/cursorhint2.test @@ -91,7 +91,7 @@ do_extract_hints_test 1.6 { t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} } -do_extract_hints_test 1.6 { +do_extract_hints_test 1.7 { SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND d=e) LEFT JOIN t3 ON (d=f); } { t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} diff --git a/test/where3.test b/test/where3.test index c2804b5579..6edbe2bcad 100644 --- a/test/where3.test +++ b/test/where3.test @@ -45,7 +45,7 @@ do_test where3-1.1 { } } {222 two 2 222 {} {}} -ifcapable explain { +ifcapable explain&&!cursorhints { do_test where3-1.1.1 { explain_no_trace {SELECT * FROM t1, t2 LEFT JOIN t3 ON q=x WHERE p=2 AND a=q} @@ -86,7 +86,7 @@ do_test where3-1.2 { } } {1 {Value for C1.1} {Value for C2.1} 2 {} {Value for C2.2} 3 {Value for C1.3} {Value for C2.3}} -ifcapable explain { +ifcapable explain&&!cursorhints { do_test where3-1.2.1 { explain_no_trace { SELECT parent1.parent1key, child1.value, child2.value From e6912fd8198b3693932bc0ddaffc423a8cec417f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 17 Jun 2016 19:27:13 +0000 Subject: [PATCH 155/302] Include WHERE terms in the cursor-hint passed to a cursor opened for the rhs of a LEFT JOIN iff we can be sure that those terms will not evaluate to true if the LEFT JOIN generates a row of NULLs. FossilOrigin-Name: 998095aba01b75f685ed981b377e1dfe650d9bbf --- manifest | 14 ++++----- manifest.uuid | 2 +- src/wherecode.c | 56 ++++++++++++++++++++++++++++------- test/cursorhint2.test | 69 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 122 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 788c218d3b..be6f9cf0da 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sduplicate\stest\sname\sin\scursorhint2.test. -D 2016-06-17T14:59:40.619 +C Include\sWHERE\sterms\sin\sthe\scursor-hint\spassed\sto\sa\scursor\sopened\sfor\sthe\srhs\sof\sa\sLEFT\sJOIN\siff\swe\scan\sbe\ssure\sthat\sthose\sterms\swill\snot\sevaluate\sto\strue\sif\sthe\sLEFT\sJOIN\sgenerates\sa\srow\sof\sNULLs. +D 2016-06-17T19:27:13.114 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -464,7 +464,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 74f0798525b6306682d7234f230ea93f86959b9b F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 -F src/wherecode.c b9d5f7d8ebed2e09376fd785a111ffd9dfd59ffc +F src/wherecode.c c1b11ad09468577afd3c36cd8c854fb6dd77f258 F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -617,7 +617,7 @@ F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 -F test/cursorhint2.test aa52c25d84366531af871f0bed91a7147b2b37e8 +F test/cursorhint2.test cef69bab25b9141071b4239fa5c3b4ce18eeafd0 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab @@ -1502,7 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c1a5a57cf10dca91082963dcbd3e3ffebc3707ef -R ae6a6e72981ae73e95b7048747b6cd4f +P fcd12b69cee1335224a65aa6d22c4e302b889398 +R aa7c436ce5d8105be03298dc84afa8de U dan -Z 130058fba07c74a7ae7dc91c3a4fa1a9 +Z a2cf93e232f8c6f0bcf6400999626f67 diff --git a/manifest.uuid b/manifest.uuid index 8c6ce154cd..efb8ac0335 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fcd12b69cee1335224a65aa6d22c4e302b889398 \ No newline at end of file +998095aba01b75f685ed981b377e1dfe650d9bbf \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 94139b6543..e6294de532 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -626,6 +626,31 @@ static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){ return WRC_Continue; } +/* +** Test whether or not expression pExpr, which was part of a WHERE clause, +** should be included in the cursor-hint for a table that is on the rhs +** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the +** expression is not suitable. +** +** An expression is unsuitable if it might evaluate to non NULL even if +** a TK_COLUMN node that does affect the value of the expression is set +** to NULL. For example: +** +** col IS NULL +** col IS NOT NULL +** coalesce(col, 1) +** CASE WHEN col THEN 0 ELSE 1 END +*/ +static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){ + if( pExpr->op==TK_IS || pExpr->op==TK_FUNCTION + || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT + || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE + ){ + pWalker->eCode = 1; + } + return WRC_Continue; +} + /* ** This function is called on every node of an expression tree used as an @@ -714,22 +739,33 @@ static void codeCursorHint( ** JOIN for which the current table is not the rhs are omitted ** from the cursor-hint. ** - ** If this table is the rhs of a LEFT JOIN, only terms that were - ** specified as part of the ON(...) clause may be included in the - ** hint. This is to address the following: + ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms + ** that were specified as part of the WHERE clause must be excluded. + ** This is to address the following: ** ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL; ** - ** If the (t2.c IS NULL) constraint is pushed down to the cursor, it - ** might filter out all rows that match (t1.a=t2.b), causing SQLite - ** to add a row of NULL values to the output that should not be - ** present (since the ON clause does actually match rows within t2). + ** Say there is a single row in t2 that matches (t1.a=t2.b), but its + ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is + ** pushed down to the cursor, this row is filtered out, causing + ** SQLite to synthesize a row of NULL values. Which does match the + ** WHERE clause, and so the query returns a row. Which is incorrect. + ** + ** For the same reason, WHERE terms such as: + ** + ** WHERE 1 = (t2.c IS NULL) + ** + ** are also excluded. See codeCursorHintIsOrFunction() for details. */ if( pTabItem->fg.jointype & JT_LEFT ){ - if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin) - || pTerm->pExpr->iRightJoinTable!=pTabItem->iCursor + Expr *pExpr = pTerm->pExpr; + if( !ExprHasProperty(pExpr, EP_FromJoin) + || pExpr->iRightJoinTable!=pTabItem->iCursor ){ - continue; + sWalker.eCode = 0; + sWalker.xExprCallback = codeCursorHintIsOrFunction; + sqlite3WalkExpr(&sWalker, pTerm->pExpr); + if( sWalker.eCode ) continue; } }else{ if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue; diff --git a/test/cursorhint2.test b/test/cursorhint2.test index b6ebda2244..b42227cdfb 100644 --- a/test/cursorhint2.test +++ b/test/cursorhint2.test @@ -94,7 +94,74 @@ do_extract_hints_test 1.6 { do_extract_hints_test 1.7 { SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND d=e) LEFT JOIN t3 ON (d=f); } { - t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)} + t2 {EQ(r[2],c0)} t3 {AND(EQ(r[6],c0),EQ(r[7],c1))} +} + +#------------------------------------------------------------------------- +# +do_execsql_test 2.0 { + CREATE TABLE x1(x, y); + CREATE TABLE x2(a, b); +} + +do_extract_hints_test 2.1 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS NULL; +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.2 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS +NULL; +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.3 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = (b IS NULL) +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.4 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = coalesce(b, 1) +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.5 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = coalesce(b, 1) +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.6 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 0 = (b IS NOT NULL) +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.7 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 0 = (b IS NOT +NULL) +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.8 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS NOT +NULL +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.9 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE CASE b WHEN 0 THEN 0 ELSE 1 END; +} { + x2 {EQ(c0,r[2])} +} + +do_extract_hints_test 2.10 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE x2.b = 32+32 +} { + x2 {AND(EQ(c1,ADD(32,32)),EQ(c0,r[2]))} } finish_test From 2b693d63e43b747169be6dcd4541a678eeb9b860 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 20 Jun 2016 17:22:06 +0000 Subject: [PATCH 156/302] Allow LIKE operators that appear in a WHERE clause to be included in the cursor-hint for a cursor on the rhs of a LEFT JOIN. FossilOrigin-Name: 7455d932f5079ffe40462a8c119fc22b8a9bcbcc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wherecode.c | 9 ++++++++- test/cursorhint2.test | 12 ++++++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index be6f9cf0da..a231acf082 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Include\sWHERE\sterms\sin\sthe\scursor-hint\spassed\sto\sa\scursor\sopened\sfor\sthe\srhs\sof\sa\sLEFT\sJOIN\siff\swe\scan\sbe\ssure\sthat\sthose\sterms\swill\snot\sevaluate\sto\strue\sif\sthe\sLEFT\sJOIN\sgenerates\sa\srow\sof\sNULLs. -D 2016-06-17T19:27:13.114 +C Allow\sLIKE\soperators\sthat\sappear\sin\sa\sWHERE\sclause\sto\sbe\sincluded\sin\sthe\scursor-hint\sfor\sa\scursor\son\sthe\srhs\sof\sa\sLEFT\sJOIN. +D 2016-06-20T17:22:06.973 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -464,7 +464,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 74f0798525b6306682d7234f230ea93f86959b9b F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 -F src/wherecode.c c1b11ad09468577afd3c36cd8c854fb6dd77f258 +F src/wherecode.c e20cb381ff621e56a4684c71e31999aca2547ca6 F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -617,7 +617,7 @@ F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 -F test/cursorhint2.test cef69bab25b9141071b4239fa5c3b4ce18eeafd0 +F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab @@ -1502,7 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fcd12b69cee1335224a65aa6d22c4e302b889398 -R aa7c436ce5d8105be03298dc84afa8de +P 998095aba01b75f685ed981b377e1dfe650d9bbf +R 6b36cf1cbd5dc0e94253a2a90e40c230 U dan -Z a2cf93e232f8c6f0bcf6400999626f67 +Z 7f5e55d96c0f8c6a30345a5c923b92ab diff --git a/manifest.uuid b/manifest.uuid index efb8ac0335..a65de1e449 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -998095aba01b75f685ed981b377e1dfe650d9bbf \ No newline at end of file +7455d932f5079ffe40462a8c119fc22b8a9bcbcc \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index e6294de532..a017b40c7d 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -642,12 +642,19 @@ static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){ ** CASE WHEN col THEN 0 ELSE 1 END */ static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){ - if( pExpr->op==TK_IS || pExpr->op==TK_FUNCTION + if( pExpr->op==TK_IS || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE ){ pWalker->eCode = 1; + }else if( pExpr->op==TK_FUNCTION ){ + int d1; + char d2[3]; + if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){ + pWalker->eCode = 1; + } } + return WRC_Continue; } diff --git a/test/cursorhint2.test b/test/cursorhint2.test index b42227cdfb..3444fdf441 100644 --- a/test/cursorhint2.test +++ b/test/cursorhint2.test @@ -164,5 +164,17 @@ do_extract_hints_test 2.10 { x2 {AND(EQ(c1,ADD(32,32)),EQ(c0,r[2]))} } +do_extract_hints_test 2.11 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE x2.b LIKE 'abc%' +} { + x2 {AND(expr,EQ(c0,r[2]))} +} + +do_extract_hints_test 2.11 { + SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE coalesce(x2.b, 1) +} { + x2 {EQ(c0,r[2])} +} + finish_test From 9c987a833cf767c7d07c071c25b353623e60ad2a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Jun 2016 10:34:41 +0000 Subject: [PATCH 157/302] Update the sqldiff utility so that if the --vtab switch is specified "rtree", "fts3", "fts4" and "fts5" tables are diff'd directly and the underlying real database tables ignored. Without this switch, all virtual tables are ignored and the diff is performed on the underlying real tables. FossilOrigin-Name: 5d0a9d4c45730e47576bc77373fa7075a74051a5 --- ext/rbu/rbudiff.test | 69 +++++++++++++++++++- manifest | 18 ++--- manifest.uuid | 2 +- tool/sqldiff.c | 152 ++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 221 insertions(+), 20 deletions(-) diff --git a/ext/rbu/rbudiff.test b/ext/rbu/rbudiff.test index 0863f6e807..fa8de319dd 100644 --- a/ext/rbu/rbudiff.test +++ b/ext/rbu/rbudiff.test @@ -25,6 +25,10 @@ proc get_rbudiff_sql {db1 db2} { exec $::PROG --rbu $db1 $db2 } +proc get_vtab_rbudiff_sql {db1 db2} { + exec $::PROG --vtab --rbu $db1 $db2 +} + proc step_rbu {target rbu} { while 1 { sqlite3rbu rbu $target $rbu @@ -44,6 +48,11 @@ proc apply_rbudiff {sql target} { step_rbu $target rbu.db } +proc sqlesc {id} { + set ret "'[string map {' ''} $id]'" + set ret +} + # The only argument is the output of an [sqldiff -rbu] run. This command # tests that the contents of the rbu_count table is correct. An exception # is thrown if it is not. @@ -54,7 +63,7 @@ proc test_rbucount {sql} { tmpdb eval { SELECT name FROM sqlite_master WHERE name LIKE 'data%' AND type='table' } { - set a [tmpdb eval "SELECT count(*) FROM $name"] + set a [tmpdb eval "SELECT count(*) FROM [sqlesc $name]"] set b [tmpdb eval {SELECT cnt FROM rbu_count WHERE tbl = $name}] if {$a != $b} { tmpdb close @@ -71,9 +80,11 @@ proc rbudiff_cksum {db1} { sqlite3 dbtmp $db1 foreach tbl [dbtmp eval {SELECT name FROM sqlite_master WHERE type='table'}] { set cols [list] - dbtmp eval "PRAGMA table_info = $tbl" { lappend cols "quote( $name )" } + dbtmp eval "PRAGMA table_info = [sqlesc $tbl]" { + lappend cols "quote( $name )" + } append txt [dbtmp eval \ - "SELECT [join $cols {||'.'||}] FROM $tbl ORDER BY 1" + "SELECT [join $cols {||'.'||}] FROM [sqlesc $tbl] ORDER BY 1" ] } dbtmp close @@ -159,5 +170,57 @@ foreach {tn init mod} { do_test 1.$tn.5 { rbudiff_cksum test.db } [rbudiff_cksum test.db2] } +#------------------------------------------------------------------------- +# Test that if the --vtab switch is present, [sqldiff] handles virtual +# table types fts[345] and rtree correctly. +# +ifcapable fts3&&fts5&&rtree { + +foreach {tn init mod} { + 1 { + CREATE VIRTUAL TABLE t1 USING fts5(c); + INSERT INTO t1 VALUES('a b c'); + INSERT INTO t1 VALUES('a b c'); + } { + DELETE FROM t1 WHERE rowid = 1; + INSERT INTO t1 VALUES('a b c'); + } + + 2 { + CREATE VIRTUAL TABLE "x y" USING 'rtree'(id, x1, x2); + INSERT INTO "x y" VALUES(1, 2, 3); + INSERT INTO "x y" VALUES(2, 4, 6); + } { + DELETE FROM "x y" WHERE rowid = 1; + INSERT INTO "x y" VALUES(3, 6, 9); + } + + 3 { + CREATE VIRTUAL TABLE 'x''y' USING fts3; + INSERT INTO 'x''y' VALUES('one two three'); + INSERT INTO 'x''y' VALUES('four five six'); + } { + DELETE FROM 'x''y' WHERE rowid = 1; + INSERT INTO 'x''y' VALUES('one two three'); + } + +} { + + forcedelete test.db test.db2 + sqlite3 db test.db + db eval "$init" + sqlite3 db test.db2 + db eval "$init ; $mod" + db close + + do_test 2.$tn.1 { + set sql [get_vtab_rbudiff_sql test.db test.db2] + apply_rbudiff $sql test.db + } {SQLITE_DONE} + do_test 2.$tn.2 { rbudiff_cksum test.db } [rbudiff_cksum test.db2] +} + +} + finish_test diff --git a/manifest b/manifest index f7bf4fc9ff..12c06cd44f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sa\stable\son\sthe\srhs\sof\sa\sLEFT\sJOIN\soperator,\sdo\snot\sinclude\sterms\slike\s"IS\sNULL"\sfrom\sthe\sWHERE\sclause\sin\sthe\scursor-hint.\sThese\smay\sbe\sfalse\sfor\srows\sthat\sthe\scursor\swould\sotherwise\svisit,\sbut\strue\sfor\sa\srow\sof\sall\sNULL\svalues\sgenerated\sby\sthe\sLEFT\sJOIN. -D 2016-06-20T17:25:50.750 +C Update\sthe\ssqldiff\sutility\sso\sthat\sif\sthe\s--vtab\sswitch\sis\sspecified\s"rtree",\s"fts3",\s"fts4"\sand\s"fts5"\stables\sare\sdiff'd\sdirectly\sand\sthe\sunderlying\sreal\sdatabase\stables\signored.\sWithout\sthis\sswitch,\sall\svirtual\stables\sare\signored\sand\sthe\sdiff\sis\sperformed\son\sthe\sunderlying\sreal\stables. +D 2016-06-21T10:34:41.782 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -243,7 +243,7 @@ F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2 F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831 F ext/rbu/rbu_common.tcl 3a4b916b6f5dca9c9da9a30863e272fe5ea4414f F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695 -F ext/rbu/rbudiff.test 2df0a8a7d998ecf81764c21eeda3cde5611c5091 +F ext/rbu/rbudiff.test 4c9f8df6f723f553781d3d117501b7e9d170a145 F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca @@ -1469,7 +1469,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c ca315aca4e2d24233e8f2000edea5880c53d1875 +F tool/sqldiff.c 131e9c6e09d3d78e3c4ae8b5fd23451521723aac F tool/srcck1.c 4c39bdfa9a92edd20233ee720df84dbeb2417602 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1502,8 +1502,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c 7455d932f5079ffe40462a8c119fc22b8a9bcbcc -R 6b36cf1cbd5dc0e94253a2a90e40c230 -T +closed 7455d932f5079ffe40462a8c119fc22b8a9bcbcc +P 913e595615e2ef40fb431f6e7678f6fc8439782e +R a344dc9988f1497ebec3b8ad168c1397 +T *branch * sqldiff-vtab-support +T *sym-sqldiff-vtab-support * +T -sym-trunk * U dan -Z 537cf80c06fd3994884c97d3059d4966 +Z 6909c0a252ed2326d78857113119f0ab diff --git a/manifest.uuid b/manifest.uuid index 53806979d6..677a251025 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -913e595615e2ef40fb431f6e7678f6fc8439782e \ No newline at end of file +5d0a9d4c45730e47576bc77373fa7075a74051a5 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 319acafdbd..4a5389c603 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -33,6 +33,7 @@ struct GlobalVars { const char *zArgv0; /* Name of program */ int bSchemaOnly; /* Only show schema differences */ int bSchemaPK; /* Use the schema-defined PK, not the true PK */ + int bHandleVtab; /* Handle fts3, fts4, fts5 and rtree vtabs */ unsigned fDebug; /* Debug flags */ sqlite3 *db; /* The database connection */ } g; @@ -1735,6 +1736,144 @@ end_changeset_one_table: sqlite3_free(zId); } +/* +** Extract the next SQL keyword or quoted string from buffer zIn and copy it +** (or a prefix of it if it will not fit) into buffer zBuf, size nBuf bytes. +** Return a pointer to the character within zIn immediately following +** the token or quoted string just extracted. +*/ +const char *gobble_token(const char *zIn, char *zBuf, int nBuf){ + const char *p = zIn; + char *pOut = zBuf; + char *pEnd = &pOut[nBuf-1]; + char q = 0; /* quote character, if any */ + + if( p==0 ) return 0; + while( *p==' ' ) p++; + switch( *p ){ + case '"': q = '"'; break; + case '\'': q = '\''; break; + case '`': q = '`'; break; + case '[': q = ']'; break; + } + + if( q ){ + p++; + while( *p && pOut Date: Thu, 23 Jun 2016 12:35:04 +0000 Subject: [PATCH 158/302] Fix the build for -DSQLITE_OMIT_VIRTUALTABLE FossilOrigin-Name: 911131424857430d46784b167399ecf192584ca2 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/where.c | 5 ++++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f7bf4fc9ff..5a9145709f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sa\stable\son\sthe\srhs\sof\sa\sLEFT\sJOIN\soperator,\sdo\snot\sinclude\sterms\slike\s"IS\sNULL"\sfrom\sthe\sWHERE\sclause\sin\sthe\scursor-hint.\sThese\smay\sbe\sfalse\sfor\srows\sthat\sthe\scursor\swould\sotherwise\svisit,\sbut\strue\sfor\sa\srow\sof\sall\sNULL\svalues\sgenerated\sby\sthe\sLEFT\sJOIN. -D 2016-06-20T17:25:50.750 +C Fix\sthe\sbuild\sfor\s-DSQLITE_OMIT_VIRTUALTABLE +D 2016-06-23T12:35:04.863 F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -462,7 +462,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 74f0798525b6306682d7234f230ea93f86959b9b +F src/where.c 0ce4793497af2feb051147a5cc6356f95d3ab381 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c e20cb381ff621e56a4684c71e31999aca2547ca6 F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 @@ -1502,8 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b1579caf06a2c42433b8bc9dc28c9ad381aa07c 7455d932f5079ffe40462a8c119fc22b8a9bcbcc -R 6b36cf1cbd5dc0e94253a2a90e40c230 -T +closed 7455d932f5079ffe40462a8c119fc22b8a9bcbcc -U dan -Z 537cf80c06fd3994884c97d3059d4966 +P 913e595615e2ef40fb431f6e7678f6fc8439782e +R b96a3531b275feb80cf3ff7b27074eda +U drh +Z 55a9839fb9d4bac563e41eaf1345cb2c diff --git a/manifest.uuid b/manifest.uuid index 53806979d6..993a909ccc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -913e595615e2ef40fb431f6e7678f6fc8439782e \ No newline at end of file +911131424857430d46784b167399ecf192584ca2 \ No newline at end of file diff --git a/src/where.c b/src/where.c index e5a476c00a..46fcb4a158 100644 --- a/src/where.c +++ b/src/where.c @@ -3240,6 +3240,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ mPrereq = mPrior; } priorJointype = pItem->fg.jointype; +#ifndef SQLITE_OMIT_VIRTUALTABLE if( IsVirtual(pItem->pTab) ){ struct SrcList_item *p; for(p=&pItem[1]; p Date: Fri, 24 Jun 2016 02:50:44 +0000 Subject: [PATCH 159/302] Fix the Makefile.in to avoid unnecessary recompiles of sqlite3.c. FossilOrigin-Name: 67c39e16442d9359b24d60d5f97bd66c19eff16a --- Makefile.in | 22 +++++++++++----------- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Makefile.in b/Makefile.in index 29c9174afa..b9f684e617 100644 --- a/Makefile.in +++ b/Makefile.in @@ -588,15 +588,15 @@ sqlite3$(TEXE): $(TOP)/src/shell.c sqlite3.c $(TOP)/src/shell.c sqlite3.c \ $(LIBREADLINE) $(TLIBS) -rpath "$(libdir)" -sqldiff$(TEXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h - $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) +sqldiff$(TEXE): $(TOP)/tool/sqldiff.c sqlite3.lo sqlite3.h + $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.lo $(TLIBS) -dbhash$(TEXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h - $(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.c $(TLIBS) +dbhash$(TEXE): $(TOP)/tool/dbhash.c sqlite3.lo sqlite3.h + $(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.lo $(TLIBS) -scrub$(TEXE): $(TOP)/ext/misc/scrub.c sqlite3.o +scrub$(TEXE): $(TOP)/ext/misc/scrub.c sqlite3.lo $(LTLINK) -o $@ -I. -DSCRUB_STANDALONE \ - $(TOP)/ext/misc/scrub.c sqlite3.o $(TLIBS) + $(TOP)/ext/misc/scrub.c sqlite3.lo $(TLIBS) srcck1$(BEXE): $(TOP)/tool/srcck1.c $(BCC) -o srcck1$(BEXE) $(TOP)/tool/srcck1.c @@ -611,8 +611,8 @@ fuzzershell$(TEXE): $(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h fuzzcheck$(TEXE): $(TOP)/test/fuzzcheck.c sqlite3.c sqlite3.h $(LTLINK) -o $@ $(FUZZCHECK_OPT) $(TOP)/test/fuzzcheck.c sqlite3.c $(TLIBS) -mptester$(TEXE): sqlite3.c $(TOP)/mptest/mptest.c - $(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.c \ +mptester$(TEXE): sqlite3.lo $(TOP)/mptest/mptest.c + $(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.lo \ $(TLIBS) -rpath "$(libdir)" MPTEST1=./mptester$(TEXE) mptest.db $(TOP)/mptest/crash01.test --repeat 20 @@ -1156,8 +1156,8 @@ rollback-test$(TEXE): $(TOP)/tool/rollback-test.c sqlite3.lo LogEst$(TEXE): $(TOP)/tool/logest.c sqlite3.h $(LTLINK) -I. -o $@ $(TOP)/tool/logest.c -wordcount$(TEXE): $(TOP)/test/wordcount.c sqlite3.c - $(LTLINK) -o $@ $(TOP)/test/wordcount.c sqlite3.c $(TLIBS) +wordcount$(TEXE): $(TOP)/test/wordcount.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/test/wordcount.c sqlite3.lo $(TLIBS) speedtest1$(TEXE): $(TOP)/test/speedtest1.c sqlite3.lo $(LTLINK) -o $@ $(TOP)/test/speedtest1.c sqlite3.lo $(TLIBS) @@ -1174,7 +1174,7 @@ loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la # VALIDIDS=' sqlite3(changeset|changegroup|session)?_' checksymbols: sqlite3.lo - nm -g --defined-only sqlite3.o | egrep -v $(VALIDIDS); test $$? -ne 0 + nm -g --defined-only sqlite3.lo | egrep -v $(VALIDIDS); test $$? -ne 0 echo '0 errors out of 1 tests' # Build the amalgamation-autoconf package. The amalamgation-tarball target builds diff --git a/manifest b/manifest index 6ede4001aa..c80dd74edf 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ -C Update\sthe\ssqldiff\sutility\sso\sthat\sif\sthe\s--vtab\sswitch\sis\sspecified\s"rtree",\s"fts3",\s"fts4"\sand\s"fts5"\stables\sare\sdiff'd\sdirectly\sand\sthe\sunderlying\sreal\sdatabase\stables\signored.\sWithout\sthis\sswitch,\sall\svirtual\stables\sare\signored\sand\sthe\sdiff\sis\sperformed\son\sthe\sunderlying\sreal\stables. -D 2016-06-23T16:48:35.249 -F Makefile.in f3f7d2060ce03af4584e711ef3a626ef0b1d6340 +C Fix\sthe\sMakefile.in\sto\savoid\sunnecessary\srecompiles\sof\ssqlite3.c. +D 2016-06-24T02:50:44.909 +F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 @@ -1502,8 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 911131424857430d46784b167399ecf192584ca2 5d0a9d4c45730e47576bc77373fa7075a74051a5 -R 208a102d85ab541408c6c49f684969ef -T +closed 5d0a9d4c45730e47576bc77373fa7075a74051a5 -U dan -Z c85e872c7e55cfaaf069baf7060cb813 +P b8671e9434180878cfe15d70b793fdee69aabccf +R bb5fcfa23277d6cebd22a760da9dcde6 +U drh +Z 138a4cc0f4ecfcd1f7ccb81cfc01b8ef diff --git a/manifest.uuid b/manifest.uuid index e7770916f2..8c3593deb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8671e9434180878cfe15d70b793fdee69aabccf \ No newline at end of file +67c39e16442d9359b24d60d5f97bd66c19eff16a \ No newline at end of file From f5fe00399f545bdc2d121472f4e76547f3d2fdb1 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 24 Jun 2016 06:23:13 +0000 Subject: [PATCH 160/302] Fix the ctime.test script so that it works with clang. FossilOrigin-Name: 77e4f7a36e6e0ebe842bcb36b2557a5bfba90d3f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/ctime.test | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c80dd74edf..0af6528b9d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sMakefile.in\sto\savoid\sunnecessary\srecompiles\sof\ssqlite3.c. -D 2016-06-24T02:50:44.909 +C Fix\sthe\sctime.test\sscript\sso\sthat\sit\sworks\swith\sclang. +D 2016-06-24T06:23:13.369 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -615,7 +615,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f -F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 +F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 @@ -1502,7 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8671e9434180878cfe15d70b793fdee69aabccf -R bb5fcfa23277d6cebd22a760da9dcde6 +P 67c39e16442d9359b24d60d5f97bd66c19eff16a +R 7e79191b4d7cf82834abc676eac1270e U drh -Z 138a4cc0f4ecfcd1f7ccb81cfc01b8ef +Z 811d7c2149778ab6cb4ca3f8ac5802c8 diff --git a/manifest.uuid b/manifest.uuid index 8c3593deb6..d7b3218dfe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67c39e16442d9359b24d60d5f97bd66c19eff16a \ No newline at end of file +77e4f7a36e6e0ebe842bcb36b2557a5bfba90d3f \ No newline at end of file diff --git a/test/ctime.test b/test/ctime.test index e4cb156168..efdf170851 100644 --- a/test/ctime.test +++ b/test/ctime.test @@ -196,9 +196,10 @@ set tc 1 foreach opt $opts { do_test ctime-2.5.$tc { set N [ expr {$tc-1} ] - set ans1 [ catchsql { + set ans1 [catch {db one { SELECT sqlite_compileoption_get($N); - } ] + }} msg] + lappend ans1 $msg set ans2 [ catchsql { SELECT sqlite_compileoption_used($opt); } ] From 4b37cd49a615dc12b39beb8389710f40358da1ac Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 25 Jun 2016 11:43:47 +0000 Subject: [PATCH 161/302] Fix the handling of OP_Eq opcodes that compare a register against itself and that require an affinity change. FossilOrigin-Name: 507014e4c7a70cd09410c89c8ed466c8edab39d2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbe.c | 2 ++ test/selectA.test | 9 +++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0af6528b9d..cd94ec1c26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sctime.test\sscript\sso\sthat\sit\sworks\swith\sclang. -D 2016-06-24T06:23:13.369 +C Fix\sthe\shandling\sof\sOP_Eq\sopcodes\sthat\scompare\sa\sregister\sagainst\sitself\nand\sthat\srequire\san\saffinity\schange. +D 2016-06-25T11:43:47.381 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -448,7 +448,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c e23a15d352e63b51cf08af8052e678e67c54ec09 +F src/vdbe.c 22b46c3b725e950e9f2760e2d76953d592600ad4 F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd F src/vdbeapi.c 02bcbc2ca5d2004b029088b05b468b394881e103 @@ -1041,7 +1041,7 @@ F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0 F test/select7.test 95e370c42d47c3c52377d05e9ffc01ccff7c1f61 F test/select8.test 8c8f5ae43894c891efc5755ed905467d1d67ad5d F test/select9.test aebc2bb0c3bc44606125033cbcaac2c8d1f33a95 -F test/selectA.test e452bdb975f488ea46d091382a9185b5853ed2c7 +F test/selectA.test 101e722370ac6e84978c2958b8931c78b10a1709 F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25 F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977 F test/selectD.test b0f02a04ef7737decb24e08be2c39b9664b43394 @@ -1502,7 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 67c39e16442d9359b24d60d5f97bd66c19eff16a -R 7e79191b4d7cf82834abc676eac1270e +P 77e4f7a36e6e0ebe842bcb36b2557a5bfba90d3f +R 3ef1ee60339b9a478f36c983b60b7e48 U drh -Z 811d7c2149778ab6cb4ca3f8ac5802c8 +Z 7d552df043719cedc46422a9795a23bd diff --git a/manifest.uuid b/manifest.uuid index d7b3218dfe..9ea9790f27 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -77e4f7a36e6e0ebe842bcb36b2557a5bfba90d3f \ No newline at end of file +507014e4c7a70cd09410c89c8ed466c8edab39d2 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 245c5beb6c..6adbcbbec1 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2016,6 +2016,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ if( (flags1 | flags3)&MEM_Str ){ if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn1,0); + flags3 = pIn3->flags; } if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn3,0); @@ -2028,6 +2029,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ sqlite3VdbeMemStringify(pIn1, encoding, 1); testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); + flags3 = pIn3->flags; } if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){ testcase( pIn3->flags & MEM_Int ); diff --git a/test/selectA.test b/test/selectA.test index 0338338902..78d04be15d 100644 --- a/test/selectA.test +++ b/test/selectA.test @@ -1434,5 +1434,14 @@ do_catchsql_test 5.4 { SELECT * FROM t8 UNION SELECT * FROM t9 ORDER BY a+b COLLATE NOCASE } {1 {1st ORDER BY term does not match any column in the result set}} +do_execsql_test 6.1 { + DROP TABLE IF EXISTS t1; + DROP TABLE IF EXISTS t2; + CREATE TABLE t1(a INTEGER); + CREATE TABLE t2(b TEXT); + INSERT INTO t2(b) VALUES('12345'); + SELECT * FROM (SELECT a FROM t1 UNION SELECT b FROM t2) WHERE a=a; +} {12345} + finish_test From 05d1bad67458843adb41c9f77dabb22aa6cd0084 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 26 Jun 2016 04:06:28 +0000 Subject: [PATCH 162/302] Prevent the WhereLoop.rSetup cost estimate from going negative on complex queries. FossilOrigin-Name: f81050859170c8708a1b296da8dd3ef0dd314a11 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index cd94ec1c26..2dd253cf30 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\shandling\sof\sOP_Eq\sopcodes\sthat\scompare\sa\sregister\sagainst\sitself\nand\sthat\srequire\san\saffinity\schange. -D 2016-06-25T11:43:47.381 +C Prevent\sthe\sWhereLoop.rSetup\scost\sestimate\sfrom\sgoing\snegative\son\scomplex\nqueries. +D 2016-06-26T04:06:28.081 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -462,7 +462,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 0ce4793497af2feb051147a5cc6356f95d3ab381 +F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c e20cb381ff621e56a4684c71e31999aca2547ca6 F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 @@ -1502,7 +1502,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 77e4f7a36e6e0ebe842bcb36b2557a5bfba90d3f -R 3ef1ee60339b9a478f36c983b60b7e48 +P 507014e4c7a70cd09410c89c8ed466c8edab39d2 +R ae55d782914cbf2db58c75f82f862316 U drh -Z 7d552df043719cedc46422a9795a23bd +Z e21bca843071316b56d3c29d5bf9cc08 diff --git a/manifest.uuid b/manifest.uuid index 9ea9790f27..ee49eb40ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -507014e4c7a70cd09410c89c8ed466c8edab39d2 \ No newline at end of file +f81050859170c8708a1b296da8dd3ef0dd314a11 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 46fcb4a158..a65f30968e 100644 --- a/src/where.c +++ b/src/where.c @@ -2701,6 +2701,7 @@ static int whereLoopAddBtree( pNew->rSetup += 24; } ApplyCostMultiplier(pNew->rSetup, pTab->costMult); + if( pNew->rSetup<0 ) pNew->rSetup = 0; /* TUNING: Each index lookup yields 20 rows in the table. This ** is more than the usual guess of 10 rows, since we have no way ** of knowing how selective the index will ultimately be. It would From a2fbe3bec66936b2f542fa6f9c9238aa2ea452b2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 28 Jun 2016 22:27:56 +0000 Subject: [PATCH 163/302] Proposed fix for a problem in the query planner. FossilOrigin-Name: a33d23560959a127e37d8213dc00210cd4b05352 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/whereexpr.c | 8 +++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 2dd253cf30..2e46c5cb6a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sthe\sWhereLoop.rSetup\scost\sestimate\sfrom\sgoing\snegative\son\scomplex\nqueries. -D 2016-06-26T04:06:28.081 +C Proposed\sfix\sfor\sa\sproblem\sin\sthe\squery\splanner. +D 2016-06-28T22:27:56.883 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -465,7 +465,7 @@ F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c e20cb381ff621e56a4684c71e31999aca2547ca6 -F src/whereexpr.c c32d47085dbaca0b8fd013210f56693c7d220d48 +F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1502,7 +1502,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 507014e4c7a70cd09410c89c8ed466c8edab39d2 -R ae55d782914cbf2db58c75f82f862316 +P f81050859170c8708a1b296da8dd3ef0dd314a11 +R dcdb165f171e6961986899e464931036 +T *branch * planner-fix +T *sym-planner-fix * +T -sym-trunk * U drh -Z e21bca843071316b56d3c29d5bf9cc08 +Z 35245dfa6950894f0d3652717f7690e0 diff --git a/manifest.uuid b/manifest.uuid index ee49eb40ac..f6e2e672d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f81050859170c8708a1b296da8dd3ef0dd314a11 \ No newline at end of file +a33d23560959a127e37d8213dc00210cd4b05352 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 90c4c45965..1cb6be8458 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -785,12 +785,10 @@ static int termIsEquivalence(Parse *pParse, Expr *pExpr){ pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight); if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1; pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); - /* Since pLeft and pRight are both a column references, their collating - ** sequence should always be defined. */ - zColl1 = ALWAYS(pColl) ? pColl->zName : 0; + zColl1 = pColl ? pColl->zName : 0; pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight); - zColl2 = ALWAYS(pColl) ? pColl->zName : 0; - return sqlite3StrICmp(zColl1, zColl2)==0; + zColl2 = pColl ? pColl->zName : 0; + return sqlite3_stricmp(zColl1, zColl2)==0; } /* From 4841624ab991a90dc84cb48cec9abcfe6f885dbf Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 29 Jun 2016 05:00:30 +0000 Subject: [PATCH 164/302] Add a prototype intarray($PTR,$N) table valued function. FossilOrigin-Name: 233b33382dc70de45f90b6dfdb5785f20b21489e --- Makefile.in | 1 + ext/misc/array.c | 296 ++++++++++++++++++++++++++++++++++++++++++++ manifest | 20 +-- manifest.uuid | 2 +- src/test1.c | 43 +++++++ test/tabfunc01.test | 22 ++++ 6 files changed, 375 insertions(+), 9 deletions(-) create mode 100644 ext/misc/array.c diff --git a/Makefile.in b/Makefile.in index b9f684e617..ff863ec906 100644 --- a/Makefile.in +++ b/Makefile.in @@ -416,6 +416,7 @@ TESTSRC = \ # TESTSRC += \ $(TOP)/ext/misc/amatch.c \ + $(TOP)/ext/misc/array.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/eval.c \ diff --git a/ext/misc/array.c b/ext/misc/array.c new file mode 100644 index 0000000000..54b249f90a --- /dev/null +++ b/ext/misc/array.c @@ -0,0 +1,296 @@ +/* +** 2016-06-29 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file demonstrates how to create a table-valued-function that +** returns the values in a C-language array. +** Examples: +** +** SELECT * FROM intarray($ptr,5) +** +** The query above returns 5 integers contained in a C-language array +** at the address $ptr. $ptr is a pointer to the array of integers that +** has been cast to an integer. +** +** HOW IT WORKS +** +** The intarray "function" is really a virtual table with the +** following schema: +** +** CREATE FUNCTION intarray( +** value, +** pointer HIDDEN, +** count HIDDEN +** ); +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include +#include + +#ifndef SQLITE_OMIT_VIRTUALTABLE + + +/* intarray_cursor is a subclass of sqlite3_vtab_cursor which will +** serve as the underlying representation of a cursor that scans +** over rows of the result +*/ +typedef struct intarray_cursor intarray_cursor; +struct intarray_cursor { + sqlite3_vtab_cursor base; /* Base class - must be first */ + int isDesc; /* True to count down rather than up */ + sqlite3_int64 iRowid; /* The rowid */ + sqlite3_int64 iPtr; /* Pointer to array of integers */ + sqlite3_int64 iCnt; /* Number of integers in the array */ +}; + +/* +** The intarrayConnect() method is invoked to create a new +** intarray_vtab that describes the intarray virtual table. +** +** Think of this routine as the constructor for intarray_vtab objects. +** +** All this routine needs to do is: +** +** (1) Allocate the intarray_vtab object and initialize all fields. +** +** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the +** result set of queries against intarray will look like. +*/ +static int intarrayConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + sqlite3_vtab *pNew; + int rc; + +/* Column numbers */ +#define INTARRAY_COLUMN_VALUE 0 +#define INTARRAY_COLUMN_POINTER 1 +#define INTARRAY_COLUMN_COUNT 2 + + rc = sqlite3_declare_vtab(db, + "CREATE TABLE x(value,pointer hidden,count hidden)"); + if( rc==SQLITE_OK ){ + pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + } + return rc; +} + +/* +** This method is the destructor for intarray_cursor objects. +*/ +static int intarrayDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** Constructor for a new intarray_cursor object. +*/ +static int intarrayOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + intarray_cursor *pCur; + pCur = sqlite3_malloc( sizeof(*pCur) ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur)); + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +/* +** Destructor for a intarray_cursor. +*/ +static int intarrayClose(sqlite3_vtab_cursor *cur){ + sqlite3_free(cur); + return SQLITE_OK; +} + + +/* +** Advance a intarray_cursor to its next row of output. +*/ +static int intarrayNext(sqlite3_vtab_cursor *cur){ + intarray_cursor *pCur = (intarray_cursor*)cur; + pCur->iRowid++; + return SQLITE_OK; +} + +/* +** Return values of columns for the row at which the intarray_cursor +** is currently pointing. +*/ +static int intarrayColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + intarray_cursor *pCur = (intarray_cursor*)cur; + sqlite3_int64 x = 0; + switch( i ){ + case INTARRAY_COLUMN_POINTER: x = pCur->iPtr; break; + case INTARRAY_COLUMN_COUNT: x = pCur->iCnt; break; + default: { + int *p = (int*)pCur->iPtr; + x = (int)p[pCur->iRowid-1]; + break; + } + } + sqlite3_result_int64(ctx, x); + return SQLITE_OK; +} + +/* +** Return the rowid for the current row. In this implementation, the +** rowid is the same as the output value. +*/ +static int intarrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + intarray_cursor *pCur = (intarray_cursor*)cur; + *pRowid = pCur->iRowid; + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int intarrayEof(sqlite3_vtab_cursor *cur){ + intarray_cursor *pCur = (intarray_cursor*)cur; + return pCur->iRowid>=pCur->iCnt; +} + +/* +** This method is called to "rewind" the intarray_cursor object back +** to the first row of output. +*/ +static int intarrayFilter( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + intarray_cursor *pCur = (intarray_cursor *)pVtabCursor; + int i = 0; + if( idxNum ){ + pCur->iPtr = sqlite3_value_int64(argv[0]); + pCur->iCnt = sqlite3_value_int64(argv[1]); + }else{ + pCur->iPtr = 0; + pCur->iCnt = 0; + } + pCur->iRowid = 1; + return SQLITE_OK; +} + +/* +** SQLite will invoke this method one or more times while planning a query +** that uses the intarray virtual table. This routine needs to create +** a query plan for each invocation and compute an estimated cost for that +** plan. +** +** In this implementation idxNum is used to represent the +** query plan. idxStr is unused. +** +** idxNum is 1 if the pointer= and count= constraints exist and is 0 otherwise. +** If idxNum is 0, then intarray becomes an empty table. +*/ +static int intarrayBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + int i; /* Loop over constraints */ + int idxNum = 0; /* The query plan bitmask */ + int ptrIdx = -1; /* Index of the pointer= constraint, or -1 if none */ + int cntIdx = -1; /* Index of the count= constraint, or -1 if none */ + int nArg = 0; /* Number of arguments that intarrayFilter() expects */ + + const struct sqlite3_index_constraint *pConstraint; + pConstraint = pIdxInfo->aConstraint; + for(i=0; inConstraint; i++, pConstraint++){ + if( pConstraint->usable==0 ) continue; + if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; + switch( pConstraint->iColumn ){ + case INTARRAY_COLUMN_POINTER: + ptrIdx = i; + break; + case INTARRAY_COLUMN_COUNT: + cntIdx = i; + break; + } + } + if( ptrIdx>=0 && cntIdx>=0 ){ + pIdxInfo->aConstraintUsage[ptrIdx].argvIndex = 1; + pIdxInfo->aConstraintUsage[ptrIdx].omit = 1; + pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2; + pIdxInfo->aConstraintUsage[cntIdx].omit = 1; + pIdxInfo->estimatedCost = (double)1; + pIdxInfo->estimatedRows = (double)100; + pIdxInfo->idxNum = 1; + }else{ + pIdxInfo->estimatedCost = (double)2147483647; + pIdxInfo->estimatedRows = (double)2147483647; + pIdxInfo->idxNum = 0; + } + return SQLITE_OK; +} + +/* +** This following structure defines all the methods for the +** intarray virtual table. +*/ +static sqlite3_module intarrayModule = { + 0, /* iVersion */ + 0, /* xCreate */ + intarrayConnect, /* xConnect */ + intarrayBestIndex, /* xBestIndex */ + intarrayDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + intarrayOpen, /* xOpen - open a cursor */ + intarrayClose, /* xClose - close a cursor */ + intarrayFilter, /* xFilter - configure scan constraints */ + intarrayNext, /* xNext - advance a cursor */ + intarrayEof, /* xEof - check for end of scan */ + intarrayColumn, /* xColumn - read data */ + intarrayRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; + +#endif /* SQLITE_OMIT_VIRTUALTABLE */ + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_array_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + SQLITE_EXTENSION_INIT2(pApi); +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( sqlite3_libversion_number()<3008012 ){ + *pzErrMsg = sqlite3_mprintf( + "intarray() requires SQLite 3.8.12 or later"); + return SQLITE_ERROR; + } + rc = sqlite3_create_module(db, "intarray", &intarrayModule, 0); +#endif + return rc; +} diff --git a/manifest b/manifest index 2dd253cf30..f6356d3145 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ -C Prevent\sthe\sWhereLoop.rSetup\scost\sestimate\sfrom\sgoing\snegative\son\scomplex\nqueries. -D 2016-06-26T04:06:28.081 -F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 +C Add\sa\sprototype\sintarray($PTR,$N)\stable\svalued\sfunction. +D 2016-06-29T05:00:30.819 +F Makefile.in 541d493154ec3b0b20b2f1d495ec66f55905191e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 @@ -204,6 +204,7 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 +F ext/misc/array.c 20af0591e6611755dd8a9d1124e9c9a8cf42761f F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c f01126ba170fd4ef7c752b156568a80c912d4441 @@ -392,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 -F src/test1.c 43b37ab2b7338fd3313e74902f0d6c821eae843b +F src/test1.c 081e4ed40525590406a51f7e7e4cee31cdb5d029 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1114,7 +1115,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test f977868fa8bb7beb4b2072883190411653473906 +F test/tabfunc01.test a1976cbc37cbcdd4b4bd1e52d19a173dd62ab9e0 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1502,7 +1503,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 507014e4c7a70cd09410c89c8ed466c8edab39d2 -R ae55d782914cbf2db58c75f82f862316 +P f81050859170c8708a1b296da8dd3ef0dd314a11 +R 609a6d062299b01b515e433d814c02e8 +T *branch * prototype-int-array +T *sym-prototype-int-array * +T -sym-trunk * U drh -Z e21bca843071316b56d3c29d5bf9cc08 +Z 45472ddb0e35914c318f364b2c8020fb diff --git a/manifest.uuid b/manifest.uuid index ee49eb40ac..2ff393eb58 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f81050859170c8708a1b296da8dd3ef0dd314a11 \ No newline at end of file +233b33382dc70de45f90b6dfdb5785f20b21489e \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 0f16d62d85..9a73e0e0b5 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3241,6 +3241,46 @@ static int test_bind_int( } +/* +** Usage: sqlite3_bind_intarray STMT N INT ... +** +** Create a C-language array of integers from the arguments. Bind a pointer +** to this array to the NAME parameter of STMT. +*/ +static int test_bind_intarray( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + int idx; + int i; + static int *p = 0; + + sqlite3_free(p); + p = 0; + if( objc<4 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " STMT NAME INT...", 0); + return TCL_ERROR; + } + + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; + if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; + p = sqlite3_malloc( sizeof(int)*(objc-3) ); + if( p==0 ) return TCL_ERROR; + for(i=0; i Date: Wed, 29 Jun 2016 05:08:01 +0000 Subject: [PATCH 165/302] Another test case for the intarray($PTR,$N) virtual table. FossilOrigin-Name: 06e1fab7527c6b4330a58f8d8873afaf2d67ae86 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/tabfunc01.test | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index f6356d3145..defdea7bc4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sprototype\sintarray($PTR,$N)\stable\svalued\sfunction. -D 2016-06-29T05:00:30.819 +C Another\stest\scase\sfor\sthe\sintarray($PTR,$N)\svirtual\stable. +D 2016-06-29T05:08:01.847 F Makefile.in 541d493154ec3b0b20b2f1d495ec66f55905191e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -1115,7 +1115,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test a1976cbc37cbcdd4b4bd1e52d19a173dd62ab9e0 +F test/tabfunc01.test bb0ef0fdf5e807c5bc3438c8c4face4c9887971d F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1503,10 +1503,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f81050859170c8708a1b296da8dd3ef0dd314a11 -R 609a6d062299b01b515e433d814c02e8 -T *branch * prototype-int-array -T *sym-prototype-int-array * -T -sym-trunk * +P 233b33382dc70de45f90b6dfdb5785f20b21489e +R 67bef7ed0b382234904201d45ecddcca U drh -Z 45472ddb0e35914c318f364b2c8020fb +Z bbb146cf4e7f714032732261f87e16f3 diff --git a/manifest.uuid b/manifest.uuid index 2ff393eb58..ba2f320cf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -233b33382dc70de45f90b6dfdb5785f20b21489e \ No newline at end of file +06e1fab7527c6b4330a58f8d8873afaf2d67ae86 \ No newline at end of file diff --git a/test/tabfunc01.test b/test/tabfunc01.test index 473f3f385c..d0de104d81 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -155,6 +155,29 @@ do_test tabfunc01-621 { sqlite3_column_int $VM 0 } 22 sqlite3_finalize $VM + +do_test tabfunc01-650 { + db eval { + DROP TABLE IF EXISTS t6; + CREATE TABLE t6(x INTEGER PRIMARY KEY, y BLOB); + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100) + INSERT INTO t6(x,y) SELECT x, randomblob(x) FROM c; + } + set TAIL {} + set VM [sqlite3_prepare db { + SELECT length(y) FROM t6 WHERE x IN (SELECT value FROM intarray(?1,3)); + } -1 TAIL] + string trim $TAIL +} {} +do_test tabfunc01-660 { + sqlite3_bind_intarray $VM 1 11 22 33 44 55 + sqlite3_step $VM +} SQLITE_ROW +do_test tabfunc01-661 { + sqlite3_column_int $VM 0 +} 11 +sqlite3_finalize $VM + catch {sqlite3_bind_intarray} finish_test From 2d05331444e0feb269a4651ba2f8c47f4a5ad6e2 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 29 Jun 2016 06:19:19 +0000 Subject: [PATCH 166/302] Add the ability to have a table-valued function on the RHS of an IN operator. FossilOrigin-Name: ba1b441b6003808810667d749635fe6b2e8c6165 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/parse.y | 9 +++++++++ test/tabfunc01.test | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index defdea7bc4..3973bf7b86 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\stest\scase\sfor\sthe\sintarray($PTR,$N)\svirtual\stable. -D 2016-06-29T05:08:01.847 +C Add\sthe\sability\sto\shave\sa\stable-valued\sfunction\son\sthe\sRHS\sof\san\sIN\soperator. +D 2016-06-29T06:19:19.192 F Makefile.in 541d493154ec3b0b20b2f1d495ec66f55905191e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -372,7 +372,7 @@ F src/os_win.c d4b8faf8896b65818e67070711fdd00d8e620bd6 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 -F src/parse.y 01b9f37c4c7009ab56fda98bc7db4c42643cecfe +F src/parse.y 300a30380bfa73c0a0d2e0ae4c4d0cd844d80199 F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d @@ -1115,7 +1115,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test bb0ef0fdf5e807c5bc3438c8c4face4c9887971d +F test/tabfunc01.test 32e620a19963c50dcf6958dc5bb352de96d948fb F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1503,7 +1503,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 233b33382dc70de45f90b6dfdb5785f20b21489e -R 67bef7ed0b382234904201d45ecddcca +P 06e1fab7527c6b4330a58f8d8873afaf2d67ae86 +R a95030951795f74126be51a632f80a74 U drh -Z bbb146cf4e7f714032732261f87e16f3 +Z 5d31abe2efd2f25b296efdbc945337ef diff --git a/manifest.uuid b/manifest.uuid index ba2f320cf9..6d65c9b627 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06e1fab7527c6b4330a58f8d8873afaf2d67ae86 \ No newline at end of file +ba1b441b6003808810667d749635fe6b2e8c6165 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 9294a30428..d69bd6841a 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1142,6 +1142,15 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { exprNot(pParse, N, &A); A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n]; } + expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) LP exprlist(E) RP. [IN] { + SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z); + Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); + sqlite3SrcListFuncArgs(pParse, pSrc, E); + A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0, 0); + sqlite3PExprAddSelect(pParse, A.pExpr, pSelect); + exprNot(pParse, N, &A); + A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n]; + } expr(A) ::= EXISTS(B) LP select(Y) RP(E). { Expr *p; spanSet(&A,&B,&E); /*A-overwrites-B*/ diff --git a/test/tabfunc01.test b/test/tabfunc01.test index d0de104d81..a0aae155bd 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -178,6 +178,22 @@ do_test tabfunc01-661 { } 11 sqlite3_finalize $VM +do_test tabfunc01-670 { + set TAIL {} + set VM [sqlite3_prepare db { + SELECT length(y) FROM t6 WHERE x IN intarray(?1,3); + } -1 TAIL] + string trim $TAIL +} {} +do_test tabfunc01-671 { + sqlite3_bind_intarray $VM 1 11 22 33 44 55 + sqlite3_step $VM +} SQLITE_ROW +do_test tabfunc01-672 { + sqlite3_column_int $VM 0 +} 11 +sqlite3_finalize $VM + catch {sqlite3_bind_intarray} finish_test From e336b8914c44d341801746e3fd66afadc603b4dc Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 1 Jul 2016 12:39:58 +0000 Subject: [PATCH 167/302] Add the sqlite3rbu_state() API. Used to determine the current state (creating OAL, ready to move OAL, incremental-checkpoint, finished or error) of an RBU operation. FossilOrigin-Name: 92e7df0ff5c4c118c63d92a767dc82700438a310 --- ext/rbu/rbu1.test | 44 +++++++++------------ ext/rbu/rbu5.test | 27 +------------ ext/rbu/rbu_common.tcl | 37 ++++++++++++++++++ ext/rbu/sqlite3rbu.c | 87 ++++++++++++++++++++++++++++-------------- ext/rbu/sqlite3rbu.h | 38 ++++++++++++++++++ ext/rbu/test_rbu.c | 14 +++++++ manifest | 27 +++++++------ manifest.uuid | 2 +- 8 files changed, 182 insertions(+), 94 deletions(-) diff --git a/ext/rbu/rbu1.test b/ext/rbu/rbu1.test index 51d2ce8171..cd41728886 100644 --- a/ext/rbu/rbu1.test +++ b/ext/rbu/rbu1.test @@ -10,10 +10,7 @@ #*********************************************************************** # -if {![info exists testdir]} { - set testdir [file join [file dirname [info script]] .. .. test] -} -source $testdir/tester.tcl +source [file join [file dirname [info script]] rbu_common.tcl] set ::testprefix rbu1 db close @@ -96,26 +93,6 @@ proc create_rbu5 {filename} { return $filename } -# Run the RBU in file $rbu on target database $target until completion. -# -proc run_rbu {target rbu} { - sqlite3rbu rbu $target $rbu - while 1 { - set rc [rbu step] - if {$rc!="SQLITE_OK"} break - } - rbu close -} - -proc step_rbu {target rbu} { - while 1 { - sqlite3rbu rbu $target $rbu - set rc [rbu step] - rbu close - if {$rc != "SQLITE_OK"} break - } - set rc -} # Same as [step_rbu], except using a URI to open the target db. # @@ -641,10 +618,25 @@ foreach {tn3 create_vfs destroy_vfs} { # correctly. reset_db forcedelete rbu.db - do_test $tn3.8 { + do_test $tn3.8.1 { list [catch { run_rbu test.db rbu.db } msg] $msg } {0 SQLITE_DONE} - + + # Test that an RBU database containing only empty data_xxx tables is + # also handled correctly. + reset_db + forcedelete rbu.db + do_execsql_test $tn3.8.2.1 { + CREATE TABLE t1(a PRIMARY KEY, b); + INSERT INTO t1 VALUES(1, 2); + ATTACH 'rbu.db' AS rbu; + CREATE TABLE data_t1(a, b, rbu_control); + DETACH rbu; + } + do_test $tn3.8.2.1 { + list [catch { run_rbu test.db rbu.db } msg] $msg + } {0 SQLITE_DONE} + # Test that RBU can update indexes containing NULL values. # reset_db diff --git a/ext/rbu/rbu5.test b/ext/rbu/rbu5.test index 9a0f17bc5d..8e4ae8cb69 100644 --- a/ext/rbu/rbu5.test +++ b/ext/rbu/rbu5.test @@ -12,35 +12,10 @@ # Test some properties of the pager_rbu_mode and rbu_mode pragmas. # -if {![info exists testdir]} { - set testdir [file join [file dirname [info script]] .. .. test] -} -source $testdir/tester.tcl +source [file join [file dirname [info script]] rbu_common.tcl] set ::testprefix rbu5 -# Run the RBU in file $rbu on target database $target until completion. -# -proc run_rbu {target rbu} { - sqlite3rbu rbu $target $rbu - while { [rbu step]=="SQLITE_OK" } {} - rbu close -} - - -# Run the RBU in file $rbu on target database $target one step at a -# time until completion. -# -proc step_rbu {target rbu} { - while 1 { - sqlite3rbu rbu $target $rbu - set rc [rbu step] - rbu close - if {$rc != "SQLITE_OK"} break - } - set rc -} - # Return a list of the primary key columns for table $tbl in the database # opened by database handle $db. # diff --git a/ext/rbu/rbu_common.tcl b/ext/rbu/rbu_common.tcl index 4a8c5cba9f..a58c3aa0a7 100644 --- a/ext/rbu/rbu_common.tcl +++ b/ext/rbu/rbu_common.tcl @@ -15,12 +15,43 @@ if {![info exists testdir]} { } source $testdir/tester.tcl +proc check_prestep_state {target state} { + set oal_exists [file exists $target-oal] + set wal_exists [file exists $target-wal] + set progress [rbu progress] + + if {($progress==0 && $state!="oal" && $state!="done") + || ($oal_exists && $wal_exists) + || ($progress>0 && $state=="oal" && (!$oal_exists || $wal_exists)) + || ($state=="move" && (!$oal_exists || $wal_exists)) + || ($state=="checkpoint" && ($oal_exists || !$wal_exists)) + || ($state=="done" && ($oal_exists && $progress!=0)) + } { + error "B: state=$state progress=$progress oal=$oal_exists wal=$wal_exists" + } +} + +proc check_poststep_state {rc target state} { + if {$rc=="SQLITE_OK" || $rc=="SQLITE_DONE"} { + set oal_exists [file exists $target-oal] + set wal_exists [file exists $target-wal] + if {$state=="move" && ($oal_exists || !$wal_exists)} { + error "A: state=$state progress=$progress oal=$oal_exists wal=$wal_exists" + } + } +} + # Run the RBU in file $rbu on target database $target until completion. # proc run_rbu {target rbu} { sqlite3rbu rbu $target $rbu while 1 { + set state [rbu state] + + check_prestep_state $target $state set rc [rbu step] + check_poststep_state $rc $target $state + if {$rc!="SQLITE_OK"} break } rbu close @@ -29,7 +60,10 @@ proc run_rbu {target rbu} { proc step_rbu {target rbu} { while 1 { sqlite3rbu rbu $target $rbu + set state [rbu state] + check_prestep_state $target $state set rc [rbu step] + check_poststep_state $rc $target $state rbu close if {$rc != "SQLITE_OK"} break } @@ -41,7 +75,10 @@ proc do_rbu_vacuum_test {tn step} { if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db } while 1 { if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db } + set state [rbu state] + check_prestep_state test.db $state set rc [rbu step] + check_poststep_state $rc test.db $state if {$rc!="SQLITE_OK"} break if {$step==1} { rbu close } } diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 1cfb71384f..73c6647a2c 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -3555,30 +3555,7 @@ static sqlite3rbu *openRbuHandle( if( p->rc==SQLITE_OK ){ if( p->eStage==RBU_STAGE_OAL ){ sqlite3 *db = p->dbMain; - - if( pState->eStage==0 && rbuIsVacuum(p) ){ - rbuCopyPragma(p, "page_size"); - rbuCopyPragma(p, "auto_vacuum"); - } - - /* Open transactions both databases. The *-oal file is opened or - ** created at this point. */ - if( p->rc==SQLITE_OK ){ - p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); - } - if( p->rc==SQLITE_OK ){ - p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg); - } - - /* Check if the main database is a zipvfs db. If it is, set the upper - ** level pager to use "journal_mode=off". This prevents it from - ** generating a large journal using a temp file. */ - if( p->rc==SQLITE_OK ){ - int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0); - if( frc==SQLITE_OK ){ - p->rc = sqlite3_exec(db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg); - } - } + p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg); /* Point the object iterator at the first object */ if( p->rc==SQLITE_OK ){ @@ -3589,12 +3566,34 @@ static sqlite3rbu *openRbuHandle( ** update finished. */ if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){ p->rc = SQLITE_DONE; - } + p->eStage = RBU_STAGE_DONE; + }else{ + if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){ + rbuCopyPragma(p, "page_size"); + rbuCopyPragma(p, "auto_vacuum"); + } - if( p->rc==SQLITE_OK ){ - rbuSetupOal(p, pState); - } + /* Open transactions both databases. The *-oal file is opened or + ** created at this point. */ + if( p->rc==SQLITE_OK ){ + p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); + } + /* Check if the main database is a zipvfs db. If it is, set the upper + ** level pager to use "journal_mode=off". This prevents it from + ** generating a large journal using a temp file. */ + if( p->rc==SQLITE_OK ){ + int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0); + if( frc==SQLITE_OK ){ + p->rc = sqlite3_exec( + db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg); + } + } + + if( p->rc==SQLITE_OK ){ + rbuSetupOal(p, pState); + } + } }else if( p->eStage==RBU_STAGE_MOVE ){ /* no-op */ }else if( p->eStage==RBU_STAGE_CKPT ){ @@ -3761,9 +3760,39 @@ void sqlite3rbu_bp_progress(sqlite3rbu *p, int *pnOne, int *pnTwo){ } } +/* +** Return the current state of the RBU vacuum or update operation. +*/ +int sqlite3rbu_state(sqlite3rbu *p){ + int aRes[] = { + 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE, + 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE + }; + + assert( RBU_STAGE_OAL==1 ); + assert( RBU_STAGE_MOVE==2 ); + assert( RBU_STAGE_CKPT==4 ); + assert( RBU_STAGE_DONE==5 ); + assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL ); + assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE ); + assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT ); + assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE ); + + if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){ + return SQLITE_RBU_STATE_ERROR; + }else{ + assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE ); + assert( p->eStage==RBU_STAGE_OAL + || p->eStage==RBU_STAGE_MOVE + || p->eStage==RBU_STAGE_CKPT + || p->eStage==RBU_STAGE_DONE + ); + return aRes[p->eStage]; + } +} + int sqlite3rbu_savestate(sqlite3rbu *p){ int rc = p->rc; - if( rc==SQLITE_DONE ) return SQLITE_OK; assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE ); diff --git a/ext/rbu/sqlite3rbu.h b/ext/rbu/sqlite3rbu.h index fce9e493db..9ce39f543c 100644 --- a/ext/rbu/sqlite3rbu.h +++ b/ext/rbu/sqlite3rbu.h @@ -474,6 +474,44 @@ sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu); */ void sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo); +/* +** Obtain an indication as to the current stage of an RBU update or vacuum. +** This function always returns one of the SQLITE_RBU_STATE_XXX constants +** defined in this file. Return values should be interpreted as follows: +** +** SQLITE_RBU_STATE_OAL: +** RBU is currently building a *-oal file. The next call to sqlite3rbu_step() +** may either add further data to the *-oal file, or compute data that will +** be added by a subsequent call. +** +** SQLITE_RBU_STATE_MOVE: +** RBU has finished building the *-oal file. The next call to sqlite3rbu_step() +** will move the *-oal file to the equivalent *-wal path. If the current +** operation is an RBU update, then the updated version of the database +** file will become visible to ordinary SQLite clients following the next +** call to sqlite3rbu_step(). +** +** SQLITE_RBU_STATE_CHECKPOINT: +** RBU is currently performing an incremental checkpoint. The next call to +** sqlite3rbu_step() will copy a page of data from the *-wal file into +** the target database file. +** +** SQLITE_RBU_STATE_DONE: +** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step() +** will immediately return SQLITE_DONE. +** +** SQLITE_RBU_STATE_ERROR: +** An error has occurred. Any subsequent calls to sqlite3rbu_step() will +** immediately return the SQLite error code associated with the error. +*/ +#define SQLITE_RBU_STATE_OAL 1 +#define SQLITE_RBU_STATE_MOVE 2 +#define SQLITE_RBU_STATE_CHECKPOINT 3 +#define SQLITE_RBU_STATE_DONE 4 +#define SQLITE_RBU_STATE_ERROR 5 + +int sqlite3rbu_state(sqlite3rbu *pRbu); + /* ** Create an RBU VFS named zName that accesses the underlying file-system ** via existing VFS zParent. Or, if the zParent parameter is passed NULL, diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index 2d52262c71..6418d30d59 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -69,6 +69,8 @@ static int test_sqlite3rbu_cmd( {"dbMain_eval", 3, "SQL"}, /* 4 */ {"bp_progress", 2, ""}, /* 5 */ {"db", 3, "RBU"}, /* 6 */ + {"state", 2, ""}, /* 7 */ + {"progress", 2, ""}, /* 8 */ {0,0,0} }; int iCmd; @@ -166,6 +168,18 @@ static int test_sqlite3rbu_cmd( } break; } + case 7: /* state */ { + const char *aRes[] = { 0, "oal", "move", "checkpoint", "done", "error" }; + int eState = sqlite3rbu_state(pRbu); + assert( eState>0 && eState<=5 ); + Tcl_SetResult(interp, (char*)aRes[eState], TCL_STATIC); + break; + } + case 8: /* progress */ { + sqlite3_int64 nStep = sqlite3rbu_progress(pRbu); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nStep)); + break; + } default: /* seems unlikely */ assert( !"cannot happen" ); diff --git a/manifest b/manifest index 2dd253cf30..20d61b1e4e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sthe\sWhereLoop.rSetup\scost\sestimate\sfrom\sgoing\snegative\son\scomplex\nqueries. -D 2016-06-26T04:06:28.081 +C Add\sthe\ssqlite3rbu_state()\sAPI.\sUsed\sto\sdetermine\sthe\scurrent\sstate\s(creating\sOAL,\sready\sto\smove\sOAL,\sincremental-checkpoint,\sfinished\sor\serror)\sof\san\sRBU\soperation. +D 2016-07-01T12:39:58.096 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -226,14 +226,14 @@ F ext/misc/vfsstat.c 6110aeeaab2f1df17a923c8a8acef3c74f6dc515 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4 -F ext/rbu/rbu1.test 42bd835e019eff789ec241017965277baeb658b1 +F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 046b0980041d30700464a800bbf6733ed2df515d F ext/rbu/rbu11.test 9bc68c2d3dbeb1720153626e3bd0466dcc017702 F ext/rbu/rbu12.test bde22ed0004dd5d1888c72a84ae407e574aeae16 F ext/rbu/rbu13.test 462ff799c4afedc3ef8a47ff818c0ffbf14ae4f2 F ext/rbu/rbu14.test 01f5dcba904aecadbaea69d4ccdc2ea43dd30560 F ext/rbu/rbu3.test 8bd4c6b87367c358981b6a47dc3d654fa60bff90 -F ext/rbu/rbu5.test 2e24fee3e615aecd99bbdd46967935a641e866f7 +F ext/rbu/rbu5.test cf1fa84d6107efd73e292a7be8e1fb31953ca45c F ext/rbu/rbu6.test 32e8ed60631b6facdb6366bd2b5f5f25245e7edb F ext/rbu/rbu7.test fd025d5ba440fcfe151fbb0e3835e1e7fe964fa1 F ext/rbu/rbu8.test 3bbf2c35d71a843c463efe93946f14ad10c3ede0 @@ -241,7 +241,7 @@ F ext/rbu/rbu9.test 0806d1772c9f4981774ff028de6656e4183082af F ext/rbu/rbuA.test c1a7b3e2d926b8f8448bb3b4ae787e314ee4b2b3 F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2 F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831 -F ext/rbu/rbu_common.tcl 3a4b916b6f5dca9c9da9a30863e272fe5ea4414f +F ext/rbu/rbu_common.tcl a38e8e2d4a50fd6aaf151633714c1b1d2fae3ead F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695 F ext/rbu/rbudiff.test 4c9f8df6f723f553781d3d117501b7e9d170a145 F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 @@ -252,9 +252,9 @@ F ext/rbu/rbuprogress.test 2023a7df2c523e3df1cb532eff811cda385a789a F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab -F ext/rbu/sqlite3rbu.c 3d35b1dc46f5ca0f0f59db8e6163fe7627ea107c -F ext/rbu/sqlite3rbu.h 2acd0a6344a6079de15c8dc9d84d3df83a665930 -F ext/rbu/test_rbu.c 9bbdf6bd8efd58fbc4f192698df50569598fbb9e +F ext/rbu/sqlite3rbu.c 948677ee0ec57da51148e6c5f64ac68afcf36ab2 +F ext/rbu/sqlite3rbu.h db8858120c9be14b60c9225f9da28221f5f6b945 +F ext/rbu/test_rbu.c 9f043b74c46c45b231f4313aed1fccb379a76fe6 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c d26a815b0df1c412a6881dae8d7fd3c9c08cce68 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -1502,7 +1502,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 507014e4c7a70cd09410c89c8ed466c8edab39d2 -R ae55d782914cbf2db58c75f82f862316 -U drh -Z e21bca843071316b56d3c29d5bf9cc08 +P f81050859170c8708a1b296da8dd3ef0dd314a11 +R 2c74d9aac55f1cbb7c7d3232cf9071e1 +T *branch * rbu-state-api +T *sym-rbu-state-api * +T -sym-trunk * +U dan +Z b7514d1a78fc46b36ed5446f76a12e50 diff --git a/manifest.uuid b/manifest.uuid index ee49eb40ac..85f8706971 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f81050859170c8708a1b296da8dd3ef0dd314a11 \ No newline at end of file +92e7df0ff5c4c118c63d92a767dc82700438a310 \ No newline at end of file From 883486bada02183e5269e231020d653401886d25 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jul 2016 19:48:43 +0000 Subject: [PATCH 168/302] Add test cases to the transitive constraint fix. FossilOrigin-Name: c952af89c22ddc31491f142b9511608a4c8f9737 --- manifest | 14 +++++------ manifest.uuid | 2 +- test/collateB.test | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 test/collateB.test diff --git a/manifest b/manifest index 2e46c5cb6a..a7d0cab6bb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Proposed\sfix\sfor\sa\sproblem\sin\sthe\squery\splanner. -D 2016-06-28T22:27:56.883 +C Add\stest\scases\sto\sthe\stransitive\sconstraint\sfix. +D 2016-07-01T19:48:43.147 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -574,6 +574,7 @@ F test/collate7.test 8ec29d98f3ee4ccebce6e16ce3863fb6b8c7b868 F test/collate8.test cd9b3d3f999b8520ffaa7cc1647061fc5bab1334 F test/collate9.test 3adcc799229545940df2f25308dd1ad65869145a F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 +F test/collateB.test 8ec2accd2d7166c1eff0d2a39bc90262c6f89632 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 029faa2d81a0d1cafb5f88614beb663d972c01db @@ -1502,10 +1503,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f81050859170c8708a1b296da8dd3ef0dd314a11 -R dcdb165f171e6961986899e464931036 -T *branch * planner-fix -T *sym-planner-fix * -T -sym-trunk * +P a33d23560959a127e37d8213dc00210cd4b05352 +R 9c182c2a1bd41d85d1ee54cc469d61e7 U drh -Z 35245dfa6950894f0d3652717f7690e0 +Z ef208312357a37b91bc1f6c737863420 diff --git a/manifest.uuid b/manifest.uuid index f6e2e672d1..7ba7a01a61 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a33d23560959a127e37d8213dc00210cd4b05352 \ No newline at end of file +c952af89c22ddc31491f142b9511608a4c8f9737 \ No newline at end of file diff --git a/test/collateB.test b/test/collateB.test new file mode 100644 index 0000000000..4815de83ee --- /dev/null +++ b/test/collateB.test @@ -0,0 +1,63 @@ +# 2016-07-01 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# Test cases for a crash bug. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_execsql_test collateB-1.1 { + CREATE TABLE t1(a INTEGER PRIMARY KEY); + CREATE TABLE t2(b INTEGER PRIMARY KEY, x1 INT COLLATE NOCASE); + CREATE TABLE t3(x2 INT); + SELECT * FROM t3, t2, t1 WHERE x2=b AND x1=a AND a=1; +} {} +do_execsql_test collateB-1.2 { + INSERT INTO t1(a) VALUES(1),(2),(3); + INSERT INTO t2(b,x1) VALUES(11,1),(22,2),(33,3); + INSERT INTO t3(x2) VALUES(11),(22),(33); + SELECT *,'|' FROM t3, t2, t1 WHERE x2=b AND x1=a AND a=1; +} {11 11 1 1 |} +do_execsql_test collateB-1.3 { + SELECT *,'|' FROM t3, t1, t2 WHERE x2=b AND x1=a AND a=1; +} {11 1 11 1 |} +do_execsql_test collateB-1.4 { + SELECT *,'|' FROM t2, t3, t1 WHERE x2=b AND x1=a AND a=1; +} {11 1 11 1 |} +do_execsql_test collateB-1.5 { + SELECT *,'|' FROM t2, t1, t3 WHERE x2=b AND x1=a AND a=1; +} {11 1 1 11 |} +do_execsql_test collateB-1.6 { + SELECT *,'|' FROM t1, t2, t3 WHERE x2=b AND x1=a AND a=1; +} {1 11 1 11 |} +do_execsql_test collateB-1.7 { + SELECT *,'|' FROM t1, t2, t3 WHERE x2=b AND x1=a AND a=1; +} {1 11 1 11 |} +do_execsql_test collateB-1.12 { + SELECT *,'|' FROM t3, t2, t1 WHERE b=x2 AND a=x1 AND 1=a; +} {11 11 1 1 |} +do_execsql_test collateB-1.13 { + SELECT *,'|' FROM t3, t1, t2 WHERE b=x2 AND a=x1 AND 1=a; +} {11 1 11 1 |} +do_execsql_test collateB-1.14 { + SELECT *,'|' FROM t2, t3, t1 WHERE b=x2 AND a=x1 AND 1=a; +} {11 1 11 1 |} +do_execsql_test collateB-1.15 { + SELECT *,'|' FROM t2, t1, t3 WHERE b=x2 AND a=x1 AND 1=a; +} {11 1 1 11 |} +do_execsql_test collateB-1.16 { + SELECT *,'|' FROM t1, t2, t3 WHERE b=x2 AND a=x1 AND 1=a; +} {1 11 1 11 |} +do_execsql_test collateB-1.17 { + SELECT *,'|' FROM t1, t2, t3 WHERE b=x2 AND a=x1 AND 1=a; +} {1 11 1 11 |} + +finish_test From 5fbab882c040a68ba3c665445e0f4672705f0991 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jul 2016 12:08:14 +0000 Subject: [PATCH 169/302] Add support for table-valued functions on the RHS of an IN operator. FossilOrigin-Name: ac6000f050ff4efcf8a87f0825077dbf4144f073 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/parse.y | 11 ++++++++++- test/tabfunc01.test | 9 +++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6abed8d72a..1906e09ab0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\stransitive\sconstraint\slogic\serror\sthat\scan\sresult\sin\sa\snull\spointer\ndereference.\s\sFix\sfor\sticket\s[e8d439c77685eca6]. -D 2016-07-01T20:12:39.149 +C Add\ssupport\sfor\stable-valued\sfunctions\son\sthe\sRHS\sof\san\sIN\soperator. +D 2016-07-02T12:08:14.436 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -371,7 +371,7 @@ F src/os_win.c d4b8faf8896b65818e67070711fdd00d8e620bd6 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 -F src/parse.y 01b9f37c4c7009ab56fda98bc7db4c42643cecfe +F src/parse.y 3660ab75e7c9212fbe9ca75264d26e6587cd0ae4 F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d @@ -1115,7 +1115,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test f977868fa8bb7beb4b2072883190411653473906 +F test/tabfunc01.test bb774639915aaaf30417f8d0faf832c3309a3338 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1503,8 +1503,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f81050859170c8708a1b296da8dd3ef0dd314a11 c952af89c22ddc31491f142b9511608a4c8f9737 -R 9c182c2a1bd41d85d1ee54cc469d61e7 -T +closed c952af89c22ddc31491f142b9511608a4c8f9737 +P 228a7879870f8689e2f9b74fbef2ff93fab7b3c2 +R 1f493f554aeef5ddfd3c1d7c325d64e1 U drh -Z 6ff2c1fb4a902fab6eeb4b75477a29a3 +Z 647695f7bc7b8a80ecfde87fc6913c51 diff --git a/manifest.uuid b/manifest.uuid index 35505c7dd1..7fc1b862dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -228a7879870f8689e2f9b74fbef2ff93fab7b3c2 \ No newline at end of file +ac6000f050ff4efcf8a87f0825077dbf4144f073 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 9294a30428..04dc49d6aa 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1134,9 +1134,10 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { exprNot(pParse, N, &A); A.zEnd = &E.z[E.n]; } - expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z). [IN] { + expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) paren_exprlist(E). [IN] { SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z); Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); + if( E ) sqlite3SrcListFuncArgs(pParse, pSrc, E); A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0, 0); sqlite3PExprAddSelect(pParse, A.pExpr, pSelect); exprNot(pParse, N, &A); @@ -1193,6 +1194,14 @@ nexprlist(A) ::= nexprlist(A) COMMA expr(Y). nexprlist(A) ::= expr(Y). {A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/} +/* A paren_exprlist is an optional expression list contained inside +** of parenthesis */ +%type paren_exprlist {ExprList*} +%destructor paren_exprlist {sqlite3ExprListDelete(pParse->db, $$);} +paren_exprlist(A) ::= . {A = 0;} +paren_exprlist(A) ::= LP exprlist(X) RP. {A = X;} + + ///////////////////////////// The CREATE INDEX command /////////////////////// // diff --git a/test/tabfunc01.test b/test/tabfunc01.test index 879a045b8e..7d32f48387 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -135,4 +135,13 @@ do_execsql_test tabfunc01-500 { ORDER BY +1; } {1 7 11 17} +# Table-valued functions on the RHS of an IN operator +# +do_execsql_test tabfunc01-600 { + CREATE TABLE t600(a INTEGER PRIMARY KEY, b TEXT); + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100) + INSERT INTO t600(a,b) SELECT x, printf('(%03d)',x) FROM c; + SELECT b FROM t600 WHERE a IN generate_series(2,52,10); +} {(002) (012) (022) (032) (042) (052)} + finish_test From 9de4757c9c10c9c36c61501314cf17cdebe81c1a Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jul 2016 12:33:21 +0000 Subject: [PATCH 170/302] Fix a problem in table-valued functions on the RHS of an IN operator that occurs following an OOM error. FossilOrigin-Name: bead151e72215e6ca2a90eb049cfca414dccea04 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/parse.y | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1906e09ab0..67ebe5290b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\stable-valued\sfunctions\son\sthe\sRHS\sof\san\sIN\soperator. -D 2016-07-02T12:08:14.436 +C Fix\sa\sproblem\sin\stable-valued\sfunctions\son\sthe\sRHS\sof\san\sIN\soperator\sthat\noccurs\sfollowing\san\sOOM\serror. +D 2016-07-02T12:33:21.171 F Makefile.in bc2b4864a23a4a21c3e26d7b4350f51bab324d45 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -371,7 +371,7 @@ F src/os_win.c d4b8faf8896b65818e67070711fdd00d8e620bd6 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 -F src/parse.y 3660ab75e7c9212fbe9ca75264d26e6587cd0ae4 +F src/parse.y f374ab20106362eb3f5c01b3e6a002f0bbead7ff F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d @@ -1503,7 +1503,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 228a7879870f8689e2f9b74fbef2ff93fab7b3c2 -R 1f493f554aeef5ddfd3c1d7c325d64e1 +P ac6000f050ff4efcf8a87f0825077dbf4144f073 +R 59b18bb8c847f9af40e3580110542be4 U drh -Z 647695f7bc7b8a80ecfde87fc6913c51 +Z 7fb23bc853c489879c3871faac168f56 diff --git a/manifest.uuid b/manifest.uuid index 7fc1b862dc..b49dcbac4b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac6000f050ff4efcf8a87f0825077dbf4144f073 \ No newline at end of file +bead151e72215e6ca2a90eb049cfca414dccea04 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 04dc49d6aa..8a65131e28 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1137,7 +1137,7 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] { expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) paren_exprlist(E). [IN] { SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z); Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); - if( E ) sqlite3SrcListFuncArgs(pParse, pSrc, E); + if( E ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, E); A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0, 0); sqlite3PExprAddSelect(pParse, A.pExpr, pSelect); exprNot(pParse, N, &A); From ba637157cad2aca6a4157d280e9a5559c5ed3a2d Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jul 2016 20:57:06 +0000 Subject: [PATCH 171/302] Fix an off-by-one comparison in the intarray() virtual table. Get the intarray() virtual table tests working using the legacy makefile. FossilOrigin-Name: 7c3d441f2a9f642f3d91dcee854a4d16d298bc34 --- ext/misc/array.c | 7 ++----- main.mk | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/tabfunc01.test | 11 +++++++++++ 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ext/misc/array.c b/ext/misc/array.c index 54b249f90a..4420dc5178 100644 --- a/ext/misc/array.c +++ b/ext/misc/array.c @@ -25,7 +25,7 @@ ** The intarray "function" is really a virtual table with the ** following schema: ** -** CREATE FUNCTION intarray( +** CREATE TABLE intarray( ** value, ** pointer HIDDEN, ** count HIDDEN @@ -168,7 +168,7 @@ static int intarrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ */ static int intarrayEof(sqlite3_vtab_cursor *cur){ intarray_cursor *pCur = (intarray_cursor*)cur; - return pCur->iRowid>=pCur->iCnt; + return pCur->iRowid>pCur->iCnt; } /* @@ -181,7 +181,6 @@ static int intarrayFilter( int argc, sqlite3_value **argv ){ intarray_cursor *pCur = (intarray_cursor *)pVtabCursor; - int i = 0; if( idxNum ){ pCur->iPtr = sqlite3_value_int64(argv[0]); pCur->iCnt = sqlite3_value_int64(argv[1]); @@ -210,10 +209,8 @@ static int intarrayBestIndex( sqlite3_index_info *pIdxInfo ){ int i; /* Loop over constraints */ - int idxNum = 0; /* The query plan bitmask */ int ptrIdx = -1; /* Index of the pointer= constraint, or -1 if none */ int cntIdx = -1; /* Index of the count= constraint, or -1 if none */ - int nArg = 0; /* Number of arguments that intarrayFilter() expects */ const struct sqlite3_index_constraint *pConstraint; pConstraint = pIdxInfo->aConstraint; diff --git a/main.mk b/main.mk index ba710bfa46..9a91625948 100644 --- a/main.mk +++ b/main.mk @@ -324,6 +324,7 @@ TESTSRC = \ # TESTSRC += \ $(TOP)/ext/misc/amatch.c \ + $(TOP)/ext/misc/array.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/eval.c \ diff --git a/manifest b/manifest index 98382c2ade..f0d5a72bb4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\salternative\stable-valued\sfunction\sRHS\sof\sIN\soperator\simplementation\nfrom\strunk. -D 2016-07-02T20:51:31.298 +C Fix\san\soff-by-one\scomparison\sin\sthe\sintarray()\svirtual\stable.\s\sGet\sthe\nintarray()\svirtual\stable\stests\sworking\susing\sthe\slegacy\smakefile. +D 2016-07-02T20:57:06.871 F Makefile.in 541d493154ec3b0b20b2f1d495ec66f55905191e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 @@ -204,7 +204,7 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/array.c 20af0591e6611755dd8a9d1124e9c9a8cf42761f +F ext/misc/array.c bce2608f123d35eff81ac73e443b0620bed89ca1 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c f01126ba170fd4ef7c752b156568a80c912d4441 @@ -308,7 +308,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 3f669c06db5c4a53ff21dda639247c6310497180 +F main.mk 162bb978db5519dbcaba141be346247c82b7caa8 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1116,7 +1116,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test 96e56e22e5be82818d9673e9e993e9f26f80079a +F test/tabfunc01.test ebcfb548b88f874a5ded67e7c85ca0d5ab31f4b5 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1504,7 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ba1b441b6003808810667d749635fe6b2e8c6165 bead151e72215e6ca2a90eb049cfca414dccea04 -R ab2f6bd04c16fa8193c86a3894a34997 +P 507fdbfb54ce377f0d870260b07d71b797843fcf +R 7bb6d7d8a00bd78e137b76d2018230b6 U drh -Z f71a4b07caffe5df9d8bd19d720e6958 +Z f5dbc3921a51d0860e9141544e9a9fdc diff --git a/manifest.uuid b/manifest.uuid index 2e561b3053..1d82fb3553 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -507fdbfb54ce377f0d870260b07d71b797843fcf \ No newline at end of file +7c3d441f2a9f642f3d91dcee854a4d16d298bc34 \ No newline at end of file diff --git a/test/tabfunc01.test b/test/tabfunc01.test index 044851705d..298872e0ef 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -201,6 +201,17 @@ do_test tabfunc01-671 { do_test tabfunc01-672 { sqlite3_column_int $VM 0 } 11 +do_test tabfunc01-673 { + sqlite3_step $VM + sqlite3_column_int $VM 0 +} 22 +do_test tabfunc01-674 { + sqlite3_step $VM + sqlite3_column_int $VM 0 +} 33 +do_test tabfunc01-675 { + sqlite3_step $VM +} {SQLITE_DONE} sqlite3_finalize $VM catch {sqlite3_bind_intarray} From 2e3f87ae8493817ceaddc316077b49d081e4e9db Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jul 2016 02:35:47 +0000 Subject: [PATCH 172/302] Change the name of the intarray() extension to carray() and give it an optional third parameter that specifies the datatype as one of 'int32', 'int64', 'double', or 'char*'. 'int32' is the default. FossilOrigin-Name: a204ba99db34b356acb259189158a32d2df25da0 --- Makefile.in | 2 +- Makefile.msc | 1 + ext/misc/array.c | 293 ----------------------------------- ext/misc/carray.c | 369 ++++++++++++++++++++++++++++++++++++++++++++ main.mk | 2 +- manifest | 22 +-- manifest.uuid | 2 +- src/test1.c | 147 +++++++++++++++--- test/tabfunc01.test | 109 ++++++------- 9 files changed, 550 insertions(+), 397 deletions(-) delete mode 100644 ext/misc/array.c create mode 100644 ext/misc/carray.c diff --git a/Makefile.in b/Makefile.in index ff863ec906..fd0ad6b6a7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -416,7 +416,7 @@ TESTSRC = \ # TESTSRC += \ $(TOP)/ext/misc/amatch.c \ - $(TOP)/ext/misc/array.c \ + $(TOP)/ext/misc/carray.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/eval.c \ diff --git a/Makefile.msc b/Makefile.msc index 93116cd0dc..cd866ce4a4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1292,6 +1292,7 @@ TESTSRC = \ # TESTEXT = \ $(TOP)\ext\misc\amatch.c \ + $(TOP)\ext\misc\carray.c \ $(TOP)\ext\misc\closure.c \ $(TOP)\ext\misc\csv.c \ $(TOP)\ext\misc\eval.c \ diff --git a/ext/misc/array.c b/ext/misc/array.c deleted file mode 100644 index 4420dc5178..0000000000 --- a/ext/misc/array.c +++ /dev/null @@ -1,293 +0,0 @@ -/* -** 2016-06-29 -** -** The author disclaims copyright to this source code. In place of -** a legal notice, here is a blessing: -** -** May you do good and not evil. -** May you find forgiveness for yourself and forgive others. -** May you share freely, never taking more than you give. -** -************************************************************************* -** -** This file demonstrates how to create a table-valued-function that -** returns the values in a C-language array. -** Examples: -** -** SELECT * FROM intarray($ptr,5) -** -** The query above returns 5 integers contained in a C-language array -** at the address $ptr. $ptr is a pointer to the array of integers that -** has been cast to an integer. -** -** HOW IT WORKS -** -** The intarray "function" is really a virtual table with the -** following schema: -** -** CREATE TABLE intarray( -** value, -** pointer HIDDEN, -** count HIDDEN -** ); -*/ -#include "sqlite3ext.h" -SQLITE_EXTENSION_INIT1 -#include -#include - -#ifndef SQLITE_OMIT_VIRTUALTABLE - - -/* intarray_cursor is a subclass of sqlite3_vtab_cursor which will -** serve as the underlying representation of a cursor that scans -** over rows of the result -*/ -typedef struct intarray_cursor intarray_cursor; -struct intarray_cursor { - sqlite3_vtab_cursor base; /* Base class - must be first */ - int isDesc; /* True to count down rather than up */ - sqlite3_int64 iRowid; /* The rowid */ - sqlite3_int64 iPtr; /* Pointer to array of integers */ - sqlite3_int64 iCnt; /* Number of integers in the array */ -}; - -/* -** The intarrayConnect() method is invoked to create a new -** intarray_vtab that describes the intarray virtual table. -** -** Think of this routine as the constructor for intarray_vtab objects. -** -** All this routine needs to do is: -** -** (1) Allocate the intarray_vtab object and initialize all fields. -** -** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the -** result set of queries against intarray will look like. -*/ -static int intarrayConnect( - sqlite3 *db, - void *pAux, - int argc, const char *const*argv, - sqlite3_vtab **ppVtab, - char **pzErr -){ - sqlite3_vtab *pNew; - int rc; - -/* Column numbers */ -#define INTARRAY_COLUMN_VALUE 0 -#define INTARRAY_COLUMN_POINTER 1 -#define INTARRAY_COLUMN_COUNT 2 - - rc = sqlite3_declare_vtab(db, - "CREATE TABLE x(value,pointer hidden,count hidden)"); - if( rc==SQLITE_OK ){ - pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); - if( pNew==0 ) return SQLITE_NOMEM; - memset(pNew, 0, sizeof(*pNew)); - } - return rc; -} - -/* -** This method is the destructor for intarray_cursor objects. -*/ -static int intarrayDisconnect(sqlite3_vtab *pVtab){ - sqlite3_free(pVtab); - return SQLITE_OK; -} - -/* -** Constructor for a new intarray_cursor object. -*/ -static int intarrayOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ - intarray_cursor *pCur; - pCur = sqlite3_malloc( sizeof(*pCur) ); - if( pCur==0 ) return SQLITE_NOMEM; - memset(pCur, 0, sizeof(*pCur)); - *ppCursor = &pCur->base; - return SQLITE_OK; -} - -/* -** Destructor for a intarray_cursor. -*/ -static int intarrayClose(sqlite3_vtab_cursor *cur){ - sqlite3_free(cur); - return SQLITE_OK; -} - - -/* -** Advance a intarray_cursor to its next row of output. -*/ -static int intarrayNext(sqlite3_vtab_cursor *cur){ - intarray_cursor *pCur = (intarray_cursor*)cur; - pCur->iRowid++; - return SQLITE_OK; -} - -/* -** Return values of columns for the row at which the intarray_cursor -** is currently pointing. -*/ -static int intarrayColumn( - sqlite3_vtab_cursor *cur, /* The cursor */ - sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ - int i /* Which column to return */ -){ - intarray_cursor *pCur = (intarray_cursor*)cur; - sqlite3_int64 x = 0; - switch( i ){ - case INTARRAY_COLUMN_POINTER: x = pCur->iPtr; break; - case INTARRAY_COLUMN_COUNT: x = pCur->iCnt; break; - default: { - int *p = (int*)pCur->iPtr; - x = (int)p[pCur->iRowid-1]; - break; - } - } - sqlite3_result_int64(ctx, x); - return SQLITE_OK; -} - -/* -** Return the rowid for the current row. In this implementation, the -** rowid is the same as the output value. -*/ -static int intarrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ - intarray_cursor *pCur = (intarray_cursor*)cur; - *pRowid = pCur->iRowid; - return SQLITE_OK; -} - -/* -** Return TRUE if the cursor has been moved off of the last -** row of output. -*/ -static int intarrayEof(sqlite3_vtab_cursor *cur){ - intarray_cursor *pCur = (intarray_cursor*)cur; - return pCur->iRowid>pCur->iCnt; -} - -/* -** This method is called to "rewind" the intarray_cursor object back -** to the first row of output. -*/ -static int intarrayFilter( - sqlite3_vtab_cursor *pVtabCursor, - int idxNum, const char *idxStr, - int argc, sqlite3_value **argv -){ - intarray_cursor *pCur = (intarray_cursor *)pVtabCursor; - if( idxNum ){ - pCur->iPtr = sqlite3_value_int64(argv[0]); - pCur->iCnt = sqlite3_value_int64(argv[1]); - }else{ - pCur->iPtr = 0; - pCur->iCnt = 0; - } - pCur->iRowid = 1; - return SQLITE_OK; -} - -/* -** SQLite will invoke this method one or more times while planning a query -** that uses the intarray virtual table. This routine needs to create -** a query plan for each invocation and compute an estimated cost for that -** plan. -** -** In this implementation idxNum is used to represent the -** query plan. idxStr is unused. -** -** idxNum is 1 if the pointer= and count= constraints exist and is 0 otherwise. -** If idxNum is 0, then intarray becomes an empty table. -*/ -static int intarrayBestIndex( - sqlite3_vtab *tab, - sqlite3_index_info *pIdxInfo -){ - int i; /* Loop over constraints */ - int ptrIdx = -1; /* Index of the pointer= constraint, or -1 if none */ - int cntIdx = -1; /* Index of the count= constraint, or -1 if none */ - - const struct sqlite3_index_constraint *pConstraint; - pConstraint = pIdxInfo->aConstraint; - for(i=0; inConstraint; i++, pConstraint++){ - if( pConstraint->usable==0 ) continue; - if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; - switch( pConstraint->iColumn ){ - case INTARRAY_COLUMN_POINTER: - ptrIdx = i; - break; - case INTARRAY_COLUMN_COUNT: - cntIdx = i; - break; - } - } - if( ptrIdx>=0 && cntIdx>=0 ){ - pIdxInfo->aConstraintUsage[ptrIdx].argvIndex = 1; - pIdxInfo->aConstraintUsage[ptrIdx].omit = 1; - pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2; - pIdxInfo->aConstraintUsage[cntIdx].omit = 1; - pIdxInfo->estimatedCost = (double)1; - pIdxInfo->estimatedRows = (double)100; - pIdxInfo->idxNum = 1; - }else{ - pIdxInfo->estimatedCost = (double)2147483647; - pIdxInfo->estimatedRows = (double)2147483647; - pIdxInfo->idxNum = 0; - } - return SQLITE_OK; -} - -/* -** This following structure defines all the methods for the -** intarray virtual table. -*/ -static sqlite3_module intarrayModule = { - 0, /* iVersion */ - 0, /* xCreate */ - intarrayConnect, /* xConnect */ - intarrayBestIndex, /* xBestIndex */ - intarrayDisconnect, /* xDisconnect */ - 0, /* xDestroy */ - intarrayOpen, /* xOpen - open a cursor */ - intarrayClose, /* xClose - close a cursor */ - intarrayFilter, /* xFilter - configure scan constraints */ - intarrayNext, /* xNext - advance a cursor */ - intarrayEof, /* xEof - check for end of scan */ - intarrayColumn, /* xColumn - read data */ - intarrayRowid, /* xRowid - read data */ - 0, /* xUpdate */ - 0, /* xBegin */ - 0, /* xSync */ - 0, /* xCommit */ - 0, /* xRollback */ - 0, /* xFindMethod */ - 0, /* xRename */ -}; - -#endif /* SQLITE_OMIT_VIRTUALTABLE */ - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int sqlite3_array_init( - sqlite3 *db, - char **pzErrMsg, - const sqlite3_api_routines *pApi -){ - int rc = SQLITE_OK; - SQLITE_EXTENSION_INIT2(pApi); -#ifndef SQLITE_OMIT_VIRTUALTABLE - if( sqlite3_libversion_number()<3008012 ){ - *pzErrMsg = sqlite3_mprintf( - "intarray() requires SQLite 3.8.12 or later"); - return SQLITE_ERROR; - } - rc = sqlite3_create_module(db, "intarray", &intarrayModule, 0); -#endif - return rc; -} diff --git a/ext/misc/carray.c b/ext/misc/carray.c new file mode 100644 index 0000000000..70d226a85f --- /dev/null +++ b/ext/misc/carray.c @@ -0,0 +1,369 @@ +/* +** 2016-06-29 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file demonstrates how to create a table-valued-function that +** returns the values in a C-language array. +** Examples: +** +** SELECT * FROM array($ptr,5) +** +** The query above returns 5 integers contained in a C-language array +** at the address $ptr. $ptr is a pointer to the array of integers that +** has been cast to an integer. +** +** There is an optional third parameter to determine the datatype of +** the C-language array. Allowed values of the third parameter are +** 'int32', 'int64', 'double', 'char*'. Example: +** +** SELECT * FROM array($ptr,10,'char*'); +** +** HOW IT WORKS +** +** The carray "function" is really a virtual table with the +** following schema: +** +** CREATE TABLE carray( +** value, +** pointer HIDDEN, +** count HIDDEN, +** ctype TEXT HIDDEN +** ); +** +** If the hidden columns "pointer" and "count" are unconstrained, then +** the virtual table has no rows. Otherwise, the virtual table interprets +** the integer value of "pointer" as a pointer to the array and "count" +** as the number of elements in the array. The virtual table steps through +** the array, element by element. +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include +#include + +#ifndef SQLITE_OMIT_VIRTUALTABLE + +/* +** Allowed datatypes +*/ +#define CARRAY_INT32 0 +#define CARRAY_INT64 1 +#define CARRAY_DOUBLE 2 +#define CARRAY_TEXT 3 + +/* +** Names of types +*/ +static const char *azType[] = { "int32", "int64", "double", "char*" }; + + +/* carray_cursor is a subclass of sqlite3_vtab_cursor which will +** serve as the underlying representation of a cursor that scans +** over rows of the result +*/ +typedef struct carray_cursor carray_cursor; +struct carray_cursor { + sqlite3_vtab_cursor base; /* Base class - must be first */ + sqlite3_int64 iRowid; /* The rowid */ + sqlite3_int64 iPtr; /* Pointer to array of values */ + sqlite3_int64 iCnt; /* Number of integers in the array */ + unsigned char eType; /* One of the CARRAY_type values */ +}; + +/* +** The carrayConnect() method is invoked to create a new +** carray_vtab that describes the carray virtual table. +** +** Think of this routine as the constructor for carray_vtab objects. +** +** All this routine needs to do is: +** +** (1) Allocate the carray_vtab object and initialize all fields. +** +** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the +** result set of queries against carray will look like. +*/ +static int carrayConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + sqlite3_vtab *pNew; + int rc; + +/* Column numbers */ +#define CARRAY_COLUMN_VALUE 0 +#define CARRAY_COLUMN_POINTER 1 +#define CARRAY_COLUMN_COUNT 2 +#define CARRAY_COLUMN_CTYPE 3 + + rc = sqlite3_declare_vtab(db, + "CREATE TABLE x(value,pointer hidden,count hidden,ctype hidden)"); + if( rc==SQLITE_OK ){ + pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + } + return rc; +} + +/* +** This method is the destructor for carray_cursor objects. +*/ +static int carrayDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** Constructor for a new carray_cursor object. +*/ +static int carrayOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + carray_cursor *pCur; + pCur = sqlite3_malloc( sizeof(*pCur) ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur)); + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +/* +** Destructor for a carray_cursor. +*/ +static int carrayClose(sqlite3_vtab_cursor *cur){ + sqlite3_free(cur); + return SQLITE_OK; +} + + +/* +** Advance a carray_cursor to its next row of output. +*/ +static int carrayNext(sqlite3_vtab_cursor *cur){ + carray_cursor *pCur = (carray_cursor*)cur; + pCur->iRowid++; + return SQLITE_OK; +} + +/* +** Return values of columns for the row at which the carray_cursor +** is currently pointing. +*/ +static int carrayColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + carray_cursor *pCur = (carray_cursor*)cur; + sqlite3_int64 x = 0; + switch( i ){ + case CARRAY_COLUMN_POINTER: x = pCur->iPtr; break; + case CARRAY_COLUMN_COUNT: x = pCur->iCnt; break; + case CARRAY_COLUMN_CTYPE: { + sqlite3_result_text(ctx, azType[pCur->eType], -1, SQLITE_STATIC); + return SQLITE_OK; + } + default: { + switch( pCur->eType ){ + case CARRAY_INT32: { + int *p = (int*)pCur->iPtr; + sqlite3_result_int(ctx, p[pCur->iRowid-1]); + return SQLITE_OK; + } + case CARRAY_INT64: { + sqlite3_int64 *p = (sqlite3_int64*)pCur->iPtr; + sqlite3_result_int64(ctx, p[pCur->iRowid-1]); + return SQLITE_OK; + } + case CARRAY_DOUBLE: { + double *p = (double*)pCur->iPtr; + sqlite3_result_double(ctx, p[pCur->iRowid-1]); + return SQLITE_OK; + } + case CARRAY_TEXT: { + const char **p = (const char**)pCur->iPtr; + sqlite3_result_text(ctx, p[pCur->iRowid-1], -1, SQLITE_TRANSIENT); + return SQLITE_OK; + } + } + } + } + sqlite3_result_int64(ctx, x); + return SQLITE_OK; +} + +/* +** Return the rowid for the current row. In this implementation, the +** rowid is the same as the output value. +*/ +static int carrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + carray_cursor *pCur = (carray_cursor*)cur; + *pRowid = pCur->iRowid; + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int carrayEof(sqlite3_vtab_cursor *cur){ + carray_cursor *pCur = (carray_cursor*)cur; + return pCur->iRowid>pCur->iCnt; +} + +/* +** This method is called to "rewind" the carray_cursor object back +** to the first row of output. +*/ +static int carrayFilter( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + carray_cursor *pCur = (carray_cursor *)pVtabCursor; + if( idxNum ){ + pCur->iPtr = sqlite3_value_int64(argv[0]); + pCur->iCnt = sqlite3_value_int64(argv[1]); + if( idxNum<3 ){ + pCur->eType = CARRAY_INT32; + }else{ + int i; + const char *zType = (const char*)sqlite3_value_text(argv[2]); + for(i=0; i=sizeof(azType)/sizeof(azType[0]) ){ + pVtabCursor->pVtab->zErrMsg = sqlite3_mprintf( + "unknown datatype: %Q", zType); + return SQLITE_ERROR; + }else{ + pCur->eType = i; + } + } + }else{ + pCur->iPtr = 0; + pCur->iCnt = 0; + } + pCur->iRowid = 1; + return SQLITE_OK; +} + +/* +** SQLite will invoke this method one or more times while planning a query +** that uses the carray virtual table. This routine needs to create +** a query plan for each invocation and compute an estimated cost for that +** plan. +** +** In this implementation idxNum is used to represent the +** query plan. idxStr is unused. +** +** idxNum is 2 if the pointer= and count= constraints exist, +** 3 if the ctype= constraint also exists, and is 0 otherwise. +** If idxNum is 0, then carray becomes an empty table. +*/ +static int carrayBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + int i; /* Loop over constraints */ + int ptrIdx = -1; /* Index of the pointer= constraint, or -1 if none */ + int cntIdx = -1; /* Index of the count= constraint, or -1 if none */ + int ctypeIdx = -1; /* Index of the ctype= constraint, or -1 if none */ + + const struct sqlite3_index_constraint *pConstraint; + pConstraint = pIdxInfo->aConstraint; + for(i=0; inConstraint; i++, pConstraint++){ + if( pConstraint->usable==0 ) continue; + if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; + switch( pConstraint->iColumn ){ + case CARRAY_COLUMN_POINTER: + ptrIdx = i; + break; + case CARRAY_COLUMN_COUNT: + cntIdx = i; + break; + case CARRAY_COLUMN_CTYPE: + ctypeIdx = i; + break; + } + } + if( ptrIdx>=0 && cntIdx>=0 ){ + pIdxInfo->aConstraintUsage[ptrIdx].argvIndex = 1; + pIdxInfo->aConstraintUsage[ptrIdx].omit = 1; + pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2; + pIdxInfo->aConstraintUsage[cntIdx].omit = 1; + pIdxInfo->estimatedCost = (double)1; + pIdxInfo->estimatedRows = (double)100; + pIdxInfo->idxNum = 2; + if( ctypeIdx>=0 ){ + pIdxInfo->aConstraintUsage[ctypeIdx].argvIndex = 3; + pIdxInfo->aConstraintUsage[ctypeIdx].omit = 1; + pIdxInfo->idxNum = 3; + } + }else{ + pIdxInfo->estimatedCost = (double)2147483647; + pIdxInfo->estimatedRows = (double)2147483647; + pIdxInfo->idxNum = 0; + } + return SQLITE_OK; +} + +/* +** This following structure defines all the methods for the +** carray virtual table. +*/ +static sqlite3_module carrayModule = { + 0, /* iVersion */ + 0, /* xCreate */ + carrayConnect, /* xConnect */ + carrayBestIndex, /* xBestIndex */ + carrayDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + carrayOpen, /* xOpen - open a cursor */ + carrayClose, /* xClose - close a cursor */ + carrayFilter, /* xFilter - configure scan constraints */ + carrayNext, /* xNext - advance a cursor */ + carrayEof, /* xEof - check for end of scan */ + carrayColumn, /* xColumn - read data */ + carrayRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; + +#endif /* SQLITE_OMIT_VIRTUALTABLE */ + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_carray_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + SQLITE_EXTENSION_INIT2(pApi); +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( sqlite3_libversion_number()<3008012 ){ + *pzErrMsg = sqlite3_mprintf( + "carray() requires SQLite 3.8.12 or later"); + return SQLITE_ERROR; + } + rc = sqlite3_create_module(db, "carray", &carrayModule, 0); +#endif + return rc; +} diff --git a/main.mk b/main.mk index 9a91625948..e3da609750 100644 --- a/main.mk +++ b/main.mk @@ -324,7 +324,7 @@ TESTSRC = \ # TESTSRC += \ $(TOP)/ext/misc/amatch.c \ - $(TOP)/ext/misc/array.c \ + $(TOP)/ext/misc/carray.c \ $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/csv.c \ $(TOP)/ext/misc/eval.c \ diff --git a/manifest b/manifest index f0d5a72bb4..4f9231b7f5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Fix\san\soff-by-one\scomparison\sin\sthe\sintarray()\svirtual\stable.\s\sGet\sthe\nintarray()\svirtual\stable\stests\sworking\susing\sthe\slegacy\smakefile. -D 2016-07-02T20:57:06.871 -F Makefile.in 541d493154ec3b0b20b2f1d495ec66f55905191e +C Change\sthe\sname\sof\sthe\sintarray()\sextension\sto\scarray()\sand\sgive\sit\san\noptional\sthird\sparameter\sthat\sspecifies\sthe\sdatatype\sas\sone\sof\s'int32',\n'int64',\s'double',\sor\s'char*'.\s\s'int32'\sis\sthe\sdefault. +D 2016-07-03T02:35:47.798 +F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 50149765ef72f4e652b9a0f1f6462c4784bb9423 +F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -204,7 +204,7 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/array.c bce2608f123d35eff81ac73e443b0620bed89ca1 +F ext/misc/carray.c f1947c7d5bbce17f8244c9a05baae11d5d68467e w ext/misc/array.c F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c f01126ba170fd4ef7c752b156568a80c912d4441 @@ -308,7 +308,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 162bb978db5519dbcaba141be346247c82b7caa8 +F main.mk e9d66f1b1c4874221d12d940be3ce5f397c10741 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 -F src/test1.c 081e4ed40525590406a51f7e7e4cee31cdb5d029 +F src/test1.c 7cbfda741fbfa541ecce305ff2d7c6bb730aa991 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1116,7 +1116,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test ebcfb548b88f874a5ded67e7c85ca0d5ab31f4b5 +F test/tabfunc01.test 50a9fb379f9747fd0d40ea6d8fa3a101361bb537 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1504,7 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 507fdbfb54ce377f0d870260b07d71b797843fcf -R 7bb6d7d8a00bd78e137b76d2018230b6 +P 7c3d441f2a9f642f3d91dcee854a4d16d298bc34 +R 41f36cbba6be0bbd66a667562505a546 U drh -Z f5dbc3921a51d0860e9141544e9a9fdc +Z 31f2105436c0dcfd40b6904e7b94f7b1 diff --git a/manifest.uuid b/manifest.uuid index 1d82fb3553..869a21e73c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c3d441f2a9f642f3d91dcee854a4d16d298bc34 \ No newline at end of file +a204ba99db34b356acb259189158a32d2df25da0 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 9a73e0e0b5..8e8020c043 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3242,41 +3242,137 @@ static int test_bind_int( /* -** Usage: sqlite3_bind_intarray STMT N INT ... +** Usage: intarray_addr INT ... ** -** Create a C-language array of integers from the arguments. Bind a pointer -** to this array to the NAME parameter of STMT. +** Return the address of a C-language array of 32-bit integers. +** +** Space to hold the array is obtained from malloc(). Call this procedure once +** with no arguments in order to release memory. Each call to this procedure +** overwrites the previous array. */ -static int test_bind_intarray( +static int test_intarray_addr( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ - sqlite3_stmt *pStmt; - int idx; int i; static int *p = 0; sqlite3_free(p); p = 0; - if( objc<4 ){ - Tcl_AppendResult(interp, "wrong # args: should be \"", - Tcl_GetStringFromObj(objv[0], 0), " STMT NAME INT...", 0); - return TCL_ERROR; - } - - if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; - if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; - p = sqlite3_malloc( sizeof(int)*(objc-3) ); - if( p==0 ) return TCL_ERROR; - for(i=0; i1 ){ + p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); + if( p==0 ) return TCL_ERROR; + for(i=0; i1 ){ + p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); + if( p==0 ) return TCL_ERROR; + for(i=0; i1 ){ + p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); + if( p==0 ) return TCL_ERROR; + for(i=0; i1 ){ + p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); + if( p==0 ) return TCL_ERROR; + for(i=0; i Date: Tue, 5 Jul 2016 12:47:28 +0000 Subject: [PATCH 173/302] Attempt to reset the error count in the Lemon-generated parser after a parse failure. FossilOrigin-Name: 91889fa30e84760e0d4b3d429c4abdef5a3f7931 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- tool/lempar.c | 5 ++++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 0a95c7965f..f3aa7ea38c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3rbu_state()\sAPI.\sUsed\sto\sdetermine\sthe\scurrent\sstate\s(creating\sOAL,\sready\sto\smove\sOAL,\sincremental-checkpoint,\sfinished\sor\serror)\sof\san\sRBU\soperation. -D 2016-07-04T11:47:48.898 +C Attempt\sto\sreset\sthe\serror\scount\sin\sthe\sLemon-generated\sparser\safter\na\sparse\sfailure. +D 2016-07-05T12:47:28.882 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1432,7 +1432,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 8c4e9d8517e50da391f1d89a519e743dd4afbc09 +F tool/lempar.c f2c88a13ab6611ce752d176fa8c83318ca715df0 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1504,8 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d8bc6feb99938a2aa06142b217045e4b54c66bf1 92e7df0ff5c4c118c63d92a767dc82700438a310 -R 985e1d1c0fa6ec62417a6fcb0acf4b8c -T +closed 92e7df0ff5c4c118c63d92a767dc82700438a310 -U dan -Z dee206ff16109350ba5a0f9bf08fce29 +P 0357875fbb1bb462feef5121287b2f84da88e497 +R a578f6c3df8fc8ba3d5f62a27a2cbf5b +U drh +Z 5d179a5613158bad283b799b101c68f6 diff --git a/manifest.uuid b/manifest.uuid index 98d13d9075..b21c3982ec 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0357875fbb1bb462feef5121287b2f84da88e497 \ No newline at end of file +91889fa30e84760e0d4b3d429c4abdef5a3f7931 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 9b76d6e3c5..112d0bdaa3 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -390,6 +390,7 @@ static void yy_destructor( static void yy_pop_parser_stack(yyParser *pParser){ yyStackEntry *yytos; assert( pParser->yytos!=0 ); + assert( pParser->yytos > pParser->yystack ); yytos = pParser->yytos--; #ifndef NDEBUG if( yyTraceFILE ){ @@ -799,7 +800,6 @@ void Parse( #endif yyParser *yypParser; /* The parser */ - /* (re)initialize the parser, if necessary */ yypParser = (yyParser*)yyp; assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) @@ -879,6 +879,9 @@ void Parse( if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); +#ifndef YYNOERRORRECOVERY + yypParser->yyerrcnt = -1; +#endif yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); From e0a6e0fda0c3b6bda7853305da88a566249cc3a1 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Jul 2016 16:11:26 +0000 Subject: [PATCH 174/302] More fixes to Fossil so that it automatically resets its error counter at the end of a parse. FossilOrigin-Name: 2683b375ad1291172fdb47d94e16fcf869c78c8a --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f3aa7ea38c..f0b8e863c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\sreset\sthe\serror\scount\sin\sthe\sLemon-generated\sparser\safter\na\sparse\sfailure. -D 2016-07-05T12:47:28.882 +C More\sfixes\sto\sFossil\sso\sthat\sit\sautomatically\sresets\sits\serror\scounter\sat\sthe\nend\sof\sa\sparse. +D 2016-07-05T16:11:26.639 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1432,7 +1432,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c f2c88a13ab6611ce752d176fa8c83318ca715df0 +F tool/lempar.c 072ff9985f36796b95bdc895820f2d77255a7067 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1504,7 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0357875fbb1bb462feef5121287b2f84da88e497 -R a578f6c3df8fc8ba3d5f62a27a2cbf5b +P 91889fa30e84760e0d4b3d429c4abdef5a3f7931 +R 9a4b1699bf11208d065bcf8cf2e02081 U drh -Z 5d179a5613158bad283b799b101c68f6 +Z a4f82b8f6b61ef506efe9cc9a72c59ae diff --git a/manifest.uuid b/manifest.uuid index b21c3982ec..956c49dd64 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -91889fa30e84760e0d4b3d429c4abdef5a3f7931 \ No newline at end of file +2683b375ad1291172fdb47d94e16fcf869c78c8a \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 112d0bdaa3..d7236efa89 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -898,6 +898,9 @@ void Parse( ** they intend to abandon the parse upon the first syntax error seen. */ yy_syntax_error(yypParser,yymajor, yyminor); +#ifndef YYNOERRORRECOVERY + yypParser->yyerrcnt = -1; +#endif yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yymajor = YYNOCODE; From 50687436f75e8fc56c495a69d8ac9eaf29b3c97e Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Jul 2016 09:19:14 +0000 Subject: [PATCH 175/302] Fix a memory leak in recently added test code. FossilOrigin-Name: 724e4cdc25fc80b8face57b3398cd338994fb23c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f0b8e863c2..2ae741da57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\sfixes\sto\sFossil\sso\sthat\sit\sautomatically\sresets\sits\serror\scounter\sat\sthe\nend\sof\sa\sparse. -D 2016-07-05T16:11:26.639 +C Fix\sa\smemory\sleak\sin\srecently\sadded\stest\scode. +D 2016-07-06T09:19:14.702 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 -F src/test1.c 7cbfda741fbfa541ecce305ff2d7c6bb730aa991 +F src/test1.c 08faa045c45b1d3f62c28c93cae955f518317f68 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1504,7 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 91889fa30e84760e0d4b3d429c4abdef5a3f7931 -R 9a4b1699bf11208d065bcf8cf2e02081 -U drh -Z a4f82b8f6b61ef506efe9cc9a72c59ae +P 2683b375ad1291172fdb47d94e16fcf869c78c8a +R bad3fed306e6177658099344318135b4 +U dan +Z b779329b8bc265169140036a21a84f9f diff --git a/manifest.uuid b/manifest.uuid index 956c49dd64..457a7b2b76 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2683b375ad1291172fdb47d94e16fcf869c78c8a \ No newline at end of file +724e4cdc25fc80b8face57b3398cd338994fb23c \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 8e8020c043..d4a5cfc3ce 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3371,7 +3371,8 @@ static int test_textarray_addr( for(i=0; i Date: Wed, 6 Jul 2016 10:12:02 +0000 Subject: [PATCH 176/302] Add the SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED sqlite3_db_status() parameter. FossilOrigin-Name: 118321c8b9d88b8f439c952436f42838c3fc80cb --- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- src/btree.c | 13 ++++++++++++- src/btree.h | 2 ++ src/sqlite.h.in | 15 ++++++++++++++- src/status.c | 7 ++++++- src/test_malloc.c | 3 ++- test/dbstatus.test | 37 +++++++++++++++++++++++++++++++++++++ 8 files changed, 88 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 2ae741da57..662bd8b161 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sin\srecently\sadded\stest\scode. -D 2016-07-06T09:19:14.702 +C Add\sthe\sSQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED\ssqlite3_db_status()\sparameter. +D 2016-07-06T10:12:02.240 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -327,8 +327,8 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 0621247619df15790f7ed5f14926cfb3925c10b1 -F src/btree.h 2107a2630e02c8cba58bb12ce14e731e734ea29c +F src/btree.c dc4e5f3e95fd57b610422e36e0913662ecd6814c +F src/btree.h aee84823bb383d6ae3728b068f9130d2b36b71eb F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 @@ -385,12 +385,12 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 -F src/sqlite.h.in 5f8113dbec74c6c093ead9930afb8c9fbd9f643d +F src/sqlite.h.in 801a34f86508662fbfc8e014f03ccf0c8bef0b4c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 F src/sqliteInt.h 2ac73e9fdd138f4607139d9bd6a1e6dcd01837dc F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 -F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba +F src/status.c d92daea3bb48023da57931719f2a2784f5487c0b F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 F src/test1.c 08faa045c45b1d3f62c28c93cae955f518317f68 @@ -419,7 +419,7 @@ F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd -F src/test_malloc.c 94c18e88d6df6d471a0d04ddb809f833d1739950 +F src/test_malloc.c 20954ab49e09be3433c8d2fd7a8bd0a0f1c76de7 F src/test_multiplex.c eafc567ebe162e36f17b5062285dfe90461cf8e9 F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 +F test/dbstatus.test c0c8752043074ab6479d2560341ae02f072ad3b9 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1504,7 +1504,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2683b375ad1291172fdb47d94e16fcf869c78c8a -R bad3fed306e6177658099344318135b4 +P 724e4cdc25fc80b8face57b3398cd338994fb23c +R 266d0a5d75bc1363b05e057e04a42c8c +T *branch * dbstatus-prop-cache-used +T *sym-dbstatus-prop-cache-used * +T -sym-trunk * U dan -Z b779329b8bc265169140036a21a84f9f +Z d4bd876af7d67d4b270c7d6acc73f5f1 diff --git a/manifest.uuid b/manifest.uuid index 457a7b2b76..412e8ccbff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -724e4cdc25fc80b8face57b3398cd338994fb23c \ No newline at end of file +118321c8b9d88b8f439c952436f42838c3fc80cb \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index f37199276f..7fc9193dc8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2337,9 +2337,9 @@ int sqlite3BtreeOpen( #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO) /* Add the new BtShared object to the linked list sharable BtShareds. */ + pBt->nRef = 1; if( p->sharable ){ MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) - pBt->nRef = 1; MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);) if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){ pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST); @@ -2410,6 +2410,7 @@ btree_open_out: assert( sqlite3_mutex_held(mutexOpen) ); sqlite3_mutex_leave(mutexOpen); } + assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 ); return rc; } @@ -9698,4 +9699,14 @@ int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); } int sqlite3BtreeSharable(Btree *p){ return p->sharable; } + +/* +** Return the number of connections to the BtShared object accessed by +** the Btree handle passed as the only argument. For private caches +** this is always 1. For shared caches it may be 1 or greater. +*/ +int sqlite3BtreeConnectionCount(Btree *p){ + testcase( p->sharable ); + return p->pBt->nRef; +} #endif diff --git a/src/btree.h b/src/btree.h index 5720df90f7..c8b293ef17 100644 --- a/src/btree.h +++ b/src/btree.h @@ -328,11 +328,13 @@ void sqlite3BtreeCursorList(Btree*); void sqlite3BtreeEnterAll(sqlite3*); int sqlite3BtreeSharable(Btree*); void sqlite3BtreeEnterCursor(BtCursor*); + int sqlite3BtreeConnectionCount(Btree*); #else # define sqlite3BtreeEnter(X) # define sqlite3BtreeEnterAll(X) # define sqlite3BtreeSharable(X) 0 # define sqlite3BtreeEnterCursor(X) +# define sqlite3BtreeConnectionCount(X) 1 #endif #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 4865f18132..e1d16008f9 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6765,6 +6765,18 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** memory used by all pager caches associated with the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. ** +** [[SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED]] +** ^(
SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED
+**
This parameter is similar to DBSTATUS_CACHE_USED, except that if a +** pager cache is shared between two or more connections the bytes of heap +** memory used by that pager cache is divided evenly between the attached +** connections.)^ In other words, if none of the pager caches associated +** with the database connection are shared, this request returns the same +** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are +** shared, the value returned by this call will be smaller than that returned +** by DBSTATUS_CACHE_USED. ^The highwater mark associated with +** SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED is always 0. +** ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
**
This parameter returns the approximate number of bytes of heap ** memory used to store the schema for all databases associated @@ -6822,7 +6834,8 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); #define SQLITE_DBSTATUS_CACHE_MISS 8 #define SQLITE_DBSTATUS_CACHE_WRITE 9 #define SQLITE_DBSTATUS_DEFERRED_FKS 10 -#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */ +#define SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED 11 +#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */ /* diff --git a/src/status.c b/src/status.c index 69f92ff7c6..bf336dfb46 100644 --- a/src/status.c +++ b/src/status.c @@ -219,6 +219,7 @@ int sqlite3_db_status( ** by all pagers associated with the given database connection. The ** highwater mark is meaningless and is returned as zero. */ + case SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED: case SQLITE_DBSTATUS_CACHE_USED: { int totalUsed = 0; int i; @@ -227,7 +228,11 @@ int sqlite3_db_status( Btree *pBt = db->aDb[i].pBt; if( pBt ){ Pager *pPager = sqlite3BtreePager(pBt); - totalUsed += sqlite3PagerMemUsed(pPager); + int nByte = sqlite3PagerMemUsed(pPager); + if( op==SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED ){ + nByte = nByte / sqlite3BtreeConnectionCount(pBt); + } + totalUsed += nByte; } } sqlite3BtreeLeaveAll(db); diff --git a/src/test_malloc.c b/src/test_malloc.c index e6be663998..db34924e6b 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -1417,7 +1417,8 @@ static int test_db_status( { "CACHE_HIT", SQLITE_DBSTATUS_CACHE_HIT }, { "CACHE_MISS", SQLITE_DBSTATUS_CACHE_MISS }, { "CACHE_WRITE", SQLITE_DBSTATUS_CACHE_WRITE }, - { "DEFERRED_FKS", SQLITE_DBSTATUS_DEFERRED_FKS } + { "DEFERRED_FKS", SQLITE_DBSTATUS_DEFERRED_FKS }, + { "PROPORTIONAL_CACHE_USED", SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED }, }; Tcl_Obj *pResult; if( objc!=4 ){ diff --git a/test/dbstatus.test b/test/dbstatus.test index 368c6b28e5..fb839b8f13 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -14,6 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix dbstatus ifcapable !compound { finish_test @@ -24,6 +25,7 @@ ifcapable !compound { db close sqlite3_shutdown sqlite3_config_memstatus 1 +sqlite3_config_uri 1 sqlite3_initialize sqlite3 db test.db @@ -377,4 +379,39 @@ foreach ::lookaside_buffer_size {0 64 120} { } } +#------------------------------------------------------------------------- +# The following tests focus on DBSTATUS_PROPORTIONAL_CACHE_USED +# +ifcapable shared_cache { + proc do_cacheused_test {tn db res} { + set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] + set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED 0] + set cu [lindex $cu 1] + set pcu [lindex $pcu 1] + uplevel [list do_test $tn [list list $cu $pcu] [list {*}$res]] + } + reset_db + sqlite3 db file:test.db?cache=shared + + do_execsql_test 4.0 { + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + } + do_cacheused_test 4.0.1 db { 4568 4568 } + do_execsql_test 4.1 { + CREATE TEMP TABLE tt(a, b, c); + INSERT INTO tt VALUES(1, 2, 3); + } + do_cacheused_test 4.1.1 db { 9000 9000 } + + sqlite3 db2 file:test.db?cache=shared + do_cacheused_test 4.2.1 db2 { 4568 2284 } + do_cacheused_test 4.2.2 db { 9000 6716 } + db close + do_cacheused_test 4.2.3 db2 { 4568 4568 } + sqlite3 db file:test.db?cache=shared + do_cacheused_test 4.2.4 db2 { 4568 2284 } + db2 close +} + finish_test From dc7b7385c9603da2b753d81819555b8788ea2336 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Jul 2016 10:17:43 +0000 Subject: [PATCH 177/302] Fix a test script problem causing a test to fail if the ICU extension is enabled. FossilOrigin-Name: 0c228f5d3db1be598ebf5d9170428c19d18e01ad --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/bestindex3.test | 25 +++++++++++++++---------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 2ae741da57..72d4af2b39 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sin\srecently\sadded\stest\scode. -D 2016-07-06T09:19:14.702 +C Fix\sa\stest\sscript\sproblem\scausing\sa\stest\sto\sfail\sif\sthe\sICU\sextension\sis\senabled. +D 2016-07-06T10:17:43.607 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -529,7 +529,7 @@ F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f F test/bc_common.tcl b5e42d80305be95697e6370e015af571e5333a1c F test/bestindex1.test 0cf1bd2d7b97d3a3a8c10736125274f64765c4ee F test/bestindex2.test 4a06b8922ab2fd09434870da8d1cdf525aaf7060 -F test/bestindex3.test b80da904d23581d233a7ceee7d6bbad2b23a8133 +F test/bestindex3.test dd5fa4f483cd0356549203c4522f8c9e21cb1fc0 F test/between.test 34d375fb5ce1ae283ffe82b6b233e9f38e84fc6c F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59 F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc @@ -1504,7 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2683b375ad1291172fdb47d94e16fcf869c78c8a -R bad3fed306e6177658099344318135b4 +P 724e4cdc25fc80b8face57b3398cd338994fb23c +R c62c8dbad784e0483dfc9fa19c59eefb U dan -Z b779329b8bc265169140036a21a84f9f +Z a917ae810e6e02aa96317b48ea0e74c6 diff --git a/manifest.uuid b/manifest.uuid index 457a7b2b76..37cc004d35 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -724e4cdc25fc80b8face57b3398cd338994fb23c \ No newline at end of file +0c228f5d3db1be598ebf5d9170428c19d18e01ad \ No newline at end of file diff --git a/test/bestindex3.test b/test/bestindex3.test index bb6d5cefd1..8baf854254 100644 --- a/test/bestindex3.test +++ b/test/bestindex3.test @@ -135,17 +135,22 @@ foreach omit {0 1} { #------------------------------------------------------------------------- # Test the same pattern works with ordinary tables. # -do_execsql_test 2.1 { - CREATE TABLE t2(x TEXT COLLATE nocase, y TEXT); - CREATE INDEX t2x ON t2(x COLLATE nocase); - CREATE INDEX t2y ON t2(y); -} +# This test does not work if the ICU extension is enabled. ICU overrides +# LIKE - and this optimization only works with the built-in LIKE function. +# +ifcapable !icu { + do_execsql_test 2.1 { + CREATE TABLE t2(x TEXT COLLATE nocase, y TEXT); + CREATE INDEX t2x ON t2(x COLLATE nocase); + CREATE INDEX t2y ON t2(y); + } -do_eqp_test 2.2 { - SELECT * FROM t2 WHERE x LIKE 'abc%' OR y = 'def' -} { - 0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x>? AND x? AND x Date: Wed, 6 Jul 2016 18:12:54 +0000 Subject: [PATCH 178/302] Change the name of the SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED to SQLITE_DBSTATUS_CACHE_USED_SHARED. FossilOrigin-Name: d58401ab26c7c5417eb7d540f47d11c4e49edcb2 --- manifest | 21 +++++++++------------ manifest.uuid | 2 +- src/sqlite.h.in | 8 ++++---- src/status.c | 4 ++-- src/test_malloc.c | 2 +- test/dbstatus.test | 4 ++-- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 662bd8b161..f138ba5137 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED\ssqlite3_db_status()\sparameter. -D 2016-07-06T10:12:02.240 +C Change\sthe\sname\sof\sthe\sSQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED\sto\sSQLITE_DBSTATUS_CACHE_USED_SHARED. +D 2016-07-06T18:12:54.292 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,12 +385,12 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 -F src/sqlite.h.in 801a34f86508662fbfc8e014f03ccf0c8bef0b4c +F src/sqlite.h.in 5e6785f6d2148b20ecd891039b12e9c7b8c552ca F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 F src/sqliteInt.h 2ac73e9fdd138f4607139d9bd6a1e6dcd01837dc F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 -F src/status.c d92daea3bb48023da57931719f2a2784f5487c0b +F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 F src/test1.c 08faa045c45b1d3f62c28c93cae955f518317f68 @@ -419,7 +419,7 @@ F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd -F src/test_malloc.c 20954ab49e09be3433c8d2fd7a8bd0a0f1c76de7 +F src/test_malloc.c 6b27e947eeeb70d11aa65406ed28d749e39b6356 F src/test_multiplex.c eafc567ebe162e36f17b5062285dfe90461cf8e9 F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test c0c8752043074ab6479d2560341ae02f072ad3b9 +F test/dbstatus.test 254427f026b55ab6eba99bd8493f4edbc370bb13 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1504,10 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 724e4cdc25fc80b8face57b3398cd338994fb23c -R 266d0a5d75bc1363b05e057e04a42c8c -T *branch * dbstatus-prop-cache-used -T *sym-dbstatus-prop-cache-used * -T -sym-trunk * +P 118321c8b9d88b8f439c952436f42838c3fc80cb +R 05426ca0e9c055af37d1a3ee4a44f5ae U dan -Z d4bd876af7d67d4b270c7d6acc73f5f1 +Z 090646989586e99cb3699b0e8d3a49b5 diff --git a/manifest.uuid b/manifest.uuid index 412e8ccbff..a57c8f34ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -118321c8b9d88b8f439c952436f42838c3fc80cb \ No newline at end of file +d58401ab26c7c5417eb7d540f47d11c4e49edcb2 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e1d16008f9..55f96dd898 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6765,8 +6765,8 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** memory used by all pager caches associated with the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. ** -** [[SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED]] -** ^(
SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED
+** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] +** ^(
SQLITE_DBSTATUS_CACHE_USED_SHARED
**
This parameter is similar to DBSTATUS_CACHE_USED, except that if a ** pager cache is shared between two or more connections the bytes of heap ** memory used by that pager cache is divided evenly between the attached @@ -6775,7 +6775,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are ** shared, the value returned by this call will be smaller than that returned ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with -** SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED is always 0. +** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0. ** ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
**
This parameter returns the approximate number of bytes of heap @@ -6834,7 +6834,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); #define SQLITE_DBSTATUS_CACHE_MISS 8 #define SQLITE_DBSTATUS_CACHE_WRITE 9 #define SQLITE_DBSTATUS_DEFERRED_FKS 10 -#define SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED 11 +#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11 #define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */ diff --git a/src/status.c b/src/status.c index bf336dfb46..949908ed23 100644 --- a/src/status.c +++ b/src/status.c @@ -219,7 +219,7 @@ int sqlite3_db_status( ** by all pagers associated with the given database connection. The ** highwater mark is meaningless and is returned as zero. */ - case SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED: + case SQLITE_DBSTATUS_CACHE_USED_SHARED: case SQLITE_DBSTATUS_CACHE_USED: { int totalUsed = 0; int i; @@ -229,7 +229,7 @@ int sqlite3_db_status( if( pBt ){ Pager *pPager = sqlite3BtreePager(pBt); int nByte = sqlite3PagerMemUsed(pPager); - if( op==SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED ){ + if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){ nByte = nByte / sqlite3BtreeConnectionCount(pBt); } totalUsed += nByte; diff --git a/src/test_malloc.c b/src/test_malloc.c index db34924e6b..37612561eb 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -1418,7 +1418,7 @@ static int test_db_status( { "CACHE_MISS", SQLITE_DBSTATUS_CACHE_MISS }, { "CACHE_WRITE", SQLITE_DBSTATUS_CACHE_WRITE }, { "DEFERRED_FKS", SQLITE_DBSTATUS_DEFERRED_FKS }, - { "PROPORTIONAL_CACHE_USED", SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED }, + { "CACHE_USED_SHARED", SQLITE_DBSTATUS_CACHE_USED_SHARED }, }; Tcl_Obj *pResult; if( objc!=4 ){ diff --git a/test/dbstatus.test b/test/dbstatus.test index fb839b8f13..7bc44353b0 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -380,12 +380,12 @@ foreach ::lookaside_buffer_size {0 64 120} { } #------------------------------------------------------------------------- -# The following tests focus on DBSTATUS_PROPORTIONAL_CACHE_USED +# The following tests focus on DBSTATUS_CACHE_USED_SHARED # ifcapable shared_cache { proc do_cacheused_test {tn db res} { set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] - set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_PROPORTIONAL_CACHE_USED 0] + set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] set cu [lindex $cu 1] set pcu [lindex $pcu 1] uplevel [list do_test $tn [list list $cu $pcu] [list {*}$res]] From 5225449e5bd7172ad1194d0bc92fa4d27ae5adbd Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jul 2016 02:14:24 +0000 Subject: [PATCH 179/302] In the sqldiff program, make sure the first argument to the db_prepare() utility function is always a valid format string. FossilOrigin-Name: 8bb8d886ffa948cd7bc66c8c62da76bce233be2e --- manifest | 15 +++++++-------- manifest.uuid | 2 +- tool/sqldiff.c | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index eae430df41..9d64eac700 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_DBSTATUS_CACHE_USED_SHARED\ssqlite3_db_status()\sparameter.\sThis\soption\sis\ssimilar\sto\sDBSTATUS_CACHE_USED,\sexcept\sthat\sit\sdivides\smemory\sused\sby\sshared\scaches\sevenly\sbetween\sall\sconnections. -D 2016-07-06T18:42:34.265 +C In\sthe\ssqldiff\sprogram,\smake\ssure\sthe\sfirst\sargument\sto\sthe\sdb_prepare()\nutility\sfunction\sis\salways\sa\svalid\sformat\sstring. +D 2016-07-08T02:14:24.531 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1471,7 +1471,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 131e9c6e09d3d78e3c4ae8b5fd23451521723aac +F tool/sqldiff.c af5d80cdc88a91a0f3cccfaa316b5a27b213568a F tool/srcck1.c 4c39bdfa9a92edd20233ee720df84dbeb2417602 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1504,8 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0c228f5d3db1be598ebf5d9170428c19d18e01ad d58401ab26c7c5417eb7d540f47d11c4e49edcb2 -R b82357a7b430039c936434bd64729f72 -T +closed d58401ab26c7c5417eb7d540f47d11c4e49edcb2 -U dan -Z cd4dfb8a318d1cd48c9fef00f9959964 +P 06cf2680588c8dc4f0cbde275a09cfdcb5943268 +R 0ae6fb283ae848ac01b5c1982f5ece36 +U drh +Z fc8cced580b536f398169074b70b6b16 diff --git a/manifest.uuid b/manifest.uuid index 445104cad7..cad934d3a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06cf2680588c8dc4f0cbde275a09cfdcb5943268 \ No newline at end of file +8bb8d886ffa948cd7bc66c8c62da76bce233be2e \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 4a5389c603..dbdf726df0 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -684,7 +684,7 @@ static void diff_one_table(const char *zTab, FILE *out){ /* Run the query and output differences */ if( !g.bSchemaOnly ){ - pStmt = db_prepare(sql.z); + pStmt = db_prepare("%s", sql.z); while( SQLITE_ROW==sqlite3_step(pStmt) ){ int iType = sqlite3_column_int(pStmt, nPk); if( iType==1 || iType==2 ){ @@ -1461,7 +1461,7 @@ static void summarize_one_table(const char *zTab, FILE *out){ } /* Run the query and output difference summary */ - pStmt = db_prepare(sql.z); + pStmt = db_prepare("%s", sql.z); nUpdate = 0; nInsert = 0; nDelete = 0; @@ -2018,7 +2018,7 @@ int main(int argc, char **argv){ xDiff(zTab, out); }else{ /* Handle tables one by one */ - pStmt = db_prepare( all_tables_sql() ); + pStmt = db_prepare("%s", all_tables_sql() ); while( SQLITE_ROW==sqlite3_step(pStmt) ){ xDiff((const char*)sqlite3_column_text(pStmt,0), out); } From d3d4b3c698cbe74662a6e6fbac92e8090068fe18 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jul 2016 19:54:38 +0000 Subject: [PATCH 180/302] Another attempt to fix error handling in Lemon. This change is a no-op for SQLite's usage. FossilOrigin-Name: e1d8ef311cabcb96495a88404991b1416655e4a8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 9d64eac700..0defcbf521 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\ssqldiff\sprogram,\smake\ssure\sthe\sfirst\sargument\sto\sthe\sdb_prepare()\nutility\sfunction\sis\salways\sa\svalid\sformat\sstring. -D 2016-07-08T02:14:24.531 +C Another\sattempt\sto\sfix\serror\shandling\sin\sLemon.\s\sThis\schange\sis\sa\sno-op\sfor\nSQLite's\susage. +D 2016-07-08T19:54:38.723 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1432,7 +1432,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 072ff9985f36796b95bdc895820f2d77255a7067 +F tool/lempar.c 77c685a612526aae9c0d9b3175176e5bcd3854d0 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1504,7 +1504,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 06cf2680588c8dc4f0cbde275a09cfdcb5943268 -R 0ae6fb283ae848ac01b5c1982f5ece36 +P 8bb8d886ffa948cd7bc66c8c62da76bce233be2e +R 855944636ee976f5addadf9e5d764c10 U drh -Z fc8cced580b536f398169074b70b6b16 +Z 1b9ee21867274cd5ef77d7b4ebcc2052 diff --git a/manifest.uuid b/manifest.uuid index cad934d3a4..f05a5cef3c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bb8d886ffa948cd7bc66c8c62da76bce233be2e \ No newline at end of file +e1d8ef311cabcb96495a88404991b1416655e4a8 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index d7236efa89..5232565f87 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -921,6 +921,9 @@ void Parse( yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); +#ifndef YYNOERRORRECOVERY + yypParser->yyerrcnt = -1; +#endif } yymajor = YYNOCODE; #endif From 1e75483cf06e7012b5a814b8e7eb1b2ca644937a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 8 Jul 2016 21:14:37 +0000 Subject: [PATCH 181/302] Initial work on a Win32 VFS with NOP locking. FossilOrigin-Name: 549abe3f89b55b05a05f267865a5dd84b8cd335d --- manifest | 18 +-- manifest.uuid | 2 +- src/os_win.c | 260 +++++++++++++++++++++++++++++++++--------- test/win32nolock.test | 126 ++++++++++++++++++++ 4 files changed, 345 insertions(+), 61 deletions(-) create mode 100644 test/win32nolock.test diff --git a/manifest b/manifest index 0defcbf521..d1bae33bb1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\sattempt\sto\sfix\serror\shandling\sin\sLemon.\s\sThis\schange\sis\sa\sno-op\sfor\nSQLite's\susage. -D 2016-07-08T19:54:38.723 +C Initial\swork\son\sa\sWin32\sVFS\swith\sNOP\slocking. +D 2016-07-08T21:14:37.641 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -368,7 +368,7 @@ F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 -F src/os_win.c d4b8faf8896b65818e67070711fdd00d8e620bd6 +F src/os_win.c 716af57117381c24c0eb43c8dc5a86a6496f98a7 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 @@ -1402,6 +1402,7 @@ F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d +F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc F test/with1.test cef099a491eac9874f2c28bd2dc86394fb3e47b3 F test/with2.test 2b40da883658eb74ad8ad06afabe11a408e7fb87 F test/with3.test 511bacdbe41c49cf34f9fd1bd3245fe1575bca98 @@ -1504,7 +1505,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8bb8d886ffa948cd7bc66c8c62da76bce233be2e -R 855944636ee976f5addadf9e5d764c10 -U drh -Z 1b9ee21867274cd5ef77d7b4ebcc2052 +P e1d8ef311cabcb96495a88404991b1416655e4a8 +R ba3e2959766a1594f290917f0109fdb1 +T *branch * win32nolock +T *sym-win32nolock * +T -sym-trunk * +U mistachkin +Z 21c6555b60ed7b3a758f8d504d1fa54f diff --git a/manifest.uuid b/manifest.uuid index f05a5cef3c..47a6068e6c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1d8ef311cabcb96495a88404991b1416655e4a8 \ No newline at end of file +549abe3f89b55b05a05f267865a5dd84b8cd335d \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index edc182a017..1c861b0fbd 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -290,6 +290,17 @@ struct winFile { #endif }; +/* +** The winVfsAppData structure is used for the pAppData member for all of the +** Win32 VFS variants. +*/ +typedef struct winVfsAppData winVfsAppData; +struct winVfsAppData { + const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */ + void *pAppData; /* The extra pAppData, if any. */ + BOOL bNoLock; /* Non-zero if locking is disabled. */ +}; + /* ** Allowed values for winFile.ctrlFlags */ @@ -2611,7 +2622,12 @@ static int winClose(sqlite3_file *id){ }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) ); #if SQLITE_OS_WINCE #define WINCE_DELETION_ATTEMPTS 3 - winceDestroyLock(pFile); + { + winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData; + if( pAppData==NULL || !pAppData->bNoLock ){ + winceDestroyLock(pFile); + } + } if( pFile->zDeleteOnClose ){ int cnt = 0; while( @@ -3343,6 +3359,44 @@ static int winUnlock(sqlite3_file *id, int locktype){ return rc; } +/****************************************************************************** +****************************** No-op Locking ********************************** +** +** Of the various locking implementations available, this is by far the +** simplest: locking is ignored. No attempt is made to lock the database +** file for reading or writing. +** +** This locking mode is appropriate for use on read-only databases +** (ex: databases that are burned into CD-ROM, for example.) It can +** also be used if the application employs some external mechanism to +** prevent simultaneous access of the same database by two or more +** database connections. But there is a serious risk of database +** corruption if this locking mode is used in situations where multiple +** database connections are accessing the same database file at the same +** time and one or more of those connections are writing. +*/ + +static int winNolockLock(sqlite3_file *id, int locktype){ + UNUSED_PARAMETER(id); + UNUSED_PARAMETER(locktype); + return SQLITE_OK; +} + +static int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){ + UNUSED_PARAMETER(id); + UNUSED_PARAMETER(pResOut); + return SQLITE_OK; +} + +static int winNolockUnlock(sqlite3_file *id, int locktype){ + UNUSED_PARAMETER(id); + UNUSED_PARAMETER(locktype); + return SQLITE_OK; +} + +/******************* End of the no-op lock implementation ********************* +******************************************************************************/ + /* ** If *pArg is initially negative then this is a query. Set *pArg to ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set. @@ -4407,6 +4461,44 @@ static const sqlite3_io_methods winIoMethod = { winUnfetch /* xUnfetch */ }; +/* +** This vector defines all the methods that can operate on an +** sqlite3_file for win32 without performing any locking. +*/ +static const sqlite3_io_methods winIoNolockMethod = { + 3, /* iVersion */ + winClose, /* xClose */ + winRead, /* xRead */ + winWrite, /* xWrite */ + winTruncate, /* xTruncate */ + winSync, /* xSync */ + winFileSize, /* xFileSize */ + winNolockLock, /* xLock */ + winNolockUnlock, /* xUnlock */ + winNolockCheckReservedLock, /* xCheckReservedLock */ + winFileControl, /* xFileControl */ + winSectorSize, /* xSectorSize */ + winDeviceCharacteristics, /* xDeviceCharacteristics */ + winShmMap, /* xShmMap */ + winShmLock, /* xShmLock */ + winShmBarrier, /* xShmBarrier */ + winShmUnmap, /* xShmUnmap */ + winFetch, /* xFetch */ + winUnfetch /* xUnfetch */ +}; + +static winVfsAppData winAppData = { + &winIoMethod, /* pMethod */ + 0, /* pAppData */ + 0 /* bNoLock */ +}; + +static winVfsAppData winNolockAppData = { + &winIoNolockMethod, /* pMethod */ + 0, /* pAppData */ + 1 /* bNoLock */ +}; + /**************************************************************************** **************************** sqlite3_vfs methods **************************** ** @@ -4739,7 +4831,7 @@ static int winIsDir(const void *zConverted){ ** Open a file. */ static int winOpen( - sqlite3_vfs *pVfs, /* Used to get maximum path name length */ + sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */ const char *zName, /* Name of the file (UTF-8) */ sqlite3_file *id, /* Write the SQLite file handle here */ int flags, /* Open mode flags */ @@ -4754,6 +4846,7 @@ static int winOpen( #if SQLITE_OS_WINCE int isTemp = 0; #endif + winVfsAppData *pAppData; winFile *pFile = (winFile*)id; void *zConverted; /* Filename in OS encoding */ const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */ @@ -4975,15 +5068,20 @@ static int winOpen( "rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ? *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok")); + pAppData = (winVfsAppData*)pVfs->pAppData; + #if SQLITE_OS_WINCE - if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB - && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK - ){ - osCloseHandle(h); - sqlite3_free(zConverted); - sqlite3_free(zTmpname); - OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc))); - return rc; + { + if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB + && ((pAppData==NULL) || !pAppData->bNoLock) + && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK + ){ + osCloseHandle(h); + sqlite3_free(zConverted); + sqlite3_free(zTmpname); + OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc))); + return rc; + } } if( isTemp ){ pFile->zDeleteOnClose = zConverted; @@ -4994,7 +5092,7 @@ static int winOpen( } sqlite3_free(zTmpname); - pFile->pMethod = &winIoMethod; + pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod; pFile->pVfs = pVfs; pFile->h = h; if( isReadonly ){ @@ -5717,53 +5815,103 @@ static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ */ int sqlite3_os_init(void){ static sqlite3_vfs winVfs = { - 3, /* iVersion */ - sizeof(winFile), /* szOsFile */ + 3, /* iVersion */ + sizeof(winFile), /* szOsFile */ SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ - 0, /* pNext */ - "win32", /* zName */ - 0, /* pAppData */ - winOpen, /* xOpen */ - winDelete, /* xDelete */ - winAccess, /* xAccess */ - winFullPathname, /* xFullPathname */ - winDlOpen, /* xDlOpen */ - winDlError, /* xDlError */ - winDlSym, /* xDlSym */ - winDlClose, /* xDlClose */ - winRandomness, /* xRandomness */ - winSleep, /* xSleep */ - winCurrentTime, /* xCurrentTime */ - winGetLastError, /* xGetLastError */ - winCurrentTimeInt64, /* xCurrentTimeInt64 */ - winSetSystemCall, /* xSetSystemCall */ - winGetSystemCall, /* xGetSystemCall */ - winNextSystemCall, /* xNextSystemCall */ + 0, /* pNext */ + "win32", /* zName */ + &winAppData, /* pAppData */ + winOpen, /* xOpen */ + winDelete, /* xDelete */ + winAccess, /* xAccess */ + winFullPathname, /* xFullPathname */ + winDlOpen, /* xDlOpen */ + winDlError, /* xDlError */ + winDlSym, /* xDlSym */ + winDlClose, /* xDlClose */ + winRandomness, /* xRandomness */ + winSleep, /* xSleep */ + winCurrentTime, /* xCurrentTime */ + winGetLastError, /* xGetLastError */ + winCurrentTimeInt64, /* xCurrentTimeInt64 */ + winSetSystemCall, /* xSetSystemCall */ + winGetSystemCall, /* xGetSystemCall */ + winNextSystemCall, /* xNextSystemCall */ }; #if defined(SQLITE_WIN32_HAS_WIDE) static sqlite3_vfs winLongPathVfs = { - 3, /* iVersion */ - sizeof(winFile), /* szOsFile */ + 3, /* iVersion */ + sizeof(winFile), /* szOsFile */ SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */ - 0, /* pNext */ - "win32-longpath", /* zName */ - 0, /* pAppData */ - winOpen, /* xOpen */ - winDelete, /* xDelete */ - winAccess, /* xAccess */ - winFullPathname, /* xFullPathname */ - winDlOpen, /* xDlOpen */ - winDlError, /* xDlError */ - winDlSym, /* xDlSym */ - winDlClose, /* xDlClose */ - winRandomness, /* xRandomness */ - winSleep, /* xSleep */ - winCurrentTime, /* xCurrentTime */ - winGetLastError, /* xGetLastError */ - winCurrentTimeInt64, /* xCurrentTimeInt64 */ - winSetSystemCall, /* xSetSystemCall */ - winGetSystemCall, /* xGetSystemCall */ - winNextSystemCall, /* xNextSystemCall */ + 0, /* pNext */ + "win32-longpath", /* zName */ + &winAppData, /* pAppData */ + winOpen, /* xOpen */ + winDelete, /* xDelete */ + winAccess, /* xAccess */ + winFullPathname, /* xFullPathname */ + winDlOpen, /* xDlOpen */ + winDlError, /* xDlError */ + winDlSym, /* xDlSym */ + winDlClose, /* xDlClose */ + winRandomness, /* xRandomness */ + winSleep, /* xSleep */ + winCurrentTime, /* xCurrentTime */ + winGetLastError, /* xGetLastError */ + winCurrentTimeInt64, /* xCurrentTimeInt64 */ + winSetSystemCall, /* xSetSystemCall */ + winGetSystemCall, /* xGetSystemCall */ + winNextSystemCall, /* xNextSystemCall */ + }; +#endif + static sqlite3_vfs winNolockVfs = { + 3, /* iVersion */ + sizeof(winFile), /* szOsFile */ + SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ + 0, /* pNext */ + "win32-none", /* zName */ + &winNolockAppData, /* pAppData */ + winOpen, /* xOpen */ + winDelete, /* xDelete */ + winAccess, /* xAccess */ + winFullPathname, /* xFullPathname */ + winDlOpen, /* xDlOpen */ + winDlError, /* xDlError */ + winDlSym, /* xDlSym */ + winDlClose, /* xDlClose */ + winRandomness, /* xRandomness */ + winSleep, /* xSleep */ + winCurrentTime, /* xCurrentTime */ + winGetLastError, /* xGetLastError */ + winCurrentTimeInt64, /* xCurrentTimeInt64 */ + winSetSystemCall, /* xSetSystemCall */ + winGetSystemCall, /* xGetSystemCall */ + winNextSystemCall, /* xNextSystemCall */ + }; +#if defined(SQLITE_WIN32_HAS_WIDE) + static sqlite3_vfs winLongPathNolockVfs = { + 3, /* iVersion */ + sizeof(winFile), /* szOsFile */ + SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */ + 0, /* pNext */ + "win32-longpath-none", /* zName */ + &winNolockAppData, /* pAppData */ + winOpen, /* xOpen */ + winDelete, /* xDelete */ + winAccess, /* xAccess */ + winFullPathname, /* xFullPathname */ + winDlOpen, /* xDlOpen */ + winDlError, /* xDlError */ + winDlSym, /* xDlSym */ + winDlClose, /* xDlClose */ + winRandomness, /* xRandomness */ + winSleep, /* xSleep */ + winCurrentTime, /* xCurrentTime */ + winGetLastError, /* xGetLastError */ + winCurrentTimeInt64, /* xCurrentTimeInt64 */ + winSetSystemCall, /* xSetSystemCall */ + winGetSystemCall, /* xGetSystemCall */ + winNextSystemCall, /* xNextSystemCall */ }; #endif @@ -5787,6 +5935,12 @@ int sqlite3_os_init(void){ sqlite3_vfs_register(&winLongPathVfs, 0); #endif + sqlite3_vfs_register(&winNolockVfs, 0); + +#if defined(SQLITE_WIN32_HAS_WIDE) + sqlite3_vfs_register(&winLongPathNolockVfs, 0); +#endif + return SQLITE_OK; } diff --git a/test/win32nolock.test b/test/win32nolock.test new file mode 100644 index 0000000000..8128860392 --- /dev/null +++ b/test/win32nolock.test @@ -0,0 +1,126 @@ +# 2016 July 8 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# + +if {$tcl_platform(platform)!="windows"} return + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix win32nolock + +do_test win32nolock-1.0 { + sqlite3 db test.db + execsql { + CREATE TABLE t1(a, b); + BEGIN; + INSERT INTO t1 VALUES(1, 2); + } +} {} + +do_test win32nolock-1.1 { + execsql COMMIT + catchsql { SELECT * FROM t1 } +} {0 {1 2}} + +db close + +do_test win32nolock-1.2 { + sqlite3 db test.db -vfs win32-none + sqlite3 db2 test.db -vfs win32-none + execsql { PRAGMA mmap_size = 0 } db2 + execsql { + BEGIN; + INSERT INTO t1 VALUES(3, 4); + } +} {} + +do_test win32nolock-1.3 { + execsql { SELECT * FROM t1 } +} {1 2 3 4} + +do_test win32nolock-1.4 { + execsql { SELECT * FROM t1; } db2 +} {1 2} + +do_test win32nolock-1.5 { + execsql { + BEGIN; + SELECT * FROM t1; + } db2 +} {1 2} + +do_test win32nolock-1.6 { + execsql COMMIT + execsql {SELECT * FROM t1} db2 +} {1 2} + +ifcapable memorymanage { + do_test win32nolock-1.7 { + sqlite3_release_memory 1000000 + execsql {SELECT * FROM t1} db2 + } {1 2 3 4} +} + +do_test win32nolock-1.8 { + db close + db2 close +} {} + +do_test win32nolock-1.9.1 { + sqlite3 db test.db + sqlite3 db2 test.db + list [catchsql { BEGIN EXCLUSIVE; } db] \ + [catchsql { BEGIN EXCLUSIVE; } db2] +} {{0 {}} {1 {database is locked}}} + +do_test win32nolock-1.9.2 { + db close + db2 close +} {} + +do_test win32nolock-1.10.1 { + sqlite3 db test.db -vfs win32-none + sqlite3 db2 test.db + list [catchsql { BEGIN EXCLUSIVE; } db] \ + [catchsql { BEGIN EXCLUSIVE; } db2] +} {{0 {}} {0 {}}} + +do_test win32nolock-1.10.2 { + db close + db2 close +} {} + +do_test win32nolock-1.11.1 { + sqlite3 db test.db + sqlite3 db2 test.db -vfs win32-none + list [catchsql { BEGIN EXCLUSIVE; } db] \ + [catchsql { BEGIN EXCLUSIVE; } db2] +} {{0 {}} {0 {}}} + +do_test win32nolock-1.11.2 { + db close + db2 close +} {} + +do_test win32nolock-1.12.1 { + sqlite3 db test.db -vfs win32-none + sqlite3 db2 test.db -vfs win32-none + list [catchsql { BEGIN EXCLUSIVE; } db] \ + [catchsql { BEGIN EXCLUSIVE; } db2] +} {{0 {}} {0 {}}} + +do_test win32nolock-1.12.2 { + db close + db2 close +} {} + +finish_test From 43f58d6a17e2875e59b72e126c9393f50fe63e79 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Jul 2016 16:14:45 +0000 Subject: [PATCH 182/302] Fix various internal #defines to conform to new C-language naming restrictions, specifically that private-use macros names must not begin with "_". FossilOrigin-Name: 5471aca0158851d3fb0a2517306917536deb38bb --- manifest | 44 ++++++++++++++++++++++---------------------- manifest.uuid | 2 +- src/btree.h | 6 +++--- src/hash.h | 6 +++--- src/hwtime.h | 6 +++--- src/msvc.h | 6 +++--- src/os.c | 2 -- src/os_setup.h | 6 +++--- src/os_win.c | 28 ++++++++++++++-------------- src/os_win.h | 6 +++--- src/pager.h | 6 +++--- src/sqlite.h.in | 6 +++--- src/sqlite3ext.h | 6 +++--- src/sqliteInt.h | 6 +++--- src/test_intarray.h | 6 +++--- src/test_multiplex.h | 6 +++--- src/vdbe.h | 6 +++--- src/vdbeInt.h | 6 +++--- src/wal.h | 6 +++--- 19 files changed, 82 insertions(+), 84 deletions(-) diff --git a/manifest b/manifest index 964bfb8a38..eef481b87d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sthe\swin32-none\sVFS. -D 2016-07-09T00:06:21.171 +C Fix\svarious\sinternal\s#defines\sto\sconform\sto\snew\sC-language\snaming\srestrictions,\nspecifically\sthat\sprivate-use\smacros\snames\smust\snot\sbegin\swith\s"_". +D 2016-07-09T16:14:45.037 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -328,7 +328,7 @@ F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c dc4e5f3e95fd57b610422e36e0913662ecd6814c -F src/btree.h aee84823bb383d6ae3728b068f9130d2b36b71eb +F src/btree.h 075c45707c0f8f8af118f739f36df8098a08b7da F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 @@ -343,8 +343,8 @@ F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 F src/global.c c45ea22aff29334f6a9ec549235ac3357c970015 F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36 -F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 -F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 +F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 +F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 @@ -356,22 +356,22 @@ F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 F src/memjournal.c 95752936c11dc6995672d1dd783cd633eea0cc95 -F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 +F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4 F src/mutex_unix.c 27bb6cc49485ee46711a6580ab7b3f1402211d23 F src/mutex_w32.c 5e6fe1c298fb5a8a15aaed4161d5759311431c17 F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7 -F src/os.c 4d83917f072ad958fba9235136fa2ed43df47905 +F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 -F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa +F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 -F src/os_win.c 716af57117381c24c0eb43c8dc5a86a6496f98a7 -F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca +F src/os_win.c 520f23475f1de530c435d30b67b7b15fe90874b0 +F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 -F src/pager.h 8ab6b6feeee4bc0439bfde7ee59ba99df98b9bc3 +F src/pager.h 031a87445e5e0afc85312d1c380e123ad6c7aeaf F src/parse.y f374ab20106362eb3f5c01b3e6a002f0bbead7ff F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 @@ -385,10 +385,10 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 -F src/sqlite.h.in 5e6785f6d2148b20ecd891039b12e9c7b8c552ca +F src/sqlite.h.in b9ba728c1083b7a8ab5f6a628b25cd2a00325fbf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2 -F src/sqliteInt.h 2ac73e9fdd138f4607139d9bd6a1e6dcd01837dc +F src/sqlite3ext.h 2a170163d121095c6ab1ef05ed0413722f391d01 +F src/sqliteInt.h dcf43b8abc5605b70f54ba80f42b6ad054b8ba95 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -416,12 +416,12 @@ F src/test_func.c 37453d346cfcf118774efd5bf6187f7e6a7e3254 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 -F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 +F src/test_intarray.h f3b7672f5d1056eac563c0d6ea8480a660b1475c F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd F src/test_malloc.c 6b27e947eeeb70d11aa65406ed28d749e39b6356 F src/test_multiplex.c eafc567ebe162e36f17b5062285dfe90461cf8e9 -F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 +F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c F src/test_onefile.c 416f87a28d6d673352d33fc4b1c7d39db878e50f F src/test_osinst.c ad0233b1dabb0390e25edded4ebd79a2a61538c6 @@ -450,8 +450,8 @@ F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 F src/vdbe.c 22b46c3b725e950e9f2760e2d76953d592600ad4 -F src/vdbe.h 5591b5add447096e31288b5a0a78ec5d7b5c5170 -F src/vdbeInt.h ddb157974436d87652de7dc641f7191496d9a8cd +F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 +F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 02bcbc2ca5d2004b029088b05b468b394881e103 F src/vdbeaux.c c90275b0e55a2b32c03dc09314194fe46f2429d8 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b @@ -461,7 +461,7 @@ F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a -F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c +F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1d8ef311cabcb96495a88404991b1416655e4a8 549abe3f89b55b05a05f267865a5dd84b8cd335d -R ba3e2959766a1594f290917f0109fdb1 +P b5f32a896d0e4010ec67fcf1d635bb9aa797d3c2 +R 1420ae412f251bd23536749aacd8c4fa U drh -Z f61bb876686c2e3e621a4eb92a4f2f5a +Z e116500fbf8eef00f67c7f388726b705 diff --git a/manifest.uuid b/manifest.uuid index 6ef4eda049..a0cf804e45 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b5f32a896d0e4010ec67fcf1d635bb9aa797d3c2 \ No newline at end of file +5471aca0158851d3fb0a2517306917536deb38bb \ No newline at end of file diff --git a/src/btree.h b/src/btree.h index c8b293ef17..b76e2ce214 100644 --- a/src/btree.h +++ b/src/btree.h @@ -13,8 +13,8 @@ ** subsystem. See comments in the source code for a detailed description ** of what each interface routine does. */ -#ifndef _BTREE_H_ -#define _BTREE_H_ +#ifndef SQLITE_BTREE_H +#define SQLITE_BTREE_H /* TODO: This definition is just included so other modules compile. It ** needs to be revisited. @@ -359,4 +359,4 @@ void sqlite3BtreeCursorList(Btree*); #endif -#endif /* _BTREE_H_ */ +#endif /* SQLITE_BTREE_H */ diff --git a/src/hash.h b/src/hash.h index 6dfa4e035c..90540eda50 100644 --- a/src/hash.h +++ b/src/hash.h @@ -12,8 +12,8 @@ ** This is the header file for the generic hash-table implementation ** used in SQLite. */ -#ifndef _SQLITE_HASH_H_ -#define _SQLITE_HASH_H_ +#ifndef SQLITE_HASH_H +#define SQLITE_HASH_H /* Forward declarations of structures. */ typedef struct Hash Hash; @@ -93,4 +93,4 @@ void sqlite3HashClear(Hash*); */ /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ -#endif /* _SQLITE_HASH_H_ */ +#endif /* SQLITE_HASH_H */ diff --git a/src/hwtime.h b/src/hwtime.h index b8bc5a295b..5b209db8af 100644 --- a/src/hwtime.h +++ b/src/hwtime.h @@ -13,8 +13,8 @@ ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 class CPUs. */ -#ifndef _HWTIME_H_ -#define _HWTIME_H_ +#ifndef SQLITE_HWTIME_H +#define SQLITE_HWTIME_H /* ** The following routine only works on pentium-class (or newer) processors. @@ -82,4 +82,4 @@ #endif -#endif /* !defined(_HWTIME_H_) */ +#endif /* !defined(SQLITE_HWTIME_H) */ diff --git a/src/msvc.h b/src/msvc.h index 01ebf2b46f..3914b05bcf 100644 --- a/src/msvc.h +++ b/src/msvc.h @@ -12,8 +12,8 @@ ** ** This file contains code that is specific to MSVC. */ -#ifndef _MSVC_H_ -#define _MSVC_H_ +#ifndef SQLITE_MSVC_H +#define SQLITE_MSVC_H #if defined(_MSC_VER) #pragma warning(disable : 4054) @@ -33,4 +33,4 @@ #pragma warning(disable : 4706) #endif /* defined(_MSC_VER) */ -#endif /* _MSVC_H_ */ +#endif /* SQLITE_MSVC_H */ diff --git a/src/os.c b/src/os.c index 6138bf4f3f..5cf0014794 100644 --- a/src/os.c +++ b/src/os.c @@ -13,9 +13,7 @@ ** This file contains OS interface code that is common to all ** architectures. */ -#define _SQLITE_OS_C_ 1 #include "sqliteInt.h" -#undef _SQLITE_OS_C_ /* ** If we compile with the SQLITE_TEST macro set, then the following block diff --git a/src/os_setup.h b/src/os_setup.h index 68de1446ed..08aaa1195a 100644 --- a/src/os_setup.h +++ b/src/os_setup.h @@ -13,8 +13,8 @@ ** This file contains pre-processor directives related to operating system ** detection and/or setup. */ -#ifndef _OS_SETUP_H_ -#define _OS_SETUP_H_ +#ifndef SQLITE_OS_SETUP_H +#define SQLITE_OS_SETUP_H /* ** Figure out if we are dealing with Unix, Windows, or some other operating @@ -54,4 +54,4 @@ # endif #endif -#endif /* _OS_SETUP_H_ */ +#endif /* SQLITE_OS_SETUP_H */ diff --git a/src/os_win.c b/src/os_win.c index 1c861b0fbd..6224088583 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3675,12 +3675,12 @@ struct winShm { /* ** Apply advisory locks for all n bytes beginning at ofst. */ -#define _SHM_UNLCK 1 -#define _SHM_RDLCK 2 -#define _SHM_WRLCK 3 +#define WINSHM_UNLCK 1 +#define WINSHM_RDLCK 2 +#define WINSHM_WRLCK 3 static int winShmSystemLock( winShmNode *pFile, /* Apply locks to this open shared-memory segment */ - int lockType, /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */ + int lockType, /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */ int ofst, /* Offset to first byte to be locked/unlocked */ int nByte /* Number of bytes to lock or unlock */ ){ @@ -3693,12 +3693,12 @@ static int winShmSystemLock( pFile->hFile.h, lockType, ofst, nByte)); /* Release/Acquire the system-level lock */ - if( lockType==_SHM_UNLCK ){ + if( lockType==WINSHM_UNLCK ){ rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0); }else{ /* Initialize the locking parameters */ DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; - if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; + if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0); } @@ -3710,7 +3710,7 @@ static int winShmSystemLock( } OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n", - pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" : + pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" : "winLockFile", pFile->lastErrno, sqlite3ErrName(rc))); return rc; @@ -3838,7 +3838,7 @@ static int winOpenSharedMemory(winFile *pDbFd){ /* Check to see if another process is holding the dead-man switch. ** If not, truncate the file to zero length. */ - if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ + if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); if( rc!=SQLITE_OK ){ rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(), @@ -3846,8 +3846,8 @@ static int winOpenSharedMemory(winFile *pDbFd){ } } if( rc==SQLITE_OK ){ - winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1); - rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1); + winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1); + rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1); } if( rc ) goto shm_open_err; } @@ -3876,7 +3876,7 @@ static int winOpenSharedMemory(winFile *pDbFd){ /* Jump here on any error */ shm_open_err: - winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1); + winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1); winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */ sqlite3_free(p); sqlite3_free(pNew); @@ -3965,7 +3965,7 @@ static int winShmLock( /* Unlock the system-level locks */ if( (mask & allMask)==0 ){ - rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n); + rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n); }else{ rc = SQLITE_OK; } @@ -3993,7 +3993,7 @@ static int winShmLock( /* Get shared locks at the system level, if necessary */ if( rc==SQLITE_OK ){ if( (allShared & mask)==0 ){ - rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n); + rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n); }else{ rc = SQLITE_OK; } @@ -4018,7 +4018,7 @@ static int winShmLock( ** also mark the local connection as being locked. */ if( rc==SQLITE_OK ){ - rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n); + rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n); if( rc==SQLITE_OK ){ assert( (p->sharedMask & mask)==0 ); p->exclMask |= mask; diff --git a/src/os_win.h b/src/os_win.h index 17d6a2bef4..27714ed079 100644 --- a/src/os_win.h +++ b/src/os_win.h @@ -12,8 +12,8 @@ ** ** This file contains code that is specific to Windows. */ -#ifndef _OS_WIN_H_ -#define _OS_WIN_H_ +#ifndef SQLITE_OS_WIN_H +#define SQLITE_OS_WIN_H /* ** Include the primary Windows SDK header file. @@ -85,4 +85,4 @@ # define SQLITE_OS_WIN_THREADS 0 #endif -#endif /* _OS_WIN_H_ */ +#endif /* SQLITE_OS_WIN_H */ diff --git a/src/pager.h b/src/pager.h index 69d3bb4435..af71d745a8 100644 --- a/src/pager.h +++ b/src/pager.h @@ -14,8 +14,8 @@ ** at a time and provides a journal for rollback. */ -#ifndef _PAGER_H_ -#define _PAGER_H_ +#ifndef SQLITE_PAGER_H +#define SQLITE_PAGER_H /* ** Default maximum size for persistent journal files. A negative @@ -229,4 +229,4 @@ void *sqlite3PagerCodec(DbPage *); # define enable_simulated_io_errors() #endif -#endif /* _PAGER_H_ */ +#endif /* SQLITE_PAGER_H */ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 55f96dd898..12a07a9b4a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -30,8 +30,8 @@ ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. */ -#ifndef _SQLITE3_H_ -#define _SQLITE3_H_ +#ifndef SQLITE3_H +#define SQLITE3_H #include /* Needed for the definition of va_list */ /* @@ -8218,4 +8218,4 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp( #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif -#endif /* _SQLITE3_H_ */ +#endif /* SQLITE3_H */ diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 20a2fcdf02..2d38e87ae7 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -15,8 +15,8 @@ ** as extensions by SQLite should #include this file instead of ** sqlite3.h. */ -#ifndef _SQLITE3EXT_H_ -#define _SQLITE3EXT_H_ +#ifndef SQLITE3EXT_H +#define SQLITE3EXT_H #include "sqlite3.h" typedef struct sqlite3_api_routines sqlite3_api_routines; @@ -543,4 +543,4 @@ struct sqlite3_api_routines { # define SQLITE_EXTENSION_INIT3 /*no-op*/ #endif -#endif /* _SQLITE3EXT_H_ */ +#endif /* SQLITE3EXT_H */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c52cd29927..998a17dac3 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -12,8 +12,8 @@ ** Internal interface definitions for SQLite. ** */ -#ifndef _SQLITEINT_H_ -#define _SQLITEINT_H_ +#ifndef SQLITEINT_H +#define SQLITEINT_H /* Special Comments: ** @@ -4237,4 +4237,4 @@ int sqlite3ThreadJoin(SQLiteThread*, void**); int sqlite3DbstatRegister(sqlite3*); #endif -#endif /* _SQLITEINT_H_ */ +#endif /* SQLITEINT_H */ diff --git a/src/test_intarray.h b/src/test_intarray.h index 84b1f3fe66..cee55b5dae 100644 --- a/src/test_intarray.h +++ b/src/test_intarray.h @@ -75,8 +75,8 @@ ** action to free the intarray objects. */ #include "sqlite3.h" -#ifndef _INTARRAY_H_ -#define _INTARRAY_H_ +#ifndef SQLITE_INTARRAY_H +#define SQLITE_INTARRAY_H /* ** Make sure we can call this stuff from C++. @@ -125,4 +125,4 @@ SQLITE_API int sqlite3_intarray_bind( #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif -#endif /* _INTARRAY_H_ */ +#endif /* SQLITE_INTARRAY_H */ diff --git a/src/test_multiplex.h b/src/test_multiplex.h index d973e4af27..790c778a35 100644 --- a/src/test_multiplex.h +++ b/src/test_multiplex.h @@ -20,8 +20,8 @@ ** */ -#ifndef _TEST_MULTIPLEX_H -#define _TEST_MULTIPLEX_H +#ifndef SQLITE_TEST_MULTIPLEX_H +#define SQLITE_TEST_MULTIPLEX_H /* ** CAPI: File-control Operations Supported by Multiplex VFS @@ -96,4 +96,4 @@ extern int sqlite3_multiplex_shutdown(int eForce); } /* End of the 'extern "C"' block */ #endif -#endif /* _TEST_MULTIPLEX_H */ +#endif /* SQLITE_TEST_MULTIPLEX_H */ diff --git a/src/vdbe.h b/src/vdbe.h index 3db32c8552..a7bc84cea5 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -15,8 +15,8 @@ ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. */ -#ifndef _SQLITE_VDBE_H_ -#define _SQLITE_VDBE_H_ +#ifndef SQLITE_VDBE_H +#define SQLITE_VDBE_H #include /* @@ -309,4 +309,4 @@ void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*); # define sqlite3VdbeScanStatus(a,b,c,d,e) #endif -#endif +#endif /* SQLITE_VDBE_H */ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 61561e9dce..ecb4fc5f06 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -15,8 +15,8 @@ ** 6000 lines long) it was split up into several smaller files and ** this header information was factored out. */ -#ifndef _VDBEINT_H_ -#define _VDBEINT_H_ +#ifndef SQLITE_VDBEINT_H +#define SQLITE_VDBEINT_H /* ** The maximum number of times that a statement will try to reparse @@ -558,4 +558,4 @@ int sqlite3VdbeMemHandleBom(Mem *pMem); #define ExpandBlob(P) SQLITE_OK #endif -#endif /* !defined(_VDBEINT_H_) */ +#endif /* !defined(SQLITE_VDBEINT_H) */ diff --git a/src/wal.h b/src/wal.h index 97e6ab4f10..6048e7985c 100644 --- a/src/wal.h +++ b/src/wal.h @@ -14,8 +14,8 @@ ** the implementation of each function in log.c for further details. */ -#ifndef _WAL_H_ -#define _WAL_H_ +#ifndef SQLITE_WAL_H +#define SQLITE_WAL_H #include "sqliteInt.h" @@ -143,4 +143,4 @@ int sqlite3WalFramesize(Wal *pWal); sqlite3_file *sqlite3WalFile(Wal *pWal); #endif /* ifndef SQLITE_OMIT_WAL */ -#endif /* _WAL_H_ */ +#endif /* SQLITE_WAL_H */ From 11499f0ab434e44e00621242bd64a97eaedee800 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Jul 2016 16:38:25 +0000 Subject: [PATCH 183/302] Fix compiler warnings on windows. FossilOrigin-Name: 8b22f777a11438ab0baadc7d9e471f415b734d1f --- ext/misc/carray.c | 4 ++-- ext/misc/csv.c | 6 +++--- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test_bestindex.c | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ext/misc/carray.c b/ext/misc/carray.c index 70d226a85f..b0c8be77d3 100644 --- a/ext/misc/carray.c +++ b/ext/misc/carray.c @@ -303,7 +303,7 @@ static int carrayBestIndex( pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2; pIdxInfo->aConstraintUsage[cntIdx].omit = 1; pIdxInfo->estimatedCost = (double)1; - pIdxInfo->estimatedRows = (double)100; + pIdxInfo->estimatedRows = 100; pIdxInfo->idxNum = 2; if( ctypeIdx>=0 ){ pIdxInfo->aConstraintUsage[ctypeIdx].argvIndex = 3; @@ -312,7 +312,7 @@ static int carrayBestIndex( } }else{ pIdxInfo->estimatedCost = (double)2147483647; - pIdxInfo->estimatedRows = (double)2147483647; + pIdxInfo->estimatedRows = 2147483647; pIdxInfo->idxNum = 0; } return SQLITE_OK; diff --git a/ext/misc/csv.c b/ext/misc/csv.c index c0d8ecd3fc..3a7e32d311 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -375,7 +375,7 @@ static int csv_string_parameter( char **pzVal /* Write the dequoted string value here */ ){ const char *zValue; - zValue = csv_parameter(zParam,strlen(zParam),zArg); + zValue = csv_parameter(zParam,(int)strlen(zParam),zArg); if( zValue==0 ) return 0; p->zErr[0] = 0; if( *pzVal ){ @@ -616,7 +616,7 @@ static int csvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ CsvCursor *pCur; size_t nByte; nByte = sizeof(*pCur) + (sizeof(char*)+sizeof(int))*pTab->nCol; - pCur = sqlite3_malloc( nByte ); + pCur = sqlite3_malloc64( nByte ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, nByte); pCur->azVal = (char**)&pCur[1]; @@ -647,7 +647,7 @@ static int csvtabNext(sqlite3_vtab_cursor *cur){ } if( inCol ){ if( pCur->aLen[i] < pCur->rdr.n+1 ){ - char *zNew = sqlite3_realloc(pCur->azVal[i], pCur->rdr.n+1); + char *zNew = sqlite3_realloc64(pCur->azVal[i], pCur->rdr.n+1); if( zNew==0 ){ csv_errmsg(&pCur->rdr, "out of memory"); csv_xfer_error(pTab, &pCur->rdr); diff --git a/manifest b/manifest index eef481b87d..3956234549 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\svarious\sinternal\s#defines\sto\sconform\sto\snew\sC-language\snaming\srestrictions,\nspecifically\sthat\sprivate-use\smacros\snames\smust\snot\sbegin\swith\s"_". -D 2016-07-09T16:14:45.037 +C Fix\scompiler\swarnings\son\swindows. +D 2016-07-09T16:38:25.217 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -204,10 +204,10 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/carray.c f1947c7d5bbce17f8244c9a05baae11d5d68467e +F ext/misc/carray.c 29f3b2dbb93b93cedcc571660203d1e24d921bd3 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c f01126ba170fd4ef7c752b156568a80c912d4441 +F ext/misc/csv.c b92692b057707f5b7bb91feaedde790b2e38304e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -405,7 +405,7 @@ F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 F src/test_backup.c 2e6e6a081870150f20c526a2e9d0d29cda47d803 -F src/test_bestindex.c 29af3cc3b963ffe5760c85d142b9b3e5302c1e3d +F src/test_bestindex.c f9e6807c52aa532e4775321ce3ed8e47c907ed45 F src/test_blob.c b2551a9b5573232db5f66f292307c37067937239 F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c 7003f6f35134de6f19c6588f44783e43390ea277 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b5f32a896d0e4010ec67fcf1d635bb9aa797d3c2 -R 1420ae412f251bd23536749aacd8c4fa +P 5471aca0158851d3fb0a2517306917536deb38bb +R 51759f55d04de93087e3d229894a3277 U drh -Z e116500fbf8eef00f67c7f388726b705 +Z 7d1dfc3636ab19ed9a6789ae76c95a5f diff --git a/manifest.uuid b/manifest.uuid index a0cf804e45..3c6dd362dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5471aca0158851d3fb0a2517306917536deb38bb \ No newline at end of file +8b22f777a11438ab0baadc7d9e471f415b734d1f \ No newline at end of file diff --git a/src/test_bestindex.c b/src/test_bestindex.c index a955c2782c..f6f9d3eaf8 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -179,8 +179,8 @@ static int tclConnect( return SQLITE_ERROR; } - zCmd = sqlite3_malloc(strlen(argv[3])+1); - pTab = (tcl_vtab*)sqlite3_malloc(sizeof(tcl_vtab)); + zCmd = sqlite3_malloc64(strlen(argv[3])+1); + pTab = (tcl_vtab*)sqlite3_malloc64(sizeof(tcl_vtab)); if( zCmd && pTab ){ memcpy(zCmd, argv[3], strlen(argv[3])+1); tclDequote(zCmd); From a912348a196d1dc895cf0fa9c5f6319883d3dfe0 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Jul 2016 17:15:05 +0000 Subject: [PATCH 184/302] Fix a compiler warning in test code - in the int64array_addr TCL command. FossilOrigin-Name: 29fb988f1afc3fe623097acee1a5d08bf8386626 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test1.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 3956234549..f7b68ae764 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarnings\son\swindows. -D 2016-07-09T16:38:25.217 +C Fix\sa\scompiler\swarning\sin\stest\scode\s-\sin\sthe\sint64array_addr\sTCL\scommand. +D 2016-07-09T17:15:05.420 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 -F src/test1.c 08faa045c45b1d3f62c28c93cae955f518317f68 +F src/test1.c 640f862c490c8eee09a9d02d0d128c6a8a75336d F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5471aca0158851d3fb0a2517306917536deb38bb -R 51759f55d04de93087e3d229894a3277 +P 8b22f777a11438ab0baadc7d9e471f415b734d1f +R 8809172c97ecd2789d873e485f1080c5 U drh -Z 7d1dfc3636ab19ed9a6789ae76c95a5f +Z b4d622f88577c8bb575918451a798624 diff --git a/manifest.uuid b/manifest.uuid index 3c6dd362dc..0979534540 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b22f777a11438ab0baadc7d9e471f415b734d1f \ No newline at end of file +29fb988f1afc3fe623097acee1a5d08bf8386626 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index d4a5cfc3ce..5ce818bf74 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3299,11 +3299,13 @@ static int test_int64array_addr( p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); if( p==0 ) return TCL_ERROR; for(i=0; i Date: Sat, 9 Jul 2016 17:47:01 +0000 Subject: [PATCH 185/302] Add the "#/value-list/" style of results for approximate value matching in the do_test command of the test infrastructure. Use this new result style to make the SQLITE_DBSTATUS_CACHE_SIZE_SHARED tests cross-platform. FossilOrigin-Name: c869bf34a8ee42ac6542862e59c7a4b89b042f79 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/dbstatus.test | 8 ++------ test/tester.tcl | 28 +++++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index f7b68ae764..679ecd4e0c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompiler\swarning\sin\stest\scode\s-\sin\sthe\sint64array_addr\sTCL\scommand. -D 2016-07-09T17:15:05.420 +C Add\sthe\s"#/value-list/"\sstyle\sof\sresults\sfor\sapproximate\svalue\smatching\nin\sthe\sdo_test\scommand\sof\sthe\stest\sinfrastructure.\s\sUse\sthis\snew\sresult\sstyle\nto\smake\sthe\sSQLITE_DBSTATUS_CACHE_SIZE_SHARED\stests\scross-platform. +D 2016-07-09T17:47:01.013 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 254427f026b55ab6eba99bd8493f4edbc370bb13 +F test/dbstatus.test 85833ba5bc95262749d080dcd40af87072ea8d5b F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1128,7 +1128,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl 3ace46dee55f07e28a1e3ab03258b929fefcee5b +F test/tester.tcl a52b5be1bb586afa1c8bcdcd4b86588645e1ae52 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b22f777a11438ab0baadc7d9e471f415b734d1f -R 8809172c97ecd2789d873e485f1080c5 +P 29fb988f1afc3fe623097acee1a5d08bf8386626 +R 767a7d8abd9b9525d1b45069b4c3dba2 U drh -Z b4d622f88577c8bb575918451a798624 +Z df36acb2648e26f22b53c52b73476f6c diff --git a/manifest.uuid b/manifest.uuid index 0979534540..d451076edf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -29fb988f1afc3fe623097acee1a5d08bf8386626 \ No newline at end of file +c869bf34a8ee42ac6542862e59c7a4b89b042f79 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index 7bc44353b0..00c5deabd5 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -69,16 +69,12 @@ ifcapable stat4||stat3 { set STAT3 0 } -ifcapable malloc_usable_size { - finish_test - return -} - #--------------------------------------------------------------------------- # Run the dbstatus-2 and dbstatus-3 tests with several of different # lookaside buffer sizes. # foreach ::lookaside_buffer_size {0 64 120} { + ifcapable malloc_usable_size break # Do not run any of these tests if there is SQL configured to run # as part of the [sqlite3] command. This prevents the script from @@ -388,7 +384,7 @@ ifcapable shared_cache { set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] set cu [lindex $cu 1] set pcu [lindex $pcu 1] - uplevel [list do_test $tn [list list $cu $pcu] [list {*}$res]] + uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"] } reset_db sqlite3 db file:test.db?cache=shared diff --git a/test/tester.tcl b/test/tester.tcl index 9fbc7b2569..3f1edc32ae 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -720,6 +720,17 @@ proc puts {args} { uplevel puts_override $args } # Invoke the do_test procedure to run a single test # +# The $expected parameter is the expected result. The result is the return +# value from the last TCL command in $cmd. +# +# Normally, $expected must match exactly. But if $expected is of the form +# "/regexp/" then regular expression matching is used. If $expected is +# "~/regexp/" then the regular expression must NOT match. If $expected is +# of the form "#/value-list/" then each term in value-list must be numeric +# and must approximately match the corresponding numeric term in $result. +# Values must match within 10%. Or if the $expected term is A..B then the +# $result term must be in between A and B. +# proc do_test {name cmd expected} { global argv cmdlinearg @@ -753,7 +764,7 @@ proc do_test {name cmd expected} { output2 "\nError: $result" fail_test $name } else { - if {[regexp {^~?/.*/$} $expected]} { + if {[regexp {^[~#]?/.*/$} $expected]} { # "expected" is of the form "/PATTERN/" then the result if correct if # regular expression PATTERN matches the result. "~/PATTERN/" means # the regular expression must not match. @@ -767,6 +778,21 @@ proc do_test {name cmd expected} { set ok [regexp $re $result] } set ok [expr {!$ok}] + } elseif {[string index $expected 0]=="#"} { + # Numeric range value comparison. Each term of the $result is matched + # against one term of $expect. Both $result and $expected terms must be + # numeric. The values must match within 10%. Or if $expected is of the + # form A..B then the $result term must be between A and B. + set e2 [string range $expected 2 end-1] + foreach i $result j $e2 { + if {[regexp {^(-?\d+)\.\.(-?\d)$} $j all A B]} { + set ok [expr {$i+0>=$A && $i+0<=$B}] + } else { + set ok [expr {$i+0>=0.9*$j && $i+0<=1.1*$j}] + } + if {!$ok} break + } + if {$ok && [llength $result]!=[llength $e2]} {set ok 0} } else { set re [string range $expected 1 end-1] if {[string index $re 0]=="*"} { From e234cfd11f76cff3e7846c56eb1ddaeda3b33ac2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 10 Jul 2016 19:35:10 +0000 Subject: [PATCH 186/302] Fix typos in comments. No changes to code. FossilOrigin-Name: 77c692a6704cd877ba35d0afb774ab9b46364d59 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 2 +- src/wherecode.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 679ecd4e0c..ad5811183a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"#/value-list/"\sstyle\sof\sresults\sfor\sapproximate\svalue\smatching\nin\sthe\sdo_test\scommand\sof\sthe\stest\sinfrastructure.\s\sUse\sthis\snew\sresult\sstyle\nto\smake\sthe\sSQLITE_DBSTATUS_CACHE_SIZE_SHARED\stests\scross-platform. -D 2016-07-09T17:47:01.013 +C Fix\stypos\sin\scomments.\s\sNo\schanges\sto\scode. +D 2016-07-10T19:35:10.288 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -337,7 +337,7 @@ F src/ctime.c 61949e83c4c36e37195a8398ebc752780b534d95 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c 523a5b1db2b6d88c6eefb224877bf635a3bcfc92 +F src/expr.c 21b153e1046c624e9387a17d3261f69b461e700c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 @@ -465,7 +465,7 @@ F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 -F src/wherecode.c e20cb381ff621e56a4684c71e31999aca2547ca6 +F src/wherecode.c 11e38f5e2dc5c007143fbf7fdb14bca40a6b74ad F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 29fb988f1afc3fe623097acee1a5d08bf8386626 -R 767a7d8abd9b9525d1b45069b4c3dba2 -U drh -Z df36acb2648e26f22b53c52b73476f6c +P c869bf34a8ee42ac6542862e59c7a4b89b042f79 +R e7b82c5fd816fe8e3d4680426d718eac +U mistachkin +Z bc88f0dbd9511ddf1cf929c200555b61 diff --git a/manifest.uuid b/manifest.uuid index d451076edf..d8458f4ae7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c869bf34a8ee42ac6542862e59c7a4b89b042f79 \ No newline at end of file +77c692a6704cd877ba35d0afb774ab9b46364d59 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index ce3a476561..ea52d66253 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1835,7 +1835,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFlags, int *prRhsHasNull){ /* If no preexisting index is available for the IN clause ** and IN_INDEX_NOOP is an allowed reply ** and the RHS of the IN operator is a list, not a subquery - ** and the RHS is not contant or has two or fewer terms, + ** and the RHS is not constant or has two or fewer terms, ** then it is not worth creating an ephemeral table to evaluate ** the IN operator so return IN_INDEX_NOOP. */ diff --git a/src/wherecode.c b/src/wherecode.c index a017b40c7d..0b307761be 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -569,7 +569,7 @@ static int codeAllEqualityTerms( ** expression: "x>='ABC' AND x<'abd'". But this requires that the range ** scan loop run twice, once for strings and a second time for BLOBs. ** The OP_String opcodes on the second pass convert the upper and lower -** bound string contants to blobs. This routine makes the necessary changes +** bound string constants to blobs. This routine makes the necessary changes ** to the OP_String opcodes for that to happen. ** ** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then From dd703e22a5a0a7314dd75e32b816f51e9f586155 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jul 2016 19:54:49 +0000 Subject: [PATCH 187/302] Fix the error counter reset in Lemon generated parsers. This has no effect on SQLite. FossilOrigin-Name: 3ef93950d30b34d852d6bbc101d433a04112868a --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lempar.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index ad5811183a..0e13a77452 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\scomments.\s\sNo\schanges\sto\scode. -D 2016-07-10T19:35:10.288 +C Fix\sthe\serror\scounter\sreset\sin\sLemon\sgenerated\sparsers.\s\sThis\shas\sno\seffect\non\sSQLite. +D 2016-07-12T19:54:49.418 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1433,7 +1433,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 77c685a612526aae9c0d9b3175176e5bcd3854d0 +F tool/lempar.c 57ffa9852901f6abc45981f0d882f31d1ccb06c0 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c869bf34a8ee42ac6542862e59c7a4b89b042f79 -R e7b82c5fd816fe8e3d4680426d718eac -U mistachkin -Z bc88f0dbd9511ddf1cf929c200555b61 +P 77c692a6704cd877ba35d0afb774ab9b46364d59 +R cb6d43e13605575cc663251c668c01f6 +U drh +Z 3209e04e0b1433ba8d0db8fc637ac637 diff --git a/manifest.uuid b/manifest.uuid index d8458f4ae7..bd8874819e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -77c692a6704cd877ba35d0afb774ab9b46364d59 \ No newline at end of file +3ef93950d30b34d852d6bbc101d433a04112868a \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 5232565f87..e0d0e88565 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -755,6 +755,9 @@ static void yy_accept( if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } +#endif +#ifndef YYNOERRORRECOVERY + yypParser->yyerrcnt = -1; #endif assert( yypParser->yytos==yypParser->yystack ); /* Here code is inserted which will be executed whenever the @@ -898,9 +901,6 @@ void Parse( ** they intend to abandon the parse upon the first syntax error seen. */ yy_syntax_error(yypParser,yymajor, yyminor); -#ifndef YYNOERRORRECOVERY - yypParser->yyerrcnt = -1; -#endif yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yymajor = YYNOCODE; From ce0442edf35bb166db7156bbe71da22e189dce78 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 00:55:28 +0000 Subject: [PATCH 188/302] Fix header comments and remove an unnecessary version restriction from the carray() table-valued function implementation. FossilOrigin-Name: 021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 --- ext/misc/carray.c | 9 ++------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ext/misc/carray.c b/ext/misc/carray.c index b0c8be77d3..6fdbecf575 100644 --- a/ext/misc/carray.c +++ b/ext/misc/carray.c @@ -14,7 +14,7 @@ ** returns the values in a C-language array. ** Examples: ** -** SELECT * FROM array($ptr,5) +** SELECT * FROM carray($ptr,5) ** ** The query above returns 5 integers contained in a C-language array ** at the address $ptr. $ptr is a pointer to the array of integers that @@ -24,7 +24,7 @@ ** the C-language array. Allowed values of the third parameter are ** 'int32', 'int64', 'double', 'char*'. Example: ** -** SELECT * FROM array($ptr,10,'char*'); +** SELECT * FROM carray($ptr,10,'char*'); ** ** HOW IT WORKS ** @@ -358,11 +358,6 @@ int sqlite3_carray_init( int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); #ifndef SQLITE_OMIT_VIRTUALTABLE - if( sqlite3_libversion_number()<3008012 ){ - *pzErrMsg = sqlite3_mprintf( - "carray() requires SQLite 3.8.12 or later"); - return SQLITE_ERROR; - } rc = sqlite3_create_module(db, "carray", &carrayModule, 0); #endif return rc; diff --git a/manifest b/manifest index 0e13a77452..03d606189a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\serror\scounter\sreset\sin\sLemon\sgenerated\sparsers.\s\sThis\shas\sno\seffect\non\sSQLite. -D 2016-07-12T19:54:49.418 +C Fix\sheader\scomments\sand\sremove\san\sunnecessary\sversion\srestriction\sfrom\sthe\ncarray()\stable-valued\sfunction\simplementation. +D 2016-07-13T00:55:28.831 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -204,7 +204,7 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/carray.c 29f3b2dbb93b93cedcc571660203d1e24d921bd3 +F ext/misc/carray.c 214c9e9d909ceaae3b2f5f917cc2204deca85cc6 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c b92692b057707f5b7bb91feaedde790b2e38304e @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 77c692a6704cd877ba35d0afb774ab9b46364d59 -R cb6d43e13605575cc663251c668c01f6 +P 3ef93950d30b34d852d6bbc101d433a04112868a +R 51e8986673c5be3a3aaceb79764f3cbc U drh -Z 3209e04e0b1433ba8d0db8fc637ac637 +Z 12b2ac3f05d95585a2345745d9c04f9c diff --git a/manifest.uuid b/manifest.uuid index bd8874819e..f56a99a1c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3ef93950d30b34d852d6bbc101d433a04112868a \ No newline at end of file +021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 \ No newline at end of file From a0620acc4a2da6aa017e3ac8b017b63d8a7d01f7 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 13:05:13 +0000 Subject: [PATCH 189/302] Fix harmless compiler warnings in shell.c for NetBSD. FossilOrigin-Name: 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 03d606189a..c9585f19cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sheader\scomments\sand\sremove\san\sunnecessary\sversion\srestriction\sfrom\sthe\ncarray()\stable-valued\sfunction\simplementation. -D 2016-07-13T00:55:28.831 +C Fix\sharmless\scompiler\swarnings\sin\sshell.c\sfor\sNetBSD. +D 2016-07-13T13:05:13.449 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 -F src/shell.c 14ff7f660530a52b117d110ba3390b7b2eb719b6 +F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 F src/sqlite.h.in b9ba728c1083b7a8ab5f6a628b25cd2a00325fbf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 2a170163d121095c6ab1ef05ed0413722f391d01 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3ef93950d30b34d852d6bbc101d433a04112868a -R 51e8986673c5be3a3aaceb79764f3cbc +P 021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 +R f2c7097376b33c065f9732879605d098 U drh -Z 12b2ac3f05d95585a2345745d9c04f9c +Z e160e6d632f23e86ebc551e9950cc211 diff --git a/manifest.uuid b/manifest.uuid index f56a99a1c0..6b7a74bfc9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 \ No newline at end of file +824b39e54fb9ba562be4d92cc9a54aee1cdf84cb \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 5148177372..874782c5f1 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2946,10 +2946,10 @@ static int db_int(ShellState *p, const char *zSql){ /* ** Convert a 2-byte or 4-byte big-endian integer into a native integer */ -unsigned int get2byteInt(unsigned char *a){ +static unsigned int get2byteInt(unsigned char *a){ return (a[0]<<8) + a[1]; } -unsigned int get4byteInt(unsigned char *a){ +static unsigned int get4byteInt(unsigned char *a){ return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3]; } From ed916ba02514b2714e61e91eb478e4d2d6f243df Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 21:30:03 +0000 Subject: [PATCH 190/302] Interface design for a new sqlite3_trace_v2() method that supersedes sqlite3_trace() and sqlite3_profile(). FossilOrigin-Name: 0c569f759f6c4701321d7fea5e7ccb371743bb6b --- manifest | 15 ++++--- manifest.uuid | 2 +- src/sqlite.h.in | 108 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c9585f19cd..91d158c9f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sshell.c\sfor\sNetBSD. -D 2016-07-13T13:05:13.449 +C Interface\sdesign\sfor\sa\snew\ssqlite3_trace_v2()\smethod\sthat\ssupersedes\nsqlite3_trace()\sand\ssqlite3_profile(). +D 2016-07-13T21:30:03.340 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in b9ba728c1083b7a8ab5f6a628b25cd2a00325fbf +F src/sqlite.h.in 63774172623fe82336ad0757f373343a87bd0b36 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 2a170163d121095c6ab1ef05ed0413722f391d01 F src/sqliteInt.h dcf43b8abc5605b70f54ba80f42b6ad054b8ba95 @@ -1505,7 +1505,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 -R f2c7097376b33c065f9732879605d098 +P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb +R eb1a84643390ea5aba50eced8805fb76 +T *branch * sqlite3_trace_v2 +T *sym-sqlite3_trace_v2 * +T -sym-trunk * U drh -Z e160e6d632f23e86ebc551e9950cc211 +Z 6025cf3e994164a26dea4fb0e96d3f78 diff --git a/manifest.uuid b/manifest.uuid index 6b7a74bfc9..42e31abf53 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -824b39e54fb9ba562be4d92cc9a54aee1cdf84cb \ No newline at end of file +0c569f759f6c4701321d7fea5e7ccb371743bb6b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 12a07a9b4a..a3b8f31f07 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2755,6 +2755,9 @@ int sqlite3_set_authorizer( ** CAPI3REF: Tracing And Profiling Functions ** METHOD: sqlite3 ** +** These routines are deprecated. Use the [sqlite3_trace_v2()] interface +** instead of the routines described here. +** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** @@ -2780,10 +2783,111 @@ int sqlite3_set_authorizer( ** sqlite3_profile() function is considered experimental and is ** subject to change in future versions of SQLite. */ -void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); -SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, +SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*, + void(*xTrace)(void*,const char*), void*); +SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); +/* +** CAPI3REF: SQL Trace Event Codes +** KEYWORDS: SQLITE_TRACE +** +** These constants identify classes of events that can be monitored +** using the [sqlite3_trace_v2()] tracing logic. The third argument +** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of +** the following constants. The first argument to the trace callback +** is one of the following constants. +** +** New tracing constants may be added in future releases. +** +** A trace callback has four arguments: xCallback(T,C,P,X). +** The T argument is one of the integer type codes above. +** The C argument is a copy of the context pointer passed in as the +** fourth argument to [sqlite3_trace_v2()]. +** The P argument is a pointer whose meaning depends on T. +** The X argument is an unsigned 64-bit integer whose meaning also +** depends on T. +** +**
+** [[SQLITE_TRACE_SQL]]
SQLITE_TRACE_SQL
+**
An SQLITE_TRACE_SQL callback provides the same functionality +** as the legacy [sqlite3_trace()] callback. +** The P argument is a pointer to the constant UTF-8 string that is text +** describing an SQL statement that is starting to run with all +** [bound parameter] expanded. The X argument is unused. The size +** of the expansion of [bound parameters] is limited by the +** [SQLITE_TRACE_SIZE_LIMIT] compile-time option. +** +** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
+**
An SQLITE_TRACE_STMT callback is invoked on the same occasions +** as SQLITE_TRACE_SQL. The difference is that the P argument is a +** pointer to the [prepared statement] rather than an SQL string. +** The X argument is unused. +** +** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
+**
An SQLITE_TRACE_PROFILE callback provides approximately the same +** information as is provided by the [sqlite3_profile()] callback. +** The P argument is a pointer to the [prepared statement] and the +** X argument is an estimate of the number of nanosecond for which +** the prepared statement ran. The SQLITE_TRACE_PROFILE callback is +** invoked when the statement finishes. +** +** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
+**
An SQLITE_TRACE_ROW callback is invoked whenever a prepared +** statement generates a single row of result. +** The P argument is a pointer to the [prepared statement] and the +** X argument is unused. +** +** [[SQLITE_TRACE_CLOSE]]
SQLITE_TRACE_CLOSE
+**
An SQLITE_TRACE_CLOSE callback is invoked when a database +** connection closes. +** The P argument is a pointer to the [database connection] object +** and the X argument is unused. +**
+*/ +#define SQLITE_TRACE_SQL 0x0001 +#define SQLITE_TRACE_STMT 0x0002 +#define SQLITE_TRACE_PROFILE 0x0004 +#define SQLITE_TRACE_ROW 0x0008 +#define SQLITE_TRACE_CLOSE 0x0010 + +/* +** CAPI3REF: SQL Trace Hook +** METHOD: sqlite3 +** +** The sqlite3_trace_v2(D,X,M,P) interface registers a trace callback +** function X against [database connection] D, using property mask M +** and context pointer P. If the X callback is +** NULL or if the M mask is zero, then tracing is disabled. The +** M argument must be one or more of the [SQLITE_TRACE] +** constants. +** +** Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides +** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). +** +** The X callback is invoked whenever any of the events identified by +** mask M occur. The integer return value from the callback is currently +** ignored, though this may change in future releases. Callback +** implementations should return zero to ensure future compatibility. +** +** A trace callback is invoked with four arguments: callback(T,C,P,X). +** The T argument is one of the [SQLITE_TRACE] +** constants to indicate why the callback was invoked. +** The C argument is a copy of the context pointer. +** The P and X arguments are a pointer and an unsigned 64-bit integer +** whose meanings depend on T. +** +** The sqlite3_trace_v2() interface is intended to replace the legacy +** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which +** are deprecated. +*/ +int sqlite3_trace_v2( + sqlite3*, + int(*xCallback)(unsigned,void*,void*,sqlite3_uint64), + unsigned uMask, + void *pCtx +); + /* ** CAPI3REF: Query Progress Callbacks ** METHOD: sqlite3 From 3d2a529df6ce9cc3e9a11e5a2214eabfb35e0b77 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 22:55:01 +0000 Subject: [PATCH 191/302] First cut at implementing the new sqlite3_trace_v2() interface. FossilOrigin-Name: cb0062feb018f52689938a58cb76886d431c33f0 --- manifest | 27 ++++++++++++--------------- manifest.uuid | 2 +- src/main.c | 31 ++++++++++++++++++++++++++++++- src/sqlite.h.in | 6 +++--- src/sqlite3ext.h | 5 +++++ src/sqliteInt.h | 12 +++++++++++- src/vacuum.c | 6 +++--- src/vdbe.c | 26 ++++++++++++++++++++++---- src/vdbeapi.c | 14 +++++++++++--- 9 files changed, 98 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 91d158c9f4..bfca64b0a8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Interface\sdesign\sfor\sa\snew\ssqlite3_trace_v2()\smethod\sthat\ssupersedes\nsqlite3_trace()\sand\ssqlite3_profile(). -D 2016-07-13T21:30:03.340 +C First\scut\sat\simplementing\sthe\snew\ssqlite3_trace_v2()\sinterface. +D 2016-07-13T22:55:01.845 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c 405d13e3a4f7c5add9fb27702ae70ed0a6e32cca +F src/main.c 05658dfa4be5704e4d6542fe0f2452be5b9df09e F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -385,10 +385,10 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 63774172623fe82336ad0757f373343a87bd0b36 +F src/sqlite.h.in 0fde7379e6a9d900802976de51cb1256f0fdac59 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 2a170163d121095c6ab1ef05ed0413722f391d01 -F src/sqliteInt.h dcf43b8abc5605b70f54ba80f42b6ad054b8ba95 +F src/sqlite3ext.h 3875aa5b3c4bb5d8d14c387628c5fe852b2846bf +F src/sqliteInt.h 5b8a3e1dc92e7459b69954cce9f653bd2391deb8 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -448,11 +448,11 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c feb1eabb20987983d9350cad98299b21fa811f52 -F src/vdbe.c 22b46c3b725e950e9f2760e2d76953d592600ad4 +F src/vacuum.c 459ff7cb3c589451111ff2d3b6eb31be83a46a54 +F src/vdbe.c c6bb62aa69a6faf1197eee36336c6de99bb4733f F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d -F src/vdbeapi.c 02bcbc2ca5d2004b029088b05b468b394881e103 +F src/vdbeapi.c a466743c8e6de100c11e044b693c9469d2cf598a F src/vdbeaux.c c90275b0e55a2b32c03dc09314194fe46f2429d8 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 @@ -1505,10 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb -R eb1a84643390ea5aba50eced8805fb76 -T *branch * sqlite3_trace_v2 -T *sym-sqlite3_trace_v2 * -T -sym-trunk * +P 0c569f759f6c4701321d7fea5e7ccb371743bb6b +R eeeb6e6908fe861e59edc045bbf20a73 U drh -Z 6025cf3e994164a26dea4fb0e96d3f78 +Z 1f8408ee484498502acfe0ea8cf0fbae diff --git a/manifest.uuid b/manifest.uuid index 42e31abf53..7db2593897 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c569f759f6c4701321d7fea5e7ccb371743bb6b \ No newline at end of file +cb0062feb018f52689938a58cb76886d431c33f0 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 30370f8cab..d2f8bf7996 100644 --- a/src/main.c +++ b/src/main.c @@ -1033,6 +1033,9 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){ return SQLITE_MISUSE_BKPT; } sqlite3_mutex_enter(db->mutex); + if( db->mTrace & SQLITE_TRACE_CLOSE ){ + db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0); + } /* Force xDisconnect calls on all virtual tables */ disconnectAllVtab(db); @@ -1801,6 +1804,7 @@ int sqlite3_overload_function( ** trace is a pointer to a function that is invoked at the start of each ** SQL statement. */ +#ifndef SQLITE_OMIT_DEPRECATED void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ void *pOld; @@ -1812,11 +1816,36 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ #endif sqlite3_mutex_enter(db->mutex); pOld = db->pTraceArg; - db->xTrace = xTrace; + db->mTrace = SQLITE_TRACE_LEGACY; + db->xTrace = (int(*)(u32,void*,void*,i64))xTrace; db->pTraceArg = pArg; sqlite3_mutex_leave(db->mutex); return pOld; } +#endif /* SQLITE_OMIT_DEPRECATED */ + +/* Register a trace callback using the version-2 interface. +*/ +int sqlite3_trace_v2( + sqlite3 *db, /* Trace this connection */ + int(*xTrace)(unsigned,void*,void*,sqlite3_int64), /* Callback to invoke */ + unsigned mTrace, /* OPs to be traced */ + void *pArg /* Context */ +){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + (void)SQLITE_MISUSE_BKPT; + return 0; + } +#endif + sqlite3_mutex_enter(db->mutex); + db->mTrace = mTrace; + db->xTrace = xTrace; + db->pTraceArg = pArg; + sqlite3_mutex_leave(db->mutex); + return SQLITE_OK; +} + /* ** Register a profile function. The pArg from the previously registered ** profile function is returned. diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a3b8f31f07..07d85b254d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2805,7 +2805,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The C argument is a copy of the context pointer passed in as the ** fourth argument to [sqlite3_trace_v2()]. ** The P argument is a pointer whose meaning depends on T. -** The X argument is an unsigned 64-bit integer whose meaning also +** The X argument is an 64-bit integer whose meaning also ** depends on T. ** **
@@ -2874,7 +2874,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The T argument is one of the [SQLITE_TRACE] ** constants to indicate why the callback was invoked. ** The C argument is a copy of the context pointer. -** The P and X arguments are a pointer and an unsigned 64-bit integer +** The P and X arguments are a pointer and a 64-bit integer ** whose meanings depend on T. ** ** The sqlite3_trace_v2() interface is intended to replace the legacy @@ -2883,7 +2883,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, */ int sqlite3_trace_v2( sqlite3*, - int(*xCallback)(unsigned,void*,void*,sqlite3_uint64), + int(*xCallback)(unsigned,void*,void*,sqlite3_int64), unsigned uMask, void *pCtx ); diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 2d38e87ae7..8bcfc68521 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -281,6 +281,9 @@ struct sqlite3_api_routines { int (*db_cacheflush)(sqlite3*); /* Version 3.12.0 and later */ int (*system_errno)(sqlite3*); + /* Version 3.14.0 and later */ + int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,sqlite3_uint64), + unsigned,void*); }; /* @@ -526,6 +529,8 @@ struct sqlite3_api_routines { #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush /* Version 3.12.0 and later */ #define sqlite3_system_errno sqlite3_api->system_errno +/* Version 3.14.0 and later */ +#define sqlite3_trace_v2 sqlite3_api->trace_v2 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 998a17dac3..225d7b2872 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1241,6 +1241,15 @@ void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**); const char*); #endif +#ifndef SQLITE_OMIT_DEPRECATED +/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing +** in the style of sqlite3_trace() +*/ +#define SQLITE_TRACE_LEGACY 0x80 +#else +#define SQLITE_TRACE_LEGACY 0 +#endif /* SQLITE_OMIT_DEPRECATED */ + /* ** Each database connection is an instance of the following structure. @@ -1270,6 +1279,7 @@ struct sqlite3 { u8 suppressErr; /* Do not issue error messages if true */ u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ + u8 mTrace; /* zero or more SQLITE_TRACE flags */ int nextPagesize; /* Pagesize after VACUUM if >0 */ u32 magic; /* Magic number for detect library misuse */ int nChange; /* Value returned by sqlite3_changes() */ @@ -1290,7 +1300,7 @@ struct sqlite3 { int nVDestroy; /* Number of active OP_VDestroy operations */ int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared library handles */ - void (*xTrace)(void*,const char*); /* Trace function */ + int (*xTrace)(u32,void*,void*,i64); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ diff --git a/src/vacuum.c b/src/vacuum.c index bc7b5831b6..93b438fb1a 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -121,7 +121,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ int saved_flags; /* Saved value of the db->flags */ int saved_nChange; /* Saved value of db->nChange */ int saved_nTotalChange; /* Saved value of db->nTotalChange */ - void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ + u8 saved_mTrace; /* Saved trace settings */ Db *pDb = 0; /* Database to detach at end of vacuum */ int isMemDb; /* True if vacuuming a :memory: database */ int nRes; /* Bytes of reserved space at the end of each page */ @@ -142,7 +142,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ saved_flags = db->flags; saved_nChange = db->nChange; saved_nTotalChange = db->nTotalChange; - saved_xTrace = db->xTrace; + saved_mTrace = db->mTrace; db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); db->xTrace = 0; @@ -345,7 +345,7 @@ end_of_vacuum: db->flags = saved_flags; db->nChange = saved_nChange; db->nTotalChange = saved_nTotalChange; - db->xTrace = saved_xTrace; + db->mTrace = saved_mTrace; sqlite3BtreeSetPageSize(pMain, -1, -1, 1); /* Currently there is an SQL level transaction open on the vacuum diff --git a/src/vdbe.c b/src/vdbe.c index 6adbcbbec1..7883536028 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1383,6 +1383,10 @@ case OP_ResultRow: { } if( db->mallocFailed ) goto no_mem; + if( db->mTrace & SQLITE_TRACE_ROW ){ + db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0); + } + /* Return SQLITE_ROW */ p->pc = (int)(pOp - aOp) + 1; @@ -6781,13 +6785,27 @@ case OP_Init: { /* jump */ char *z; #ifndef SQLITE_OMIT_TRACE - if( db->xTrace + if( (db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){ - z = sqlite3VdbeExpandSql(p, zTrace); - db->xTrace(db->pTraceArg, z); - sqlite3DbFree(db, z); + if( db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_LEGACY) ){ + z = sqlite3VdbeExpandSql(p, zTrace); +#ifndef SQLITE_OMIT_DEPRECATED + if( SQLITE_TRACE_LEGACY ){ + void (*x)(void*,const char*); + x = (void(*)(void*,const char*))db->xTrace; + x(db->pTraceArg, z); + }else +#endif + { + db->xTrace(SQLITE_TRACE_SQL,db->pTraceArg,z,0); + } + sqlite3DbFree(db, z); + } + if( db->mTrace & SQLITE_TRACE_STMT ){ + (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,0); + } } #ifdef SQLITE_USE_FCNTL_TRACE zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 83718eae39..a602fad383 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -60,12 +60,19 @@ static int vdbeSafetyNotNull(Vdbe *p){ */ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ sqlite3_int64 iNow; + sqlite3_int64 iElapse; assert( p->startTime>0 ); - assert( db->xProfile!=0 ); + assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 ); assert( db->init.busy==0 ); assert( p->zSql!=0 ); sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); - db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); + iElapse = (iNow - p->startTime)*1000000; + if( db->xProfile ){ + db->xProfile(db->pProfileArg, p->zSql, iElapse); + } + if( db->mTrace & SQLITE_TRACE_PROFILE ){ + db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, iElapse); + } p->startTime = 0; } /* @@ -569,7 +576,8 @@ static int sqlite3Step(Vdbe *p){ ); #ifndef SQLITE_OMIT_TRACE - if( db->xProfile && !db->init.busy && p->zSql ){ + if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0) + && !db->init.busy && p->zSql ){ sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); }else{ assert( p->startTime==0 ); From 1637a5171f25bd6d5eb4e04dc855776c3af2c1da Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jul 2016 23:18:27 +0000 Subject: [PATCH 192/302] Legacy tests now passing. FossilOrigin-Name: f33526a341132435cb4185149a784eef6b3a1a2d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 2 +- src/vacuum.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index bfca64b0a8..a7725c09a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C First\scut\sat\simplementing\sthe\snew\ssqlite3_trace_v2()\sinterface. -D 2016-07-13T22:55:01.845 +C Legacy\stests\snow\spassing. +D 2016-07-13T23:18:27.653 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c 05658dfa4be5704e4d6542fe0f2452be5b9df09e +F src/main.c a3be9a816c72fe658838e33e42afabfff93526f2 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -448,7 +448,7 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c 459ff7cb3c589451111ff2d3b6eb31be83a46a54 +F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 F src/vdbe.c c6bb62aa69a6faf1197eee36336c6de99bb4733f F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0c569f759f6c4701321d7fea5e7ccb371743bb6b -R eeeb6e6908fe861e59edc045bbf20a73 +P cb0062feb018f52689938a58cb76886d431c33f0 +R d7e93f0729616f164eba3e9e1862aa07 U drh -Z 1f8408ee484498502acfe0ea8cf0fbae +Z a0be5e80cc5b797f562ce4c096d88be2 diff --git a/manifest.uuid b/manifest.uuid index 7db2593897..5103610b4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cb0062feb018f52689938a58cb76886d431c33f0 \ No newline at end of file +f33526a341132435cb4185149a784eef6b3a1a2d \ No newline at end of file diff --git a/src/main.c b/src/main.c index d2f8bf7996..5969738f6b 100644 --- a/src/main.c +++ b/src/main.c @@ -1816,7 +1816,7 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ #endif sqlite3_mutex_enter(db->mutex); pOld = db->pTraceArg; - db->mTrace = SQLITE_TRACE_LEGACY; + db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0; db->xTrace = (int(*)(u32,void*,void*,i64))xTrace; db->pTraceArg = pArg; sqlite3_mutex_leave(db->mutex); diff --git a/src/vacuum.c b/src/vacuum.c index 93b438fb1a..9ab7f766ee 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -145,7 +145,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ saved_mTrace = db->mTrace; db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); - db->xTrace = 0; + db->mTrace = 0; pMain = db->aDb[0].pBt; isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); From fca760c841227207bb8dd0dd43fb89a100ca18fb Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 01:09:08 +0000 Subject: [PATCH 193/302] Add the sqlite3_expanded_sql() interface. Refinements to the sqlite3_trace_v2() interface to make it more useful. FossilOrigin-Name: 99ee7ee58d45b29a0000492306ddc0b90563ff51 --- manifest | 28 +++++++++---------- manifest.uuid | 2 +- src/main.c | 12 ++++---- src/sqlite.h.in | 71 +++++++++++++++++++++++++++--------------------- src/sqlite3ext.h | 5 ++-- src/sqliteInt.h | 2 +- src/test1.c | 21 ++++++++++++++ src/vdbe.c | 24 ++++++---------- src/vdbeapi.c | 2 +- src/vdbeaux.c | 15 ++++++++++ src/vdbetrace.c | 2 +- 11 files changed, 112 insertions(+), 72 deletions(-) diff --git a/manifest b/manifest index a7725c09a7..98c634e400 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Legacy\stests\snow\spassing. -D 2016-07-13T23:18:27.653 +C Add\sthe\ssqlite3_expanded_sql()\sinterface.\s\sRefinements\sto\sthe\nsqlite3_trace_v2()\sinterface\sto\smake\sit\smore\suseful. +D 2016-07-14T01:09:08.369 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c a3be9a816c72fe658838e33e42afabfff93526f2 +F src/main.c ade3b39f3bde9212b3fabcff2367d29052002df6 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -385,15 +385,15 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 0fde7379e6a9d900802976de51cb1256f0fdac59 +F src/sqlite.h.in 6ba80e88ee17b9071f35121271784ecef60df863 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 3875aa5b3c4bb5d8d14c387628c5fe852b2846bf -F src/sqliteInt.h 5b8a3e1dc92e7459b69954cce9f653bd2391deb8 +F src/sqlite3ext.h 6fb1639d41907544cb3905c69a348ee64c5da79e +F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 -F src/test1.c 640f862c490c8eee09a9d02d0d128c6a8a75336d +F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -449,15 +449,15 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 -F src/vdbe.c c6bb62aa69a6faf1197eee36336c6de99bb4733f +F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d -F src/vdbeapi.c a466743c8e6de100c11e044b693c9469d2cf598a -F src/vdbeaux.c c90275b0e55a2b32c03dc09314194fe46f2429d8 +F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b +F src/vdbeaux.c 6083ff395021ac8c40e1b53798ee6483037e3fb7 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484 +F src/vdbetrace.c d0371769fe66fe4eb85bdcacf82b6f2af50feb9b F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cb0062feb018f52689938a58cb76886d431c33f0 -R d7e93f0729616f164eba3e9e1862aa07 +P f33526a341132435cb4185149a784eef6b3a1a2d +R b996b3134868ad007e1e44124ba2e740 U drh -Z a0be5e80cc5b797f562ce4c096d88be2 +Z 809ea44b43d6348d635e64228e5049a8 diff --git a/manifest.uuid b/manifest.uuid index 5103610b4f..6a7d48edff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f33526a341132435cb4185149a784eef6b3a1a2d \ No newline at end of file +99ee7ee58d45b29a0000492306ddc0b90563ff51 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 5969738f6b..2e996b5545 100644 --- a/src/main.c +++ b/src/main.c @@ -1805,7 +1805,7 @@ int sqlite3_overload_function( ** SQL statement. */ #ifndef SQLITE_OMIT_DEPRECATED -void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ +void *sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){ void *pOld; #ifdef SQLITE_ENABLE_API_ARMOR @@ -1817,7 +1817,7 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ sqlite3_mutex_enter(db->mutex); pOld = db->pTraceArg; db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0; - db->xTrace = (int(*)(u32,void*,void*,i64))xTrace; + db->xTrace = (int(*)(u32,void*,void*,void*))xTrace; db->pTraceArg = pArg; sqlite3_mutex_leave(db->mutex); return pOld; @@ -1827,10 +1827,10 @@ void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ /* Register a trace callback using the version-2 interface. */ int sqlite3_trace_v2( - sqlite3 *db, /* Trace this connection */ - int(*xTrace)(unsigned,void*,void*,sqlite3_int64), /* Callback to invoke */ - unsigned mTrace, /* OPs to be traced */ - void *pArg /* Context */ + sqlite3 *db, /* Trace this connection */ + unsigned mTrace, /* Mask of events to be traced */ + int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */ + void *pArg /* Context */ ){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ){ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 07d85b254d..8b9aa7402d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2804,33 +2804,25 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The T argument is one of the integer type codes above. ** The C argument is a copy of the context pointer passed in as the ** fourth argument to [sqlite3_trace_v2()]. -** The P argument is a pointer whose meaning depends on T. -** The X argument is an 64-bit integer whose meaning also -** depends on T. +** The P and X arguments are pointers whose meanings depend on T. ** **
-** [[SQLITE_TRACE_SQL]]
SQLITE_TRACE_SQL
-**
An SQLITE_TRACE_SQL callback provides the same functionality -** as the legacy [sqlite3_trace()] callback. -** The P argument is a pointer to the constant UTF-8 string that is text -** describing an SQL statement that is starting to run with all -** [bound parameter] expanded. The X argument is unused. The size -** of the expansion of [bound parameters] is limited by the -** [SQLITE_TRACE_SIZE_LIMIT] compile-time option. -** ** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
-**
An SQLITE_TRACE_STMT callback is invoked on the same occasions -** as SQLITE_TRACE_SQL. The difference is that the P argument is a -** pointer to the [prepared statement] rather than an SQL string. -** The X argument is unused. +**
An SQLITE_TRACE_STMT callback is invoked when a prepared statement +** first begins running and possibly at other times during the +** execution of the prepared statement, such as at the start of each +** trigger subprogram. The P argument is a pointer to the +** [prepared statement]. The X argument is a pointer to a string which +** is the expanded SQL text of the prepared statement or a comment that +** indicates the invocation of a trigger. ** ** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
**
An SQLITE_TRACE_PROFILE callback provides approximately the same ** information as is provided by the [sqlite3_profile()] callback. ** The P argument is a pointer to the [prepared statement] and the -** X argument is an estimate of the number of nanosecond for which -** the prepared statement ran. The SQLITE_TRACE_PROFILE callback is -** invoked when the statement finishes. +** X argument points to a 64-bit integer which is the estimated of +** the number of nanosecond that the prepared statement took to run. +** The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. ** ** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
**
An SQLITE_TRACE_ROW callback is invoked whenever a prepared @@ -2845,17 +2837,16 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** and the X argument is unused. **
*/ -#define SQLITE_TRACE_SQL 0x0001 -#define SQLITE_TRACE_STMT 0x0002 -#define SQLITE_TRACE_PROFILE 0x0004 -#define SQLITE_TRACE_ROW 0x0008 -#define SQLITE_TRACE_CLOSE 0x0010 +#define SQLITE_TRACE_STMT 0x01 +#define SQLITE_TRACE_PROFILE 0x02 +#define SQLITE_TRACE_ROW 0x04 +#define SQLITE_TRACE_CLOSE 0x08 /* ** CAPI3REF: SQL Trace Hook ** METHOD: sqlite3 ** -** The sqlite3_trace_v2(D,X,M,P) interface registers a trace callback +** The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback ** function X against [database connection] D, using property mask M ** and context pointer P. If the X callback is ** NULL or if the M mask is zero, then tracing is disabled. The @@ -2874,8 +2865,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** The T argument is one of the [SQLITE_TRACE] ** constants to indicate why the callback was invoked. ** The C argument is a copy of the context pointer. -** The P and X arguments are a pointer and a 64-bit integer -** whose meanings depend on T. +** The P and X arguments are pointers whose meanings depend on T. ** ** The sqlite3_trace_v2() interface is intended to replace the legacy ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which @@ -2883,8 +2873,8 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, */ int sqlite3_trace_v2( sqlite3*, - int(*xCallback)(unsigned,void*,void*,sqlite3_int64), unsigned uMask, + int(*xCallback)(unsigned,void*,void*,void*), void *pCtx ); @@ -3506,11 +3496,30 @@ int sqlite3_prepare16_v2( ** CAPI3REF: Retrieving Statement SQL ** METHOD: sqlite3_stmt ** -** ^This interface can be used to retrieve a saved copy of the original -** SQL text used to create a [prepared statement] if that statement was -** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. +** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 +** SQL text used to create [prepared statement] P if P was +** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. +** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 +** string containing the SQL text of prepared statement P with +** [bound parameters] expanded. +** +** For example, if a prepared statement is created using the SQL +** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 +** and parameter :xyz is unbound, then sqlite3_sql() will return +** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() +** will return "SELECT 2345,NULL". +** +** The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a +** bound parameter expansion. +** +** ^The string returned by sqlite3_sql(P) is managed by SQLite and is +** automatically freed when the prepared statement is finalized. +** ^The string returned by sqlite3_expanded_sql(P), on the other hand, +** is obtained from [sqlite3_malloc()] and must be free by the application +** by passing it to [sqlite3_free()]. */ const char *sqlite3_sql(sqlite3_stmt *pStmt); +char *sqlite3_expanded_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If An SQL Statement Writes The Database diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 8bcfc68521..4d5023292b 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -282,8 +282,8 @@ struct sqlite3_api_routines { /* Version 3.12.0 and later */ int (*system_errno)(sqlite3*); /* Version 3.14.0 and later */ - int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,sqlite3_uint64), - unsigned,void*); + int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,void*),unsigned,void*); + char *(*expanded_sql)(sqlite3_stmt*); }; /* @@ -531,6 +531,7 @@ struct sqlite3_api_routines { #define sqlite3_system_errno sqlite3_api->system_errno /* Version 3.14.0 and later */ #define sqlite3_trace_v2 sqlite3_api->trace_v2 +#define sqlite3_expanded_sql sqlite3_api->expanded_sql #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 225d7b2872..0be4947513 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1300,7 +1300,7 @@ struct sqlite3 { int nVDestroy; /* Number of active OP_VDestroy operations */ int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared library handles */ - int (*xTrace)(u32,void*,void*,i64); /* Trace function */ + int (*xTrace)(u32,void*,void*,void*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ diff --git a/src/test1.c b/src/test1.c index 5ce818bf74..a1fdcb5cfb 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4386,6 +4386,26 @@ static int test_sql( Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE); return TCL_OK; } +static int test_ex_sql( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + char *z; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "STMT"); + return TCL_ERROR; + } + + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; + z = sqlite3_expanded_sql(pStmt); + Tcl_SetResult(interp, z, TCL_VOLATILE); + sqlite3_free(z); + return TCL_OK; +} /* ** Usage: sqlite3_column_count STMT @@ -7276,6 +7296,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_changes", test_changes ,0 }, { "sqlite3_step", test_step ,0 }, { "sqlite3_sql", test_sql ,0 }, + { "sqlite3_expanded_sql", test_ex_sql ,0 }, { "sqlite3_next_stmt", test_next_stmt ,0 }, { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, { "sqlite3_stmt_busy", test_stmt_busy ,0 }, diff --git a/src/vdbe.c b/src/vdbe.c index 7883536028..cdbd7301b8 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6785,27 +6785,21 @@ case OP_Init: { /* jump */ char *z; #ifndef SQLITE_OMIT_TRACE - if( (db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 + if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){ - if( db->mTrace & (SQLITE_TRACE_SQL|SQLITE_TRACE_LEGACY) ){ - z = sqlite3VdbeExpandSql(p, zTrace); + z = sqlite3VdbeExpandSql(p, zTrace); #ifndef SQLITE_OMIT_DEPRECATED - if( SQLITE_TRACE_LEGACY ){ - void (*x)(void*,const char*); - x = (void(*)(void*,const char*))db->xTrace; - x(db->pTraceArg, z); - }else + if( db->mTrace & SQLITE_TRACE_LEGACY ){ + void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; + x(db->pTraceArg, z); + }else #endif - { - db->xTrace(SQLITE_TRACE_SQL,db->pTraceArg,z,0); - } - sqlite3DbFree(db, z); - } - if( db->mTrace & SQLITE_TRACE_STMT ){ - (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,0); + { + (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z); } + sqlite3_free(z); } #ifdef SQLITE_USE_FCNTL_TRACE zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index a602fad383..883e5c95bf 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -71,7 +71,7 @@ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ db->xProfile(db->pProfileArg, p->zSql, iElapse); } if( db->mTrace & SQLITE_TRACE_PROFILE ){ - db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, iElapse); + db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse); } p->startTime = 0; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 63609d72dd..355021e970 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -72,6 +72,21 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){ return p ? p->zSql : 0; } +/* +** Return the SQL associated with a prepared statement with +** bound parameters expanded. Space to hold the returned string is +** obtained from sqlite3_malloc(). The caller is responsible for +** freeing the returned string by passing it to sqlite3_free(). +** +** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of +** expanded bound parameters. +*/ +char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ + Vdbe *p = (Vdbe *)pStmt; + return p ? sqlite3VdbeExpandSql(p, p->zSql) : 0; + if( p->zSql==0 ) return 0; +} + /* ** Swap all content between two VDBE structures. */ diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 07235c931b..7311bc35c6 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -84,7 +84,7 @@ char *sqlite3VdbeExpandSql( char zBase[100]; /* Initial working space */ db = p->db; - sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase), + sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), db->aLimit[SQLITE_LIMIT_LENGTH]); if( db->nVdbeExec>1 ){ while( *zRawSql ){ From c0e2203adb52051f623b6a3ef9a27511ca4ae8b3 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 01:13:36 +0000 Subject: [PATCH 194/302] Fix a parameter misordering on sqlite3_trace_v2() in the loadable extension interface. FossilOrigin-Name: 989de2d5b5e7155654d3eebadb9651b23f422c58 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite3ext.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 98c634e400..8c007e6739 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_expanded_sql()\sinterface.\s\sRefinements\sto\sthe\nsqlite3_trace_v2()\sinterface\sto\smake\sit\smore\suseful. -D 2016-07-14T01:09:08.369 +C Fix\sa\sparameter\smisordering\son\ssqlite3_trace_v2()\sin\sthe\sloadable\sextension\ninterface. +D 2016-07-14T01:13:36.176 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -387,7 +387,7 @@ F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 F src/sqlite.h.in 6ba80e88ee17b9071f35121271784ecef60df863 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 6fb1639d41907544cb3905c69a348ee64c5da79e +F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f33526a341132435cb4185149a784eef6b3a1a2d -R b996b3134868ad007e1e44124ba2e740 +P 99ee7ee58d45b29a0000492306ddc0b90563ff51 +R 2e489e2cf495d4b07e42b94b658ce2d8 U drh -Z 809ea44b43d6348d635e64228e5049a8 +Z d214f48401d2ba878ebf65269a7b92c1 diff --git a/manifest.uuid b/manifest.uuid index 6a7d48edff..b1e5ac35c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99ee7ee58d45b29a0000492306ddc0b90563ff51 \ No newline at end of file +989de2d5b5e7155654d3eebadb9651b23f422c58 \ No newline at end of file diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 4d5023292b..338e1becd5 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -282,7 +282,7 @@ struct sqlite3_api_routines { /* Version 3.12.0 and later */ int (*system_errno)(sqlite3*); /* Version 3.14.0 and later */ - int (*trace_v2)(sqlite3*,int(*)(unsigned,void*,void*,void*),unsigned,void*); + int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*); char *(*expanded_sql)(sqlite3_stmt*); }; From 0129a54a167cd10f94cc5830890589e5138de7d5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jul 2016 09:22:16 +0000 Subject: [PATCH 195/302] Fix copy/paste typo in the new sqlite3_expanded_sql() function. FossilOrigin-Name: e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8c007e6739..0d6dec24f5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sparameter\smisordering\son\ssqlite3_trace_v2()\sin\sthe\sloadable\sextension\ninterface. -D 2016-07-14T01:13:36.176 +C Fix\scopy/paste\stypo\sin\sthe\snew\ssqlite3_expanded_sql()\sfunction. +D 2016-07-14T09:22:16.664 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -453,7 +453,7 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 6083ff395021ac8c40e1b53798ee6483037e3fb7 +F src/vdbeaux.c 08a459b6906dfcce0e921daba3a471a28ea65d41 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 99ee7ee58d45b29a0000492306ddc0b90563ff51 -R 2e489e2cf495d4b07e42b94b658ce2d8 -U drh -Z d214f48401d2ba878ebf65269a7b92c1 +P 989de2d5b5e7155654d3eebadb9651b23f422c58 +R 22fe35d8085a083776873f2a488c7041 +U mistachkin +Z 0cf3ee8d7f2e128326cc9e0cdcd59d22 diff --git a/manifest.uuid b/manifest.uuid index b1e5ac35c8..9a4a235af8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -989de2d5b5e7155654d3eebadb9651b23f422c58 \ No newline at end of file +e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 355021e970..72a882c176 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -83,8 +83,8 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){ */ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe *)pStmt; - return p ? sqlite3VdbeExpandSql(p, p->zSql) : 0; - if( p->zSql==0 ) return 0; + if( p==0 || p->zSql==0 ) return 0; + return sqlite3VdbeExpandSql(p, p->zSql); } /* From 86396219a31261a0cc1a69a6cded57073040661d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 19:13:11 +0000 Subject: [PATCH 196/302] Fix ALTER TABLE so that it does not promote the schema version past 3, as that will cause DESC indexes to go corrupt. Ticket [f68bf68513a1c]. FossilOrigin-Name: a7db6e45ad45be9b3003f61d4163f543498a7c9d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/alter.c | 21 ++++++++++++--------- test/alter3.test | 12 ++++++------ test/alter4.test | 19 +++++++++++++++++++ 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index c9585f19cd..966b26fc0e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sshell.c\sfor\sNetBSD. -D 2016-07-13T13:05:13.449 +C Fix\sALTER\sTABLE\sso\sthat\sit\sdoes\snot\spromote\sthe\sschema\sversion\spast\s3,\sas\nthat\swill\scause\sDESC\sindexes\sto\sgo\scorrupt.\nTicket\s[f68bf68513a1c]. +D 2016-07-14T19:13:11.812 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -320,7 +320,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a -F src/alter.c 1bb0709b3048e24217b80ec6bd78a3e99a47c01b +F src/alter.c cc28ab933ae615b22add0d609794ffb6596b42ea F src/analyze.c 37fedc80ac966ce1745811746e68e4d8fa64c7fe F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 @@ -475,8 +475,8 @@ F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 6ff7b43c2b4b905c74dc4a813d201d0fa64c5783 F test/alter.test 2facdddf08d0d48e75dc6cc312cd2b030f4835dd F test/alter2.test 7ea05c7d92ac99349a802ef7ada17294dd647060 -F test/alter3.test b3568d11c38c4599c92f24242eda34144d78dc10 -F test/alter4.test c461150723ac957f3b2214aa0b11552cd72023ec +F test/alter3.test 4d79934d812eaeacc6f22781a080f8cfe012fdc3 +F test/alter4.test 0c33c542247ba5aee4f4a0133ac44bcf8f97e5e0 F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 3eb35a4af972f98422e5dc0586501b17d103d321 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 021d0fb8d85e44839d2b4fdb90b15f0e1f2442e6 -R f2c7097376b33c065f9732879605d098 +P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb +R 7d842c7254944c448483c1d7ddff9ad6 U drh -Z e160e6d632f23e86ebc551e9950cc211 +Z f6a6c237e43006b812e6af2a3e69c586 diff --git a/manifest.uuid b/manifest.uuid index 6b7a74bfc9..1fc14b81a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -824b39e54fb9ba562be4d92cc9a54aee1cdf84cb \ No newline at end of file +a7db6e45ad45be9b3003f61d4163f543498a7c9d \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 642c1fb677..806ed49172 100644 --- a/src/alter.c +++ b/src/alter.c @@ -601,6 +601,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ Expr *pDflt; /* Default value for the new column */ sqlite3 *db; /* The database connection; */ Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */ + int r1; /* Temporary registers */ db = pParse->db; if( pParse->nErr || db->mallocFailed ) return; @@ -695,16 +696,18 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ db->flags = savedDbFlags; } - /* If the default value of the new column is NULL, then the file - ** format to 2. If the default value of the new column is not NULL, - ** the file format be 3. Back when this feature was first added - ** in 2006, we went to the trouble to upgrade the file format to the - ** minimum support values. But 10-years on, we can assume that all - ** extent versions of SQLite support file-format 4, so we always and - ** unconditionally upgrade to 4. + /* Make sure the schema version is at least 3. But do not upgrade + ** from less than 3 to 4, as that will corrupt any preexisting DESC + ** index. */ - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, - SQLITE_MAX_FILE_FORMAT); + r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT); + sqlite3VdbeUsesBtree(v, iDb); + sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2); + sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2); + VdbeCoverage(v); + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3); + sqlite3ReleaseTempReg(pParse, r1); /* Reload the schema of the modified table. */ reloadTableSchema(pParse, pTab, pTab->zName); diff --git a/test/alter3.test b/test/alter3.test index f8ebe056f2..44b31c9833 100644 --- a/test/alter3.test +++ b/test/alter3.test @@ -184,7 +184,7 @@ do_test alter3-3.2 { if {!$has_codec} { do_test alter3-3.3 { get_file_format - } {4} + } {3} } ifcapable schema_version { do_test alter3-3.4 { @@ -220,7 +220,7 @@ do_test alter3-4.2 { if {!$has_codec} { do_test alter3-4.3 { get_file_format - } {4} + } {3} } ifcapable schema_version { do_test alter3-4.4 { @@ -270,7 +270,7 @@ ifcapable attach { if {!$has_codec} { do_test alter3-5.5 { list [get_file_format test2.db] [get_file_format] - } {4 4} + } {3 3} } do_test alter3-5.6 { execsql { @@ -347,19 +347,19 @@ if {!$has_codec} { ALTER TABLE abc ADD d DEFAULT NULL; } get_file_format - } {4} + } {3} do_test alter3-7.3 { execsql { ALTER TABLE abc ADD e DEFAULT 10; } get_file_format - } {4} + } {3} do_test alter3-7.4 { execsql { ALTER TABLE abc ADD f DEFAULT NULL; } get_file_format - } {4} + } {3} do_test alter3-7.5 { execsql { VACUUM; diff --git a/test/alter4.test b/test/alter4.test index ac39d614a5..2cd78777a2 100644 --- a/test/alter4.test +++ b/test/alter4.test @@ -355,4 +355,23 @@ do_execsql_test alter4-9.3 { SELECT typeof(c), c FROM t5; } {real 9.22337203685478e+18} +# Confirm that doing an ALTER TABLE on a legacy format database +# does not corrupt DESC indexes. +# +# Ticket https://www.sqlite.org/src/tktview/f68bf68513a1c +# +do_test alter4-10.1 { + db close + sqlite3 db :memory: + db eval { + PRAGMA legacy_file_format=on; + CREATE TABLE t1(a,b,c); + CREATE INDEX t1a ON t1(a DESC); + INSERT INTO t1 VALUES(1,2,3); + INSERT INTO t1 VALUES(2,3,4); + ALTER TABLE t1 ADD COLUMN d; + PRAGMA integrity_check; + } +} {ok} + finish_test From 0b4c042b867e71bfd64a17e62d60ee2923707561 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jul 2016 19:48:08 +0000 Subject: [PATCH 197/302] Minor tweak the the b-tree balancer. FossilOrigin-Name: d2a0af7a37e390439c3001fedb5834f47fb24a1f --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 966b26fc0e..47fc104dda 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sALTER\sTABLE\sso\sthat\sit\sdoes\snot\spromote\sthe\sschema\sversion\spast\s3,\sas\nthat\swill\scause\sDESC\sindexes\sto\sgo\scorrupt.\nTicket\s[f68bf68513a1c]. -D 2016-07-14T19:13:11.812 +C Minor\stweak\sthe\sthe\sb-tree\sbalancer. +D 2016-07-14T19:48:08.366 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -327,7 +327,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c dc4e5f3e95fd57b610422e36e0913662ecd6814c +F src/btree.c 6a42efa461cf3a0c33e8755e9d236371ac80d1b3 F src/btree.h 075c45707c0f8f8af118f739f36df8098a08b7da F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 @@ -1505,7 +1505,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb -R 7d842c7254944c448483c1d7ddff9ad6 +P a7db6e45ad45be9b3003f61d4163f543498a7c9d +R cf8c76c330a7fe6ea73db33dfc44a97f +T *branch * btree-tuning +T *sym-btree-tuning * +T -sym-trunk * U drh -Z f6a6c237e43006b812e6af2a3e69c586 +Z 48948e5bf85e9b289f89aa7970884ba4 diff --git a/manifest.uuid b/manifest.uuid index 1fc14b81a9..467d7f99b2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7db6e45ad45be9b3003f61d4163f543498a7c9d \ No newline at end of file +d2a0af7a37e390439c3001fedb5834f47fb24a1f \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7fc9193dc8..8ea20b9ad0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7340,7 +7340,7 @@ static int balance_nonroot( assert( r szLeft-(b.szCell[r]+2)) ){ + && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){ break; } szRight += b.szCell[d] + 2; From b56660f5a4bb4acdcdd21d0dcce6a90daa1e6ee7 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jul 2016 21:26:09 +0000 Subject: [PATCH 198/302] Initial work on the Tcl API interface to the new sqlite3_trace_v2() function. FossilOrigin-Name: 7b59fa40a01c89cc98414d90a798169c26e04256 --- manifest | 12 +- manifest.uuid | 2 +- src/tclsqlite.c | 303 ++++++++++++++++++++++++++++++++++-------------- 3 files changed, 223 insertions(+), 94 deletions(-) diff --git a/manifest b/manifest index 0d6dec24f5..b880ee391d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scopy/paste\stypo\sin\sthe\snew\ssqlite3_expanded_sql()\sfunction. -D 2016-07-14T09:22:16.664 +C Initial\swork\son\sthe\sTcl\sAPI\sinterface\sto\sthe\snew\ssqlite3_trace_v2()\sfunction. +D 2016-07-14T21:26:09.090 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -392,7 +392,7 @@ F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 25fbbbb97f76dbfd113153fb63f52d7ecfac5dd0 +F src/tclsqlite.c 361167055f0d0d9883b729f1db698edcd3b46065 F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 989de2d5b5e7155654d3eebadb9651b23f422c58 -R 22fe35d8085a083776873f2a488c7041 +P e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 +R 85912bc13f3699d6087855b14808f819 U mistachkin -Z 0cf3ee8d7f2e128326cc9e0cdcd59d22 +Z 312d6409632132f635d6a5f40333e628 diff --git a/manifest.uuid b/manifest.uuid index 9a4a235af8..f5bb4e0461 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 \ No newline at end of file +7b59fa40a01c89cc98414d90a798169c26e04256 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 476bdf235e..bcae05d795 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -133,6 +133,7 @@ struct SqliteDb { char *zBusy; /* The busy callback routine */ char *zCommit; /* The commit hook callback routine */ char *zTrace; /* The trace callback routine */ + char *zTraceV2; /* The trace_v2 callback routine */ char *zProfile; /* The profile callback routine */ char *zProgress; /* The progress callback routine */ char *zAuth; /* The authorization callback routine */ @@ -192,7 +193,7 @@ static void closeIncrblobChannels(SqliteDb *pDb){ for(p=pDb->pIncrblob; p; p=pNext){ pNext = p->pNext; - /* Note: Calling unregister here call Tcl_Close on the incrblob channel, + /* Note: Calling unregister here call Tcl_Close on the incrblob channel, ** which deletes the IncrblobChannel structure at *p. So do not ** call Tcl_Free() here. */ @@ -233,8 +234,8 @@ static int incrblobClose(ClientData instanceData, Tcl_Interp *interp){ ** Read data from an incremental blob channel. */ static int incrblobInput( - ClientData instanceData, - char *buf, + ClientData instanceData, + char *buf, int bufSize, int *errorCodePtr ){ @@ -265,8 +266,8 @@ static int incrblobInput( ** Write data to an incremental blob channel. */ static int incrblobOutput( - ClientData instanceData, - CONST char *buf, + ClientData instanceData, + CONST char *buf, int toWrite, int *errorCodePtr ){ @@ -298,7 +299,7 @@ static int incrblobOutput( ** Seek an incremental blob channel. */ static int incrblobSeek( - ClientData instanceData, + ClientData instanceData, long offset, int seekMode, int *errorCodePtr @@ -323,8 +324,8 @@ static int incrblobSeek( } -static void incrblobWatch(ClientData instanceData, int mode){ - /* NO-OP */ +static void incrblobWatch(ClientData instanceData, int mode){ + /* NO-OP */ } static int incrblobHandle(ClientData instanceData, int dir, ClientData *hPtr){ return TCL_ERROR; @@ -352,11 +353,11 @@ static Tcl_ChannelType IncrblobChannelType = { ** Create a new incrblob channel. */ static int createIncrblobChannel( - Tcl_Interp *interp, - SqliteDb *pDb, + Tcl_Interp *interp, + SqliteDb *pDb, const char *zDb, - const char *zTable, - const char *zColumn, + const char *zTable, + const char *zColumn, sqlite_int64 iRow, int isReadonly ){ @@ -438,7 +439,7 @@ static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){ pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + nName + 1 ); pNew->zName = (char*)&pNew[1]; memcpy(pNew->zName, zName, nName+1); - for(p=pDb->pFunc; p; p=p->pNext){ + for(p=pDb->pFunc; p; p=p->pNext){ if( sqlite3_stricmp(p->zName, pNew->zName)==0 ){ Tcl_Free((char*)pNew); return p; @@ -508,6 +509,9 @@ static void DbDeleteCmd(void *db){ if( pDb->zTrace ){ Tcl_Free(pDb->zTrace); } + if( pDb->zTraceV2 ){ + Tcl_Free(pDb->zTraceV2); + } if( pDb->zProfile ){ Tcl_Free(pDb->zProfile); } @@ -587,6 +591,82 @@ static void DbTraceHandler(void *cd, const char *zSql){ } #endif +#ifndef SQLITE_OMIT_TRACE +/* +** This routine is called by the SQLite trace_v2 handler whenever a new +** supported event is generated. Unsupported event types are ignored. +** The TCL script in pDb->zTraceV2 is executed, with the arguments for +** the event appended to it (as list elements). +*/ +static int DbTraceV2Handler( + unsigned type, /* One of the SQLITE_TRACE_* event types. */ + void *cd, /* The original context data pointer. */ + void *pd, /* Primary event data, depends on event type. */ + void *xd /* Extra event data, depends on event type. */ +){ + SqliteDb *pDb = (SqliteDb*)cd; + Tcl_Obj *pCmd; + + switch( type ){ + case SQLITE_TRACE_STMT: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + char *zSql = (char *)xd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewStringObj(zSql, -1)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + case SQLITE_TRACE_PROFILE: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + sqlite3_int64 ns = (sqlite3_int64)xd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)ns)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + case SQLITE_TRACE_ROW: { + sqlite3_stmt *pStmt = (sqlite3_stmt *)pd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)pStmt)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + case SQLITE_TRACE_CLOSE: { + sqlite3 *db = (sqlite3 *)pd; + + pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1); + Tcl_IncrRefCount(pCmd); + Tcl_ListObjAppendElement(pDb->interp, pCmd, + Tcl_NewWideIntObj((Tcl_WideInt)db)); + Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT); + Tcl_DecrRefCount(pCmd); + Tcl_ResetResult(pDb->interp); + break; + } + } + return SQLITE_OK; +} +#endif + #ifndef SQLITE_OMIT_TRACE /* ** This routine is called by the SQLite profile handler after a statement @@ -637,9 +717,9 @@ static void DbRollbackHandler(void *clientData){ ** This procedure handles wal_hook callbacks. */ static int DbWalHandler( - void *clientData, - sqlite3 *db, - const char *zDb, + void *clientData, + sqlite3 *db, + const char *zDb, int nEntry ){ int ret = SQLITE_OK; @@ -653,7 +733,7 @@ static int DbWalHandler( Tcl_IncrRefCount(p); Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj(zDb, -1)); Tcl_ListObjAppendElement(interp, p, Tcl_NewIntObj(nEntry)); - if( TCL_OK!=Tcl_EvalObjEx(interp, p, 0) + if( TCL_OK!=Tcl_EvalObjEx(interp, p, 0) || TCL_OK!=Tcl_GetIntFromObj(interp, Tcl_GetObjResult(interp), &ret) ){ Tcl_BackgroundError(interp); @@ -695,11 +775,11 @@ static void DbUnlockNotify(void **apArg, int nArg){ ** Pre-update hook callback. */ static void DbPreUpdateHandler( - void *p, + void *p, sqlite3 *db, int op, - const char *zDb, - const char *zTbl, + const char *zDb, + const char *zTbl, sqlite_int64 iKey1, sqlite_int64 iKey2 ){ @@ -727,10 +807,10 @@ static void DbPreUpdateHandler( #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ static void DbUpdateHandler( - void *p, + void *p, int op, - const char *zDb, - const char *zTbl, + const char *zDb, + const char *zTbl, sqlite_int64 rowid ){ SqliteDb *pDb = (SqliteDb *)p; @@ -815,7 +895,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ ** script object, lappend the arguments, then evaluate the copy. ** ** By "shallow" copy, we mean only the outer list Tcl_Obj is duplicated. - ** The new Tcl_Obj contains pointers to the original list elements. + ** The new Tcl_Obj contains pointers to the original list elements. ** That way, when Tcl_EvalObjv() is run and shimmers the first element ** of the list to tclCmdNameType, that alternate representation will ** be preserved and reused on the next invocation. @@ -823,15 +903,15 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ Tcl_Obj **aArg; int nArg; if( Tcl_ListObjGetElements(p->interp, p->pScript, &nArg, &aArg) ){ - sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); + sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); return; - } + } pCmd = Tcl_NewListObj(nArg, aArg); Tcl_IncrRefCount(pCmd); for(i=0; iinterp, pCmd, pVal); if( rc ){ Tcl_DecrRefCount(pCmd); - sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); + sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); return; } } @@ -881,7 +961,7 @@ static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){ } if( rc && rc!=TCL_RETURN ){ - sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); + sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); }else{ Tcl_Obj *pVar = Tcl_GetObjResult(p->interp); int n; @@ -983,7 +1063,7 @@ static int auth_callback( Tcl_DStringAppendElement(&str, zArg4 ? zArg4 : ""); #ifdef SQLITE_USER_AUTHENTICATION Tcl_DStringAppendElement(&str, zArg5 ? zArg5 : ""); -#endif +#endif rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str)); Tcl_DStringFree(&str); zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : "SQLITE_DENY"; @@ -1075,12 +1155,12 @@ static int DbTransPostCmd( pDb->disableAuth++; if( sqlite3_exec(pDb->db, zEnd, 0, 0, 0) ){ /* This is a tricky scenario to handle. The most likely cause of an - ** error is that the exec() above was an attempt to commit the + ** error is that the exec() above was an attempt to commit the ** top-level transaction that returned SQLITE_BUSY. Or, less likely, ** that an IO-error has occurred. In either case, throw a Tcl exception ** and try to rollback the transaction. ** - ** But it could also be that the user executed one or more BEGIN, + ** But it could also be that the user executed one or more BEGIN, ** COMMIT, SAVEPOINT, RELEASE or ROLLBACK commands that are confusing ** this method's logic. Not clear how this would be best handled. */ @@ -1099,7 +1179,7 @@ static int DbTransPostCmd( ** Unless SQLITE_TEST is defined, this function is a simple wrapper around ** sqlite3_prepare_v2(). If SQLITE_TEST is defined, then it uses either ** sqlite3_prepare_v2() or legacy interface sqlite3_prepare(), depending -** on whether or not the [db_use_legacy_prepare] command has been used to +** on whether or not the [db_use_legacy_prepare] command has been used to ** configure the connection. */ static int dbPrepare( @@ -1155,7 +1235,7 @@ static int dbPrepareAndBind( for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){ int n = pPreStmt->nSql; - if( nSql>=n + if( nSql>=n && memcmp(pPreStmt->zSql, zSql, n)==0 && (zSql[n]==0 || zSql[n-1]==';') ){ @@ -1181,7 +1261,7 @@ static int dbPrepareAndBind( break; } } - + /* If no prepared statement was found. Compile the SQL text. Also allocate ** a new SqlPreparedStmt structure. */ if( pPreStmt==0 ){ @@ -1227,7 +1307,7 @@ static int dbPrepareAndBind( assert( strlen30(pPreStmt->zSql)==pPreStmt->nSql ); assert( 0==memcmp(pPreStmt->zSql, zSql, pPreStmt->nSql) ); - /* Bind values to parameters that begin with $ or : */ + /* Bind values to parameters that begin with $ or : */ for(i=1; i<=nVar; i++){ const char *zVar = sqlite3_bind_parameter_name(pStmt, i); if( zVar!=0 && (zVar[0]=='$' || zVar[0]==':' || zVar[0]=='@') ){ @@ -1315,8 +1395,8 @@ static void dbReleaseStmt( assert( pDb->nStmt>0 ); } pDb->nStmt++; - - /* If we have too many statement in cache, remove the surplus from + + /* If we have too many statement in cache, remove the surplus from ** the end of the cache list. */ while( pDb->nStmt>pDb->maxStmt ){ SqlPreparedStmt *pLast = pDb->stmtLast; @@ -1370,8 +1450,8 @@ static void dbReleaseColumnNames(DbEvalContext *p){ ** If pArray is not NULL, then it contains the name of a Tcl array ** variable. The "*" member of this array is set to a list containing ** the names of the columns returned by the statement as part of each -** call to dbEvalStep(), in order from left to right. e.g. if the names -** of the returned columns are a, b and c, it does the equivalent of the +** call to dbEvalStep(), in order from left to right. e.g. if the names +** of the returned columns are a, b and c, it does the equivalent of the ** tcl command: ** ** set ${pArray}(*) {a b c} @@ -1492,7 +1572,7 @@ static int dbEvalStep(DbEvalContext *p){ #if SQLITE_TEST if( p->pDb->bLegacyPrepare && rcs==SQLITE_SCHEMA && zPrevSql ){ /* If the runtime error was an SQLITE_SCHEMA, and the database - ** handle is configured to use the legacy sqlite3_prepare() + ** handle is configured to use the legacy sqlite3_prepare() ** interface, retry prepare()/step() on the same SQL statement. ** This only happens once. If there is a second SQLITE_SCHEMA ** error, the error will be returned to the caller. */ @@ -1580,11 +1660,11 @@ static int DbUseNre(void){ return( (major==8 && minor>=6) || major>8 ); } #else -/* +/* ** Compiling using headers earlier than 8.6. In this case NR cannot be ** used, so DbUseNre() to always return zero. Add #defines for the other ** Tcl_NRxxx() functions to prevent them from causing compilation errors, -** even though the only invocations of them are within conditional blocks +** even though the only invocations of them are within conditional blocks ** of the form: ** ** if( DbUseNre() ) { ... } @@ -1630,11 +1710,11 @@ static int DbEvalNextCmd( } } - /* The required interpreter variables are now populated with the data + /* The required interpreter variables are now populated with the data ** from the current row. If using NRE, schedule callbacks to evaluate ** script pScript, then to invoke this function again to fetch the next ** row (or clean up if there is no next row or the script throws an - ** exception). After scheduling the callbacks, return control to the + ** exception). After scheduling the callbacks, return control to the ** caller. ** ** If not using NRE, evaluate pScript directly and continue with the @@ -1659,7 +1739,7 @@ static int DbEvalNextCmd( } /* -** This function is used by the implementations of the following database +** This function is used by the implementations of the following database ** handle sub-commands: ** ** $db update_hook ?SCRIPT? @@ -1726,9 +1806,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ "preupdate", "profile", "progress", "rekey", "restore", "rollback_hook", "status", "timeout", "total_changes", - "trace", "transaction", "unlock_notify", - "update_hook", "version", "wal_hook", - 0 + "trace", "trace_v2", "transaction", + "unlock_notify", "update_hook", "version", + "wal_hook", + 0 }; enum DB_enum { DB_AUTHORIZER, DB_BACKUP, DB_BUSY, @@ -1741,8 +1822,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ DB_PREUPDATE, DB_PROFILE, DB_PROGRESS, DB_REKEY, DB_RESTORE, DB_ROLLBACK_HOOK, DB_STATUS, DB_TIMEOUT, DB_TOTAL_CHANGES, - DB_TRACE, DB_TRANSACTION, DB_UNLOCK_NOTIFY, - DB_UPDATE_HOOK, DB_VERSION, DB_WAL_HOOK, + DB_TRACE, DB_TRACE_V2, DB_TRANSACTION, + DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK, DB_VERSION, + DB_WAL_HOOK, }; /* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */ @@ -1928,7 +2010,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ return TCL_ERROR; }else{ if( TCL_ERROR==Tcl_GetIntFromObj(interp, objv[3], &n) ){ - Tcl_AppendResult( interp, "cannot convert \"", + Tcl_AppendResult( interp, "cannot convert \"", Tcl_GetStringFromObj(objv[3],0), "\" to integer", (char*)0); return TCL_ERROR; }else{ @@ -1942,7 +2024,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } } }else{ - Tcl_AppendResult( interp, "bad option \"", + Tcl_AppendResult( interp, "bad option \"", Tcl_GetStringFromObj(objv[2],0), "\": must be flush or size", (char*)0); return TCL_ERROR; @@ -1953,7 +2035,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* $db changes ** ** Return the number of rows that were modified, inserted, or deleted by - ** the most recent INSERT, UPDATE or DELETE statement, not including + ** the most recent INSERT, UPDATE or DELETE statement, not including ** any changes made by trigger programs. */ case DB_CHANGES: { @@ -2000,7 +2082,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ pCollate->zScript = (char*)&pCollate[1]; pDb->pCollate = pCollate; memcpy(pCollate->zScript, zScript, nScript+1); - if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, + if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8, pCollate, tclSqlCollate) ){ Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE); return TCL_ERROR; @@ -2126,7 +2208,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ const char *zSep; const char *zNull; if( objc<5 || objc>7 ){ - Tcl_WrongNumArgs(interp, 2, objv, + Tcl_WrongNumArgs(interp, 2, objv, "CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"); return TCL_ERROR; } @@ -2155,7 +2237,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ strcmp(zConflict, "fail" ) != 0 && strcmp(zConflict, "ignore" ) != 0 && strcmp(zConflict, "replace" ) != 0 ) { - Tcl_AppendResult(interp, "Error: \"", zConflict, + Tcl_AppendResult(interp, "Error: \"", zConflict, "\", conflict-algorithm must be one of: rollback, " "abort, fail, ignore, or replace", (char*)0); return TCL_ERROR; @@ -2244,7 +2326,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ for(i=0; i0 && strcmp(azCol[i], zNull)==0) - || strlen30(azCol[i])==0 + || strlen30(azCol[i])==0 ){ sqlite3_bind_null(pStmt, i+1); }else{ @@ -2323,7 +2405,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ ** The onecolumn method is the equivalent of: ** lindex [$db eval $sql] 0 */ - case DB_EXISTS: + case DB_EXISTS: case DB_ONECOLUMN: { Tcl_Obj *pResult = 0; DbEvalContext sEval; @@ -2351,7 +2433,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } break; } - + /* ** $db eval $sql ?array? ?{ ...code... }? ** @@ -2397,7 +2479,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } pScript = objv[objc-1]; Tcl_IncrRefCount(pScript); - + p = (DbEvalContext *)Tcl_Alloc(sizeof(DbEvalContext)); dbEvalInit(p, pDb, objv[2], pArray); @@ -2444,7 +2526,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ if( n>2 && strncmp(z, "-deterministic",n)==0 ){ flags |= SQLITE_DETERMINISTIC; }else{ - Tcl_AppendResult(interp, "bad option \"", z, + Tcl_AppendResult(interp, "bad option \"", z, "\": must be -argcount or -deterministic", 0 ); return TCL_ERROR; @@ -2553,7 +2635,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } /* - ** $db last_insert_rowid + ** $db last_insert_rowid ** ** Return an integer which is the ROWID for the most recent insert. */ @@ -2575,7 +2657,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ */ /* $db progress ?N CALLBACK? - ** + ** ** Invoke the given callback every N virtual machine opcodes while executing ** queries. */ @@ -2682,7 +2764,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* $db restore ?DATABASE? FILENAME ** - ** Open a database file named FILENAME. Transfer the content + ** Open a database file named FILENAME. Transfer the content ** of FILENAME into the local database DATABASE (default: "main"). */ case DB_RESTORE: { @@ -2743,7 +2825,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* ** $db status (step|sort|autoindex) ** - ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or + ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or ** SQLITE_STMTSTATUS_SORT for the most recent eval. */ case DB_STATUS: { @@ -2761,15 +2843,15 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ }else if( strcmp(zOp, "autoindex")==0 ){ v = pDb->nIndex; }else{ - Tcl_AppendResult(interp, - "bad argument: should be autoindex, step, or sort", + Tcl_AppendResult(interp, + "bad argument: should be autoindex, step, or sort", (char*)0); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(v)); break; } - + /* ** $db timeout MILLESECONDS ** @@ -2785,11 +2867,11 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ sqlite3_busy_timeout(pDb->db, ms); break; } - + /* ** $db total_changes ** - ** Return the number of rows that were modified, inserted, or deleted + ** Return the number of rows that were modified, inserted, or deleted ** since the database handle was created. */ case DB_TOTAL_CHANGES: { @@ -2842,6 +2924,53 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ break; } + /* $db trace_v2 ?CALLBACK? ?MASK? + ** + ** Make arrangements to invoke the CALLBACK routine for each trace event + ** matching the mask that is generated. The parameters are appended to + ** CALLBACK before it is executed. + */ + case DB_TRACE_V2: { + if( objc>4 ){ + Tcl_WrongNumArgs(interp, 2, objv, "?CALLBACK? ?MASK?"); + return TCL_ERROR; + }else if( objc==2 ){ + if( pDb->zTraceV2 ){ + Tcl_AppendResult(interp, pDb->zTraceV2, (char*)0); + } + }else{ + Tcl_WideInt wMask; + char *zTraceV2; + int len; + if( objc==4 ){ + if( TCL_OK!=Tcl_GetWideIntFromObj(interp, objv[3], &wMask) ){ + return TCL_ERROR; + } + }else{ + wMask = SQLITE_TRACE_STMT; + } + if( pDb->zTraceV2 ){ + Tcl_Free(pDb->zTraceV2); + } + zTraceV2 = Tcl_GetStringFromObj(objv[2], &len); + if( zTraceV2 && len>0 ){ + pDb->zTraceV2 = Tcl_Alloc( len + 1 ); + memcpy(pDb->zTraceV2, zTraceV2, len+1); + }else{ + pDb->zTraceV2 = 0; + } +#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) + if( pDb->zTraceV2 ){ + pDb->interp = interp; + sqlite3_trace_v2(pDb->db, (unsigned)wMask, DbTraceV2Handler, pDb); + }else{ + sqlite3_trace_v2(pDb->db, 0, 0, 0); + } +#endif + } + break; + } + /* $db transaction [-deferred|-immediate|-exclusive] SCRIPT ** ** Start a new transaction (if we are not already in the midst of a @@ -2894,7 +3023,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ /* If using NRE, schedule a callback to invoke the script pScript, then ** a second callback to commit (or rollback) the transaction or savepoint ** opened above. If not using NRE, evaluate the script directly, then - ** call function DbTransPostCmd() to commit (or rollback) the transaction + ** call function DbTransPostCmd() to commit (or rollback) the transaction ** or savepoint. */ if( DbUseNre() ){ Tcl_NRAddCallback(interp, DbTransPostCmd, cd, 0, 0, 0); @@ -2925,14 +3054,14 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_DecrRefCount(pDb->pUnlockNotify); pDb->pUnlockNotify = 0; } - + if( objc==3 ){ xNotify = DbUnlockNotify; pNotifyArg = (void *)pDb; pDb->pUnlockNotify = objv[2]; Tcl_IncrRefCount(pDb->pUnlockNotify); } - + if( sqlite3_unlock_notify(pDb->db, xNotify, pNotifyArg) ){ Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0); rc = TCL_ERROR; @@ -3031,13 +3160,13 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ ** $db update_hook ?script? ** $db rollback_hook ?script? */ - case DB_WAL_HOOK: - case DB_UPDATE_HOOK: + case DB_WAL_HOOK: + case DB_UPDATE_HOOK: case DB_ROLLBACK_HOOK: { - /* set ppHook to point at pUpdateHook or pRollbackHook, depending on + /* set ppHook to point at pUpdateHook or pRollbackHook, depending on ** whether [$db update_hook] or [$db rollback_hook] was invoked. */ - Tcl_Obj **ppHook = 0; + Tcl_Obj **ppHook = 0; if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook; if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook; if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook; @@ -3198,7 +3327,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } } if( objc<3 || (objc&1)!=1 ){ - Tcl_WrongNumArgs(interp, 1, objv, + Tcl_WrongNumArgs(interp, 1, objv, "HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?" " ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?" #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL) @@ -3490,7 +3619,7 @@ static void MD5Init(MD5Context *ctx){ * Update context to reflect the concatenation of another buffer full * of bytes. */ -static +static void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){ uint32 t; @@ -3536,7 +3665,7 @@ void MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){ } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ static void MD5Final(unsigned char digest[16], MD5Context *ctx){ @@ -3612,7 +3741,7 @@ static void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){ /* ** A TCL command for md5. The argument is the text to be hashed. The -** Result is the hash in base64. +** Result is the hash in base64. */ static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ MD5Context ctx; @@ -3621,7 +3750,7 @@ static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ void (*converter)(unsigned char*, char*); if( argc!=2 ){ - Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], + Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], " TEXT\"", (char*)0); return TCL_ERROR; } @@ -3646,13 +3775,13 @@ static int md5file_cmd(void*cd, Tcl_Interp*interp, int argc, const char **argv){ char zBuf[10240]; if( argc!=2 ){ - Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], + Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], " FILENAME\"", (char*)0); return TCL_ERROR; } in = fopen(argv[1],"rb"); if( in==0 ){ - Tcl_AppendResult(interp,"unable to open file \"", argv[1], + Tcl_AppendResult(interp,"unable to open file \"", argv[1], "\" for reading", (char*)0); return TCL_ERROR; } @@ -3719,7 +3848,7 @@ static void md5finalize(sqlite3_context *context){ sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } int Md5_Register(sqlite3 *db){ - int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, + int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize); sqlite3_overload_function(db, "md5sum", -1); /* To exercise this API */ return rc; @@ -3870,7 +3999,7 @@ static int db_last_stmt_ptr( ** Configure the interpreter passed as the first argument to have access ** to the commands and linked variables that make up: ** -** * the [sqlite3] extension itself, +** * the [sqlite3] extension itself, ** ** * If SQLITE_TCLMD5 or SQLITE_TEST is defined, the Md5 commands, and ** From b52dcd898936ad3e397d3e696573c8768d8c2422 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jul 2016 23:17:03 +0000 Subject: [PATCH 199/302] More work on the Tcl interface and tests for the sqlite3_trace_v2() API. FossilOrigin-Name: f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 --- manifest | 13 ++--- manifest.uuid | 2 +- src/tclsqlite.c | 41 ++++++++++++++-- test/trace3.test | 124 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 test/trace3.test diff --git a/manifest b/manifest index b880ee391d..ae6c2d0353 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Initial\swork\son\sthe\sTcl\sAPI\sinterface\sto\sthe\snew\ssqlite3_trace_v2()\sfunction. -D 2016-07-14T21:26:09.090 +C More\swork\son\sthe\sTcl\sinterface\sand\stests\sfor\sthe\ssqlite3_trace_v2()\sAPI. +D 2016-07-14T23:17:03.656 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -392,7 +392,7 @@ F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 361167055f0d0d9883b729f1db698edcd3b46065 +F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1285,6 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 +F test/trace3.test bc598719949e59b8ba5152cc42fea75e99766478 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1505,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e7d18c70d2b8f09c9f5b978fe3d69d1088e42322 -R 85912bc13f3699d6087855b14808f819 +P 7b59fa40a01c89cc98414d90a798169c26e04256 +R f3e8ed411550909534d86cfeab7a6746 U mistachkin -Z 312d6409632132f635d6a5f40333e628 +Z 5840e23d72dcfac70e0e20acc9abb290 diff --git a/manifest.uuid b/manifest.uuid index f5bb4e0461..0d1c4fc278 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7b59fa40a01c89cc98414d90a798169c26e04256 \ No newline at end of file +f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index bcae05d795..43dfedb727 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2939,15 +2939,50 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_AppendResult(interp, pDb->zTraceV2, (char*)0); } }else{ - Tcl_WideInt wMask; char *zTraceV2; int len; + Tcl_WideInt wMask = 0; if( objc==4 ){ - if( TCL_OK!=Tcl_GetWideIntFromObj(interp, objv[3], &wMask) ){ + static const char *TTYPE_strs[] = { + "statement", "profile", "row", "close", 0 + }; + enum TTYPE_enum { + TTYPE_STMT, TTYPE_PROFILE, TTYPE_ROW, TTYPE_CLOSE + }; + int i; + if( TCL_OK!=Tcl_ListObjLength(interp, objv[3], &len) ){ return TCL_ERROR; } + for(i=0; izTraceV2 ){ Tcl_Free(pDb->zTraceV2); diff --git a/test/trace3.test b/test/trace3.test new file mode 100644 index 0000000000..b9977178ad --- /dev/null +++ b/test/trace3.test @@ -0,0 +1,124 @@ +# 2016 July 14 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The focus +# of this test file is the "sqlite3_trace_v2()" API. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !trace { finish_test ; return } +set ::testprefix trace3 + +proc trace_v2_error { args } { + lappend ::stmtlist(error) [string trim $args] + error "trace error"; # this will be ignored. +} +proc trace_v2_record { args } { + lappend ::stmtlist(record) [string trim $args] +} +proc trace_v2_nop { args } {}; # do nothing. + +do_test trace3-1.0 { + execsql { + CREATE TABLE t1(a,b); + INSERT INTO t1 VALUES(1,NULL); + INSERT INTO t1 VALUES(2,-1); + INSERT INTO t1 VALUES(3,0); + INSERT INTO t1 VALUES(4,1); + INSERT INTO t1 VALUES(5,-2147483648); + INSERT INTO t1 VALUES(6,2147483647); + INSERT INTO t1 VALUES(7,-9223372036854775808); + INSERT INTO t1 VALUES(8,9223372036854775807); + INSERT INTO t1 VALUES(9,-1.0); + INSERT INTO t1 VALUES(10,0.0); + INSERT INTO t1 VALUES(11,1.0); + INSERT INTO t1 VALUES(12,''); + INSERT INTO t1 VALUES(13,'1'); + INSERT INTO t1 VALUES(14,'one'); + INSERT INTO t1 VALUES(15,x'abcd0123'); + INSERT INTO t1 VALUES(16,x'4567cdef'); + } +} {} + +do_test trace3-1.1 { + set rc [catch {db trace_v2 1 2 3} msg] + lappend rc $msg +} {1 {wrong # args: should be "db trace_v2 ?CALLBACK? ?MASK?"}} +do_test trace3-1.2 { + set rc [catch {db trace_v2 1 bad} msg] + lappend rc $msg +} {1 {bad trace type "bad": must be statement, profile, row, or close}} + +do_test trace3-2.1 { + db trace_v2 trace_v2_nop + db trace_v2 +} {trace_v2_nop} + +do_test trace3-3.1 { + unset -nocomplain ::stmtlist + db trace_v2 trace_v2_nop + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + array get ::stmtlist +} {} +do_test trace3-3.2 { + set ::stmtlist(error) {} + db trace_v2 trace_v2_error + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(error) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} +do_test trace3-3.3 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} + +do_test trace3-4.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record profile + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ -?\d+\}$/} + +do_test trace3-5.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record row + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^[string trim [string repeat {\d+ } 16]]\$/" + +do_test trace3-6.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record {profile row} + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/" + +do_test trace3-7.1 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record close + db close + set ::stmtlist(record) +} {/^-?\d+$/} + +finish_test From e2f84b403c982d48ed4e9f49677ab40119c7db4b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:07:47 +0000 Subject: [PATCH 200/302] Add tests, including some for the sqlite3_expanded_sql() API. FossilOrigin-Name: 8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 --- manifest | 12 ++++----- manifest.uuid | 2 +- test/trace3.test | 64 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ae6c2d0353..1075a137e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\swork\son\sthe\sTcl\sinterface\sand\stests\sfor\sthe\ssqlite3_trace_v2()\sAPI. -D 2016-07-14T23:17:03.656 +C Add\stests,\sincluding\ssome\sfor\sthe\ssqlite3_expanded_sql()\sAPI. +D 2016-07-15T00:07:47.847 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test bc598719949e59b8ba5152cc42fea75e99766478 +F test/trace3.test fb9242446aeef4f6e559edb126b3d67185b9a1c0 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7b59fa40a01c89cc98414d90a798169c26e04256 -R f3e8ed411550909534d86cfeab7a6746 +P f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 +R 433ed72af7d798e30b744dbac703a881 U mistachkin -Z 5840e23d72dcfac70e0e20acc9abb290 +Z c19e7bc180fcaf3fc05253b5c21f7fa0 diff --git a/manifest.uuid b/manifest.uuid index 0d1c4fc278..d877fc43c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 \ No newline at end of file +8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 \ No newline at end of file diff --git a/test/trace3.test b/test/trace3.test index b9977178ad..760fd33fe5 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -8,8 +8,9 @@ # May you share freely, never taking more than you give. # #*********************************************************************** -# This file implements regression tests for SQLite library. The focus -# of this test file is the "sqlite3_trace_v2()" API. +# This file implements regression tests for SQLite library. The focus of +# this test file is the "sqlite3_trace_v2()" and "sqlite3_expanded_sql()" +# APIs. # set testdir [file dirname $argv0] @@ -113,8 +114,67 @@ do_test trace3-6.1 { } set ::stmtlist(record) } "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/" +do_test trace3-6.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record {statement profile row} + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^\\\{-?\\d+ \\\{SELECT a, b FROM t1 ORDER BY a;\\\}\\\} [string trim \ +[string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/" do_test trace3-7.1 { + set DB [sqlite3_connection_pointer db] + + set STMT [sqlite3_prepare_v2 $DB \ + "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL] +} {/^[0-9A-F]+$/} + +do_test trace3-8.1 { + list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = NULL ORDER BY a;}} +do_test trace3-8.2 { + list [sqlite3_bind_int $STMT 1 123] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}} +do_test trace3-8.3 { + list [sqlite3_bind_int64 $STMT 1 123] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}} +do_test trace3-8.4 { + list [sqlite3_bind_text $STMT 1 "some string" 11] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 'some string' ORDER BY a;}} +do_test trace3-8.5 { + list [sqlite3_bind_text $STMT 1 "some 'bad' string" 17] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 'some ''bad'' string' ORDER BY a;}} +do_test trace3-8.6 { + list [sqlite3_bind_double $STMT 1 123] [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 123.0 ORDER BY a;}} +do_test trace3-8.7 { + list [sqlite3_bind_text16 $STMT 1 \ + [encoding convertto unicode hi\000yall\000] 16] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = 'hi' ORDER BY a;}} +do_test trace3-8.8 { + list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}} + +do_test trace3-9.1 { + db trace_v2 "" + db trace_v2 +} {} +do_test trace3-9.2 { + unset -nocomplain ::stmtlist + db trace_v2 "" {statement profile row} + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + array get ::stmtlist +} {} + +do_test trace3-10.1 { set ::stmtlist(record) {} db trace_v2 trace_v2_record close db close From a8f286a38a1c89bca1af69ff59a38d0cb1c412cc Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:09:53 +0000 Subject: [PATCH 201/302] Modify one test result to be case-insensitive. FossilOrigin-Name: 5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/trace3.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1075a137e4..4323ff299d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests,\sincluding\ssome\sfor\sthe\ssqlite3_expanded_sql()\sAPI. -D 2016-07-15T00:07:47.847 +C Modify\sone\stest\sresult\sto\sbe\scase-insensitive. +D 2016-07-15T00:09:53.145 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test fb9242446aeef4f6e559edb126b3d67185b9a1c0 +F test/trace3.test 0cb672483450fd430b24bc53eaddd13b2e69ffb7 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f3c4aa97d8c10fdb69efc6405b5fa45781f45a61 -R 433ed72af7d798e30b744dbac703a881 +P 8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 +R 4595806197ce86b476490cbf571f56e0 U mistachkin -Z c19e7bc180fcaf3fc05253b5c21f7fa0 +Z b642433aedf1b36843816b1e93dd1f01 diff --git a/manifest.uuid b/manifest.uuid index d877fc43c8..c8129cd085 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 \ No newline at end of file +5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 \ No newline at end of file diff --git a/test/trace3.test b/test/trace3.test index 760fd33fe5..eef9198791 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -129,7 +129,7 @@ do_test trace3-7.1 { set STMT [sqlite3_prepare_v2 $DB \ "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL] -} {/^[0-9A-F]+$/} +} {/^[0-9A-Fa-f]+$/} do_test trace3-8.1 { list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT] From 170e9982369e9b80b70fd654003a86f22a79330f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:23:01 +0000 Subject: [PATCH 202/302] Corrections and enhancements for the new tests. FossilOrigin-Name: 20e74c638537aa207de41a4f3c932cc05024ea9a --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/trace3.test | 49 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4323ff299d..e0b98e55b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sone\stest\sresult\sto\sbe\scase-insensitive. -D 2016-07-15T00:09:53.145 +C Corrections\sand\senhancements\sfor\sthe\snew\stests. +D 2016-07-15T00:23:01.539 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test 0cb672483450fd430b24bc53eaddd13b2e69ffb7 +F test/trace3.test 7d174e42aab63f528a0d04ea1ddf3b49497a9cf5 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b8c0b749a9a1daca49e7ea9351e253443bb1fc2 -R 4595806197ce86b476490cbf571f56e0 +P 5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 +R 614bfc4ccb78b65b369725b4f27e97e3 U mistachkin -Z b642433aedf1b36843816b1e93dd1f01 +Z a476d2a0aebfb671981b15fc2ac6c121 diff --git a/manifest.uuid b/manifest.uuid index c8129cd085..22e8d58574 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 \ No newline at end of file +20e74c638537aa207de41a4f3c932cc05024ea9a \ No newline at end of file diff --git a/test/trace3.test b/test/trace3.test index eef9198791..1149bea3f2 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -87,6 +87,22 @@ do_test trace3-3.3 { } set ::stmtlist(record) } {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} +do_test trace3-3.4 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record statement + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} +do_test trace3-3.5 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 1 + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/} do_test trace3-4.1 { set ::stmtlist(record) {} @@ -96,6 +112,14 @@ do_test trace3-4.1 { } set ::stmtlist(record) } {/^\{-?\d+ -?\d+\}$/} +do_test trace3-4.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 2 + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} {/^\{-?\d+ -?\d+\}$/} do_test trace3-5.1 { set ::stmtlist(record) {} @@ -105,6 +129,14 @@ do_test trace3-5.1 { } set ::stmtlist(record) } "/^[string trim [string repeat {\d+ } 16]]\$/" +do_test trace3-5.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 4 + execsql { + SELECT a, b FROM t1 ORDER BY a; + } + set ::stmtlist(record) +} "/^[string trim [string repeat {\d+ } 16]]\$/" do_test trace3-6.1 { set ::stmtlist(record) {} @@ -162,10 +194,14 @@ do_test trace3-8.8 { } {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}} do_test trace3-9.1 { + sqlite3_finalize $STMT +} {SQLITE_OK} + +do_test trace3-10.1 { db trace_v2 "" db trace_v2 } {} -do_test trace3-9.2 { +do_test trace3-10.2 { unset -nocomplain ::stmtlist db trace_v2 "" {statement profile row} execsql { @@ -174,11 +210,20 @@ do_test trace3-9.2 { array get ::stmtlist } {} -do_test trace3-10.1 { +do_test trace3-11.1 { set ::stmtlist(record) {} db trace_v2 trace_v2_record close db close set ::stmtlist(record) } {/^-?\d+$/} +reset_db + +do_test trace3-11.2 { + set ::stmtlist(record) {} + db trace_v2 trace_v2_record 8 + db close + set ::stmtlist(record) +} {/^-?\d+$/} + finish_test From 283a85ca212d4cc42a115c13011e7d88189d6dac Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 00:39:47 +0000 Subject: [PATCH 203/302] Fix typo in sqlite3_trace_v2(). FossilOrigin-Name: 97ccf15fb7e5103c8317d06a1985ba9c88544a60 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e0b98e55b5..72176f68e4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Corrections\sand\senhancements\sfor\sthe\snew\stests. -D 2016-07-15T00:23:01.539 +C Fix\stypo\sin\ssqlite3_trace_v2(). +D 2016-07-15T00:39:47.683 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -348,7 +348,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c ade3b39f3bde9212b3fabcff2367d29052002df6 +F src/main.c 2d3e62a971e7f169a74448e81af9ebde95b07381 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5ccbeeea7d7933402f7ccb0b1c9b3038989ca746 -R 614bfc4ccb78b65b369725b4f27e97e3 +P 20e74c638537aa207de41a4f3c932cc05024ea9a +R 6a6c93d9b0435cebe88086cbb6537465 U mistachkin -Z a476d2a0aebfb671981b15fc2ac6c121 +Z 470459b5b02059a7c191e033bd2eea7f diff --git a/manifest.uuid b/manifest.uuid index 22e8d58574..8fa3e9fe97 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -20e74c638537aa207de41a4f3c932cc05024ea9a \ No newline at end of file +97ccf15fb7e5103c8317d06a1985ba9c88544a60 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 2e996b5545..5cd1ea7185 100644 --- a/src/main.c +++ b/src/main.c @@ -1834,8 +1834,7 @@ int sqlite3_trace_v2( ){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ){ - (void)SQLITE_MISUSE_BKPT; - return 0; + return SQLITE_MISUSE_BKPT; } #endif sqlite3_mutex_enter(db->mutex); From de6fde6af69f9ea2cc0e3a0180cf97a48a0dcb03 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jul 2016 01:49:25 +0000 Subject: [PATCH 204/302] Modify the Tcl test command 'sqlite3_bind_blob' to make use of the Tcl_GetByteArrayFromObj() API. FossilOrigin-Name: e03c81895e52096ab055d8231841e9070602ca84 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 13 +++++++++++-- test/trace3.test | 4 ++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 72176f68e4..42028828b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\ssqlite3_trace_v2(). -D 2016-07-15T00:39:47.683 +C Modify\sthe\sTcl\stest\scommand\s'sqlite3_bind_blob'\sto\smake\suse\sof\sthe\sTcl_GetByteArrayFromObj()\sAPI. +D 2016-07-15T01:49:25.642 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e -F src/test1.c 5124aff86fba753a6994e9621696ccfdc8bbf24e +F src/test1.c 4bdfccf93a33453b427fb01cf12dfe26a5dd2cbc F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1285,7 +1285,7 @@ F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4 F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836 F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983 -F test/trace3.test 7d174e42aab63f528a0d04ea1ddf3b49497a9cf5 +F test/trace3.test 01e4111d582c7b20ab1c63156169157d256bc3d5 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 20e74c638537aa207de41a4f3c932cc05024ea9a -R 6a6c93d9b0435cebe88086cbb6537465 +P 97ccf15fb7e5103c8317d06a1985ba9c88544a60 +R 23f12c56d57425cd5e6978d10e653771 U mistachkin -Z 470459b5b02059a7c191e033bd2eea7f +Z ce44a3acd6ed0a8254df88a4b23a0c52 diff --git a/manifest.uuid b/manifest.uuid index 8fa3e9fe97..4fc1c619aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -97ccf15fb7e5103c8317d06a1985ba9c88544a60 \ No newline at end of file +e03c81895e52096ab055d8231841e9070602ca84 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index a1fdcb5cfb..11cd17e722 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3633,7 +3633,7 @@ static int test_bind_blob( Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; - int idx; + int len, idx; int bytes; char *value; int rc; @@ -3652,9 +3652,18 @@ static int test_bind_blob( if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; - value = Tcl_GetString(objv[3]); + + value = Tcl_GetByteArrayFromObj(objv[3], &len); if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; + if( bytes>len ){ + char zBuf[200]; + sqlite3_snprintf(sizeof(zBuf), zBuf, + "cannot use %d blob bytes, have %d", bytes, len); + Tcl_AppendResult(interp, zBuf, -1); + return TCL_ERROR; + } + rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ diff --git a/test/trace3.test b/test/trace3.test index 1149bea3f2..0809759d80 100644 --- a/test/trace3.test +++ b/test/trace3.test @@ -192,6 +192,10 @@ do_test trace3-8.8 { list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \ [sqlite3_expanded_sql $STMT] } {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}} +do_test trace3-8.9 { + list [sqlite3_bind_blob $STMT 1 "\xAB\xCD\xEF" 3] \ + [sqlite3_expanded_sql $STMT] +} {{} {SELECT a, b FROM t1 WHERE b = x'abcdef' ORDER BY a;}} do_test trace3-9.1 { sqlite3_finalize $STMT From eb5a549ecfb1fb67c66b1061f5db95bae46f4c47 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 15 Jul 2016 02:50:18 +0000 Subject: [PATCH 205/302] Disable the CSV extension when virtual tables are disabled. FossilOrigin-Name: ec7180892ac737f0731cf61f2d095a5c1d18ad93 --- ext/misc/csv.c | 7 +++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ext/misc/csv.c b/ext/misc/csv.c index 3a7e32d311..a055a8df13 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -48,6 +48,8 @@ SQLITE_EXTENSION_INIT1 #include #include +#ifndef SQLITE_OMIT_VIRTUALTABLE + /* ** A macro to hint to the compiler that a function should not be ** inlined. @@ -834,6 +836,7 @@ static sqlite3_module CsvModuleFauxWrite = { }; #endif /* SQLITE_TEST */ +#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */ #ifdef _WIN32 @@ -849,6 +852,7 @@ int sqlite3_csv_init( char **pzErrMsg, const sqlite3_api_routines *pApi ){ +#ifndef SQLITE_OMIT_VIRTUALTABLE int rc; SQLITE_EXTENSION_INIT2(pApi); rc = sqlite3_create_module(db, "csv", &CsvModule, 0); @@ -858,4 +862,7 @@ int sqlite3_csv_init( } #endif return rc; +#else + return SQLITE_OK; +#endif } diff --git a/manifest b/manifest index 966b26fc0e..3e9a346ef3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sALTER\sTABLE\sso\sthat\sit\sdoes\snot\spromote\sthe\sschema\sversion\spast\s3,\sas\nthat\swill\scause\sDESC\sindexes\sto\sgo\scorrupt.\nTicket\s[f68bf68513a1c]. -D 2016-07-14T19:13:11.812 +C Disable\sthe\sCSV\sextension\swhen\svirtual\stables\sare\sdisabled. +D 2016-07-15T02:50:18.913 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -207,7 +207,7 @@ F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 F ext/misc/carray.c 214c9e9d909ceaae3b2f5f917cc2204deca85cc6 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c b92692b057707f5b7bb91feaedde790b2e38304e +F ext/misc/csv.c f51b0566ea15e24cce871037e30a4db99ea6cf77 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 824b39e54fb9ba562be4d92cc9a54aee1cdf84cb -R 7d842c7254944c448483c1d7ddff9ad6 +P a7db6e45ad45be9b3003f61d4163f543498a7c9d +R ec00a189cb07c46ebd136f03f1e34d37 U drh -Z f6a6c237e43006b812e6af2a3e69c586 +Z 4982072efce5132597470baa33eb57d2 diff --git a/manifest.uuid b/manifest.uuid index 1fc14b81a9..3747973d87 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7db6e45ad45be9b3003f61d4163f543498a7c9d \ No newline at end of file +ec7180892ac737f0731cf61f2d095a5c1d18ad93 \ No newline at end of file From 8d85364261a96a0e370bce1f1f6b858612e838f0 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 15 Jul 2016 10:01:06 +0000 Subject: [PATCH 206/302] The sqlite3_expanded_sql() function compiles, but always returns NULL, when the SQLITE_OMIT_TRACE compile-time option is used. FossilOrigin-Name: 53c25ebe34e6776a12260078852973b1d581d20f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 4 +++- src/test1.c | 2 +- src/vdbeaux.c | 4 ++++ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 373a08e7de..fdc8e8e54c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sfixes\sfrom\strunk.\s\sFix\sthe\stclsqlite.test\sscript. -D 2016-07-15T02:55:51.860 +C The\ssqlite3_expanded_sql()\sfunction\scompiles,\sbut\salways\sreturns\sNULL,\swhen\nthe\sSQLITE_OMIT_TRACE\scompile-time\soption\sis\sused. +D 2016-07-15T10:01:06.596 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 6ba80e88ee17b9071f35121271784ecef60df863 +F src/sqlite.h.in aad252c428329522c4146a8da236e92496b15de5 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -393,7 +393,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e -F src/test1.c 4bdfccf93a33453b427fb01cf12dfe26a5dd2cbc +F src/test1.c 186e3b53c402b7a73bcb4ade2b77709675c39fe3 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -453,7 +453,7 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 08a459b6906dfcce0e921daba3a471a28ea65d41 +F src/vdbeaux.c 23df1e66e420a0e591bc877eace43be1f16f0f28 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e03c81895e52096ab055d8231841e9070602ca84 ec7180892ac737f0731cf61f2d095a5c1d18ad93 -R 8bd18a5122e19b3b0675d3bc2674a51e +P d2b1fa55e8809ffc25a25f256349b8d08beadab5 +R 62f79e8e18332d747e11f9ca2d1624d9 U drh -Z 68d53222f802b7ae8fc8a7f808e2ed8d +Z 83a3df8e5ff251b53fc0f846b015b7e8 diff --git a/manifest.uuid b/manifest.uuid index af07c18f62..84bd71ab4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2b1fa55e8809ffc25a25f256349b8d08beadab5 \ No newline at end of file +53c25ebe34e6776a12260078852973b1d581d20f \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8b9aa7402d..2a34fb8e9d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3510,7 +3510,9 @@ int sqlite3_prepare16_v2( ** will return "SELECT 2345,NULL". ** ** The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a -** bound parameter expansion. +** bound parameter expansion. If SQLite is built with the +** [SQLITE_OMIT_TRACE] compile-time option then the sqlite3_expanded_sql() +** interface is non-functional and always returns NULL. ** ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is ** automatically freed when the prepared statement is finalized. diff --git a/src/test1.c b/src/test1.c index 11cd17e722..7d83881139 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3653,7 +3653,7 @@ static int test_bind_blob( if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; - value = Tcl_GetByteArrayFromObj(objv[3], &len); + value = (char*)Tcl_GetByteArrayFromObj(objv[3], &len); if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; if( bytes>len ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 72a882c176..ec702b3c8c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -82,9 +82,13 @@ const char *sqlite3_sql(sqlite3_stmt *pStmt){ ** expanded bound parameters. */ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ +#ifdef SQLITE_OMIT_TRACE + return 0; +#else Vdbe *p = (Vdbe *)pStmt; if( p==0 || p->zSql==0 ) return 0; return sqlite3VdbeExpandSql(p, p->zSql); +#endif } /* From 8414e81359076c73a176627df912ed0e33c46d10 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 15 Jul 2016 19:17:19 +0000 Subject: [PATCH 207/302] Add the largely untested SQLITE_FTS5_NO_WITHOUT_ROWID compile time option to fts5. For building a dynamically loadable extension that does not use WITHOUT ROWID. FossilOrigin-Name: d0a1cf1c56c237617fb73cb31f4950365b1f3e9b --- ext/fts5/fts5_storage.c | 6 +++++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 90df3396c3..a695887458 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -247,7 +247,11 @@ int sqlite3Fts5CreateTable( char *zErr = 0; rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s", - pConfig->zDb, pConfig->zName, zPost, zDefn, bWithout?" WITHOUT ROWID":"" + pConfig->zDb, pConfig->zName, zPost, zDefn, +#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID + bWithout?" WITHOUT ROWID": +#endif + "" ); if( zErr ){ *pzErr = sqlite3_mprintf( diff --git a/manifest b/manifest index 3e9a346ef3..9a69ac1bf0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\sCSV\sextension\swhen\svirtual\stables\sare\sdisabled. -D 2016-07-15T02:50:18.913 +C Add\sthe\slargely\suntested\sSQLITE_FTS5_NO_WITHOUT_ROWID\scompile\stime\soption\sto\sfts5.\sFor\sbuilding\sa\sdynamically\sloadable\sextension\sthat\sdoes\snot\suse\sWITHOUT\sROWID. +D 2016-07-15T19:17:19.168 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -106,7 +106,7 @@ F ext/fts5/fts5_expr.c bcb238ee4ac1164302ab528487520488516bd030 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 -F ext/fts5/fts5_storage.c 3309c6a8e34b974513016fd1ef47c83f5898f94c +F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 F ext/fts5/fts5_tcl.c f8731e0508299bd43f1a2eff7dbeaac870768966 F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be @@ -1505,7 +1505,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a7db6e45ad45be9b3003f61d4163f543498a7c9d -R ec00a189cb07c46ebd136f03f1e34d37 -U drh -Z 4982072efce5132597470baa33eb57d2 +P ec7180892ac737f0731cf61f2d095a5c1d18ad93 +R e7e67692a9bf28fabbef5b90b609823b +U dan +Z 6e92686cc60df8d9ecf6a38e315fe4e5 diff --git a/manifest.uuid b/manifest.uuid index 3747973d87..6d86586167 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec7180892ac737f0731cf61f2d095a5c1d18ad93 \ No newline at end of file +d0a1cf1c56c237617fb73cb31f4950365b1f3e9b \ No newline at end of file From 89441bf185b7d6ee79164bcc4198eaff0e98fe2e Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 21 Jul 2016 16:43:54 +0000 Subject: [PATCH 208/302] Add new test file vacuummem.test. To test that any temporary memory used by VACUUM is freed as soon as the VACUUM has finished (not, for example, when sqlite3_close() is finally called). FossilOrigin-Name: 1b1ad0b28c392ade4321734e9b022a545b845b04 --- manifest | 11 ++++----- manifest.uuid | 2 +- test/vacuummem.test | 54 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 test/vacuummem.test diff --git a/manifest b/manifest index 9a69ac1bf0..d47aa8101b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\slargely\suntested\sSQLITE_FTS5_NO_WITHOUT_ROWID\scompile\stime\soption\sto\sfts5.\sFor\sbuilding\sa\sdynamically\sloadable\sextension\sthat\sdoes\snot\suse\sWITHOUT\sROWID. -D 2016-07-15T19:17:19.168 +C Add\snew\stest\sfile\svacuummem.test.\sTo\stest\sthat\sany\stemporary\smemory\sused\sby\sVACUUM\sis\sfreed\sas\ssoon\sas\sthe\sVACUUM\shas\sfinished\s(not,\sfor\sexample,\swhen\ssqlite3_close()\sis\sfinally\scalled). +D 2016-07-21T16:43:54.563 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1323,6 +1323,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 +F test/vacuummem.test 09c8b72a12405649ed84564367dad729bff88760 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test 765802c7a66d37fabd5ac8e2f2dbe572b43eb9ab @@ -1505,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ec7180892ac737f0731cf61f2d095a5c1d18ad93 -R e7e67692a9bf28fabbef5b90b609823b +P d0a1cf1c56c237617fb73cb31f4950365b1f3e9b +R c861801c1aa1bd5e3e0533101c0a9583 U dan -Z 6e92686cc60df8d9ecf6a38e315fe4e5 +Z 9b35e9b2fd0052d524acf36a9f5b4f2b diff --git a/manifest.uuid b/manifest.uuid index 6d86586167..9af2c82fe3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0a1cf1c56c237617fb73cb31f4950365b1f3e9b \ No newline at end of file +1b1ad0b28c392ade4321734e9b022a545b845b04 \ No newline at end of file diff --git a/test/vacuummem.test b/test/vacuummem.test new file mode 100644 index 0000000000..967e28cec7 --- /dev/null +++ b/test/vacuummem.test @@ -0,0 +1,54 @@ +# 2005 February 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing that the VACUUM statement correctly +# frees any memory used for a temporary cache. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix vacuummem + +proc memory_used {} { + set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1] + lindex $stat 1 +} + +do_execsql_test 1.0 { + PRAGMA cache_size = -2000; + CREATE TABLE t1(a, b, c); + + WITH r(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<100000 + ) + INSERT INTO t1 SELECT randomblob(100),randomblob(100),randomblob(100) FROM r; + + CREATE INDEX t1a ON t1(a); + CREATE INDEX t1b ON t1(b); + CREATE INDEX t1c ON t1(c); +} + +do_test 1.1 { memory_used } {#/2300000/} + +do_execsql_test 1.2 VACUUM + +do_test 1.3 { memory_used } {#/2300000/} + +do_execsql_test 1.4 { + SELECT count(*) FROM t1 WHERE +a IS NOT NULL +} {100000} + +do_test 1.5 { memory_used } {#/2300000/} + + + +finish_test + From 033ac6af7e7fd926299e5b2f9a50a727676681b9 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 21 Jul 2016 18:02:20 +0000 Subject: [PATCH 209/302] Add extra test cases to verify the fix in [64ca1a835]. FossilOrigin-Name: bf98a2de7ed41a8acca89d7369b353f12182cfb4 --- ext/fts5/test/fts5rank.test | 35 ++++++++++++++++++++++++++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/ext/fts5/test/fts5rank.test b/ext/fts5/test/fts5rank.test index e958aea15b..a70c5d68e3 100644 --- a/ext/fts5/test/fts5rank.test +++ b/ext/fts5/test/fts5rank.test @@ -100,30 +100,55 @@ do_test 2.7 { # following tests verify that that problem has been addressed. # foreach_detail_mode $::testprefix { - do_execsql_test 3.0 { + do_execsql_test 3.1.0 { CREATE VIRTUAL TABLE y1 USING fts5(z, detail=%DETAIL%); INSERT INTO y1 VALUES('test xyz'); INSERT INTO y1 VALUES('test test xyz test'); INSERT INTO y1 VALUES('test test xyz'); } - do_execsql_test 3.1 { + do_execsql_test 3.1.1 { SELECT rowid FROM y1('test OR tset'); } {1 2 3} - do_execsql_test 3.2 { + do_execsql_test 3.1.2 { SELECT rowid FROM y1('test OR tset') ORDER BY bm25(y1) } {2 3 1} - do_execsql_test 3.3 { + do_execsql_test 3.1.3 { SELECT rowid FROM y1('test OR tset') ORDER BY +rank } {2 3 1} - do_execsql_test 3.4 { + do_execsql_test 3.1.4 { SELECT rowid FROM y1('test OR tset') ORDER BY rank } {2 3 1} + + do_execsql_test 3.1.5 { + SELECT rowid FROM y1('test OR xyz') ORDER BY rank + } {3 2 1} + + + do_execsql_test 3.2.1 { + CREATE VIRTUAL TABLE z1 USING fts5(a, detail=%DETAIL%); + INSERT INTO z1 VALUES('wrinkle in time'); + SELECT * FROM z1 WHERE z1 MATCH 'wrinkle in time OR a wrinkle in time'; + } {{wrinkle in time}} } +do_execsql_test 4.1 { + DROP TABLE IF EXISTS VTest; + CREATE virtual TABLE VTest USING FTS5( + Title, AUthor, tokenize ='porter unicode61 remove_diacritics 1', + columnsize='1', detail=full + ); + INSERT INTO VTest (Title, Author) VALUES ('wrinkle in time', 'Bill Smith'); + + SELECT * FROM VTest WHERE + VTest MATCH 'wrinkle in time OR a wrinkle in time' ORDER BY rank; +} {{wrinkle in time} {Bill Smith}} + + + finish_test diff --git a/manifest b/manifest index d47aa8101b..d38d5f0960 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\stest\sfile\svacuummem.test.\sTo\stest\sthat\sany\stemporary\smemory\sused\sby\sVACUUM\sis\sfreed\sas\ssoon\sas\sthe\sVACUUM\shas\sfinished\s(not,\sfor\sexample,\swhen\ssqlite3_close()\sis\sfinally\scalled). -D 2016-07-21T16:43:54.563 +C Add\sextra\stest\scases\sto\sverify\sthe\sfix\sin\s[64ca1a835]. +D 2016-07-21T18:02:20.434 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -176,7 +176,7 @@ F ext/fts5/test/fts5porter.test 7cdc07bef301d70eebbfa75dcaf45c3680e1d0e1 F ext/fts5/test/fts5porter2.test 2e65633d58a1c525d5af0f6c01e5a59155bb3487 F ext/fts5/test/fts5prefix.test efd42e00bb8e8a36383f25c838185508681c093f F ext/fts5/test/fts5query.test f5ec25f5f2fbb70033424113cdffc101b1985a40 -F ext/fts5/test/fts5rank.test 3e55e7eeb4c98728e4a3171c9e994e1a2f24eb99 +F ext/fts5/test/fts5rank.test 2bdc0c5f22ccc1f9dbe9f4d0b82a491dce6f8a32 F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 16908a99d6efc9ba21081b4f2b86b3fc699839a6 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d0a1cf1c56c237617fb73cb31f4950365b1f3e9b -R c861801c1aa1bd5e3e0533101c0a9583 +P 1b1ad0b28c392ade4321734e9b022a545b845b04 +R 4cf3b663820541379bf632bbc3528bb8 U dan -Z 9b35e9b2fd0052d524acf36a9f5b4f2b +Z d680066d496973101c651a3de727e285 diff --git a/manifest.uuid b/manifest.uuid index 9af2c82fe3..2bc7fd5a25 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b1ad0b28c392ade4321734e9b022a545b845b04 \ No newline at end of file +bf98a2de7ed41a8acca89d7369b353f12182cfb4 \ No newline at end of file From 12ca5ac3d2da1115b9462ebd65cddb850a550bfd Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 22 Jul 2016 10:09:26 +0000 Subject: [PATCH 210/302] Fix a problem with upper case module names in the "sqldiff --vtab" command. FossilOrigin-Name: 87e25fc472604b3978811be53991104c665a95e7 --- ext/rbu/rbudiff.test | 60 +++++++++++++++++++++++++++++++++++++++++++- manifest | 14 +++++------ manifest.uuid | 2 +- tool/sqldiff.c | 2 +- 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/ext/rbu/rbudiff.test b/ext/rbu/rbudiff.test index fa8de319dd..041a242428 100644 --- a/ext/rbu/rbudiff.test +++ b/ext/rbu/rbudiff.test @@ -203,7 +203,6 @@ foreach {tn init mod} { DELETE FROM 'x''y' WHERE rowid = 1; INSERT INTO 'x''y' VALUES('one two three'); } - } { forcedelete test.db test.db2 @@ -222,5 +221,64 @@ foreach {tn init mod} { } +ifcapable fts5 { + foreach {tn init mod} { + 1 { + CREATE VIRTUAL TABLE t1 USING fts5(c); + INSERT INTO t1 VALUES('a b c'); + INSERT INTO t1 VALUES('a b c'); + } { + DELETE FROM t1 WHERE rowid = 1; + INSERT INTO t1 VALUES('a b c'); + } + + 2 { + CREATE VIRTUAL TABLE t1 USING FTs5(c); + INSERT INTO t1 VALUES('a b c'); + INSERT INTO t1 VALUES('a b c'); + } { + DELETE FROM t1 WHERE rowid = 1; + INSERT INTO t1 VALUES('a b c'); + } + + 3 { + creAte virTUal +tablE t1 USING FTs5(c); + INSERT INTO t1 VALUES('a b c'); + INSERT INTO t1 VALUES('a b c'); + } { + DELETE FROM t1 WHERE rowid = 1; + INSERT INTO t1 VALUES('a b c'); + } + + } { + forcedelete test.db test.db2 + sqlite3 db test.db + db eval "$init" + sqlite3 db test.db2 + db eval "$init ; $mod" + db eval { INSERT INTO t1(t1) VALUES('optimize') } + db close + + do_test 3.$tn.1 { + set sql [get_vtab_rbudiff_sql test.db test.db2] + apply_rbudiff $sql test.db + } {SQLITE_DONE} + + sqlite3 db test.db + sqlite3 db2 test.db2 + do_test 3.$tn.2 { + db2 eval { SELECT * FROM t1 ORDER BY rowid } + } [db eval { SELECT * FROM t1 ORDER BY rowid }] + + do_test 3.$tn.3 { + db2 eval { INSERT INTO t1(t1) VALUES('integrity-check') } + } {} + + db close + db2 close + } +} + finish_test diff --git a/manifest b/manifest index d38d5f0960..15a467b95d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stest\scases\sto\sverify\sthe\sfix\sin\s[64ca1a835]. -D 2016-07-21T18:02:20.434 +C Fix\sa\sproblem\swith\supper\scase\smodule\snames\sin\sthe\s"sqldiff\s--vtab"\scommand. +D 2016-07-22T10:09:26.990 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -244,7 +244,7 @@ F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2 F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831 F ext/rbu/rbu_common.tcl a38e8e2d4a50fd6aaf151633714c1b1d2fae3ead F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695 -F ext/rbu/rbudiff.test 4c9f8df6f723f553781d3d117501b7e9d170a145 +F ext/rbu/rbudiff.test b3c7675810b81de98a930a87fcd40d9ae545619d F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca @@ -1473,7 +1473,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c af5d80cdc88a91a0f3cccfaa316b5a27b213568a +F tool/sqldiff.c 4478f0d30230de6adde90bdb0bfe60f68c5ab782 F tool/srcck1.c 4c39bdfa9a92edd20233ee720df84dbeb2417602 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1b1ad0b28c392ade4321734e9b022a545b845b04 -R 4cf3b663820541379bf632bbc3528bb8 +P bf98a2de7ed41a8acca89d7369b353f12182cfb4 +R 21feff5d71e42b08ceb5cf54c6ef8c4f U dan -Z d680066d496973101c651a3de727e285 +Z 0597e24d7597ffc51d59928722cf37fa diff --git a/manifest.uuid b/manifest.uuid index 2bc7fd5a25..a48b14490b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf98a2de7ed41a8acca89d7369b353f12182cfb4 \ No newline at end of file +87e25fc472604b3978811be53991104c665a95e7 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index dbdf726df0..e92e8aab25 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -1822,7 +1822,7 @@ const char *all_tables_sql(){ int rc; rc = sqlite3_exec(g.db, - "CREATE TEMP TABLE tblmap(module, postfix);" + "CREATE TEMP TABLE tblmap(module COLLATE nocase, postfix);" "INSERT INTO temp.tblmap VALUES" "('fts3', '_content'), ('fts3', '_segments'), ('fts3', '_segdir')," From dec8bc0eb49b5af519ead428296dbfce884ae1cb Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 Jul 2016 20:20:53 +0000 Subject: [PATCH 211/302] Add requirements marks to the sqlite3_expanded_sql() documentation. FossilOrigin-Name: 409535e6dfc307f26ea3d9f51be51c439b6d7b22 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index fdc8e8e54c..a198d7e20b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_expanded_sql()\sfunction\scompiles,\sbut\salways\sreturns\sNULL,\swhen\nthe\sSQLITE_OMIT_TRACE\scompile-time\soption\sis\sused. -D 2016-07-15T10:01:06.596 +C Add\srequirements\smarks\sto\sthe\ssqlite3_expanded_sql()\sdocumentation. +D 2016-07-22T20:20:53.758 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in aad252c428329522c4146a8da236e92496b15de5 +F src/sqlite.h.in f1e866f8b789391ba7f77f71164e51b7f8b4b111 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d2b1fa55e8809ffc25a25f256349b8d08beadab5 -R 62f79e8e18332d747e11f9ca2d1624d9 +P 53c25ebe34e6776a12260078852973b1d581d20f +R d9d54b2d05c15d2014a2ffa7a3228fb1 U drh -Z 83a3df8e5ff251b53fc0f846b015b7e8 +Z 3464c79040c125df7d1b54a6ef5c52ad diff --git a/manifest.uuid b/manifest.uuid index 84bd71ab4a..5369a8751e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -53c25ebe34e6776a12260078852973b1d581d20f \ No newline at end of file +409535e6dfc307f26ea3d9f51be51c439b6d7b22 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2a34fb8e9d..5c4c373b80 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3503,14 +3503,14 @@ int sqlite3_prepare16_v2( ** string containing the SQL text of prepared statement P with ** [bound parameters] expanded. ** -** For example, if a prepared statement is created using the SQL +** ^(For example, if a prepared statement is created using the SQL ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 ** and parameter :xyz is unbound, then sqlite3_sql() will return ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() -** will return "SELECT 2345,NULL". +** will return "SELECT 2345,NULL".)^ ** -** The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a -** bound parameter expansion. If SQLite is built with the +** ^The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a +** bound parameter expansion. ^If SQLite is built with the ** [SQLITE_OMIT_TRACE] compile-time option then the sqlite3_expanded_sql() ** interface is non-functional and always returns NULL. ** From 9a8b9ec51c3cb0897d8a7311cf6216e9e34df480 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 Jul 2016 20:45:03 +0000 Subject: [PATCH 212/302] Be sure to hold the database connection mutex while calling sqlite3VdbeExpand() from within sqlite3_expanded_sql(). FossilOrigin-Name: 527b5ba68c0b0185958b945b197f9022951d9379 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a198d7e20b..cbb93bb180 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\srequirements\smarks\sto\sthe\ssqlite3_expanded_sql()\sdocumentation. -D 2016-07-22T20:20:53.758 +C Be\ssure\sto\shold\sthe\sdatabase\sconnection\smutex\swhile\scalling\ssqlite3VdbeExpand()\nfrom\swithin\ssqlite3_expanded_sql(). +D 2016-07-22T20:45:03.857 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -453,7 +453,7 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 23df1e66e420a0e591bc877eace43be1f16f0f28 +F src/vdbeaux.c 7a09b945ebc4893e3a15bd68c4634d4aff34ebd5 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 53c25ebe34e6776a12260078852973b1d581d20f -R d9d54b2d05c15d2014a2ffa7a3228fb1 +P 409535e6dfc307f26ea3d9f51be51c439b6d7b22 +R 2b4fbb49220ef1cdb35ff0cc787c0937 U drh -Z 3464c79040c125df7d1b54a6ef5c52ad +Z 1a401e59c5d6714d520ae3898a7c3c7e diff --git a/manifest.uuid b/manifest.uuid index 5369a8751e..8a31fb63f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -409535e6dfc307f26ea3d9f51be51c439b6d7b22 \ No newline at end of file +527b5ba68c0b0185958b945b197f9022951d9379 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index ec702b3c8c..6eeb325b1e 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -86,8 +86,12 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ return 0; #else Vdbe *p = (Vdbe *)pStmt; + char *z; if( p==0 || p->zSql==0 ) return 0; - return sqlite3VdbeExpandSql(p, p->zSql); + sqlite3_mutex_enter(p->db->mutex); + z = sqlite3VdbeExpandSql(p, p->zSql); + sqlite3_mutex_leave(p->db->mutex); + return z; #endif } From 80f2b33a12214ca194babd468f2618ed805d2f95 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jul 2016 21:26:56 +0000 Subject: [PATCH 213/302] Fix harmless compiler warnings seen with MSVC. FossilOrigin-Name: 8bb6e6fcedf7d0ae796b8848593106c921ebf21a --- ext/misc/carray.c | 2 +- ext/misc/csv.c | 13 +++++++------ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ext/misc/carray.c b/ext/misc/carray.c index 6fdbecf575..3c2398ec45 100644 --- a/ext/misc/carray.c +++ b/ext/misc/carray.c @@ -247,7 +247,7 @@ static int carrayFilter( "unknown datatype: %Q", zType); return SQLITE_ERROR; }else{ - pCur->eType = i; + pCur->eType = (unsigned char)i; } } }else{ diff --git a/ext/misc/csv.c b/ext/misc/csv.c index a055a8df13..2a9463bd6e 100644 --- a/ext/misc/csv.c +++ b/ext/misc/csv.c @@ -232,7 +232,7 @@ static char *csv_read_one_field(CsvReader *p){ || (c==EOF && pc=='"') ){ do{ p->n--; }while( p->z[p->n]!='"' ); - p->cTerm = c; + p->cTerm = (char)c; break; } if( pc=='"' && c!='\r' ){ @@ -242,7 +242,7 @@ static char *csv_read_one_field(CsvReader *p){ if( c==EOF ){ csv_errmsg(p, "line %d: unterminated %c-quoted field\n", startLine, '"'); - p->cTerm = c; + p->cTerm = (char)c; break; } } @@ -259,7 +259,7 @@ static char *csv_read_one_field(CsvReader *p){ p->nLine++; if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--; } - p->cTerm = c; + p->cTerm = (char)c; } if( p->z ) p->z[p->n] = 0; return p->z; @@ -338,9 +338,9 @@ static void csv_trim_whitespace(char *z){ /* Dequote the string */ static void csv_dequote(char *z){ - int i, j; + int j; char cQuote = z[0]; - size_t n; + size_t i, n; if( cQuote!='\'' && cQuote!='"' ) return; n = strlen(z); @@ -725,7 +725,8 @@ static int csvtabFilter( pCur->iRowid = 0; if( pCur->rdr.in==0 ){ assert( pCur->rdr.zIn==pTab->zData ); - assert( pTab->iStart<=pCur->rdr.nIn ); + assert( pTab->iStart>=0 ); + assert( (size_t)pTab->iStart<=pCur->rdr.nIn ); pCur->rdr.iIn = pTab->iStart; }else{ fseek(pCur->rdr.in, pTab->iStart, SEEK_SET); diff --git a/manifest b/manifest index 15a467b95d..718e7796c0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\supper\scase\smodule\snames\sin\sthe\s"sqldiff\s--vtab"\scommand. -D 2016-07-22T10:09:26.990 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. +D 2016-07-22T21:26:56.199 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -204,10 +204,10 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/carray.c 214c9e9d909ceaae3b2f5f917cc2204deca85cc6 +F ext/misc/carray.c b0478416ab01368e40c4e9231c4e15c00a6c1c4c F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 -F ext/misc/csv.c f51b0566ea15e24cce871037e30a4db99ea6cf77 +F ext/misc/csv.c 816a3715356e4210dae2d242057745e937050896 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf98a2de7ed41a8acca89d7369b353f12182cfb4 -R 21feff5d71e42b08ceb5cf54c6ef8c4f -U dan -Z 0597e24d7597ffc51d59928722cf37fa +P 87e25fc472604b3978811be53991104c665a95e7 +R 0235f59a00c54f640f61c277b29bcc69 +U mistachkin +Z 015e7c1f4d0390bbef94656d13220477 diff --git a/manifest.uuid b/manifest.uuid index a48b14490b..efdad925f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87e25fc472604b3978811be53991104c665a95e7 \ No newline at end of file +8bb6e6fcedf7d0ae796b8848593106c921ebf21a \ No newline at end of file From a4c07346b79cff61782e9bb6eb8812aea156f8ce Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jul 2016 21:35:38 +0000 Subject: [PATCH 214/302] Revise a warning fix from the previous check-in to improve clarity. Also, fix an incorrect test prefix (typo). FossilOrigin-Name: f50a3fd6606c14b82c9b938bfca284d54b6c650f --- ext/misc/carray.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- test/csv01.test | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/misc/carray.c b/ext/misc/carray.c index 3c2398ec45..025eb5db2c 100644 --- a/ext/misc/carray.c +++ b/ext/misc/carray.c @@ -237,7 +237,7 @@ static int carrayFilter( if( idxNum<3 ){ pCur->eType = CARRAY_INT32; }else{ - int i; + unsigned char i; const char *zType = (const char*)sqlite3_value_text(argv[2]); for(i=0; ieType = (unsigned char)i; + pCur->eType = i; } } }else{ diff --git a/manifest b/manifest index 718e7796c0..1a7b6fcb75 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2016-07-22T21:26:56.199 +C Revise\sa\swarning\sfix\sfrom\sthe\sprevious\scheck-in\sto\simprove\sclarity.\s\sAlso,\sfix\san\sincorrect\stest\sprefix\s(typo). +D 2016-07-22T21:35:38.430 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -204,7 +204,7 @@ F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c 43df9d8ef2fae7a325100ebd713ab089dc829dd7 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 211108e201105e4bb0c076527b8cfd34330fc234 -F ext/misc/carray.c b0478416ab01368e40c4e9231c4e15c00a6c1c4c +F ext/misc/carray.c 40c27641010a4dc67e3690bdb7c9d36ca58b3c2d F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 816a3715356e4210dae2d242057745e937050896 @@ -616,7 +616,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c -F test/csv01.test 0929a9ce47021519512be92861f29e32d2538e5f +F test/csv01.test e0ba3caaa57e4c667a0b45977689fb8082f14348 F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87e25fc472604b3978811be53991104c665a95e7 -R 0235f59a00c54f640f61c277b29bcc69 +P 8bb6e6fcedf7d0ae796b8848593106c921ebf21a +R 5b6ff2c3db1a5eba26e3cea3eedea20b U mistachkin -Z 015e7c1f4d0390bbef94656d13220477 +Z 074e5835acae805d82010c066036788b diff --git a/manifest.uuid b/manifest.uuid index efdad925f7..2171fc8fa7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bb6e6fcedf7d0ae796b8848593106c921ebf21a \ No newline at end of file +f50a3fd6606c14b82c9b938bfca284d54b6c650f \ No newline at end of file diff --git a/test/csv01.test b/test/csv01.test index a6fff81c3f..8151c47714 100644 --- a/test/csv01.test +++ b/test/csv01.test @@ -13,7 +13,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -set testprefix closure01 +set testprefix csv01 ifcapable !vtab||!cte { finish_test ; return } From cf1e395acb41d886d72aa77d7e49f08ed1d36317 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 00:43:14 +0000 Subject: [PATCH 215/302] Fix sqlite3VdbeExpandSql() so that it handles OOMs by always returning NULL. FossilOrigin-Name: 5a027fe4127d498e0dc0d9439131c6a29085cf0a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 14 ++++++++------ src/vdbetrace.c | 13 ++++++++++--- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index cbb93bb180..a844004956 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Be\ssure\sto\shold\sthe\sdatabase\sconnection\smutex\swhile\scalling\ssqlite3VdbeExpand()\nfrom\swithin\ssqlite3_expanded_sql(). -D 2016-07-22T20:45:03.857 +C Fix\ssqlite3VdbeExpandSql()\sso\sthat\sit\shandles\sOOMs\sby\salways\sreturning\sNULL. +D 2016-07-23T00:43:14.540 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -453,11 +453,11 @@ F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 7a09b945ebc4893e3a15bd68c4634d4aff34ebd5 +F src/vdbeaux.c 8557563e9b0fed6ba05b0ce42e3b3049d93f26fa F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c d0371769fe66fe4eb85bdcacf82b6f2af50feb9b +F src/vdbetrace.c bea16fb07070b33f6efdece3169c3c4b423894a8 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 409535e6dfc307f26ea3d9f51be51c439b6d7b22 -R 2b4fbb49220ef1cdb35ff0cc787c0937 +P 527b5ba68c0b0185958b945b197f9022951d9379 +R e119b9614fe99fd5a44e65f51db3182b U drh -Z 1a401e59c5d6714d520ae3898a7c3c7e +Z 16700eecfd0a8ed6af44720c8587b7e0 diff --git a/manifest.uuid b/manifest.uuid index 8a31fb63f9..7d4379e1ee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -527b5ba68c0b0185958b945b197f9022951d9379 \ No newline at end of file +5a027fe4127d498e0dc0d9439131c6a29085cf0a \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 6eeb325b1e..b04a1d23f2 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -85,12 +85,14 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ #ifdef SQLITE_OMIT_TRACE return 0; #else - Vdbe *p = (Vdbe *)pStmt; - char *z; - if( p==0 || p->zSql==0 ) return 0; - sqlite3_mutex_enter(p->db->mutex); - z = sqlite3VdbeExpandSql(p, p->zSql); - sqlite3_mutex_leave(p->db->mutex); + char *z = 0; + const char *zSql = sqlite3_sql(pStmt); + if( zSql ){ + Vdbe *p = (Vdbe *)pStmt; + sqlite3_mutex_enter(p->db->mutex); + z = sqlite3VdbeExpandSql(p, zSql); + sqlite3_mutex_leave(p->db->mutex); + } return z; #endif } diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 7311bc35c6..8a1c23bc35 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -81,6 +81,9 @@ char *sqlite3VdbeExpandSql( int i; /* Loop counter */ Mem *pVar; /* Value of a host parameter */ StrAccum out; /* Accumulate the output here */ +#ifndef SQLITE_OMIT_UTF16 + Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */ +#endif char zBase[100]; /* Initial working space */ db = p->db; @@ -135,12 +138,16 @@ char *sqlite3VdbeExpandSql( int nOut; /* Number of bytes of the string text to include in output */ #ifndef SQLITE_OMIT_UTF16 u8 enc = ENC(db); - Mem utf8; if( enc!=SQLITE_UTF8 ){ memset(&utf8, 0, sizeof(utf8)); utf8.db = db; - sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); - sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8); + if( SQLITE_NOMEM== sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) + || SQLITE_NOMEM== sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) + ){ + sqlite3StrAccumReset(&out); + sqlite3VdbeMemRelease(&utf8); + return 0; + } pVar = &utf8; } #endif From 557341e8fa72f03a35768a34c33cfb18645f95cd Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 02:07:26 +0000 Subject: [PATCH 216/302] Add requirements marks to the sqlite3_trace_v2() interface documentation. FossilOrigin-Name: ebd388e94da4a2b29c2a546f832d359619803ec5 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 46 +++++++++++++++++++++++----------------------- src/vdbeapi.c | 33 +++++++++++++++++++++++++++++++++ src/vdbeaux.c | 33 --------------------------------- src/vdbetrace.c | 4 ++-- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/manifest b/manifest index a844004956..631dae73d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssqlite3VdbeExpandSql()\sso\sthat\sit\shandles\sOOMs\sby\salways\sreturning\sNULL. -D 2016-07-23T00:43:14.540 +C Add\srequirements\smarks\sto\sthe\ssqlite3_trace_v2()\sinterface\sdocumentation. +D 2016-07-23T02:07:26.475 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in f1e866f8b789391ba7f77f71164e51b7f8b4b111 +F src/sqlite.h.in 35e253c3b408157a9edc3306d4f1b770af73a398 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -452,12 +452,12 @@ F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d -F src/vdbeapi.c 460b90f7f0894753d33df377702c1dc9cc5fa21b -F src/vdbeaux.c 8557563e9b0fed6ba05b0ce42e3b3049d93f26fa +F src/vdbeapi.c c3f6715a99995c11748ecad91d25e93fd9fc390b +F src/vdbeaux.c a32d79aeaa88dc2b97c261172d952d395254a055 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c bea16fb07070b33f6efdece3169c3c4b423894a8 +F src/vdbetrace.c 05d1f843117c4fdcc1f8b1e950011bbeef0cef84 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 527b5ba68c0b0185958b945b197f9022951d9379 -R e119b9614fe99fd5a44e65f51db3182b +P 5a027fe4127d498e0dc0d9439131c6a29085cf0a +R 424a44eb6e790a98bbdc6c3248de6bc5 U drh -Z 16700eecfd0a8ed6af44720c8587b7e0 +Z 5a7cc904a805d16230629029b0dc335a diff --git a/manifest.uuid b/manifest.uuid index 7d4379e1ee..4db50f7e69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a027fe4127d498e0dc0d9439131c6a29085cf0a \ No newline at end of file +ebd388e94da4a2b29c2a546f832d359619803ec5 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5c4c373b80..1308a1122d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2795,45 +2795,45 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** These constants identify classes of events that can be monitored ** using the [sqlite3_trace_v2()] tracing logic. The third argument ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of -** the following constants. The first argument to the trace callback +** the following constants. ^The first argument to the trace callback ** is one of the following constants. ** ** New tracing constants may be added in future releases. ** -** A trace callback has four arguments: xCallback(T,C,P,X). -** The T argument is one of the integer type codes above. -** The C argument is a copy of the context pointer passed in as the +** ^A trace callback has four arguments: xCallback(T,C,P,X). +** ^The T argument is one of the integer type codes above. +** ^The C argument is a copy of the context pointer passed in as the ** fourth argument to [sqlite3_trace_v2()]. ** The P and X arguments are pointers whose meanings depend on T. ** **
** [[SQLITE_TRACE_STMT]]
SQLITE_TRACE_STMT
-**
An SQLITE_TRACE_STMT callback is invoked when a prepared statement +**
^An SQLITE_TRACE_STMT callback is invoked when a prepared statement ** first begins running and possibly at other times during the ** execution of the prepared statement, such as at the start of each -** trigger subprogram. The P argument is a pointer to the -** [prepared statement]. The X argument is a pointer to a string which +** trigger subprogram. ^The P argument is a pointer to the +** [prepared statement]. ^The X argument is a pointer to a string which ** is the expanded SQL text of the prepared statement or a comment that ** indicates the invocation of a trigger. ** ** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
-**
An SQLITE_TRACE_PROFILE callback provides approximately the same +**
^An SQLITE_TRACE_PROFILE callback provides approximately the same ** information as is provided by the [sqlite3_profile()] callback. -** The P argument is a pointer to the [prepared statement] and the -** X argument points to a 64-bit integer which is the estimated of +** ^The P argument is a pointer to the [prepared statement] and the +** ^X argument points to a 64-bit integer which is the estimated of ** the number of nanosecond that the prepared statement took to run. -** The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. +** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. ** ** [[SQLITE_TRACE_ROW]]
SQLITE_TRACE_ROW
-**
An SQLITE_TRACE_ROW callback is invoked whenever a prepared +**
^An SQLITE_TRACE_ROW callback is invoked whenever a prepared ** statement generates a single row of result. -** The P argument is a pointer to the [prepared statement] and the +** ^The P argument is a pointer to the [prepared statement] and the ** X argument is unused. ** ** [[SQLITE_TRACE_CLOSE]]
SQLITE_TRACE_CLOSE
-**
An SQLITE_TRACE_CLOSE callback is invoked when a database +**
^An SQLITE_TRACE_CLOSE callback is invoked when a database ** connection closes. -** The P argument is a pointer to the [database connection] object +** ^The P argument is a pointer to the [database connection] object ** and the X argument is unused. **
*/ @@ -2846,25 +2846,25 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** CAPI3REF: SQL Trace Hook ** METHOD: sqlite3 ** -** The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback +** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback ** function X against [database connection] D, using property mask M -** and context pointer P. If the X callback is +** and context pointer P. ^If the X callback is ** NULL or if the M mask is zero, then tracing is disabled. The ** M argument must be one or more of the [SQLITE_TRACE] ** constants. ** -** Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides +** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). ** -** The X callback is invoked whenever any of the events identified by -** mask M occur. The integer return value from the callback is currently +** ^The X callback is invoked whenever any of the events identified by +** mask M occur. ^The integer return value from the callback is currently ** ignored, though this may change in future releases. Callback ** implementations should return zero to ensure future compatibility. ** -** A trace callback is invoked with four arguments: callback(T,C,P,X). -** The T argument is one of the [SQLITE_TRACE] +** ^A trace callback is invoked with four arguments: callback(T,C,P,X). +** ^The T argument is one of the [SQLITE_TRACE] ** constants to indicate why the callback was invoked. -** The C argument is a copy of the context pointer. +** ^The C argument is a copy of the context pointer. ** The P and X arguments are pointers whose meanings depend on T. ** ** The sqlite3_trace_v2() interface is intended to replace the legacy diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 883e5c95bf..b17c0e0a40 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1612,6 +1612,39 @@ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ return (int)v; } +/* +** Return the SQL associated with a prepared statement +*/ +const char *sqlite3_sql(sqlite3_stmt *pStmt){ + Vdbe *p = (Vdbe *)pStmt; + return p ? p->zSql : 0; +} + +/* +** Return the SQL associated with a prepared statement with +** bound parameters expanded. Space to hold the returned string is +** obtained from sqlite3_malloc(). The caller is responsible for +** freeing the returned string by passing it to sqlite3_free(). +** +** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of +** expanded bound parameters. +*/ +char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ +#ifdef SQLITE_OMIT_TRACE + return 0; +#else + char *z = 0; + const char *zSql = sqlite3_sql(pStmt); + if( zSql ){ + Vdbe *p = (Vdbe *)pStmt; + sqlite3_mutex_enter(p->db->mutex); + z = sqlite3VdbeExpandSql(p, zSql); + sqlite3_mutex_leave(p->db->mutex); + } + return z; +#endif +} + #ifdef SQLITE_ENABLE_PREUPDATE_HOOK /* ** Allocate and populate an UnpackedRecord structure based on the serialized diff --git a/src/vdbeaux.c b/src/vdbeaux.c index b04a1d23f2..992fa4db9e 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -64,39 +64,6 @@ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){ p->isPrepareV2 = (u8)isPrepareV2; } -/* -** Return the SQL associated with a prepared statement -*/ -const char *sqlite3_sql(sqlite3_stmt *pStmt){ - Vdbe *p = (Vdbe *)pStmt; - return p ? p->zSql : 0; -} - -/* -** Return the SQL associated with a prepared statement with -** bound parameters expanded. Space to hold the returned string is -** obtained from sqlite3_malloc(). The caller is responsible for -** freeing the returned string by passing it to sqlite3_free(). -** -** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of -** expanded bound parameters. -*/ -char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ -#ifdef SQLITE_OMIT_TRACE - return 0; -#else - char *z = 0; - const char *zSql = sqlite3_sql(pStmt); - if( zSql ){ - Vdbe *p = (Vdbe *)pStmt; - sqlite3_mutex_enter(p->db->mutex); - z = sqlite3VdbeExpandSql(p, zSql); - sqlite3_mutex_leave(p->db->mutex); - } - return z; -#endif -} - /* ** Swap all content between two VDBE structures. */ diff --git a/src/vdbetrace.c b/src/vdbetrace.c index 8a1c23bc35..d30cf3acd5 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -141,8 +141,8 @@ char *sqlite3VdbeExpandSql( if( enc!=SQLITE_UTF8 ){ memset(&utf8, 0, sizeof(utf8)); utf8.db = db; - if( SQLITE_NOMEM== sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) - || SQLITE_NOMEM== sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) + if( SQLITE_NOMEM==sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) + || SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){ sqlite3StrAccumReset(&out); sqlite3VdbeMemRelease(&utf8); From 8afffe7244c9e66c1667e92da35bb258b59ee170 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 04:58:57 +0000 Subject: [PATCH 217/302] Improvements to sqlite3_trace_v2() documentation. Fix the sqlite3VdbeExpandSql() routine to respond better to OOM conditions. FossilOrigin-Name: 0400f642d542e62bb428e0bf263964c65691368e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 17 ++++++++++------- src/vdbetrace.c | 11 +++++------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 631dae73d0..1bd6c3bab6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\srequirements\smarks\sto\sthe\ssqlite3_trace_v2()\sinterface\sdocumentation. -D 2016-07-23T02:07:26.475 +C Improvements\sto\ssqlite3_trace_v2()\sdocumentation.\s\sFix\sthe\nsqlite3VdbeExpandSql()\sroutine\sto\srespond\sbetter\sto\sOOM\sconditions. +D 2016-07-23T04:58:57.202 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 -F src/sqlite.h.in 35e253c3b408157a9edc3306d4f1b770af73a398 +F src/sqlite.h.in 3dc7317ded4bf66facd845705f45f21d03517940 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -457,7 +457,7 @@ F src/vdbeaux.c a32d79aeaa88dc2b97c261172d952d395254a055 F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c -F src/vdbetrace.c 05d1f843117c4fdcc1f8b1e950011bbeef0cef84 +F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a @@ -1506,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5a027fe4127d498e0dc0d9439131c6a29085cf0a -R 424a44eb6e790a98bbdc6c3248de6bc5 +P ebd388e94da4a2b29c2a546f832d359619803ec5 +R 19a6abe5f5ce376943dab16457333fb2 U drh -Z 5a7cc904a805d16230629029b0dc335a +Z 006f9291eaaf608f3169b0980f613014 diff --git a/manifest.uuid b/manifest.uuid index 4db50f7e69..06586e70c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebd388e94da4a2b29c2a546f832d359619803ec5 \ No newline at end of file +0400f642d542e62bb428e0bf263964c65691368e \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1308a1122d..ed68cf0a13 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2820,7 +2820,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, **
^An SQLITE_TRACE_PROFILE callback provides approximately the same ** information as is provided by the [sqlite3_profile()] callback. ** ^The P argument is a pointer to the [prepared statement] and the -** ^X argument points to a 64-bit integer which is the estimated of +** X argument points to a 64-bit integer which is the estimated of ** the number of nanosecond that the prepared statement took to run. ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. ** @@ -2850,8 +2850,8 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** function X against [database connection] D, using property mask M ** and context pointer P. ^If the X callback is ** NULL or if the M mask is zero, then tracing is disabled. The -** M argument must be one or more of the [SQLITE_TRACE] -** constants. +** M argument should be the bitwise OR-ed combination of +** zero or more [SQLITE_TRACE] constants. ** ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). @@ -3509,10 +3509,13 @@ int sqlite3_prepare16_v2( ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() ** will return "SELECT 2345,NULL".)^ ** -** ^The [SQLITE_TRACE_SIZE_LIMIT] setting limits the size of a -** bound parameter expansion. ^If SQLite is built with the -** [SQLITE_OMIT_TRACE] compile-time option then the sqlite3_expanded_sql() -** interface is non-functional and always returns NULL. +** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory +** is available to hold the result, or if the result would exceed the +** the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. +** +** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of +** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time +** option causes sqlite3_expanded_sql() to always return NULL. ** ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is ** automatically freed when the prepared statement is finalized. diff --git a/src/vdbetrace.c b/src/vdbetrace.c index d30cf3acd5..7b47363991 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -141,12 +141,10 @@ char *sqlite3VdbeExpandSql( if( enc!=SQLITE_UTF8 ){ memset(&utf8, 0, sizeof(utf8)); utf8.db = db; - if( SQLITE_NOMEM==sqlite3VdbeMemSetStr(&utf8,pVar->z,pVar->n,enc,SQLITE_STATIC) - || SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) - ){ - sqlite3StrAccumReset(&out); - sqlite3VdbeMemRelease(&utf8); - return 0; + sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); + if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){ + out.accError = STRACCUM_NOMEM; + out.nAlloc = 0; } pVar = &utf8; } @@ -189,6 +187,7 @@ char *sqlite3VdbeExpandSql( } } } + if( out.accError ) sqlite3StrAccumReset(&out); return sqlite3StrAccumFinish(&out); } From 49dcd79e7d2d759df3fbe7446b100dbd90cd4bd6 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 14:50:26 +0000 Subject: [PATCH 218/302] Fix recently added tests so that they work in all configurations. FossilOrigin-Name: d0bcaf0cd92ae5bbea7ad68537ba89437d5c39e8 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/dbstatus.test | 1 + test/vacuummem.test | 7 ++++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index feb1cf9a6e..412a1d98e5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_expanded_sql()\sand\ssqlite3_trace_v2()\sinterfaces. -D 2016-07-23T05:22:02.142 +C Fix\srecently\sadded\stests\sso\sthat\sthey\swork\sin\sall\sconfigurations. +D 2016-07-23T14:50:26.969 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 85833ba5bc95262749d080dcd40af87072ea8d5b +F test/dbstatus.test 2bb4d576f11c0f57f5633dad373ad1a57c2a7195 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1324,7 +1324,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 -F test/vacuummem.test 09c8b72a12405649ed84564367dad729bff88760 +F test/vacuummem.test ae20cc80a4960d3507d27cf0f2f4555988ceb6df F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test 765802c7a66d37fabd5ac8e2f2dbe572b43eb9ab @@ -1507,8 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f50a3fd6606c14b82c9b938bfca284d54b6c650f 0400f642d542e62bb428e0bf263964c65691368e -R 4a3af12ad9efd4d7dc81ee4ca45f95f6 -T +closed 0400f642d542e62bb428e0bf263964c65691368e +P 99a6c51887d9d78409944c5a028d5a3ac2e066a7 +R dcbad5b66668d4f45eebea8d8e4c4fc1 U drh -Z 2820f9890a85b78d1796850ebe9bb3ba +Z b2cb07cac2703599b169fabec6f383c3 diff --git a/manifest.uuid b/manifest.uuid index 288e6dc899..77b620836b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99a6c51887d9d78409944c5a028d5a3ac2e066a7 \ No newline at end of file +d0bcaf0cd92ae5bbea7ad68537ba89437d5c39e8 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index 00c5deabd5..fb4cbe04ba 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -390,6 +390,7 @@ ifcapable shared_cache { sqlite3 db file:test.db?cache=shared do_execsql_test 4.0 { + PRAGMA auto_vacuum=NONE; CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES(1, 2, 3); } diff --git a/test/vacuummem.test b/test/vacuummem.test index 967e28cec7..b0f5cf2038 100644 --- a/test/vacuummem.test +++ b/test/vacuummem.test @@ -17,6 +17,12 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix vacuummem +if {[permutation]=="memsubsys1"} { + finish_test + return +} + + proc memory_used {} { set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1] lindex $stat 1 @@ -51,4 +57,3 @@ do_test 1.5 { memory_used } {#/2300000/} finish_test - From 4b363a5130eeb67734da40007eeb46c48c268e9e Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 23 Jul 2016 20:27:41 +0000 Subject: [PATCH 219/302] Use sqlite3_trace_v2() instead of sqlite3_trace() in the shell. FossilOrigin-Name: c8e0539b970585cbb3619461a53abb0c3b308a17 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/shell.c | 13 ++++++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 58ad849efb..882bad7357 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_quote()\sfunction\sto\sthe\sJSON1\sextension. -D 2016-07-23T19:34:53.707 +C Use\ssqlite3_trace_v2()\sinstead\sof\ssqlite3_trace()\sin\sthe\sshell. +D 2016-07-23T20:27:41.266 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 -F src/shell.c a8a9e392a6a2777fabf5feb536931cb190f235e5 +F src/shell.c ad6375a1cbfb13786bfc7ae28e00d822aedefd35 F src/sqlite.h.in 3dc7317ded4bf66facd845705f45f21d03517940 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 @@ -1507,8 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8817dedb75430e6c78ff527f7ded4abb35776cef 2c3714aebf5e40e3728877a235b3c1f93defa33e -R d8b644436fd0d857689e119dadae618e -T +closed 2c3714aebf5e40e3728877a235b3c1f93defa33e +P 269892abf6e59c417729669cc764d1f237e093fd +R 38c94a12899d68429eb06d66defc6359 U drh -Z e34798b2dc952c68e869c2ddf5f79301 +Z 4041e092b34c5d7817e039ca6e44ec6c diff --git a/manifest.uuid b/manifest.uuid index 49e513c3f7..771fe8bf2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -269892abf6e59c417729669cc764d1f237e093fd \ No newline at end of file +c8e0539b970585cbb3619461a53abb0c3b308a17 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 874782c5f1..4a546ccfef 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2543,13 +2543,20 @@ static FILE *output_file_open(const char *zFile){ /* ** A routine for handling output from sqlite3_trace(). */ -static void sql_trace_callback(void *pArg, const char *z){ +static int sql_trace_callback( + unsigned mType, + void *pArg, + void *pP, + void *pX +){ FILE *f = (FILE*)pArg; if( f ){ + const char *z = (const char*)pX; int i = (int)strlen(z); while( i>0 && z[i-1]==';' ){ i--; } utf8_printf(f, "%.*s;\n", i, z); } + return 0; } /* @@ -4655,9 +4662,9 @@ static int do_meta_command(char *zLine, ShellState *p){ p->traceOut = output_file_open(azArg[1]); #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if( p->traceOut==0 ){ - sqlite3_trace(p->db, 0, 0); + sqlite3_trace_v2(p->db, 0, 0, 0); }else{ - sqlite3_trace(p->db, sql_trace_callback, p->traceOut); + sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut); } #endif }else From 087ec072ef45e9aaca031a4535cc93b4dbd530f3 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 00:05:56 +0000 Subject: [PATCH 220/302] Fix code so that the deprecated sqlite3_trace() and sqlite3_profile() interfaces are not called when SQLITE_OMIT_DEPRECATED is used. FossilOrigin-Name: 1c5baae3c545096a29a093f7d4387771f1db507c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/loadext.c | 2 +- src/main.c | 2 ++ src/tclsqlite.c | 3 ++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 882bad7357..da3ec9d304 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\ssqlite3_trace_v2()\sinstead\sof\ssqlite3_trace()\sin\sthe\sshell. -D 2016-07-23T20:27:41.266 +C Fix\scode\sso\sthat\sthe\sdeprecated\ssqlite3_trace()\sand\ssqlite3_profile()\s\ninterfaces\sare\snot\scalled\swhen\sSQLITE_OMIT_DEPRECATED\sis\sused. +D 2016-07-25T00:05:56.727 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -347,8 +347,8 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c 4237fd37ca589f1d90b3ea925dd9df20da8e0c84 -F src/main.c 2d3e62a971e7f169a74448e81af9ebde95b07381 +F src/loadext.c 5dd8b5a67d32a98bb75657c2a9e48b2cedbf13a4 +F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -392,7 +392,7 @@ F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 573e63c959b314d77486f3565fa79c60cda3df7e +F src/tclsqlite.c 5c213bf5fee084390f632df2328cf0821d483799 F src/test1.c 186e3b53c402b7a73bcb4ade2b77709675c39fe3 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 269892abf6e59c417729669cc764d1f237e093fd -R 38c94a12899d68429eb06d66defc6359 +P c8e0539b970585cbb3619461a53abb0c3b308a17 +R d97169b5da173af1e8c3e0989fc5f73b U drh -Z 4041e092b34c5d7817e039ca6e44ec6c +Z 74b666fd406733750b5703b09cc23966 diff --git a/manifest.uuid b/manifest.uuid index 771fe8bf2c..5edb03d00b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c8e0539b970585cbb3619461a53abb0c3b308a17 \ No newline at end of file +1c5baae3c545096a29a093f7d4387771f1db507c \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 718dae5777..ce1f5317c6 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -91,7 +91,7 @@ # define sqlite3_enable_shared_cache 0 #endif -#ifdef SQLITE_OMIT_TRACE +#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED) # define sqlite3_profile 0 # define sqlite3_trace 0 #endif diff --git a/src/main.c b/src/main.c index 5cd1ea7185..f31f865818 100644 --- a/src/main.c +++ b/src/main.c @@ -1845,6 +1845,7 @@ int sqlite3_trace_v2( return SQLITE_OK; } +#ifndef SQLITE_OMIT_DEPRECATED /* ** Register a profile function. The pArg from the previously registered ** profile function is returned. @@ -1873,6 +1874,7 @@ void *sqlite3_profile( sqlite3_mutex_leave(db->mutex); return pOld; } +#endif /* SQLITE_OMIT_DEPRECATED */ #endif /* SQLITE_OMIT_TRACE */ /* diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 43dfedb727..2de88f41f4 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2912,7 +2912,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ }else{ pDb->zTrace = 0; } -#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) +#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) \ + && !defined(SQLITE_OMIT_DEPRECATED) if( pDb->zTrace ){ pDb->interp = interp; sqlite3_trace(pDb->db, DbTraceHandler, pDb); From bd441f77009be56eb5c815a3accd578f03c609b7 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 02:31:48 +0000 Subject: [PATCH 221/302] Change SQLITE_TRACE_STMT to return unexpanded SQL text in the X argument. Add documentation on how and when to use sqlite3_expanded_sql(P) to compute the expanded text for legacy sqlite3_trace() compatibility. FossilOrigin-Name: 163e15229d837a5471007cffb8d41faafd081737 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 7 +++++-- src/vdbe.c | 9 ++++++--- tool/srcck1.c | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index da3ec9d304..819e488286 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scode\sso\sthat\sthe\sdeprecated\ssqlite3_trace()\sand\ssqlite3_profile()\s\ninterfaces\sare\snot\scalled\swhen\sSQLITE_OMIT_DEPRECATED\sis\sused. -D 2016-07-25T00:05:56.727 +C Change\sSQLITE_TRACE_STMT\sto\sreturn\sunexpanded\sSQL\stext\sin\sthe\sX\sargument.\nAdd\sdocumentation\son\show\sand\swhen\sto\suse\ssqlite3_expanded_sql(P)\sto\scompute\nthe\sexpanded\stext\sfor\slegacy\ssqlite3_trace()\scompatibility. +D 2016-07-25T02:31:48.358 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c ad6375a1cbfb13786bfc7ae28e00d822aedefd35 -F src/sqlite.h.in 3dc7317ded4bf66facd845705f45f21d03517940 +F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 @@ -449,7 +449,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 -F src/vdbe.c 7b5570f77e32766949fd8f9478e4a9bb06e6ab24 +F src/vdbe.c 7718d72427fd3abae6603a7a225e3eec12137d4a F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c c3f6715a99995c11748ecad91d25e93fd9fc390b @@ -1475,7 +1475,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/sqldiff.c 4478f0d30230de6adde90bdb0bfe60f68c5ab782 -F tool/srcck1.c 4c39bdfa9a92edd20233ee720df84dbeb2417602 +F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh c5a617b8c61a0926747a56c65f5671ef8ac0e148 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c8e0539b970585cbb3619461a53abb0c3b308a17 -R d97169b5da173af1e8c3e0989fc5f73b +P 1c5baae3c545096a29a093f7d4387771f1db507c +R 287171615483ae1144a14be35a6974e0 U drh -Z 74b666fd406733750b5703b09cc23966 +Z fb84b0dd7373ed024b44202f95be044f diff --git a/manifest.uuid b/manifest.uuid index 5edb03d00b..6cdf0fb62f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c5baae3c545096a29a093f7d4387771f1db507c \ No newline at end of file +163e15229d837a5471007cffb8d41faafd081737 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ed68cf0a13..e8f5d24845 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2813,8 +2813,11 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** execution of the prepared statement, such as at the start of each ** trigger subprogram. ^The P argument is a pointer to the ** [prepared statement]. ^The X argument is a pointer to a string which -** is the expanded SQL text of the prepared statement or a comment that -** indicates the invocation of a trigger. +** is the unexpanded SQL text of the prepared statement or an SQL comment +** that indicates the invocation of a trigger. ^The callback can compute +** the same text that would have been returned by the legacy [sqlite3_trace()] +** interface by using the X argument when X begins with "--" and invoking +** [sqlite3_expanded_sql(P)] otherwise. ** ** [[SQLITE_TRACE_PROFILE]]
SQLITE_TRACE_PROFILE
**
^An SQLITE_TRACE_PROFILE callback provides approximately the same diff --git a/src/vdbe.c b/src/vdbe.c index cdbd7301b8..d198d1ff8c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6785,21 +6785,24 @@ case OP_Init: { /* jump */ char *z; #ifndef SQLITE_OMIT_TRACE + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c */ + assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){ - z = sqlite3VdbeExpandSql(p, zTrace); #ifndef SQLITE_OMIT_DEPRECATED if( db->mTrace & SQLITE_TRACE_LEGACY ){ void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; + z = sqlite3VdbeExpandSql(p, zTrace); x(db->pTraceArg, z); + sqlite3_free(z); }else #endif { - (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z); + (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace); } - sqlite3_free(z); } #ifdef SQLITE_USE_FCNTL_TRACE zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); diff --git a/tool/srcck1.c b/tool/srcck1.c index e95765185f..20084ac47f 100644 --- a/tool/srcck1.c +++ b/tool/srcck1.c @@ -58,7 +58,7 @@ static char *readFile(const char *zFilename){ return z; } -/* Change the C code in the argument to see if it might have +/* Check the C code in the argument to see if it might have ** side effects. The only accurate way to know this is to do a full ** parse of the C code, which this routine does not do. This routine ** uses a simple heuristic of looking for: From 5fe63bfb93ebccf1f00b8a8e1c9d2ed82f0bd86f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 02:42:22 +0000 Subject: [PATCH 222/302] Evidence marks and code reformatting for SQLITE_TRACE_STMT operation. FossilOrigin-Name: e1e022383114525241454f63ea8b9768fb7ec657 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 819e488286..9f9642d316 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sSQLITE_TRACE_STMT\sto\sreturn\sunexpanded\sSQL\stext\sin\sthe\sX\sargument.\nAdd\sdocumentation\son\show\sand\swhen\sto\suse\ssqlite3_expanded_sql(P)\sto\scompute\nthe\sexpanded\stext\sfor\slegacy\ssqlite3_trace()\scompatibility. -D 2016-07-25T02:31:48.358 +C Evidence\smarks\sand\scode\sreformatting\sfor\sSQLITE_TRACE_STMT\soperation. +D 2016-07-25T02:42:22.338 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -449,7 +449,7 @@ F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 -F src/vdbe.c 7718d72427fd3abae6603a7a225e3eec12137d4a +F src/vdbe.c ea260b61e73b11a71e70b28a8e25866e2899e5da F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d F src/vdbeapi.c c3f6715a99995c11748ecad91d25e93fd9fc390b @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c5baae3c545096a29a093f7d4387771f1db507c -R 287171615483ae1144a14be35a6974e0 +P 163e15229d837a5471007cffb8d41faafd081737 +R 54f5b446e83fdc6cfb9e4fb83bcacd6b U drh -Z fb84b0dd7373ed024b44202f95be044f +Z cd50dce290ecc3f8f1fad92c2e3b32fc diff --git a/manifest.uuid b/manifest.uuid index 6cdf0fb62f..be4af97fc7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -163e15229d837a5471007cffb8d41faafd081737 \ No newline at end of file +e1e022383114525241454f63ea8b9768fb7ec657 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index d198d1ff8c..5d21ad064c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6782,12 +6782,19 @@ case OP_MaxPgcnt: { /* out2 */ */ case OP_Init: { /* jump */ char *zTrace; - char *z; + + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c. + ** + ** This assert() provides evidence for: + ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that + ** would have been returned by the legacy sqlite3_trace() interface by + ** using the X argument when X begins with "--" and invoking + ** sqlite3_expanded_sql(P) otherwise. + */ + assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); #ifndef SQLITE_OMIT_TRACE - /* If the P4 argument is not NULL, then it must be an SQL comment string. - ** The "--" string is broken up to prevent false-positives with srcck1.c */ - assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 && !p->doingRerun && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 @@ -6795,7 +6802,7 @@ case OP_Init: { /* jump */ #ifndef SQLITE_OMIT_DEPRECATED if( db->mTrace & SQLITE_TRACE_LEGACY ){ void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; - z = sqlite3VdbeExpandSql(p, zTrace); + char *z = sqlite3VdbeExpandSql(p, zTrace); x(db->pTraceArg, z); sqlite3_free(z); }else From c530b9c65bab03a581a9f898151256ecf2680649 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:27:22 +0000 Subject: [PATCH 223/302] Add --enable-memsys3 and --enable-memsys5 options to the configure script. FossilOrigin-Name: 67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 --- configure | 73 +++++++++++++++++++++++++++++++++++++++++---------- configure.ac | 24 +++++++++++++++++ manifest | 16 +++++------ manifest.uuid | 2 +- src/shell.c | 2 ++ 5 files changed, 94 insertions(+), 23 deletions(-) diff --git a/configure b/configure index f4d4c48077..ee62dcc9bd 100755 --- a/configure +++ b/configure @@ -772,6 +772,7 @@ LIBOBJS BUILD_CFLAGS USE_GCOV OPT_FEATURE_FLAGS +SQLITE_MEMSYS5 USE_AMALGAMATION TARGET_DEBUG TARGET_HAVE_EDITLINE @@ -903,6 +904,8 @@ with_readline_inc enable_debug enable_amalgamation enable_load_extension +enable_memsys3 +enable_memsys5 enable_fts3 enable_fts4 enable_fts5 @@ -1552,6 +1555,8 @@ Optional Features: separately --disable-load-extension Disable loading of external extensions + --enable-memsys3 Enable MEMSYS3 + --enable-memsys5 Enable MEMSYS5 --enable-fts3 Enable the FTS3 extension --enable-fts4 Enable the FTS4 extension --enable-fts5 Enable the FTS5 extension @@ -3925,13 +3930,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3928: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3933: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3931: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3936: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3934: output\"" >&5) + (eval echo "\"\$as_me:3939: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5137,7 +5142,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5140 "configure"' > conftest.$ac_ext + echo '#line 5145 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6662,11 +6667,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6665: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6670: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6669: \$? = $ac_status" >&5 + echo "$as_me:6674: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7001,11 +7006,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7004: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7009: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7008: \$? = $ac_status" >&5 + echo "$as_me:7013: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7106,11 +7111,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7109: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7114: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7113: \$? = $ac_status" >&5 + echo "$as_me:7118: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7161,11 +7166,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7164: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7169: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7168: \$? = $ac_status" >&5 + echo "$as_me:7173: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9541,7 +9546,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9544 "configure" +#line 9549 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9637,7 +9642,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9640 "configure" +#line 9645 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11339,6 +11344,46 @@ else OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1" fi +########## +# Do we want to support memsys3 and/or memsys5 +# +# Check whether --enable-memsys3 was given. +if test "${enable_memsys3+set}" = set; then : + enableval=$enable_memsys3; +else + enable_memsys3=yes +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 +$as_echo_n "checking whether to support MEMSYS3... " >&6; } +if test "$enable_memsys3" = "yes"; then + SQLITE_ENABLE_MEMSYS3=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + +# Check whether --enable-memsys5 was given. +if test "${enable_memsys5+set}" = set; then : + enableval=$enable_memsys5; +else + enable_memsys3=yes +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5 +$as_echo_n "checking whether to support MEMSYS5... " >&6; } +if test "$enable_memsys5" = "yes"; then + SQLITE_ENABLE_MEMSYS5=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + ######### # See whether we should enable Full Text Search extensions # Check whether --enable-fts3 was given. diff --git a/configure.ac b/configure.ac index e5727ea7f2..7ab6bf9024 100644 --- a/configure.ac +++ b/configure.ac @@ -588,6 +588,30 @@ else OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1" fi +########## +# Do we want to support memsys3 and/or memsys5 +# +AC_ARG_ENABLE(memsys3, +AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),,enable_memsys3=yes) +AC_MSG_CHECKING([whether to support MEMSYS3]) +if test "$enable_memsys3" = "yes"; then + SQLITE_ENABLE_MEMSYS3=1 + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST(SQLITE_MEMSYS5) +AC_ARG_ENABLE(memsys5, +AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),,enable_memsys3=yes) +AC_MSG_CHECKING([whether to support MEMSYS5]) +if test "$enable_memsys5" = "yes"; then + SQLITE_ENABLE_MEMSYS5=1 + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST(SQLITE_MEMSYS5) + ######### # See whether we should enable Full Text Search extensions AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3], diff --git a/manifest b/manifest index 9f9642d316..6391e1baa3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Evidence\smarks\sand\scode\sreformatting\sfor\sSQLITE_TRACE_STMT\soperation. -D 2016-07-25T02:42:22.338 +C Add\s--enable-memsys3\sand\s--enable-memsys5\soptions\sto\sthe\sconfigure\sscript. +D 2016-07-25T11:27:22.245 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 25cf7eb52a88846e4c1978016a9db22763c54f41 x -F configure.ac 480e1a17d5316b1751c8edcb15b8e6b8ab0a6cc3 +F configure 7f1096018e7277653bdccbc3522763950716c04e x +F configure.ac 312a1d5cee98d125c4d5af63ae244d1d4d4e61ae F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 -F src/shell.c ad6375a1cbfb13786bfc7ae28e00d822aedefd35 +F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 163e15229d837a5471007cffb8d41faafd081737 -R 54f5b446e83fdc6cfb9e4fb83bcacd6b +P e1e022383114525241454f63ea8b9768fb7ec657 +R f029b1d7e77fec56f765d45dc22f3d18 U drh -Z cd50dce290ecc3f8f1fad92c2e3b32fc +Z 774059649b6fa0105cfafff42cfa581a diff --git a/manifest.uuid b/manifest.uuid index be4af97fc7..3b4218203e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1e022383114525241454f63ea8b9768fb7ec657 \ No newline at end of file +67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 4a546ccfef..e8d215b95a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -5324,6 +5324,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ szHeap = integerValue(zSize); if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); +#else + (void)cmdline_option_value(argc, argv, ++i); #endif }else if( strcmp(z,"-scratch")==0 ){ int n, sz; From 26197d1b62c26a5f13a720e478238af4e3b8ee1b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:32:09 +0000 Subject: [PATCH 224/302] Fix the --enable-memsysN options in configure so that they actually work. FossilOrigin-Name: 679552550e085497b98478bbe28056d99fe4aab4 --- configure | 12 ++++++------ configure.ac | 10 ++++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/configure b/configure index ee62dcc9bd..de3dfdd49d 100755 --- a/configure +++ b/configure @@ -11349,14 +11349,14 @@ fi # # Check whether --enable-memsys3 was given. if test "${enable_memsys3+set}" = set; then : - enableval=$enable_memsys3; + enableval=$enable_memsys3; enable_memsys3=yes else - enable_memsys3=yes + enable_memsys3=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 $as_echo_n "checking whether to support MEMSYS3... " >&6; } -if test "$enable_memsys3" = "yes"; then +if test "${enable_memsys3}" = "yes"; then SQLITE_ENABLE_MEMSYS3=1 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -11367,14 +11367,14 @@ fi # Check whether --enable-memsys5 was given. if test "${enable_memsys5+set}" = set; then : - enableval=$enable_memsys5; + enableval=$enable_memsys5; enable_memsys5=yes else - enable_memsys3=yes + enable_memsys5=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5 $as_echo_n "checking whether to support MEMSYS5... " >&6; } -if test "$enable_memsys5" = "yes"; then +if test "${enable_memsys5}" = "yes"; then SQLITE_ENABLE_MEMSYS5=1 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } diff --git a/configure.ac b/configure.ac index 7ab6bf9024..da8d7db09f 100644 --- a/configure.ac +++ b/configure.ac @@ -592,9 +592,10 @@ fi # Do we want to support memsys3 and/or memsys5 # AC_ARG_ENABLE(memsys3, -AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]),,enable_memsys3=yes) + AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]), + [enable_memsys3=yes],[enable_memsys3=no]) AC_MSG_CHECKING([whether to support MEMSYS3]) -if test "$enable_memsys3" = "yes"; then +if test "${enable_memsys3}" = "yes"; then SQLITE_ENABLE_MEMSYS3=1 AC_MSG_RESULT([yes]) else @@ -602,9 +603,10 @@ else fi AC_SUBST(SQLITE_MEMSYS5) AC_ARG_ENABLE(memsys5, -AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]),,enable_memsys3=yes) + AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]), + [enable_memsys5=yes],[enable_memsys5=no]) AC_MSG_CHECKING([whether to support MEMSYS5]) -if test "$enable_memsys5" = "yes"; then +if test "${enable_memsys5}" = "yes"; then SQLITE_ENABLE_MEMSYS5=1 AC_MSG_RESULT([yes]) else diff --git a/manifest b/manifest index 6391e1baa3..2f9c340bb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s--enable-memsys3\sand\s--enable-memsys5\soptions\sto\sthe\sconfigure\sscript. -D 2016-07-25T11:27:22.245 +C Fix\sthe\s--enable-memsysN\soptions\sin\sconfigure\sso\sthat\sthey\sactually\swork. +D 2016-07-25T11:32:09.826 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 7f1096018e7277653bdccbc3522763950716c04e x -F configure.ac 312a1d5cee98d125c4d5af63ae244d1d4d4e61ae +F configure 71e6c9bb642ef53357cb8dbc858fc84998f3bc6d x +F configure.ac b67f6fc9f3e22edabd4be3911289400423e5ffa9 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1e022383114525241454f63ea8b9768fb7ec657 -R f029b1d7e77fec56f765d45dc22f3d18 +P 67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 +R bb2ee4817e32d59609fbb5b8d40bbd12 U drh -Z 774059649b6fa0105cfafff42cfa581a +Z dcc29f2a3f4c1199964573b0937d7a95 diff --git a/manifest.uuid b/manifest.uuid index 3b4218203e..faaef17b8e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 \ No newline at end of file +679552550e085497b98478bbe28056d99fe4aab4 \ No newline at end of file From 6fe4c184fb593a593d690f34cb0e1591ac5715a2 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:39:24 +0000 Subject: [PATCH 225/302] Another attempt at getting --enable-memsysN working. FossilOrigin-Name: 5f40e6ad599eea59a5adc3a11d6f7998872736b4 --- configure | 35 ++++++++++++++++------------------- configure.ac | 6 ++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/configure b/configure index de3dfdd49d..85d56a1ede 100755 --- a/configure +++ b/configure @@ -772,7 +772,6 @@ LIBOBJS BUILD_CFLAGS USE_GCOV OPT_FEATURE_FLAGS -SQLITE_MEMSYS5 USE_AMALGAMATION TARGET_DEBUG TARGET_HAVE_EDITLINE @@ -3930,13 +3929,13 @@ if ${lt_cv_nm_interface+:} false; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3933: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3932: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3936: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3935: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3939: output\"" >&5) + (eval echo "\"\$as_me:3938: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5142,7 +5141,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5145 "configure"' > conftest.$ac_ext + echo '#line 5144 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6667,11 +6666,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6670: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6669: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6674: \$? = $ac_status" >&5 + echo "$as_me:6673: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7006,11 +7005,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7009: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7008: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7013: \$? = $ac_status" >&5 + echo "$as_me:7012: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7111,11 +7110,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7114: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7113: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7118: \$? = $ac_status" >&5 + echo "$as_me:7117: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7166,11 +7165,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7169: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7168: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7173: \$? = $ac_status" >&5 + echo "$as_me:7172: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9546,7 +9545,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9549 "configure" +#line 9548 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9642,7 +9641,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9645 "configure" +#line 9644 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11357,14 +11356,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 $as_echo_n "checking whether to support MEMSYS3... " >&6; } if test "${enable_memsys3}" = "yes"; then - SQLITE_ENABLE_MEMSYS3=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - # Check whether --enable-memsys5 was given. if test "${enable_memsys5+set}" = set; then : enableval=$enable_memsys5; enable_memsys5=yes @@ -11375,7 +11373,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS5" >&5 $as_echo_n "checking whether to support MEMSYS5... " >&6; } if test "${enable_memsys5}" = "yes"; then - SQLITE_ENABLE_MEMSYS5=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS5" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else @@ -11383,7 +11381,6 @@ else $as_echo "no" >&6; } fi - ######### # See whether we should enable Full Text Search extensions # Check whether --enable-fts3 was given. diff --git a/configure.ac b/configure.ac index da8d7db09f..07dd3cb88a 100644 --- a/configure.ac +++ b/configure.ac @@ -596,23 +596,21 @@ AC_ARG_ENABLE(memsys3, [enable_memsys3=yes],[enable_memsys3=no]) AC_MSG_CHECKING([whether to support MEMSYS3]) if test "${enable_memsys3}" = "yes"; then - SQLITE_ENABLE_MEMSYS3=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi -AC_SUBST(SQLITE_MEMSYS5) AC_ARG_ENABLE(memsys5, AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]), [enable_memsys5=yes],[enable_memsys5=no]) AC_MSG_CHECKING([whether to support MEMSYS5]) if test "${enable_memsys5}" = "yes"; then - SQLITE_ENABLE_MEMSYS5=1 + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS5" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi -AC_SUBST(SQLITE_MEMSYS5) ######### # See whether we should enable Full Text Search extensions diff --git a/manifest b/manifest index 2f9c340bb9..8310f7e4f2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s--enable-memsysN\soptions\sin\sconfigure\sso\sthat\sthey\sactually\swork. -D 2016-07-25T11:32:09.826 +C Another\sattempt\sat\sgetting\s--enable-memsysN\sworking. +D 2016-07-25T11:39:24.067 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 71e6c9bb642ef53357cb8dbc858fc84998f3bc6d x -F configure.ac b67f6fc9f3e22edabd4be3911289400423e5ffa9 +F configure f62e6614b26418ce81392b2c28b2a6cf268f1d5d x +F configure.ac 83c4e53031a3582d0b9200dcb3700189a24f1b1c F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 67e1dc9842dc8a6ae5edef21bdb2ef6d3f4a17b7 -R bb2ee4817e32d59609fbb5b8d40bbd12 +P 679552550e085497b98478bbe28056d99fe4aab4 +R 5c303973b5bb214411149d73b1469581 U drh -Z dcc29f2a3f4c1199964573b0937d7a95 +Z 6145af1bb509746e3a2a7850c862eafe diff --git a/manifest.uuid b/manifest.uuid index faaef17b8e..8d55876e78 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -679552550e085497b98478bbe28056d99fe4aab4 \ No newline at end of file +5f40e6ad599eea59a5adc3a11d6f7998872736b4 \ No newline at end of file From 5d513ba08ca3b60dceb0b1223acf42ef0d443c1e Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 11:57:21 +0000 Subject: [PATCH 226/302] If both MEMSYS3 and MEMSYS5 are enabled, than automatically disable MEMSYS3. FossilOrigin-Name: ccc22e14dc5d910d632807f49484be54dc2fde83 --- configure | 38 +++++++++++++++++++------------------- configure.ac | 20 ++++++++++---------- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqliteInt.h | 10 +++++++--- test/releasetest.tcl | 1 - 6 files changed, 46 insertions(+), 43 deletions(-) diff --git a/configure b/configure index 85d56a1ede..fbcf7309b1 100755 --- a/configure +++ b/configure @@ -903,8 +903,8 @@ with_readline_inc enable_debug enable_amalgamation enable_load_extension -enable_memsys3 enable_memsys5 +enable_memsys3 enable_fts3 enable_fts4 enable_fts5 @@ -1554,8 +1554,8 @@ Optional Features: separately --disable-load-extension Disable loading of external extensions - --enable-memsys3 Enable MEMSYS3 --enable-memsys5 Enable MEMSYS5 + --enable-memsys3 Enable MEMSYS3 --enable-fts3 Enable the FTS3 extension --enable-fts4 Enable the FTS4 extension --enable-fts5 Enable the FTS5 extension @@ -11346,23 +11346,6 @@ fi ########## # Do we want to support memsys3 and/or memsys5 # -# Check whether --enable-memsys3 was given. -if test "${enable_memsys3+set}" = set; then : - enableval=$enable_memsys3; enable_memsys3=yes -else - enable_memsys3=no -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 -$as_echo_n "checking whether to support MEMSYS3... " >&6; } -if test "${enable_memsys3}" = "yes"; then - OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi # Check whether --enable-memsys5 was given. if test "${enable_memsys5+set}" = set; then : enableval=$enable_memsys5; enable_memsys5=yes @@ -11380,6 +11363,23 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +# Check whether --enable-memsys3 was given. +if test "${enable_memsys3+set}" = set; then : + enableval=$enable_memsys3; enable_memsys3=yes +else + enable_memsys3=no +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support MEMSYS3" >&5 +$as_echo_n "checking whether to support MEMSYS3... " >&6; } +if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi ######### # See whether we should enable Full Text Search extensions diff --git a/configure.ac b/configure.ac index 07dd3cb88a..c9e3af9220 100644 --- a/configure.ac +++ b/configure.ac @@ -591,16 +591,6 @@ fi ########## # Do we want to support memsys3 and/or memsys5 # -AC_ARG_ENABLE(memsys3, - AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]), - [enable_memsys3=yes],[enable_memsys3=no]) -AC_MSG_CHECKING([whether to support MEMSYS3]) -if test "${enable_memsys3}" = "yes"; then - OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi AC_ARG_ENABLE(memsys5, AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5]), [enable_memsys5=yes],[enable_memsys5=no]) @@ -611,6 +601,16 @@ if test "${enable_memsys5}" = "yes"; then else AC_MSG_RESULT([no]) fi +AC_ARG_ENABLE(memsys3, + AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3]), + [enable_memsys3=yes],[enable_memsys3=no]) +AC_MSG_CHECKING([whether to support MEMSYS3]) +if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then + OPT_FEATURE_FLAGS+=" -DSQLITE_ENABLE_MEMSYS3" + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi ######### # See whether we should enable Full Text Search extensions diff --git a/manifest b/manifest index 8310f7e4f2..6a45ebc22e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\sattempt\sat\sgetting\s--enable-memsysN\sworking. -D 2016-07-25T11:39:24.067 +C If\sboth\sMEMSYS3\sand\sMEMSYS5\sare\senabled,\sthan\sautomatically\sdisable\sMEMSYS3. +D 2016-07-25T11:57:21.222 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -30,8 +30,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure f62e6614b26418ce81392b2c28b2a6cf268f1d5d x -F configure.ac 83c4e53031a3582d0b9200dcb3700189a24f1b1c +F configure 35ce04a15ca046262bf9baaa2ced9337708cc653 x +F configure.ac b5d3df43161374f8dffd2e5f4b88fbb51685b975 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -388,7 +388,7 @@ F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 -F src/sqliteInt.h 48cd97eb134665348393dfe277b4c14d1085bfc7 +F src/sqliteInt.h 49081ceab08eda9943d555aee57392c5b35d1c60 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1009,7 +1009,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/regexp2.test aa7ffcc21350007a78361b82bcf3b74d12227144 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 7d80014d0245b3f9d02d393d420bf03ca155aec0 +F test/releasetest.tcl 3a66c7b8fbe55bcd97c907217c3d812d1d3c6b93 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 679552550e085497b98478bbe28056d99fe4aab4 -R 5c303973b5bb214411149d73b1469581 +P 5f40e6ad599eea59a5adc3a11d6f7998872736b4 +R b01daae186a7f9a051c9362d4aae0591 U drh -Z 6145af1bb509746e3a2a7850c862eafe +Z d2602db348bfa53fd2c4a084ddf1dc40 diff --git a/manifest.uuid b/manifest.uuid index 8d55876e78..9bc4c35374 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f40e6ad599eea59a5adc3a11d6f7998872736b4 \ No newline at end of file +ccc22e14dc5d910d632807f49484be54dc2fde83 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0be4947513..879e6703ca 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3440,11 +3440,15 @@ int sqlite3HeapNearlyFull(void); # define sqlite3StackFree(D,P) sqlite3DbFree(D,P) #endif -#ifdef SQLITE_ENABLE_MEMSYS3 -const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); -#endif +/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together. If they +** are, disable MEMSYS3 +*/ #ifdef SQLITE_ENABLE_MEMSYS5 const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); +#undef SQLITE_ENABLE_MEMSYS3 +#endif +#ifdef SQLITE_ENABLE_MEMSYS3 +const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); #endif diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 2961fc385d..e13a3d7340 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -120,7 +120,6 @@ array set ::Configs [strip_comments { -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_MEMSYS5=1 - -DSQLITE_ENABLE_MEMSYS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_HIDDEN_COLUMNS From 26fe413be6d02028d56ce8e4970ab3655af2132c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 12:01:18 +0000 Subject: [PATCH 227/302] Update the vacuummem.test script so that it works on mac as well as on linux. FossilOrigin-Name: ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vacuummem.test | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6a45ebc22e..9cd5c96943 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sboth\sMEMSYS3\sand\sMEMSYS5\sare\senabled,\sthan\sautomatically\sdisable\sMEMSYS3. -D 2016-07-25T11:57:21.222 +C Update\sthe\svacuummem.test\sscript\sso\sthat\sit\sworks\son\smac\sas\swell\sas\son\slinux. +D 2016-07-25T12:01:18.862 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1324,7 +1324,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 -F test/vacuummem.test ae20cc80a4960d3507d27cf0f2f4555988ceb6df +F test/vacuummem.test e53a3fdca4612a99c515e1afe7934728a2383764 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test 765802c7a66d37fabd5ac8e2f2dbe572b43eb9ab @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f40e6ad599eea59a5adc3a11d6f7998872736b4 -R b01daae186a7f9a051c9362d4aae0591 +P ccc22e14dc5d910d632807f49484be54dc2fde83 +R f8760ea1979a3d1e72e54c3ea906ea99 U drh -Z d2602db348bfa53fd2c4a084ddf1dc40 +Z 5b9cf50a9e82d7593d62c569e8fac940 diff --git a/manifest.uuid b/manifest.uuid index 9bc4c35374..9f906f5e5e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ccc22e14dc5d910d632807f49484be54dc2fde83 \ No newline at end of file +ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e \ No newline at end of file diff --git a/test/vacuummem.test b/test/vacuummem.test index b0f5cf2038..b214c83b3d 100644 --- a/test/vacuummem.test +++ b/test/vacuummem.test @@ -41,18 +41,19 @@ do_execsql_test 1.0 { CREATE INDEX t1b ON t1(b); CREATE INDEX t1c ON t1(c); } +set ans "#/[memory_used]/" -do_test 1.1 { memory_used } {#/2300000/} +do_test 1.1 { memory_used } $ans do_execsql_test 1.2 VACUUM -do_test 1.3 { memory_used } {#/2300000/} +do_test 1.3 { memory_used } $ans do_execsql_test 1.4 { SELECT count(*) FROM t1 WHERE +a IS NOT NULL } {100000} -do_test 1.5 { memory_used } {#/2300000/} +do_test 1.5 { memory_used } $ans From 2aed97959263530f211c80bb70fe3c55cca09787 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 12:10:25 +0000 Subject: [PATCH 228/302] Disable the DBSTATUS_CACHE_USED_SHARED tests on mac when memsys3/5 is disabled due to differences in the allocation sizes for the Darwin memory allocator. FossilOrigin-Name: d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 --- manifest | 12 ++++----- manifest.uuid | 2 +- test/dbstatus.test | 62 ++++++++++++++++++++++++---------------------- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index 9cd5c96943..7e15c062ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\svacuummem.test\sscript\sso\sthat\sit\sworks\son\smac\sas\swell\sas\son\slinux. -D 2016-07-25T12:01:18.862 +C Disable\sthe\sDBSTATUS_CACHE_USED_SHARED\stests\son\smac\swhen\smemsys3/5\sis\sdisabled\ndue\sto\sdifferences\sin\sthe\sallocation\ssizes\sfor\sthe\sDarwin\smemory\sallocator. +D 2016-07-25T12:10:25.504 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 2bb4d576f11c0f57f5633dad373ad1a57c2a7195 +F test/dbstatus.test 58b31ba1dee1a6524189666c5882ab145d1f229b F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ccc22e14dc5d910d632807f49484be54dc2fde83 -R f8760ea1979a3d1e72e54c3ea906ea99 +P ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e +R 3485ec1f1845ad365519b5b860f50dc5 U drh -Z 5b9cf50a9e82d7593d62c569e8fac940 +Z 3712e6b13d05abd58f12d65f644b4035 diff --git a/manifest.uuid b/manifest.uuid index 9f906f5e5e..1d8d5dc41a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e \ No newline at end of file +d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index fb4cbe04ba..a3518e9b6f 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -379,36 +379,40 @@ foreach ::lookaside_buffer_size {0 64 120} { # The following tests focus on DBSTATUS_CACHE_USED_SHARED # ifcapable shared_cache { - proc do_cacheused_test {tn db res} { - set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] - set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] - set cu [lindex $cu 1] - set pcu [lindex $pcu 1] - uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"] + if {[permutation]=="memsys3" + || [permutation]=="memsys5" + || $::tcl_platform(os)!="Darwin"} { + proc do_cacheused_test {tn db res} { + set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] + set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] + set cu [lindex $cu 1] + set pcu [lindex $pcu 1] + uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"] + } + reset_db + sqlite3 db file:test.db?cache=shared + + do_execsql_test 4.0 { + PRAGMA auto_vacuum=NONE; + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES(1, 2, 3); + } + do_cacheused_test 4.0.1 db { 4568 4568 } + do_execsql_test 4.1 { + CREATE TEMP TABLE tt(a, b, c); + INSERT INTO tt VALUES(1, 2, 3); + } + do_cacheused_test 4.1.1 db { 9000 9000 } + + sqlite3 db2 file:test.db?cache=shared + do_cacheused_test 4.2.1 db2 { 4568 2284 } + do_cacheused_test 4.2.2 db { 9000 6716 } + db close + do_cacheused_test 4.2.3 db2 { 4568 4568 } + sqlite3 db file:test.db?cache=shared + do_cacheused_test 4.2.4 db2 { 4568 2284 } + db2 close } - reset_db - sqlite3 db file:test.db?cache=shared - - do_execsql_test 4.0 { - PRAGMA auto_vacuum=NONE; - CREATE TABLE t1(a, b, c); - INSERT INTO t1 VALUES(1, 2, 3); - } - do_cacheused_test 4.0.1 db { 4568 4568 } - do_execsql_test 4.1 { - CREATE TEMP TABLE tt(a, b, c); - INSERT INTO tt VALUES(1, 2, 3); - } - do_cacheused_test 4.1.1 db { 9000 9000 } - - sqlite3 db2 file:test.db?cache=shared - do_cacheused_test 4.2.1 db2 { 4568 2284 } - do_cacheused_test 4.2.2 db { 9000 6716 } - db close - do_cacheused_test 4.2.3 db2 { 4568 4568 } - sqlite3 db file:test.db?cache=shared - do_cacheused_test 4.2.4 db2 { 4568 2284 } - db2 close } finish_test From 017256802b4ca58df779e7a7d32abc5373fa3175 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 14:20:01 +0000 Subject: [PATCH 229/302] Changes to test scripts to get them all running on OpenBSD. FossilOrigin-Name: 9e7bedeee444cbf0b1a9165e88928c5d85088de1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/dbstatus.test | 2 +- test/shell1.test | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7e15c062ff..621866c6f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\sDBSTATUS_CACHE_USED_SHARED\stests\son\smac\swhen\smemsys3/5\sis\sdisabled\ndue\sto\sdifferences\sin\sthe\sallocation\ssizes\sfor\sthe\sDarwin\smemory\sallocator. -D 2016-07-25T12:10:25.504 +C Changes\sto\stest\sscripts\sto\sget\sthem\sall\srunning\son\sOpenBSD. +D 2016-07-25T14:20:01.353 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -621,7 +621,7 @@ F test/ctime.test 0b995accd44a52914bd4744d5c1b6e1a56c7897c F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/cursorhint2.test 2b45341d32d1aae9991a00ef31ebca339b274255 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 -F test/dbstatus.test 58b31ba1dee1a6524189666c5882ab145d1f229b +F test/dbstatus.test 73149851b3aff14fc6db478e58f9083a66422cf5 F test/dbstatus2.test e93ab03bfae6d62d4d935f20de928c19ca0ed0ab F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d F test/delete.test e1bcdf8926234e27aac24b346ad83d3329ec8b6f @@ -1064,7 +1064,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 2f2aee20db294b9924e81f6ccbe60f19e21e8506 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test c90b0415cea6eeefb86b4ab1651b06247922ca52 +F test/shell1.test 77896b65f1cde4ee79e38b2c0ed8578a8f4000e5 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ea7fb98b96f13f7dc5ed83ec5e8ad8857e20e06e -R 3485ec1f1845ad365519b5b860f50dc5 +P d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 +R f74cc55ec1e76de02d5d11db76d4d3f2 U drh -Z 3712e6b13d05abd58f12d65f644b4035 +Z 27b5d9cc228b8d41a7c82f29fd5cd771 diff --git a/manifest.uuid b/manifest.uuid index 1d8d5dc41a..83360d7bd0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 \ No newline at end of file +9e7bedeee444cbf0b1a9165e88928c5d85088de1 \ No newline at end of file diff --git a/test/dbstatus.test b/test/dbstatus.test index a3518e9b6f..711d66ebb3 100644 --- a/test/dbstatus.test +++ b/test/dbstatus.test @@ -381,7 +381,7 @@ foreach ::lookaside_buffer_size {0 64 120} { ifcapable shared_cache { if {[permutation]=="memsys3" || [permutation]=="memsys5" - || $::tcl_platform(os)!="Darwin"} { + || $::tcl_platform(os)=="Linux"} { proc do_cacheused_test {tn db res} { set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0] set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0] diff --git a/test/shell1.test b/test/shell1.test index 498cd64a9f..03c2dee1d1 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -870,6 +870,7 @@ do_test shell1-5.0 { if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} { continue } + if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue set hex [format %02X $i] set char [subst \\x$hex]; set oldChar $char set escapes [list] From a522473c65f6705a8d18023208dbebea41a9b79f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 14:40:43 +0000 Subject: [PATCH 230/302] Add a new %ifdef to parse.y so that the build works with SQLITE_OMIT_SUBQUERY. FossilOrigin-Name: 38a48cfb9a8212970c4a4f8458643c22ed067e8b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/parse.y | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 621866c6f1..bd35ced110 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\stest\sscripts\sto\sget\sthem\sall\srunning\son\sOpenBSD. -D 2016-07-25T14:20:01.353 +C Add\sa\snew\s%ifdef\sto\sparse.y\sso\sthat\sthe\sbuild\sworks\swith\sSQLITE_OMIT_SUBQUERY. +D 2016-07-25T14:40:43.866 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -372,7 +372,7 @@ F src/os_win.c 520f23475f1de530c435d30b67b7b15fe90874b0 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 F src/pager.h 031a87445e5e0afc85312d1c380e123ad6c7aeaf -F src/parse.y f374ab20106362eb3f5c01b3e6a002f0bbead7ff +F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d6f6c87c9c0acf609a9d5bea818bb7a5437109a1 -R f74cc55ec1e76de02d5d11db76d4d3f2 +P 9e7bedeee444cbf0b1a9165e88928c5d85088de1 +R 235239c649979125e6dc80ee3d149e81 U drh -Z 27b5d9cc228b8d41a7c82f29fd5cd771 +Z 63a00886286115a66584905bc421be70 diff --git a/manifest.uuid b/manifest.uuid index 83360d7bd0..b1d3af8c41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e7bedeee444cbf0b1a9165e88928c5d85088de1 \ No newline at end of file +38a48cfb9a8212970c4a4f8458643c22ed067e8b \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 8a65131e28..087c52c839 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1194,13 +1194,14 @@ nexprlist(A) ::= nexprlist(A) COMMA expr(Y). nexprlist(A) ::= expr(Y). {A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/} +%ifndef SQLITE_OMIT_SUBQUERY /* A paren_exprlist is an optional expression list contained inside ** of parenthesis */ %type paren_exprlist {ExprList*} %destructor paren_exprlist {sqlite3ExprListDelete(pParse->db, $$);} paren_exprlist(A) ::= . {A = 0;} paren_exprlist(A) ::= LP exprlist(X) RP. {A = X;} - +%endif SQLITE_OMIT_SUBQUERY ///////////////////////////// The CREATE INDEX command /////////////////////// From 422dded5a9f9fe9aa26da20c5565be903609a83f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 16:10:43 +0000 Subject: [PATCH 231/302] Minor test infrastructure changes to better support SEE testing. FossilOrigin-Name: 8dcb9d506b5eef3a21d97877217e0df69966a915 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/tester.tcl | 1 + test/walcrash4.test | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index bd35ced110..d28b4841ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\s%ifdef\sto\sparse.y\sso\sthat\sthe\sbuild\sworks\swith\sSQLITE_OMIT_SUBQUERY. -D 2016-07-25T14:40:43.866 +C Minor\stest\sinfrastructure\schanges\sto\sbetter\ssupport\sSEE\stesting. +D 2016-07-25T16:10:43.028 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1128,7 +1128,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl a52b5be1bb586afa1c8bcdcd4b86588645e1ae52 +F test/tester.tcl 949b4a73bd0324b7c796818d0d6a6715712932b3 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1366,7 +1366,7 @@ F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af -F test/walcrash4.test 3374d6a0813bfe9d841a973958e0552b545a6423 +F test/walcrash4.test e7b6e7639a950a0cca8e210e248c8dad4d63bf20 F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9e7bedeee444cbf0b1a9165e88928c5d85088de1 -R 235239c649979125e6dc80ee3d149e81 +P 38a48cfb9a8212970c4a4f8458643c22ed067e8b +R abfe7130c6ed9b2d2a4c15502875beef U drh -Z 63a00886286115a66584905bc421be70 +Z 61654b6f48f562a527ce39380211aaf2 diff --git a/manifest.uuid b/manifest.uuid index b1d3af8c41..ccfb379c00 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38a48cfb9a8212970c4a4f8458643c22ed067e8b \ No newline at end of file +8dcb9d506b5eef3a21d97877217e0df69966a915 \ No newline at end of file diff --git a/test/tester.tcl b/test/tester.tcl index 3f1edc32ae..3fe84c641f 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -373,6 +373,7 @@ proc do_not_use_codec {} { set ::do_not_use_codec 1 reset_db } +unset -nocomplain do_not_use_codec # Return true if the "reserved_bytes" integer on database files is non-zero. # diff --git a/test/walcrash4.test b/test/walcrash4.test index 3abc16d1eb..80839b39e5 100644 --- a/test/walcrash4.test +++ b/test/walcrash4.test @@ -17,6 +17,7 @@ source $testdir/lock_common.tcl source $testdir/wal_common.tcl ifcapable !wal {finish_test ; return } set testprefix walcrash4 +do_not_use_codec #------------------------------------------------------------------------- # At one point, if "PRAGMA synchronous=full" is set and the platform From 07d9a031870a5eacb5cb31fdf67138ff5579acab Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 21:11:53 +0000 Subject: [PATCH 232/302] Fix a test case in FTS5 to make it compatible with Tcl 8.5. FossilOrigin-Name: a495f8e77e14241150f79e746c7303284f04621a --- ext/fts5/test/fts5simple.test | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 2bc02cf49a..5ac413c885 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -265,7 +265,7 @@ do_test 11.0 { execsql " INSERT INTO t4 VALUES('a b c \x1A'); INSERT INTO t4 VALUES('a b c d\x1A'); - INSERT INTO t4 VALUES('a b c \x1Ad'); + INSERT INTO t4 VALUES('a b c \x1Ag'); INSERT INTO t4 VALUES('a b c d'); " } {} diff --git a/manifest b/manifest index d28b4841ce..e46a5f0762 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stest\sinfrastructure\schanges\sto\sbetter\ssupport\sSEE\stesting. -D 2016-07-25T16:10:43.028 +C Fix\sa\stest\scase\sin\sFTS5\sto\smake\sit\scompatible\swith\sTcl\s8.5. +D 2016-07-25T21:11:53.996 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -180,7 +180,7 @@ F ext/fts5/test/fts5rank.test 2bdc0c5f22ccc1f9dbe9f4d0b82a491dce6f8a32 F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 16908a99d6efc9ba21081b4f2b86b3fc699839a6 -F ext/fts5/test/fts5simple.test cd23d4072ea095d652c9b6db12284cc642e49c98 +F ext/fts5/test/fts5simple.test 5da9b15ed534eb0be9f279d8a2bb2e24d30e4e38 F ext/fts5/test/fts5simple2.test 98377ae1ff7749a42c21fe1a139c1ed312522c46 F ext/fts5/test/fts5simple3.test 8e71733b3d1b0e695011d02c68ebc5ca40b6124e F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38a48cfb9a8212970c4a4f8458643c22ed067e8b -R abfe7130c6ed9b2d2a4c15502875beef +P 8dcb9d506b5eef3a21d97877217e0df69966a915 +R 39b75cd52198f904a29885025a5d8665 U drh -Z 61654b6f48f562a527ce39380211aaf2 +Z ed1d5b465897ee96bacfa15f366335db diff --git a/manifest.uuid b/manifest.uuid index ccfb379c00..9a340b022c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8dcb9d506b5eef3a21d97877217e0df69966a915 \ No newline at end of file +a495f8e77e14241150f79e746c7303284f04621a \ No newline at end of file From 2b62b5def80c984918d197631723ea583a215efb Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 25 Jul 2016 22:40:12 +0000 Subject: [PATCH 233/302] In the VACUUM command, set the cache_size of the transient vacuum_db database to be the same as the database being vacuumed. FossilOrigin-Name: b78d99548ac53ac10dcc38368cc4b29c8cbcb09b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vacuum.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e46a5f0762..e225d5909f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sin\sFTS5\sto\smake\sit\scompatible\swith\sTcl\s8.5. -D 2016-07-25T21:11:53.996 +C In\sthe\sVACUUM\scommand,\sset\sthe\scache_size\sof\sthe\stransient\svacuum_db\sdatabase\nto\sbe\sthe\ssame\sas\sthe\sdatabase\sbeing\svacuumed. +D 2016-07-25T22:40:12.561 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -448,7 +448,7 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c 544ec90a66a4b0460b7c1baeadbc21b45e6ca0b6 +F src/vacuum.c 7949183a9ce2270fc76503384b1159fcb1e39723 F src/vdbe.c ea260b61e73b11a71e70b28a8e25866e2899e5da F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8dcb9d506b5eef3a21d97877217e0df69966a915 -R 39b75cd52198f904a29885025a5d8665 +P a495f8e77e14241150f79e746c7303284f04621a +R 8704dbefb85fb183a067d36d9af66cac U drh -Z ed1d5b465897ee96bacfa15f366335db +Z 422685421478fa78357b95bed0587f82 diff --git a/manifest.uuid b/manifest.uuid index 9a340b022c..3c7462248c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a495f8e77e14241150f79e746c7303284f04621a \ No newline at end of file +b78d99548ac53ac10dcc38368cc4b29c8cbcb09b \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 9ab7f766ee..16c4be01c0 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -197,6 +197,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ } #endif + sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size); rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); if( rc!=SQLITE_OK ) goto end_of_vacuum; From 426f4ab0092550430f76bb73bebc0b9f49c052b3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Jul 2016 04:31:14 +0000 Subject: [PATCH 234/302] Make sure affinity is applied correctly on lower-bound range constraints in the min() optimization. Fix for ticket [a0bac8b3c3d1bb]. FossilOrigin-Name: b819bace9c2a0b0159122b26db96a8f50a6f0eac --- manifest | 15 ++++++++------- manifest.uuid | 2 +- src/wherecode.c | 1 + test/minmax.test | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e225d5909f..287421d143 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sVACUUM\scommand,\sset\sthe\scache_size\sof\sthe\stransient\svacuum_db\sdatabase\nto\sbe\sthe\ssame\sas\sthe\sdatabase\sbeing\svacuumed. -D 2016-07-25T22:40:12.561 +C Make\ssure\saffinity\sis\sapplied\scorrectly\son\slower-bound\srange\sconstraints\nin\sthe\smin()\soptimization.\s\sFix\sfor\sticket\s[a0bac8b3c3d1bb]. +D 2016-07-26T04:31:14.412 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -465,7 +465,7 @@ F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 -F src/wherecode.c 11e38f5e2dc5c007143fbf7fdb14bca40a6b74ad +F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -929,7 +929,7 @@ F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7 F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2 F test/memsubsys1.test 6d268d0ae90f8d61a2356a1838665654d83de518 F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08 -F test/minmax.test 42fbad0e81afaa6e0de41c960329f2b2c3526efd +F test/minmax.test 6751e87b409fe11b02e70a306d846fa544e25a41 F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f @@ -1507,7 +1507,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a495f8e77e14241150f79e746c7303284f04621a -R 8704dbefb85fb183a067d36d9af66cac +P b78d99548ac53ac10dcc38368cc4b29c8cbcb09b +Q +0e9f534fef72ca142a4296ab5285c82aada38ba7 +R b5725dd72810ef0d52d5b0abd989daf2 U drh -Z 422685421478fa78357b95bed0587f82 +Z a046c0beaad1d7947f30a6bdc44927b5 diff --git a/manifest.uuid b/manifest.uuid index 3c7462248c..989f1b27ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b78d99548ac53ac10dcc38368cc4b29c8cbcb09b \ No newline at end of file +b819bace9c2a0b0159122b26db96a8f50a6f0eac \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 0b307761be..d78982f5b5 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1319,6 +1319,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( } nConstraint++; testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); + bSeekPastNull = 0; }else if( bSeekPastNull ){ sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq); nConstraint++; diff --git a/test/minmax.test b/test/minmax.test index fb9bbb383a..04a3f06dff 100644 --- a/test/minmax.test +++ b/test/minmax.test @@ -628,5 +628,19 @@ do_test_13_noopt 13.7 { SELECT min(c), count(c) FROM t1 WHERE a='a'; } {1 5} +# 2016-07-26. https://www.sqlite.org/src/info/a0bac8b3c3d1bb75 +# Incorrect result on a min() query after a CREATE INDEX. +# +do_execsql_test 14.1 { + CREATE TABLE t14(a INTEGER, b INTEGER); + INSERT INTO t14(a,b) VALUES(100,2),(200,2),(300,2),(400,1),(500,2); + SELECT min(a) FROM t14 WHERE b='2' AND a>'50'; +} {100} +do_execsql_test 14.2 { + CREATE INDEX t14ba ON t14(b,a); + SELECT min(a) FROM t14 WHERE b='2' AND a>'50'; +} {100} + + finish_test From 9d608759016b18d532a5a8e6bb17840f05e4b7d8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 26 Jul 2016 04:49:43 +0000 Subject: [PATCH 235/302] Copy the cache_spill setting from the main database over to the vacuum_db transient database when running a VACUUM. FossilOrigin-Name: c0e7d98ef2a13ede5ae865083ede1aaffdf43310 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vacuum.c | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 287421d143..8ca4a9cd2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\saffinity\sis\sapplied\scorrectly\son\slower-bound\srange\sconstraints\nin\sthe\smin()\soptimization.\s\sFix\sfor\sticket\s[a0bac8b3c3d1bb]. -D 2016-07-26T04:31:14.412 +C Copy\sthe\scache_spill\ssetting\sfrom\sthe\smain\sdatabase\sover\sto\sthe\nvacuum_db\stransient\sdatabase\swhen\srunning\sa\sVACUUM. +D 2016-07-26T04:49:43.617 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -448,7 +448,7 @@ F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d -F src/vacuum.c 7949183a9ce2270fc76503384b1159fcb1e39723 +F src/vacuum.c 9dd2f5d276bc6094d8f1d85ecd41b30c1a002a43 F src/vdbe.c ea260b61e73b11a71e70b28a8e25866e2899e5da F src/vdbe.h 67bc551f7faf04c33493892e4b378aada823ed10 F src/vdbeInt.h c59381049af5c7751a83456c39b80d1a6fde1f9d @@ -1507,8 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b78d99548ac53ac10dcc38368cc4b29c8cbcb09b -Q +0e9f534fef72ca142a4296ab5285c82aada38ba7 -R b5725dd72810ef0d52d5b0abd989daf2 +P b819bace9c2a0b0159122b26db96a8f50a6f0eac +R 2279949c9ee671e45067af58637c4ef8 U drh -Z a046c0beaad1d7947f30a6bdc44927b5 +Z ef49efbba33d277501e077ba267218c2 diff --git a/manifest.uuid b/manifest.uuid index 989f1b27ca..59d5af71df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b819bace9c2a0b0159122b26db96a8f50a6f0eac \ No newline at end of file +c0e7d98ef2a13ede5ae865083ede1aaffdf43310 \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 16c4be01c0..b72663c066 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -198,6 +198,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ #endif sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size); + sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0)); rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); if( rc!=SQLITE_OK ) goto end_of_vacuum; From 2900a6222f475f4d495c302aa5d5aab3dc1f0237 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 26 Jul 2016 10:46:21 +0000 Subject: [PATCH 236/302] Ensure that the sqlite3_scrub_backup() extension creates a backup database at least as large as indicated by the database header, even if the last page of the input database is a free-list leaf. FossilOrigin-Name: 483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd --- ext/misc/scrub.c | 16 ++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ext/misc/scrub.c b/ext/misc/scrub.c index 1d21fc5389..92718e23d1 100644 --- a/ext/misc/scrub.c +++ b/ext/misc/scrub.c @@ -74,6 +74,7 @@ struct ScrubState { u32 szPage; /* Page size */ u32 szUsable; /* Usable bytes on each page */ u32 nPage; /* Number of pages */ + u32 iLastPage; /* Page number of last page written so far*/ u8 *page1; /* Content of page 1 */ }; @@ -130,6 +131,7 @@ static void scrubBackupWrite(ScrubState *p, int pgno, const u8 *pData){ scrubBackupErr(p, "write failed for page %d", pgno); p->rcErr = SQLITE_IOERR; } + if( pgno>p->iLastPage ) p->iLastPage = pgno; } /* Prepare a statement against the "db" database. */ @@ -541,6 +543,20 @@ int sqlite3_scrub_backup( } sqlite3_finalize(pStmt); + /* If the last page of the input db file is a free-list leaf, then the + ** backup file on disk is still smaller than the size indicated within + ** the database header. In this case, write a page of zeroes to the + ** last page of the backup database so that SQLite does not mistakenly + ** think the db is corrupt. */ + if( s.iLastPage Date: Wed, 27 Jul 2016 16:03:54 +0000 Subject: [PATCH 237/302] Initialize a variable in where.c to avoid a valgrind warning. FossilOrigin-Name: 4d59df02d3713b3e3804e1a88e676749b2794286 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- test/in.test | 11 +++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7f897eb954..185e06b3cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\ssqlite3_scrub_backup()\sextension\screates\sa\sbackup\sdatabase\sat\sleast\sas\slarge\sas\sindicated\sby\sthe\sdatabase\sheader,\seven\sif\sthe\slast\spage\sof\sthe\sinput\sdatabase\sis\sa\sfree-list\sleaf. -D 2016-07-26T10:46:21.988 +C Initialize\sa\svariable\sin\swhere.c\sto\savoid\sa\svalgrind\swarning. +D 2016-07-27T16:03:54.108 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -463,7 +463,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 +F src/where.c 9981707ac01438baea5caa0ca6108237be6630da F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 @@ -822,7 +822,7 @@ F test/hook.test 3b7b99d0eece6d279812c2aef6fa08bdfabc633e F test/icu.test 73956798bace8982909c00476b216714a6d0559a F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 -F test/in.test 61a24ae38d4b64ec69f06ccdf022992f68a98176 +F test/in.test 61d940ced6817bee66e4e0b09d5bc8608f57134b F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test d2b38cba404bc4320f4fe1b595b3d163f212c068 @@ -1507,7 +1507,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c0e7d98ef2a13ede5ae865083ede1aaffdf43310 -R 783c6677056c1c6297ef166e24fadbce +P 483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd +R d3646a4fd33e16c76415db60501a55b1 U dan -Z 42a389186c57610d077ea553714cade1 +Z 64999ea9da24ca9027e2e455a4d899cc diff --git a/manifest.uuid b/manifest.uuid index 1e810448d2..83f63152b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd \ No newline at end of file +4d59df02d3713b3e3804e1a88e676749b2794286 \ No newline at end of file diff --git a/src/where.c b/src/where.c index a65f30968e..23ec21c160 100644 --- a/src/where.c +++ b/src/where.c @@ -3949,7 +3949,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( pWInfo->nOBSat<=0 ){ pWInfo->nOBSat = 0; if( nLoop>0 ){ - Bitmask m; + Bitmask m = 0; int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m); if( rc==pWInfo->pOrderBy->nExpr ){ diff --git a/test/in.test b/test/in.test index 3a42e84b9a..3c87a2a86f 100644 --- a/test/in.test +++ b/test/in.test @@ -640,4 +640,15 @@ do_test in-13.X { db nullvalue "" } {} +# At one point the following was causing valgrind to report a "jump +# depends on unitialized location" problem. +# +do_execsql_test in-14.0 { + CREATE TABLE c1(a); + INSERT INTO c1 VALUES(1), (2), (4), (3); +} +do_execsql_test in-14.1 { + SELECT * FROM c1 WHERE a IN (SELECT a FROM c1) ORDER BY 1 +} {1 2 3 4} + finish_test From 2409f8a11232ff4e2999168f01e954502f189f02 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 27 Jul 2016 18:27:02 +0000 Subject: [PATCH 238/302] When estimating the cost of an index scan, factor in the cost savings of being able to use the index to evaluate some WHERE clause terms without having to do a table lookup. FossilOrigin-Name: a59b5622f7cc6e502d71aabc12c053582cd03609 --- manifest | 21 +++++++++++-------- manifest.uuid | 2 +- src/expr.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ src/sqliteInt.h | 2 ++ src/where.c | 29 +++++++++++++++++++++++--- 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 7f897eb954..0e15122481 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\ssqlite3_scrub_backup()\sextension\screates\sa\sbackup\sdatabase\sat\sleast\sas\slarge\sas\sindicated\sby\sthe\sdatabase\sheader,\seven\sif\sthe\slast\spage\sof\sthe\sinput\sdatabase\sis\sa\sfree-list\sleaf. -D 2016-07-26T10:46:21.988 +C When\sestimating\sthe\scost\sof\san\sindex\sscan,\sfactor\sin\sthe\scost\ssavings\sof\nbeing\sable\sto\suse\sthe\sindex\sto\sevaluate\ssome\sWHERE\sclause\sterms\swithout\nhaving\sto\sdo\sa\stable\slookup. +D 2016-07-27T18:27:02.556 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -337,7 +337,7 @@ F src/ctime.c 61949e83c4c36e37195a8398ebc752780b534d95 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c 21b153e1046c624e9387a17d3261f69b461e700c +F src/expr.c 3347e66d4e27ec5f3ec7573b9a5f899bbd7d1df8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 @@ -388,7 +388,7 @@ F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 -F src/sqliteInt.h 49081ceab08eda9943d555aee57392c5b35d1c60 +F src/sqliteInt.h d25c18c1272a7811e2569c39bfc2fca96156eead F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -463,7 +463,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 48eed8ebe319c6cbc7bf7682018f32af0f5189f5 +F src/where.c 7e4d676b5ac4434e5f93606a744d396dc40d9977 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 @@ -1507,7 +1507,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c0e7d98ef2a13ede5ae865083ede1aaffdf43310 -R 783c6677056c1c6297ef166e24fadbce -U dan -Z 42a389186c57610d077ea553714cade1 +P 483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd +R 9e4bd013f5c2cf2171d472668aed0d1c +T *branch * improved-index-scan +T *sym-improved-index-scan * +T -sym-trunk * +U drh +Z 8f3398744130761f466da0e8b7212fe4 diff --git a/manifest.uuid b/manifest.uuid index 1e810448d2..6da37e4d78 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd \ No newline at end of file +a59b5622f7cc6e502d71aabc12c053582cd03609 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index ea52d66253..c027cf02a4 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3965,6 +3965,61 @@ int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){ return 0; } +/* +** An instance of the following structure is used by the tree walker +** to determine if an expression can be evaluated by reference to the +** index only, without having to do a search for the corresponding +** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur +** is the cursor for the table. +*/ +struct IdxCover { + Index *pIdx; /* The index to be tested for coverage */ + int iCur; /* Cursor number for the table corresponding to the index */ +}; + +/* +** Check to see if there are references to columns in table +** pWalker->u.pIdxCover->iCur can be satisfied using the index +** pWalker->u.pIdxCover->pIdx. +*/ +static int exprIdxCover(Walker *pWalker, Expr *pExpr){ + if( pExpr->op==TK_COLUMN + && pExpr->iTable==pWalker->u.pIdxCover->iCur + && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0 + ){ + pWalker->eCode = 1; + return WRC_Abort; + } + return WRC_Continue; +} + +/* +** Determine if an index on table iCur that contains the columns in +** Bitmask m will cover the expression pExpr. Return true if the index +** does cover the expression and false if the expression references +** table columns that are not found in the index. +** +** An index covering an expression means that the expression can be +** evaluated using only the index and without having to lookup the +** corresponding table entry. +*/ +int sqlite3ExprCoveredByIndex( + Expr *pExpr, /* The index to be tested */ + int iCur, /* The cursor number for the corresponding table */ + Index *pIdx /* The index that might be used for coverage */ +){ + Walker w; + struct IdxCover xcov; + memset(&w, 0, sizeof(w)); + xcov.iCur = iCur; + xcov.pIdx = pIdx; + w.xExprCallback = exprIdxCover; + w.u.pIdxCover = &xcov; + sqlite3WalkExpr(&w, pExpr); + return !w.eCode; +} + + /* ** An instance of the following structure is used by the tree walker ** to count references to table columns in the arguments of an diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 879e6703ca..c5b1eccc03 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3257,6 +3257,7 @@ struct Walker { struct SrcCount *pSrcCount; /* Counting column references */ struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ int *aiCol; /* array of column indexes */ + struct IdxCover *pIdxCover; /* Check for index coverage */ } u; }; @@ -3700,6 +3701,7 @@ int sqlite3ExprListCompare(ExprList*, ExprList*, int); int sqlite3ExprImpliesExpr(Expr*, Expr*, int); void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); +int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); Vdbe *sqlite3GetVdbe(Parse*); #ifndef SQLITE_OMIT_BUILTIN_TEST diff --git a/src/where.c b/src/where.c index a65f30968e..6a02574921 100644 --- a/src/where.c +++ b/src/where.c @@ -2775,11 +2775,34 @@ static int whereLoopAddBtree( /* The cost of visiting the index rows is N*K, where K is ** between 1.1 and 3.0, depending on the relative sizes of the - ** index and table rows. If this is a non-covering index scan, - ** also add the cost of visiting table rows (N*3.0). */ + ** index and table rows. */ pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow; if( m!=0 ){ - pNew->rRun = sqlite3LogEstAdd(pNew->rRun, rSize+16); + /* If this is a non-covering index scan, add in the cost of + ** doing table lookups. The cost will be 3x the number of + ** lookups. Take into account WHERE clause terms that can be + ** satisfied using just the index, and that do not require a + ** table lookup. */ + LogEst nLookup = rSize + 16; /* Base cost: N*3 */ + int ii; + int iCur = pSrc->iCursor; + WhereClause *pWC = &pWInfo->sWC; + for(ii=0; iinTerm; ii++){ + WhereTerm *pTerm = &pWC->a[ii]; + if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){ + break; + } + /* pTerm can be evaluated using just the index. So reduce + ** the expected number of table lookups accordingly */ + if( pTerm->truthProb<=0 ){ + nLookup += pTerm->truthProb; + }else{ + nLookup--; + if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19; + } + } + + pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup); } ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); From e604ec0be02b4e550883c0998c5872a2ba2459ce Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 27 Jul 2016 19:20:58 +0000 Subject: [PATCH 239/302] Add test cases and fix a comment. FossilOrigin-Name: 50f8ea37fb9647c4a9da2c269a4d6f54b10ce96b --- manifest | 20 +++++++-------- manifest.uuid | 2 +- src/expr.c | 8 +++--- src/where.c | 4 +-- test/index8.test | 60 ++++++++++++++++++++++++++++++++++++++++++++ test/scanstatus.test | 4 +-- 6 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 test/index8.test diff --git a/manifest b/manifest index 0e15122481..b810c2000b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sestimating\sthe\scost\sof\san\sindex\sscan,\sfactor\sin\sthe\scost\ssavings\sof\nbeing\sable\sto\suse\sthe\sindex\sto\sevaluate\ssome\sWHERE\sclause\sterms\swithout\nhaving\sto\sdo\sa\stable\slookup. -D 2016-07-27T18:27:02.556 +C Add\stest\scases\sand\sfix\sa\scomment. +D 2016-07-27T19:20:58.611 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -337,7 +337,7 @@ F src/ctime.c 61949e83c4c36e37195a8398ebc752780b534d95 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c 3347e66d4e27ec5f3ec7573b9a5f899bbd7d1df8 +F src/expr.c fbc17c717a80b5b61158ea8f25b5af6f8cad66f8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 @@ -463,7 +463,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 7e4d676b5ac4434e5f93606a744d396dc40d9977 +F src/where.c 66a290310e71491ffc9c74108413176438aa8718 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 @@ -845,6 +845,7 @@ F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6 F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7 F test/index6.test 43b4e29258b978fcdab84fc61df4f5212119dd09 F test/index7.test 9c6765a74fc3fcde7aebc5b3bd40d98df14a527c +F test/index8.test bc2e3db70e8e62459aaa1bd7e4a9b39664f8f9d7 F test/indexedby.test 9c4cd331224e57f79fbf411ae245e6272d415985 F test/indexexpr1.test cb71b6586177b840e28110dd952178bb2bdfedc2 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d @@ -1026,7 +1027,7 @@ F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd F test/savepoint6.test f41279c5e137139fa5c21485773332c7adb98cd7 F test/savepoint7.test cde525ea3075283eb950cdcdefe23ead4f700daa F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2 -F test/scanstatus.test 5253c219e331318a437f436268e0e82345700285 +F test/scanstatus.test 030acbbdcea6a3fc676fee99edc84f6f16c0cf92 F test/schema.test 8f7999be894260f151adf15c2c7540f1c6d6a481 F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5 F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38 @@ -1507,10 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 483994a54dee3c7a3801e0e9d3c96fa9dbd8d2fd -R 9e4bd013f5c2cf2171d472668aed0d1c -T *branch * improved-index-scan -T *sym-improved-index-scan * -T -sym-trunk * +P a59b5622f7cc6e502d71aabc12c053582cd03609 +R f515f9eadedb75a99af064851213e82e U drh -Z 8f3398744130761f466da0e8b7212fe4 +Z 99f5c72d7c6c2cd0c635c52258200786 diff --git a/manifest.uuid b/manifest.uuid index 6da37e4d78..213abdc7d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a59b5622f7cc6e502d71aabc12c053582cd03609 \ No newline at end of file +50f8ea37fb9647c4a9da2c269a4d6f54b10ce96b \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index c027cf02a4..c6d74cfd32 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3994,10 +3994,10 @@ static int exprIdxCover(Walker *pWalker, Expr *pExpr){ } /* -** Determine if an index on table iCur that contains the columns in -** Bitmask m will cover the expression pExpr. Return true if the index -** does cover the expression and false if the expression references -** table columns that are not found in the index. +** Determine if an index pIdx on table with cursor iCur contains will +** the expression pExpr. Return true if the index does cover the +** expression and false if the pExpr expression references table columns +** that are not found in the index pIdx. ** ** An index covering an expression means that the expression can be ** evaluated using only the index and without having to lookup the diff --git a/src/where.c b/src/where.c index 6a02574921..699dc2a614 100644 --- a/src/where.c +++ b/src/where.c @@ -2478,11 +2478,11 @@ static int whereLoopAddBtreeIndex( pNew->nSkip++; pNew->aLTerm[pNew->nLTerm++] = 0; pNew->wsFlags |= WHERE_SKIPSCAN; - nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1]; + nIter = pProbe->aiRowLogEst[saved_nEq]+1 - pProbe->aiRowLogEst[saved_nEq+1]; pNew->nOut -= nIter; /* TUNING: Because uncertainties in the estimates for skip-scan queries, ** add a 1.375 fudge factor to make skip-scan slightly less likely. */ - nIter += 5; + nIter += 4; whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul); pNew->nOut = saved_nOut; pNew->u.btree.nEq = saved_nEq; diff --git a/test/index8.test b/test/index8.test new file mode 100644 index 0000000000..bb58228527 --- /dev/null +++ b/test/index8.test @@ -0,0 +1,60 @@ +# 2016-07-27 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Test cases for ORDER BY and LIMIT on an index scan. +# + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Performance regression reported at +# http://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg98615.html +# +# Caused by the ORDER BY LIMIT optionation for check-in +# https://sqlite.org/src/info/bf46179d44843769 +# +# Fixed on approximately 2016-07-27 by changes that compute a better score +# for index scans by taking into account WHERE clause constraints that can +# be handled by the index and do not require a table lookup. +# +do_execsql_test 1.0 { + CREATE TABLE t1(a,b,c,d); + WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<100) + INSERT INTO t1(a,b,c,d) + SELECT x/10, x%10, x%19, x FROM c; + CREATE INDEX t1abc ON t1(a,b,c); + SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2; +} {0 4 4 4 2 3 4 23} + +# Prior to the fix, the following EQP would show a table scan and a sort +# rather than an index scan. +# +do_execsql_test 1.0eqp { + EXPLAIN QUERY PLAN + SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2; +} {/SCAN TABLE t1 USING INDEX t1abc/} + +# If we change the index so that it no longer covers the WHERE clause, +# then we should (correctly) revert to using a table scan. +# +do_execsql_test 1.1 { + DROP INDEX t1abc; + CREATE INDEX t1abd ON t1(a,b,d); + SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2; +} {0 4 4 4 2 3 4 23} +do_execsql_test 1.1eqp { + EXPLAIN QUERY PLAN + SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2; +} {~/USING INDEX/} + + +finish_test diff --git a/test/scanstatus.test b/test/scanstatus.test index ed24d97437..48365a8794 100644 --- a/test/scanstatus.test +++ b/test/scanstatus.test @@ -333,7 +333,7 @@ do_execsql_test 5.3.2 { SELECT count(*) FROM t2 WHERE y = 'j'; } {19} do_scanstatus_test 5.3.3 { - nLoop 1 nVisit 19 nEst 56.0 zName t2xy zExplain + nLoop 1 nVisit 19 nEst 52.0 zName t2xy zExplain {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)} } @@ -349,7 +349,7 @@ do_execsql_test 5.4.2 { do_scanstatus_test 5.4.3 { nLoop 1 nVisit 10 nEst 10.0 zName t1bc zExplain {SCAN TABLE t1 USING COVERING INDEX t1bc} - nLoop 10 nVisit 200 nEst 56.0 zName t2xy + nLoop 10 nVisit 200 nEst 52.0 zName t2xy zExplain {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)} } From 69def7ff2f872b3c7579d93843ba504e61dc2b2f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 04:14:37 +0000 Subject: [PATCH 240/302] Work in progress on setting a calling convention for all callback functions. FossilOrigin-Name: 02b8040e1add02734d2dbc6c59737ab74ff8fb18 --- Makefile.msc | 13 +- autoconf/Makefile.msc | 8 +- ext/misc/percentile.c | 2 +- ext/misc/spellfix.c | 2 +- manifest | 36 ++-- manifest.uuid | 2 +- src/sqlite.h.in | 339 +++++++++++++++++++++----------------- src/tclsqlite.c | 2 +- src/test1.c | 2 +- tool/mksqlite3c-noext.tcl | 2 +- tool/mksqlite3c.tcl | 2 +- tool/mksqlite3h.tcl | 2 +- 12 files changed, 230 insertions(+), 182 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index cd866ce4a4..7220f71cd4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -464,20 +464,24 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) # !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0 !IF "$(PLATFORM)"=="x86" -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall !ELSE !IFNDEF PLATFORM -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = +TEST_CCONV_OPTS = !ENDIF !ENDIF !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = +TEST_CCONV_OPTS = !ENDIF # These are additional compiler options used for the core library. @@ -1960,6 +1964,7 @@ TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_CORE $(NO_WARN) TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERIES_CONSTRAINT_VERIFY=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_DEFAULT_PAGE_SIZE=1024 +TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS) TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) TESTFIXTURE_SRC1 = $(TESTEXT) $(SQLITE3C) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index 7f62bcb129..2f7447383f 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -449,12 +449,12 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS) # !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0 !IF "$(PLATFORM)"=="x86" -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall !ELSE !IFNDEF PLATFORM -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = diff --git a/ext/misc/percentile.c b/ext/misc/percentile.c index 74a4c9d12b..a5d7e84913 100644 --- a/ext/misc/percentile.c +++ b/ext/misc/percentile.c @@ -167,7 +167,7 @@ static void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){ /* ** Compare to doubles for sorting using qsort() */ -static int doubleCmp(const void *pA, const void *pB){ +static int SQLITE_CDECL doubleCmp(const void *pA, const void *pB){ double a = *(double*)pA; double b = *(double*)pB; if( a==b ) return 0; diff --git a/ext/misc/spellfix.c b/ext/misc/spellfix.c index cbcf8b7c5d..1ac1712f4e 100644 --- a/ext/misc/spellfix.c +++ b/ext/misc/spellfix.c @@ -2231,7 +2231,7 @@ static int spellfix1Score(int iDistance, int iRank){ ** Compare two spellfix1_row objects for sorting purposes in qsort() such ** that they sort in order of increasing distance. */ -static int spellfix1RowCompare(const void *A, const void *B){ +static int SQLITE_CDECL spellfix1RowCompare(const void *A, const void *B){ const struct spellfix1_row *a = (const struct spellfix1_row*)A; const struct spellfix1_row *b = (const struct spellfix1_row*)B; return a->iScore - b->iScore; diff --git a/manifest b/manifest index d0e7b14e54..a174c165d9 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Enhance\sthe\squery\splanner\scost\sestimation\sfor\sindex\sscans\sto\stake\sinto\saccount\nWHERE\sclause\sterms\sthat\scan\sbe\scomputed\susing\sonly\sthe\sindex\sand\sthat\sdo\snot\nrequire\slooking\sup\srows\sin\sthe\soriginal\stable.\s\sThis\sfixes\san\sobscure\nperformance\sregression\sthat\sarose\swhen\sthe\sORDER\sBY\sLIMIT\soptimization\swas\nadded\sby\scheck-in\s[bf46179d44843]. -D 2016-07-27T19:30:53.586 +C Work\sin\sprogress\son\ssetting\sa\scalling\sconvention\sfor\sall\scallback\sfunctions. +D 2016-07-28T04:14:37.455 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a +F Makefile.msc 843c563182b26a358674c520d7b8d40b832e9436 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -11,7 +11,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 -F autoconf/Makefile.msc 0eca137c12542bd76c253a2d24380f29ade59b95 +F autoconf/Makefile.msc 05a99e98a8895461574ccb9604444d9e97c1f0b6 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac cacf2616abf6e4a569bde2ef365c143caeec40bc @@ -214,13 +214,13 @@ F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c d51a764ba43a49e191bc3536238bfab3def258ca F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 -F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 +F ext/misc/percentile.c 92699c8cd7d517ff610e6037e56506f8904dae2e F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4 F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/scrub.c 1c5bfb8b0cd18b602fcb55755e84abf0023ac2fb F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 -F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be +F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vfsstat.c 6110aeeaab2f1df17a923c8a8acef3c74f6dc515 @@ -385,15 +385,15 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 -F src/sqlite.h.in c6e68a4a47610631822a4f8f83a44c9f75339331 +F src/sqlite.h.in a0760a3f7b1939e395a3e74d245e5bb03cd54fb1 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h d25c18c1272a7811e2569c39bfc2fca96156eead F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 5c213bf5fee084390f632df2328cf0821d483799 -F src/test1.c 186e3b53c402b7a73bcb4ade2b77709675c39fe3 +F src/tclsqlite.c 53274d5bbd66e7246c573a6b48026781d42c7efe +F src/test1.c 5ec959d088af063cac44cf1685455f3fcddecc8c F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -1448,9 +1448,9 @@ F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 -F tool/mksqlite3c-noext.tcl 87240b09c20042999b41d5fabe091b7111287835 -F tool/mksqlite3c.tcl 63af8429841f08552e6da1d93b3dee4a93ff8071 -F tool/mksqlite3h.tcl e7b106fc4f29fbc258e8ba9b88d9108332ea2ade +F tool/mksqlite3c-noext.tcl aa58ea3be311c81821c2cd3209f55e46b07ab656 +F tool/mksqlite3c.tcl a52ead27e2ac5d4b616e945a0601f628f4328329 +F tool/mksqlite3h.tcl fab97967314e63384a3ed23fd35f0d8188352400 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1508,8 +1508,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4d59df02d3713b3e3804e1a88e676749b2794286 50f8ea37fb9647c4a9da2c269a4d6f54b10ce96b -R a589b595bdfe9868de18def836f199ce -T +closed 50f8ea37fb9647c4a9da2c269a4d6f54b10ce96b -U drh -Z 994e8dc5cbb7e25d0e8cc4a952504fbd +P 9e2b26811452a5011d0a97a689636fa4409da856 +R 6c56defa4f9211ce028bec2ac1e13231 +T *branch * callbackConv +T *sym-callbackConv * +T -sym-trunk * +U mistachkin +Z d50c4a0ba4b8e38dec3c91619f068656 diff --git a/manifest.uuid b/manifest.uuid index 9b63447ecc..57781e18c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e2b26811452a5011d0a97a689636fa4409da856 \ No newline at end of file +02b8040e1add02734d2dbc6c59737ab74ff8fb18 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e8f5d24845..009f080a86 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -54,9 +54,19 @@ extern "C" { #ifndef SQLITE_CDECL # define SQLITE_CDECL #endif -#ifndef SQLITE_STDCALL -# define SQLITE_STDCALL +#ifndef SQLITE_APICALL +# define SQLITE_APICALL #endif +#ifndef SQLITE_STDCALL +# define SQLITE_STDCALL SQLITE_APICALL +#endif +#ifndef SQLITE_CALLBACK +# define SQLITE_CALLBACK +#endif +#ifndef SQLITE_SYSAPI +# define SQLITE_SYSAPI +#endif + /* ** These no-op macros are used in front of interfaces to mark those @@ -318,7 +328,7 @@ int sqlite3_close_v2(sqlite3*); ** This is legacy and deprecated. It is included for historical ** compatibility and is not documented. */ -typedef int (*sqlite3_callback)(void*,int,char**, char**); +typedef int (SQLITE_CALLBACK *sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface @@ -385,7 +395,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluated */ - int (*callback)(void*,int,char**,char**), /* Callback function */ + int (SQLITE_CALLBACK *callback)(void*,int,char**,char**), /* Callback func */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); @@ -733,26 +743,30 @@ struct sqlite3_file { typedef struct sqlite3_io_methods sqlite3_io_methods; struct sqlite3_io_methods { int iVersion; - int (*xClose)(sqlite3_file*); - int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); - int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); - int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); - int (*xSync)(sqlite3_file*, int flags); - int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); - int (*xLock)(sqlite3_file*, int); - int (*xUnlock)(sqlite3_file*, int); - int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); - int (*xFileControl)(sqlite3_file*, int op, void *pArg); - int (*xSectorSize)(sqlite3_file*); - int (*xDeviceCharacteristics)(sqlite3_file*); + int (SQLITE_CALLBACK *xClose)(sqlite3_file*); + int (SQLITE_CALLBACK *xRead)(sqlite3_file*, void*, int iAmt, + sqlite3_int64 iOfst); + int (SQLITE_CALLBACK *xWrite)(sqlite3_file*, const void*, int iAmt, + sqlite3_int64 iOfst); + int (SQLITE_CALLBACK *xTruncate)(sqlite3_file*, sqlite3_int64 size); + int (SQLITE_CALLBACK *xSync)(sqlite3_file*, int flags); + int (SQLITE_CALLBACK *xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); + int (SQLITE_CALLBACK *xLock)(sqlite3_file*, int); + int (SQLITE_CALLBACK *xUnlock)(sqlite3_file*, int); + int (SQLITE_CALLBACK *xCheckReservedLock)(sqlite3_file*, int *pResOut); + int (SQLITE_CALLBACK *xFileControl)(sqlite3_file*, int op, void *pArg); + int (SQLITE_CALLBACK *xSectorSize)(sqlite3_file*); + int (SQLITE_CALLBACK *xDeviceCharacteristics)(sqlite3_file*); /* Methods above are valid for version 1 */ - int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); - int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); - void (*xShmBarrier)(sqlite3_file*); - int (*xShmUnmap)(sqlite3_file*, int deleteFlag); + int (SQLITE_CALLBACK *xShmMap)(sqlite3_file*, int iPg, int pgsz, int, + void volatile**); + int (SQLITE_CALLBACK *xShmLock)(sqlite3_file*, int offset, int n, int flags); + void (SQLITE_CALLBACK *xShmBarrier)(sqlite3_file*); + int (SQLITE_CALLBACK *xShmUnmap)(sqlite3_file*, int deleteFlag); /* Methods above are valid for version 2 */ - int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); - int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); + int (SQLITE_CALLBACK *xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, + void **pp); + int (SQLITE_CALLBACK *xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); /* Methods above are valid for version 3 */ /* Additional methods may be added in future releases */ }; @@ -1194,7 +1208,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; ** any of these methods if the iVersion of the VFS is less than 3. */ typedef struct sqlite3_vfs sqlite3_vfs; -typedef void (*sqlite3_syscall_ptr)(void); +typedef void (SQLITE_SYSAPI *sqlite3_syscall_ptr)(void); struct sqlite3_vfs { int iVersion; /* Structure version number (currently 3) */ int szOsFile; /* Size of subclassed sqlite3_file */ @@ -1202,31 +1216,37 @@ struct sqlite3_vfs { sqlite3_vfs *pNext; /* Next registered VFS */ const char *zName; /* Name of this virtual file system */ void *pAppData; /* Pointer to application-specific data */ - int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, + int (SQLITE_CALLBACK *xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, int flags, int *pOutFlags); - int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); - int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); - int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); - void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); - void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); - void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); - void (*xDlClose)(sqlite3_vfs*, void*); - int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); - int (*xSleep)(sqlite3_vfs*, int microseconds); - int (*xCurrentTime)(sqlite3_vfs*, double*); - int (*xGetLastError)(sqlite3_vfs*, int, char *); + int (SQLITE_CALLBACK *xDelete)(sqlite3_vfs*, const char *zName, int syncDir); + int (SQLITE_CALLBACK *xAccess)(sqlite3_vfs*, const char *zName, int flags, + int *pResOut); + int (SQLITE_CALLBACK *xFullPathname)(sqlite3_vfs*, const char *zName, + int nOut, char *zOut); + void *(SQLITE_CALLBACK *xDlOpen)(sqlite3_vfs*, const char *zFilename); + void (SQLITE_CALLBACK *xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); + void (*(SQLITE_CALLBACK *xDlSym)(sqlite3_vfs*,void*, + const char *zSymbol))(void); + void (SQLITE_CALLBACK *xDlClose)(sqlite3_vfs*, void*); + int (SQLITE_CALLBACK *xRandomness)(sqlite3_vfs*, int nByte, char *zOut); + int (SQLITE_CALLBACK *xSleep)(sqlite3_vfs*, int microseconds); + int (SQLITE_CALLBACK *xCurrentTime)(sqlite3_vfs*, double*); + int (SQLITE_CALLBACK *xGetLastError)(sqlite3_vfs*, int, char *); /* ** The methods above are in version 1 of the sqlite_vfs object ** definition. Those that follow are added in version 2 or later */ - int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); + int (SQLITE_CALLBACK *xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); /* ** The methods above are in versions 1 and 2 of the sqlite_vfs object. ** Those below are for version 3 and greater. */ - int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr); - sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName); - const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName); + int (SQLITE_CALLBACK *xSetSystemCall)(sqlite3_vfs*, const char *zName, + sqlite3_syscall_ptr); + sqlite3_syscall_ptr (SQLITE_CALLBACK *xGetSystemCall)(sqlite3_vfs*, + const char *zName); + const char *(SQLITE_CALLBACK *xNextSystemCall)(sqlite3_vfs*, + const char *zName); /* ** The methods above are in versions 1 through 3 of the sqlite_vfs object. ** New fields may be appended in future versions. The iVersion @@ -1493,13 +1513,13 @@ int sqlite3_db_config(sqlite3*, int op, ...); */ typedef struct sqlite3_mem_methods sqlite3_mem_methods; struct sqlite3_mem_methods { - void *(*xMalloc)(int); /* Memory allocation function */ - void (*xFree)(void*); /* Free a prior allocation */ - void *(*xRealloc)(void*,int); /* Resize an allocation */ - int (*xSize)(void*); /* Return the size of an allocation */ - int (*xRoundup)(int); /* Round up request size to allocation size */ - int (*xInit)(void*); /* Initialize the memory allocator */ - void (*xShutdown)(void*); /* Deinitialize the memory allocator */ + void *(SQLITE_CALLBACK *xMalloc)(int); /* Memory allocation function */ + void (SQLITE_CALLBACK *xFree)(void*); /* Free a prior allocation */ + void *(SQLITE_CALLBACK *xRealloc)(void*,int); /* Resize an allocation */ + int (SQLITE_CALLBACK *xSize)(void*); /* Return the size of an allocation */ + int (SQLITE_CALLBACK *xRoundup)(int); /* Round up size to allocation size */ + int (SQLITE_CALLBACK *xInit)(void*); /* Initialize the memory allocator */ + void (SQLITE_CALLBACK *xShutdown)(void*); /* Deinitialize memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; @@ -2233,7 +2253,7 @@ int sqlite3_complete16(const void *sql); ** A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ -int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); +int sqlite3_busy_handler(sqlite3*, int(SQLITE_CALLBACK *)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout @@ -2677,7 +2697,8 @@ void sqlite3_randomness(int N, void *P); */ int sqlite3_set_authorizer( sqlite3*, - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), + int (SQLITE_CALLBACK *xAuth)(void*,int,const char*,const char*,const char*, + const char*), void *pUserData ); @@ -2784,9 +2805,9 @@ int sqlite3_set_authorizer( ** subject to change in future versions of SQLite. */ SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*, - void(*xTrace)(void*,const char*), void*); + void(SQLITE_CALLBACK *xTrace)(void*,const char*), void*); SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, - void(*xProfile)(void*,const char*,sqlite3_uint64), void*); + void(SQLITE_CALLBACK *xProfile)(void*,const char*,sqlite3_uint64), void*); /* ** CAPI3REF: SQL Trace Event Codes @@ -2877,7 +2898,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, int sqlite3_trace_v2( sqlite3*, unsigned uMask, - int(*xCallback)(unsigned,void*,void*,void*), + int(SQLITE_CALLBACK *xCallback)(unsigned,void*,void*,void*), void *pCtx ); @@ -2913,7 +2934,7 @@ int sqlite3_trace_v2( ** database connections for the meaning of "modify" in this paragraph. ** */ -void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); +void sqlite3_progress_handler(sqlite3*,int,int(SQLITE_CALLBACK *)(void*),void*); /* ** CAPI3REF: Opening A New Database Connection @@ -3744,17 +3765,20 @@ typedef struct sqlite3_context sqlite3_context; ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ -int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); +int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, + void(SQLITE_CALLBACK *)(void*)); int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, - void(*)(void*)); + void(SQLITE_CALLBACK *)(void*)); int sqlite3_bind_double(sqlite3_stmt*, int, double); int sqlite3_bind_int(sqlite3_stmt*, int, int); int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); int sqlite3_bind_null(sqlite3_stmt*, int); -int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); -int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); +int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int, + void(SQLITE_CALLBACK *)(void*)); +int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, + void(SQLITE_CALLBACK *)(void*)); int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, - void(*)(void*), unsigned char encoding); + void(SQLITE_CALLBACK *)(void*), unsigned char encoding); int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); @@ -4422,9 +4446,9 @@ int sqlite3_create_function( int nArg, int eTextRep, void *pApp, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*) + void (SQLITE_CALLBACK *xFunc)(sqlite3_context*,int,sqlite3_value**), + void (SQLITE_CALLBACK *xStep)(sqlite3_context*,int,sqlite3_value**), + void (SQLITE_CALLBACK *xFinal)(sqlite3_context*) ); int sqlite3_create_function16( sqlite3 *db, @@ -4432,9 +4456,9 @@ int sqlite3_create_function16( int nArg, int eTextRep, void *pApp, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*) + void (SQLITE_CALLBACK *xFunc)(sqlite3_context*,int,sqlite3_value**), + void (SQLITE_CALLBACK *xStep)(sqlite3_context*,int,sqlite3_value**), + void (SQLITE_CALLBACK *xFinal)(sqlite3_context*) ); int sqlite3_create_function_v2( sqlite3 *db, @@ -4442,10 +4466,10 @@ int sqlite3_create_function_v2( int nArg, int eTextRep, void *pApp, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*), - void(*xDestroy)(void*) + void (SQLITE_CALLBACK *xFunc)(sqlite3_context*,int,sqlite3_value**), + void (SQLITE_CALLBACK *xStep)(sqlite3_context*,int,sqlite3_value**), + void (SQLITE_CALLBACK *xFinal)(sqlite3_context*), + void (SQLITE_CALLBACK *xDestroy)(void*) ); /* @@ -4487,8 +4511,9 @@ SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); SQLITE_DEPRECATED int sqlite3_global_recover(void); SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); -SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), - void*,sqlite3_int64); +SQLITE_DEPRECATED int sqlite3_memory_alarm( + void(SQLITE_CALLBACK *)(void*,sqlite3_int64,int), + void*,sqlite3_int64); #endif /* @@ -4707,7 +4732,8 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** the SQL function is running. */ void *sqlite3_get_auxdata(sqlite3_context*, int N); -void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); +void sqlite3_set_auxdata(sqlite3_context*, int N, void*, + void (SQLITE_CALLBACK *)(void*)); /* @@ -4724,7 +4750,7 @@ void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); ** The typedef is necessary to work around problems in certain ** C++ compilers. */ -typedef void (*sqlite3_destructor_type)(void*); +typedef void (SQLITE_CALLBACK *sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) @@ -4843,9 +4869,10 @@ typedef void (*sqlite3_destructor_type)(void*); ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ -void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); +void sqlite3_result_blob(sqlite3_context*, const void*, int, + void(SQLITE_CALLBACK *)(void*)); void sqlite3_result_blob64(sqlite3_context*,const void*, - sqlite3_uint64,void(*)(void*)); + sqlite3_uint64,void(SQLITE_CALLBACK *)(void*)); void sqlite3_result_double(sqlite3_context*, double); void sqlite3_result_error(sqlite3_context*, const char*, int); void sqlite3_result_error16(sqlite3_context*, const void*, int); @@ -4855,12 +4882,17 @@ void sqlite3_result_error_code(sqlite3_context*, int); void sqlite3_result_int(sqlite3_context*, int); void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); void sqlite3_result_null(sqlite3_context*); -void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); +void sqlite3_result_text(sqlite3_context*, const char*, int, + void(SQLITE_CALLBACK *)(void*)); void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, - void(*)(void*), unsigned char encoding); -void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); -void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); -void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); + void(SQLITE_CALLBACK *)(void*), + unsigned char encoding); +void sqlite3_result_text16(sqlite3_context*, const void*, int, + void(SQLITE_CALLBACK *)(void*)); +void sqlite3_result_text16le(sqlite3_context*, const void*, int, + void(SQLITE_CALLBACK *)(void*)); +void sqlite3_result_text16be(sqlite3_context*, const void*, int, + void(SQLITE_CALLBACK *)(void*)); void sqlite3_result_value(sqlite3_context*, sqlite3_value*); void sqlite3_result_zeroblob(sqlite3_context*, int n); int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); @@ -4965,22 +4997,22 @@ int sqlite3_create_collation( const char *zName, int eTextRep, void *pArg, - int(*xCompare)(void*,int,const void*,int,const void*) + int(SQLITE_CALLBACK *xCompare)(void*,int,const void*,int,const void*) ); int sqlite3_create_collation_v2( sqlite3*, const char *zName, int eTextRep, void *pArg, - int(*xCompare)(void*,int,const void*,int,const void*), - void(*xDestroy)(void*) + int(SQLITE_CALLBACK *xCompare)(void*,int,const void*,int,const void*), + void(SQLITE_CALLBACK *xDestroy)(void*) ); int sqlite3_create_collation16( sqlite3*, const void *zName, int eTextRep, void *pArg, - int(*xCompare)(void*,int,const void*,int,const void*) + int(SQLITE_CALLBACK *xCompare)(void*,int,const void*,int,const void*) ); /* @@ -5013,12 +5045,12 @@ int sqlite3_create_collation16( int sqlite3_collation_needed( sqlite3*, void*, - void(*)(void*,sqlite3*,int eTextRep,const char*) + void(SQLITE_CALLBACK *)(void*,sqlite3*,int eTextRep,const char*) ); int sqlite3_collation_needed16( sqlite3*, void*, - void(*)(void*,sqlite3*,int eTextRep,const void*) + void(SQLITE_CALLBACK *)(void*,sqlite3*,int eTextRep,const void*) ); #ifdef SQLITE_HAS_CODEC @@ -5317,8 +5349,8 @@ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); ** ** See also the [sqlite3_update_hook()] interface. */ -void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); -void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); +void *sqlite3_commit_hook(sqlite3*, int(SQLITE_CALLBACK *)(void*), void*); +void *sqlite3_rollback_hook(sqlite3*, void(SQLITE_CALLBACK *)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks @@ -5371,7 +5403,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); */ void *sqlite3_update_hook( sqlite3*, - void(*)(void *,int ,char const *,char const *,sqlite3_int64), + void(SQLITE_CALLBACK *)(void *,int ,char const *,char const *,sqlite3_int64), void* ); @@ -5698,7 +5730,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] */ -int sqlite3_auto_extension(void (*xEntryPoint)(void)); +int sqlite3_auto_extension(void (SQLITE_CALLBACK *xEntryPoint)(void)); /* ** CAPI3REF: Cancel Automatic Extension Loading @@ -5710,7 +5742,7 @@ int sqlite3_auto_extension(void (*xEntryPoint)(void)); ** unregistered and it returns 0 if X was not on the list of initialization ** routines. */ -int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); +int sqlite3_cancel_auto_extension(void (SQLITE_CALLBACK *xEntryPoint)(void)); /* ** CAPI3REF: Reset Automatic Extension Loading @@ -5755,37 +5787,41 @@ typedef struct sqlite3_module sqlite3_module; */ struct sqlite3_module { int iVersion; - int (*xCreate)(sqlite3*, void *pAux, + int (SQLITE_CALLBACK *xCreate)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); - int (*xConnect)(sqlite3*, void *pAux, + int (SQLITE_CALLBACK *xConnect)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); - int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); - int (*xDisconnect)(sqlite3_vtab *pVTab); - int (*xDestroy)(sqlite3_vtab *pVTab); - int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); - int (*xClose)(sqlite3_vtab_cursor*); - int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, - int argc, sqlite3_value **argv); - int (*xNext)(sqlite3_vtab_cursor*); - int (*xEof)(sqlite3_vtab_cursor*); - int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); - int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); - int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); - int (*xBegin)(sqlite3_vtab *pVTab); - int (*xSync)(sqlite3_vtab *pVTab); - int (*xCommit)(sqlite3_vtab *pVTab); - int (*xRollback)(sqlite3_vtab *pVTab); - int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, - void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), - void **ppArg); - int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); + int (SQLITE_CALLBACK *xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); + int (SQLITE_CALLBACK *xDisconnect)(sqlite3_vtab *pVTab); + int (SQLITE_CALLBACK *xDestroy)(sqlite3_vtab *pVTab); + int (SQLITE_CALLBACK *xOpen)(sqlite3_vtab *pVTab, + sqlite3_vtab_cursor **ppCursor); + int (SQLITE_CALLBACK *xClose)(sqlite3_vtab_cursor*); + int (SQLITE_CALLBACK *xFilter)(sqlite3_vtab_cursor*, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv); + int (SQLITE_CALLBACK *xNext)(sqlite3_vtab_cursor*); + int (SQLITE_CALLBACK *xEof)(sqlite3_vtab_cursor*); + int (SQLITE_CALLBACK *xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); + int (SQLITE_CALLBACK *xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); + int (SQLITE_CALLBACK *xUpdate)(sqlite3_vtab *, int, sqlite3_value **, + sqlite3_int64 *); + int (SQLITE_CALLBACK *xBegin)(sqlite3_vtab *pVTab); + int (SQLITE_CALLBACK *xSync)(sqlite3_vtab *pVTab); + int (SQLITE_CALLBACK *xCommit)(sqlite3_vtab *pVTab); + int (SQLITE_CALLBACK *xRollback)(sqlite3_vtab *pVTab); + int (SQLITE_CALLBACK *xFindFunction)(sqlite3_vtab *pVtab, + int nArg, const char *zName, + void (SQLITE_CALLBACK **pxFunc)(sqlite3_context*,int,sqlite3_value**), + void **ppArg); + int (SQLITE_CALLBACK *xRename)(sqlite3_vtab *pVtab, const char *zNew); /* The methods above are in version 1 of the sqlite_module object. Those ** below are for version 2 and greater. */ - int (*xSavepoint)(sqlite3_vtab *pVTab, int); - int (*xRelease)(sqlite3_vtab *pVTab, int); - int (*xRollbackTo)(sqlite3_vtab *pVTab, int); + int (SQLITE_CALLBACK *xSavepoint)(sqlite3_vtab *pVTab, int); + int (SQLITE_CALLBACK *xRelease)(sqlite3_vtab *pVTab, int); + int (SQLITE_CALLBACK *xRollbackTo)(sqlite3_vtab *pVTab, int); }; /* @@ -5974,7 +6010,7 @@ int sqlite3_create_module_v2( const char *zName, /* Name of the module */ const sqlite3_module *p, /* Methods for the module */ void *pClientData, /* Client data for xCreate/xConnect */ - void(*xDestroy)(void*) /* Module destructor function */ + void(SQLITE_CALLBACK *xDestroy)(void*) /* Module destructor function */ ); /* @@ -6515,15 +6551,15 @@ void sqlite3_mutex_leave(sqlite3_mutex*); */ typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; struct sqlite3_mutex_methods { - int (*xMutexInit)(void); - int (*xMutexEnd)(void); - sqlite3_mutex *(*xMutexAlloc)(int); - void (*xMutexFree)(sqlite3_mutex *); - void (*xMutexEnter)(sqlite3_mutex *); - int (*xMutexTry)(sqlite3_mutex *); - void (*xMutexLeave)(sqlite3_mutex *); - int (*xMutexHeld)(sqlite3_mutex *); - int (*xMutexNotheld)(sqlite3_mutex *); + int (SQLITE_CALLBACK *xMutexInit)(void); + int (SQLITE_CALLBACK *xMutexEnd)(void); + sqlite3_mutex *(SQLITE_CALLBACK *xMutexAlloc)(int); + void (SQLITE_CALLBACK *xMutexFree)(sqlite3_mutex *); + void (SQLITE_CALLBACK *xMutexEnter)(sqlite3_mutex *); + int (SQLITE_CALLBACK *xMutexTry)(sqlite3_mutex *); + void (SQLITE_CALLBACK *xMutexLeave)(sqlite3_mutex *); + int (SQLITE_CALLBACK *xMutexHeld)(sqlite3_mutex *); + int (SQLITE_CALLBACK *xMutexNotheld)(sqlite3_mutex *); }; /* @@ -7219,18 +7255,21 @@ typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; struct sqlite3_pcache_methods2 { int iVersion; void *pArg; - int (*xInit)(void*); - void (*xShutdown)(void*); - sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable); - void (*xCachesize)(sqlite3_pcache*, int nCachesize); - int (*xPagecount)(sqlite3_pcache*); - sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); - void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, - unsigned oldKey, unsigned newKey); - void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - void (*xDestroy)(sqlite3_pcache*); - void (*xShrink)(sqlite3_pcache*); + int (SQLITE_CALLBACK *xInit)(void*); + void (SQLITE_CALLBACK *xShutdown)(void*); + sqlite3_pcache *(SQLITE_CALLBACK *xCreate)(int szPage, int szExtra, + int bPurgeable); + void (SQLITE_CALLBACK *xCachesize)(sqlite3_pcache*, int nCachesize); + int (SQLITE_CALLBACK *xPagecount)(sqlite3_pcache*); + sqlite3_pcache_page *(SQLITE_CALLBACK *xFetch)(sqlite3_pcache*, unsigned key, + int createFlag); + void (SQLITE_CALLBACK *xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, + int discard); + void (SQLITE_CALLBACK *xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, + unsigned oldKey, unsigned newKey); + void (SQLITE_CALLBACK *xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (SQLITE_CALLBACK *xDestroy)(sqlite3_pcache*); + void (SQLITE_CALLBACK *xShrink)(sqlite3_pcache*); }; /* @@ -7241,16 +7280,18 @@ struct sqlite3_pcache_methods2 { typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; struct sqlite3_pcache_methods { void *pArg; - int (*xInit)(void*); - void (*xShutdown)(void*); - sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); - void (*xCachesize)(sqlite3_pcache*, int nCachesize); - int (*xPagecount)(sqlite3_pcache*); - void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - void (*xUnpin)(sqlite3_pcache*, void*, int discard); - void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); - void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - void (*xDestroy)(sqlite3_pcache*); + int (SQLITE_CALLBACK *xInit)(void*); + void (SQLITE_CALLBACK *xShutdown)(void*); + sqlite3_pcache *(SQLITE_CALLBACK *xCreate)(int szPage, int bPurgeable); + void (SQLITE_CALLBACK *xCachesize)(sqlite3_pcache*, int nCachesize); + int (SQLITE_CALLBACK *xPagecount)(sqlite3_pcache*); + void *(SQLITE_CALLBACK *xFetch)(sqlite3_pcache*, unsigned key, + int createFlag); + void (SQLITE_CALLBACK *xUnpin)(sqlite3_pcache*, void*, int discard); + void (SQLITE_CALLBACK *xRekey)(sqlite3_pcache*, void*, unsigned oldKey, + unsigned newKey); + void (SQLITE_CALLBACK *xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (SQLITE_CALLBACK *xDestroy)(sqlite3_pcache*); }; @@ -7580,7 +7621,7 @@ int sqlite3_backup_pagecount(sqlite3_backup *p); */ int sqlite3_unlock_notify( sqlite3 *pBlocked, /* Waiting connection */ - void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ + void (SQLITE_CALLBACK *xNotify)(void **apArg, int nArg), /* Callback func */ void *pNotifyArg /* Argument to pass to xNotify */ ); @@ -7695,7 +7736,7 @@ void sqlite3_log(int iErrCode, const char *zFormat, ...); */ void *sqlite3_wal_hook( sqlite3*, - int(*)(void *,sqlite3*,const char*,int), + int(SQLITE_CALLBACK *)(void *,sqlite3*,const char*,int), void* ); @@ -8168,7 +8209,7 @@ int sqlite3_db_cacheflush(sqlite3*); */ SQLITE_EXPERIMENTAL void *sqlite3_preupdate_hook( sqlite3 *db, - void(*xPreUpdate)( + void(SQLITE_CALLBACK *xPreUpdate)( void *pCtx, /* Copy of third arg to preupdate_hook() */ sqlite3 *db, /* Database handle */ int op, /* SQLITE_UPDATE, DELETE or INSERT */ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 2de88f41f4..e559043c08 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -4167,7 +4167,7 @@ static void init_all(Tcl_Interp *interp){ #endif #define TCLSH_MAIN main /* Needed to fake out mktclapp */ -int TCLSH_MAIN(int argc, char **argv){ +int SQLITE_CDECL TCLSH_MAIN(int argc, char **argv){ Tcl_Interp *interp; #if !defined(_WIN32_WCE) diff --git a/src/test1.c b/src/test1.c index 7d83881139..35c43d0ef9 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6444,7 +6444,7 @@ struct win32FileLocker { /* ** The background thread that does file locking. */ -static void win32_file_locker(void *pAppData){ +static void SQLITE_CDECL win32_file_locker(void *pAppData){ struct win32FileLocker *p = (struct win32FileLocker*)pAppData; if( p->evName ){ HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName); diff --git a/tool/mksqlite3c-noext.tcl b/tool/mksqlite3c-noext.tcl index 601b8cce8c..fad6c9e584 100644 --- a/tool/mksqlite3c-noext.tcl +++ b/tool/mksqlite3c-noext.tcl @@ -220,7 +220,7 @@ proc copy_file {filename} { if {[lsearch -exact $cdecllist $funcname] >= 0} { append line SQLITE_CDECL } else { - append line SQLITE_STDCALL + append line SQLITE_APICALL } append line " " $funcname $rest puts $out $line diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 7e8558d2ab..b7561cfa5b 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -232,7 +232,7 @@ proc copy_file {filename} { if {[lsearch -exact $cdecllist $funcname] >= 0} { append line SQLITE_CDECL } else { - append line SQLITE_STDCALL + append line SQLITE_APICALL } append line " " $funcname $rest puts $out $line diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index 1af6d75730..d0ddba9cfa 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -120,7 +120,7 @@ foreach file $filelist { if {[lsearch -exact $cdecllist $funcname] >= 0} { append line SQLITE_CDECL } else { - append line SQLITE_STDCALL + append line SQLITE_APICALL } append line " " $funcname $rest } From 4aff119f3a270e6b453cd32f0226a09bc1c4cd24 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Jul 2016 12:52:30 +0000 Subject: [PATCH 241/302] New test case to insure legacy CREATE TABLE syntax is supported. FossilOrigin-Name: 6feff15cae8f0427be790355841d49c479c1c586 --- manifest | 13 ++++++------- manifest.uuid | 2 +- test/parser1.test | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d0e7b14e54..d4a4aa1bdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\squery\splanner\scost\sestimation\sfor\sindex\sscans\sto\stake\sinto\saccount\nWHERE\sclause\sterms\sthat\scan\sbe\scomputed\susing\sonly\sthe\sindex\sand\sthat\sdo\snot\nrequire\slooking\sup\srows\sin\sthe\soriginal\stable.\s\sThis\sfixes\san\sobscure\nperformance\sregression\sthat\sarose\swhen\sthe\sORDER\sBY\sLIMIT\soptimization\swas\nadded\sby\scheck-in\s[bf46179d44843]. -D 2016-07-27T19:30:53.586 +C New\stest\scase\sto\sinsure\slegacy\sCREATE\sTABLE\ssyntax\sis\ssupported. +D 2016-07-28T12:52:30.552 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -985,7 +985,7 @@ F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f F test/pagerfault3.test 1003fcda009bf48a8e22a516e193b6ef0dd1bbd8 F test/pageropt.test 84e4cc5cbca285357f7906e99b21be4f2bf5abc0 F test/pagesize.test 5769fc62d8c890a83a503f67d47508dfdc543305 -F test/parser1.test 222b5cbf3e2e659fec1bf7d723488c8b9c94f1d0 +F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff @@ -1508,8 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4d59df02d3713b3e3804e1a88e676749b2794286 50f8ea37fb9647c4a9da2c269a4d6f54b10ce96b -R a589b595bdfe9868de18def836f199ce -T +closed 50f8ea37fb9647c4a9da2c269a4d6f54b10ce96b +P 9e2b26811452a5011d0a97a689636fa4409da856 +R d76a2fc86bbf1915af6bf1dd54a28237 U drh -Z 994e8dc5cbb7e25d0e8cc4a952504fbd +Z 803b725d666d5af434be7409c67eabe6 diff --git a/manifest.uuid b/manifest.uuid index 9b63447ecc..f4495ea5c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e2b26811452a5011d0a97a689636fa4409da856 \ No newline at end of file +6feff15cae8f0427be790355841d49c479c1c586 \ No newline at end of file diff --git a/test/parser1.test b/test/parser1.test index 78c1a40c63..c708dded1f 100644 --- a/test/parser1.test +++ b/test/parser1.test @@ -76,4 +76,27 @@ do_catchsql_test parser1-2.2 { SELECT x FROM c; } {1 {syntax error after column name "x"}} +# Verify that the comma between multiple table constraints is +# optional. +# +# The missing comma is technically a syntax error. But we have to support +# it because there might be legacy databases that omit the commas in their +# sqlite_master tables. +# +do_execsql_test parser1-3.1 { + CREATE TABLE t300(id INTEGER PRIMARY KEY); + CREATE TABLE t301( + id INTEGER PRIMARY KEY, + c1 INTEGER NOT NULL, + c2 INTEGER NOT NULL, + c3 BOOLEAN NOT NULL DEFAULT 0, + FOREIGN KEY(c1) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT + /* no comma */ + FOREIGN KEY(c2) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT + /* no comma */ + UNIQUE(c1, c2) + ); + PRAGMA foreign_key_list(t301); +} {0 0 t300 c2 id RESTRICT CASCADE NONE 1 0 t300 c1 id RESTRICT CASCADE NONE} + finish_test From 52b1dbb5fc949a629d7213661c968c722b9e5029 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 14:37:04 +0000 Subject: [PATCH 242/302] Allow the 'testfixture.exe' target to be compiled with the __stdcall calling convention. FossilOrigin-Name: e8be3dfeabaa31b3490793cf8230faae1204be15 --- Makefile.msc | 32 +++++++++--- ext/fts2/fts2_tokenizer.c | 6 ++- ext/fts3/fts3_test.c | 6 ++- ext/fts3/fts3_tokenizer.c | 6 ++- ext/fts5/fts5_tcl.c | 6 ++- ext/rbu/test_rbu.c | 12 ++++- ext/session/test_session.c | 6 ++- manifest | 99 ++++++++++++++++++-------------------- manifest.uuid | 2 +- src/tclsqlite.c | 10 ++-- src/test1.c | 6 ++- src/test2.c | 6 ++- src/test3.c | 6 ++- src/test4.c | 6 ++- src/test5.c | 6 ++- src/test6.c | 6 ++- src/test7.c | 6 ++- src/test8.c | 6 ++- src/test9.c | 6 ++- src/test_async.c | 6 ++- src/test_autoext.c | 6 ++- src/test_backup.c | 6 ++- src/test_bestindex.c | 6 ++- src/test_blob.c | 6 ++- src/test_btree.c | 6 ++- src/test_config.c | 6 ++- src/test_demovfs.c | 6 ++- src/test_fs.c | 6 ++- src/test_func.c | 6 ++- src/test_hexio.c | 6 ++- src/test_init.c | 6 ++- src/test_intarray.c | 6 ++- src/test_malloc.c | 6 ++- src/test_multiplex.c | 6 ++- src/test_mutex.c | 6 ++- src/test_osinst.c | 6 ++- src/test_quota.c | 6 ++- src/test_rtree.c | 12 ++++- src/test_schema.c | 10 ++-- src/test_superlock.c | 6 ++- src/test_syscall.c | 6 ++- src/test_tclvar.c | 6 ++- src/test_thread.c | 6 ++- src/test_vfs.c | 6 ++- tool/replace.tcl | 3 +- 45 files changed, 294 insertions(+), 108 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 7220f71cd4..c3f7f3a2b0 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -466,12 +466,12 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) !IF "$(PLATFORM)"=="x86" CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl !ELSE !IFNDEF PLATFORM CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = @@ -1239,6 +1239,12 @@ SRC11 = \ parse.h \ $(SQLITE3H) +# Generated Tcl header files +# +SRC12 = \ + sqlite_tcl.h \ + sqlite_tclDecls.h + # All source code files. # SRC = $(SRC00) $(SRC01) $(SRC02) $(SRC03) $(SRC04) $(SRC05) $(SRC06) $(SRC07) $(SRC08) $(SRC09) $(SRC10) $(SRC11) @@ -1503,7 +1509,7 @@ mptest: mptester.exe # files are automatically generated. This target takes care of # all that automatic generation. # -.target_source: $(SRC) $(TOP)\tool\vdbe-compress.tcl fts5.c +.target_source: $(SRC) $(TOP)\tool\vdbe-compress.tcl fts5.c sqlite_tcl.h -rmdir /Q/S tsrc 2>NUL -mkdir tsrc for %i in ($(SRC00)) do copy /Y %i tsrc @@ -1518,6 +1524,7 @@ mptest: mptester.exe for %i in ($(SRC09)) do copy /Y %i tsrc for %i in ($(SRC10)) do copy /Y %i tsrc for %i in ($(SRC11)) do copy /Y %i tsrc + for %i in ($(SRC12)) do copy /Y %i tsrc copy /Y fts5.c tsrc copy /Y fts5.h tsrc del /Q tsrc\sqlite.h.in tsrc\parse.y 2>NUL @@ -1799,10 +1806,10 @@ wherecode.lo: $(TOP)\src\wherecode.c $(HDR) whereexpr.lo: $(TOP)\src\whereexpr.c $(HDR) $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\whereexpr.c -tclsqlite.lo: $(TOP)\src\tclsqlite.c $(HDR) +tclsqlite.lo: $(TOP)\src\tclsqlite.c $(HDR) sqlite_tcl.h $(LTCOMPILE) $(NO_WARN) -DUSE_TCL_STUBS=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c -tclsqlite-shell.lo: $(TOP)\src\tclsqlite.c $(HDR) +tclsqlite-shell.lo: $(TOP)\src\tclsqlite.c $(HDR) sqlite_tcl.h $(LTCOMPILE) $(NO_WARN) -DTCLSH=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c tclsqlite3.exe: tclsqlite-shell.lo $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS) @@ -1974,7 +1981,16 @@ TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0) TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC1) !ENDIF -testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) +sqlite_tclDecls.h: + echo #ifndef SQLITE_TCLAPI > sqlite_tclDecls.h + echo # define SQLITE_TCLAPI __cdecl >> sqlite_tclDecls.h + echo #endif >> sqlite_tclDecls.h + type "$(TCLINCDIR)\tclDecls.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?.*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" >> sqlite_tclDecls.h + +sqlite_tcl.h: sqlite_tclDecls.h + type "$(TCLINCDIR)\tcl.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact tclDecls.h sqlite_tclDecls.h >> sqlite_tcl.h + +testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) sqlite_tcl.h $(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \ -DBUILD_sqlite -I$(TCLINCDIR) \ $(TESTFIXTURE_SRC) \ @@ -2023,7 +2039,7 @@ smoketest: $(TESTPROGS) @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\main.test $(TESTOPTS) -sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl +sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl sqlite_tcl.h echo #define TCLSH 2 > $@ echo #define SQLITE_ENABLE_DBSTAT_VTAB 1 >> $@ copy $@ + $(SQLITE3C) + $(TOP)\src\tclsqlite.c $@ @@ -2103,7 +2119,7 @@ clean: -rmdir /Q/S .libs 2>NUL -rmdir /Q/S tsrc 2>NUL del /Q .target_source 2>NUL - del /Q tclsqlite3.exe 2>NUL + del /Q tclsqlite3.exe sqlite_tcl.h sqlite_tclDecls.h 2>NUL del /Q testloadext.dll 2>NUL del /Q testfixture.exe test.db 2>NUL del /Q LogEst.exe fts3view.exe rollback-test.exe showdb.exe 2>NUL diff --git a/ext/fts2/fts2_tokenizer.c b/ext/fts2/fts2_tokenizer.c index a3d6a6312a..dda33a72d2 100644 --- a/ext/fts2/fts2_tokenizer.c +++ b/ext/fts2/fts2_tokenizer.c @@ -99,7 +99,11 @@ static void scalarFunc( #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include /* diff --git a/ext/fts3/fts3_test.c b/ext/fts3/fts3_test.c index 2596e6dec7..c3b71284ec 100644 --- a/ext/fts3/fts3_test.c +++ b/ext/fts3/fts3_test.c @@ -18,7 +18,11 @@ ** that the sqlite3_tokenizer_module.xLanguage() method is invoked correctly. */ -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/ext/fts3/fts3_tokenizer.c b/ext/fts3/fts3_tokenizer.c index b7d9d2b3b2..bfc36af3e3 100644 --- a/ext/fts3/fts3_tokenizer.c +++ b/ext/fts3/fts3_tokenizer.c @@ -224,7 +224,11 @@ int sqlite3Fts3InitTokenizer( #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include /* diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 72db65777f..dee9bc7f18 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -14,7 +14,11 @@ #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #ifdef SQLITE_ENABLE_FTS5 diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index 6418d30d59..671f16c553 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -17,7 +17,11 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) #include "sqlite3rbu.h" -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include /* From main.c */ @@ -347,7 +351,11 @@ int SqliteRbu_Init(Tcl_Interp *interp){ } #else -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif int SqliteRbu_Init(Tcl_Interp *interp){ return TCL_OK; } #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */ #endif /* defined(SQLITE_TEST) */ diff --git a/ext/session/test_session.c b/ext/session/test_session.c index 1aa63b74ed..9f6bc3f70d 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -5,7 +5,11 @@ #include "sqlite3session.h" #include #include -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif typedef struct TestSession TestSession; struct TestSession { diff --git a/manifest b/manifest index a174c165d9..8f0151d5f2 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Work\sin\sprogress\son\ssetting\sa\scalling\sconvention\sfor\sall\scallback\sfunctions. -D 2016-07-28T04:14:37.455 +C Allow\sthe\s'testfixture.exe'\starget\sto\sbe\scompiled\swith\sthe\s__stdcall\scalling\sconvention. +D 2016-07-28T14:37:04.758 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 843c563182b26a358674c520d7b8d40b832e9436 +F Makefile.msc da4c9f5bc46f6f12d7313d12be18a2d2c55e06c0 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -62,7 +62,7 @@ F ext/fts2/fts2_hash.c 011a1d32de45bb1b519a1fd0048e857d6a843558 F ext/fts2/fts2_hash.h 1824b99dfd8d0225facbdb26a2c87289b2e7dcf8 F ext/fts2/fts2_icu.c 51c5cd3c04954badd329fa738c95fcdb717b5188 F ext/fts2/fts2_porter.c 2cd4a507bf3c3085fe66f59b0f2a325f65aaacf5 -F ext/fts2/fts2_tokenizer.c 3dbe8058e97afb55fff3ea844120ce3208b114cc +F ext/fts2/fts2_tokenizer.c b529493d55e55497213c37e1f31680a77746be26 F ext/fts2/fts2_tokenizer.h 27a1a99ca2d615cf7e142839b8d79e8751b4529e F ext/fts2/fts2_tokenizer1.c 07e223eecb483d448313b5f1553a4f299a7fb7a1 F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 @@ -81,9 +81,9 @@ F ext/fts3/fts3_icu.c deb46f7020d87ea7a14a433fb7a7f4bef42a9652 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 F ext/fts3/fts3_snippet.c 68ae118b0f834ea53d2b89e4087fc0f0b8c4ee4e F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 -F ext/fts3/fts3_test.c a940cf104d545ad1abf926956ce65db2aa5af0cf +F ext/fts3/fts3_test.c 7d8c9e17bc11cc245c91585ef5a47ee4a600f7b2 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 -F ext/fts3/fts3_tokenizer.c 3cf21cd2212db17a88d4ef7da0fd8a80275979a1 +F ext/fts3/fts3_tokenizer.c a22bf311a71f3efa9d7012d8cc48fc9b0f3dace7 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c a93f5edc0aff44ef8b06d7cb55b52026541ca145 @@ -107,7 +107,7 @@ F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 -F ext/fts5/fts5_tcl.c f8731e0508299bd43f1a2eff7dbeaac870768966 +F ext/fts5/fts5_tcl.c b41f04600936a2b910b5dff179e8bd050ccb34c7 F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -255,7 +255,7 @@ F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab F ext/rbu/sqlite3rbu.c 948677ee0ec57da51148e6c5f64ac68afcf36ab2 F ext/rbu/sqlite3rbu.h db8858120c9be14b60c9225f9da28221f5f6b945 -F ext/rbu/test_rbu.c 9f043b74c46c45b231f4313aed1fccb379a76fe6 +F ext/rbu/test_rbu.c c2c1859dfd69f1a55125d38009d0d49e36895780 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c d26a815b0df1c412a6881dae8d7fd3c9c08cce68 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -301,7 +301,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 F ext/session/sqlite3session.h 69bf73cfd71e58f2ae5d2aa935b2c1a541aee555 -F ext/session/test_session.c 464f2c8bf502795d95969387eb8e93f68c513c15 +F ext/session/test_session.c ebf9acf2bd70885e6245512427f800693b65dc9c F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e @@ -392,51 +392,51 @@ F src/sqliteInt.h d25c18c1272a7811e2569c39bfc2fca96156eead F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 53274d5bbd66e7246c573a6b48026781d42c7efe -F src/test1.c 5ec959d088af063cac44cf1685455f3fcddecc8c -F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b -F src/test3.c c75c8af0eadb335236c9e61b51044c58a8f7dd59 -F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e -F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 -F src/test6.c a684b7abd01352ab50cb79c0bf727e6b3f381a3d -F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 -F src/test8.c fa262391d3edea6490a71bfaa8fed477ccbbac75 -F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 -F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 -F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 -F src/test_backup.c 2e6e6a081870150f20c526a2e9d0d29cda47d803 -F src/test_bestindex.c f9e6807c52aa532e4775321ce3ed8e47c907ed45 -F src/test_blob.c b2551a9b5573232db5f66f292307c37067937239 -F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f -F src/test_config.c 7003f6f35134de6f19c6588f44783e43390ea277 -F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 +F src/tclsqlite.c e348648c28fcaa04ab8da98bf7e8a37b3629e634 +F src/test1.c a625e4d2857e0b08a9d66bdb737ce95b02326a9f +F src/test2.c ce1e56fd0983866df1dbaf6c0558f3ad726ec222 +F src/test3.c 68b6b3b17df3028deda0a79607af70ff4ac5fc52 +F src/test4.c a305bb93783fa0db03b9e5e899ec5367cf139903 +F src/test5.c 3ca6874d52d658607d2f25bb6ed88fd03ad78a6c +F src/test6.c 4fc2c870b4f41d46f11a24b5c7dcff89486442b8 +F src/test7.c 57b6dae963ff12cb6ef8389285427f07e8b042ff +F src/test8.c 33cefbf2911e12c74c6adb798cc0c8ee3287a58d +F src/test9.c 6b9792e8a692a67fcce77dfe4a2ca4744c4ece54 +F src/test_async.c 233536b7e364a4a95597d6aa6fdf07fa9351de67 +F src/test_autoext.c 2a2343174ff46477dd081b7582dc1e72c69330bc +F src/test_backup.c 7fe86c0be6c1a05a254b845a6aa32294dbdab012 +F src/test_bestindex.c 832b9968bf15d60029c1700905d56cefeb0f5dd7 +F src/test_blob.c 6af2552a059f326a107214fb13917f31a1606caf +F src/test_btree.c 3d2abd96336f1cbb760c7c5a758e74eaae98aed6 +F src/test_config.c 4d3d4a886416f369771d69a6dba926866deda788 +F src/test_demovfs.c ed337b14964a5f5ba08bf9472c94c64e88c547a7 F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 -F src/test_fs.c f10f840ca4f8c72e4837908bd8347ac4bcab074b -F src/test_func.c 37453d346cfcf118774efd5bf6187f7e6a7e3254 -F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd -F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 -F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 +F src/test_fs.c 39086f99413e73f60afe2280a0ff27dfab63ab47 +F src/test_func.c 4197173afb7d8453d3d0c7f7b109226dcef52997 +F src/test_hexio.c 2ab200d91f77085bd69c721dcb2b649f036d608b +F src/test_init.c a55015461868ca979d819f8db72aa682ba068185 +F src/test_intarray.c 9fee7f930ff988dd0fc20315da4c762f77f01a78 F src/test_intarray.h f3b7672f5d1056eac563c0d6ea8480a660b1475c F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd -F src/test_malloc.c 6b27e947eeeb70d11aa65406ed28d749e39b6356 -F src/test_multiplex.c eafc567ebe162e36f17b5062285dfe90461cf8e9 +F src/test_malloc.c 90cbc63ebab11d16b440d394e77bc26629829f11 +F src/test_multiplex.c a0bcea72bc981f64c9c71edf22cc503cf83e0348 F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635 -F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c +F src/test_mutex.c 85021f2ffe67cdb4dfa6089f3f55f5e01cd76aea F src/test_onefile.c 416f87a28d6d673352d33fc4b1c7d39db878e50f -F src/test_osinst.c ad0233b1dabb0390e25edded4ebd79a2a61538c6 +F src/test_osinst.c 4e21c7b2709955f9907b80bfc874afb81ce1b4a7 F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 -F src/test_quota.c 180813f43683be5725458fc1ff13ac455d8e722d +F src/test_quota.c 7c2bb6d302f9cab9d4782b1a37dd01f0c7bde071 F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d -F src/test_rtree.c 43fff4c5a01576d6d213f27472598801a247890c -F src/test_schema.c 2bdba21b82f601da69793e1f1d11bf481a79b091 +F src/test_rtree.c 0aad72f4854b01957b20c3c325eecd8512e9731d +F src/test_schema.c ab94aeab8a94486de3d2ce06567b7ee35f3a59b8 F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b -F src/test_superlock.c 06797157176eb7085027d9dd278c0d7a105e3ec9 -F src/test_syscall.c 268c072541162564a882c57f54a6fee12ef4a4d2 -F src/test_tclvar.c d86412527da65468ee6fa1b8607c65d0af736bc4 -F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9 -F src/test_vfs.c 4d02f38bfb8f7f273da7ba84bfe000f5babf206c +F src/test_superlock.c 9389ee2aa8f8fa7487ea2e3bf01c033c65eaf21a +F src/test_syscall.c 8313aa5d43989913c2dfd42b987e6ed29d6b8770 +F src/test_tclvar.c 0239df9e83f9adc7b21ae01dce20229dd8592e71 +F src/test_thread.c 30ae6818d21a168ef8cbceb9456411751c714cd9 +F src/test_vfs.c 2edd39d413301baf15c1d7384f21c2e8b3fca2dd F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 F src/test_windirent.h b12055cab6227f7be10f5c19296f67c60cc5e2a5 @@ -1457,7 +1457,7 @@ F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97 F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b -F tool/replace.tcl 7727c60a04299b65a92f5e1590896fea0f25b9e0 +F tool/replace.tcl 3856f87247dde5418d16dac92fa4060813431778 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/run-speed-test.sh f95d19fd669b68c4c38b6b475242841d47c66076 @@ -1508,10 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9e2b26811452a5011d0a97a689636fa4409da856 -R 6c56defa4f9211ce028bec2ac1e13231 -T *branch * callbackConv -T *sym-callbackConv * -T -sym-trunk * +P 02b8040e1add02734d2dbc6c59737ab74ff8fb18 +R ccdbec6a43a33ea0f78bbd174bf27dd8 U mistachkin -Z d50c4a0ba4b8e38dec3c91619f068656 +Z 9a093adb6bae045a3c1e5e0de6859957 diff --git a/manifest.uuid b/manifest.uuid index 57781e18c1..8d4ac6e27c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -02b8040e1add02734d2dbc6c59737ab74ff8fb18 \ No newline at end of file +e8be3dfeabaa31b3490793cf8230faae1204be15 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index e559043c08..d26c622859 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -30,10 +30,14 @@ ** If requested, include the SQLite compiler options file for MSVC. */ #if defined(INCLUDE_MSVC_H) -#include "msvc.h" +# include "msvc.h" #endif -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include /* @@ -4123,7 +4127,7 @@ static void init_all(Tcl_Interp *interp){ Sqlitetesttclvar_Init(interp); Sqlitetestfs_Init(interp); SqlitetestThread_Init(interp); - SqlitetestOnefile_Init(interp); + SqlitetestOnefile_Init(); SqlitetestOsinst_Init(interp); Sqlitetestbackup_Init(interp); Sqlitetestintarray_Init(interp); diff --git a/src/test1.c b/src/test1.c index 35c43d0ef9..e1b4fc0f31 100644 --- a/src/test1.c +++ b/src/test1.c @@ -19,7 +19,11 @@ #endif #include "vdbeInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test2.c b/src/test2.c index d16ba5016a..8946196ff3 100644 --- a/src/test2.c +++ b/src/test2.c @@ -14,7 +14,11 @@ ** testing of the SQLite library. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include #include diff --git a/src/test3.c b/src/test3.c index bfd7c30b65..f1b9f37924 100644 --- a/src/test3.c +++ b/src/test3.c @@ -15,7 +15,11 @@ */ #include "sqliteInt.h" #include "btreeInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test4.c b/src/test4.c index d689030303..85b521b060 100644 --- a/src/test4.c +++ b/src/test4.c @@ -12,7 +12,11 @@ ** Code for testing the SQLite library in a multithreaded environment. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #if SQLITE_OS_UNIX && SQLITE_THREADSAFE #include #include diff --git a/src/test5.c b/src/test5.c index 952e3325e5..2b49e408b6 100644 --- a/src/test5.c +++ b/src/test5.c @@ -17,7 +17,11 @@ */ #include "sqliteInt.h" #include "vdbeInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test6.c b/src/test6.c index 24fe725f78..e6eabf996a 100644 --- a/src/test6.c +++ b/src/test6.c @@ -16,7 +16,11 @@ */ #if SQLITE_TEST /* This file is used for testing only */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #ifndef SQLITE_OMIT_DISKIO /* This file is a no-op if disk I/O is disabled */ diff --git a/src/test7.c b/src/test7.c index 6ba3631b41..d3b789e967 100644 --- a/src/test7.c +++ b/src/test7.c @@ -13,7 +13,11 @@ ** Derived from test4.c. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif /* ** This test only works on UNIX with a SQLITE_THREADSAFE build that includes diff --git a/src/test8.c b/src/test8.c index fb781ac8fd..e635d5ed2c 100644 --- a/src/test8.c +++ b/src/test8.c @@ -14,7 +14,11 @@ ** testing of the SQLite library. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test9.c b/src/test9.c index e5993e8ff7..3c3629c0a7 100644 --- a/src/test9.c +++ b/src/test9.c @@ -15,7 +15,11 @@ ** as there is not much point in binding to Tcl. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test_async.c b/src/test_async.c index b0b943185b..8389e75dbd 100644 --- a/src/test_async.c +++ b/src/test_async.c @@ -15,7 +15,11 @@ */ #define TCL_THREADS -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #ifdef SQLITE_ENABLE_ASYNCIO diff --git a/src/test_autoext.c b/src/test_autoext.c index a5236d2390..b536cd7321 100644 --- a/src/test_autoext.c +++ b/src/test_autoext.c @@ -11,7 +11,11 @@ ************************************************************************* ** Test extension for testing the sqlite3_auto_extension() function. */ -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include "sqlite3ext.h" #ifndef SQLITE_OMIT_LOAD_EXTENSION diff --git a/src/test_backup.c b/src/test_backup.c index 6b4d6b9b1c..3e91f1f219 100644 --- a/src/test_backup.c +++ b/src/test_backup.c @@ -13,7 +13,11 @@ ** */ -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include "sqlite3.h" #include diff --git a/src/test_bestindex.c b/src/test_bestindex.c index f6f9d3eaf8..8e0ff00b52 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -93,7 +93,11 @@ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #ifndef SQLITE_OMIT_VIRTUALTABLE diff --git a/src/test_blob.c b/src/test_blob.c index ec2227bb39..703664190b 100644 --- a/src/test_blob.c +++ b/src/test_blob.c @@ -12,7 +12,11 @@ ** */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include #include diff --git a/src/test_btree.c b/src/test_btree.c index dfe77051b6..46860afb30 100644 --- a/src/test_btree.c +++ b/src/test_btree.c @@ -14,7 +14,11 @@ ** testing of the SQLite library. */ #include "btreeInt.h" -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif /* ** Usage: sqlite3_shared_cache_report diff --git a/src/test_config.c b/src/test_config.c index 9ce9bfcaca..1e68e58d8d 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -24,7 +24,11 @@ # include "os_win.h" #endif -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test_demovfs.c b/src/test_demovfs.c index 9410a309a6..9cc0eb0309 100644 --- a/src/test_demovfs.c +++ b/src/test_demovfs.c @@ -641,7 +641,11 @@ sqlite3_vfs *sqlite3_demovfs(void){ #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #if SQLITE_OS_UNIX static int register_demovfs( diff --git a/src/test_fs.c b/src/test_fs.c index 32026d0f38..329594a5ab 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -62,7 +62,11 @@ ** SELECT * FROM fstree WHERE path LIKE '/home/dan/sqlite/%' */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test_func.c b/src/test_func.c index 579177b70c..08ea98fb7a 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -13,7 +13,11 @@ ** implements new SQL functions used by the test scripts. */ #include "sqlite3.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include #include diff --git a/src/test_hexio.c b/src/test_hexio.c index b20b5ce730..88f5ed7bfa 100644 --- a/src/test_hexio.c +++ b/src/test_hexio.c @@ -18,7 +18,11 @@ ** easier and safer to build our own mechanism. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include #include diff --git a/src/test_init.c b/src/test_init.c index 502d95c052..c66b5785d0 100644 --- a/src/test_init.c +++ b/src/test_init.c @@ -27,7 +27,11 @@ #include "sqliteInt.h" #include -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif static struct Wrapped { sqlite3_pcache_methods2 pcache; diff --git a/src/test_intarray.c b/src/test_intarray.c index 70e34db3e1..c27b4597c0 100644 --- a/src/test_intarray.c +++ b/src/test_intarray.c @@ -270,7 +270,11 @@ SQLITE_API int sqlite3_intarray_bind( ** Everything below is interface for testing this module. */ #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif /* ** Routines to encode and decode pointers diff --git a/src/test_malloc.c b/src/test_malloc.c index 37612561eb..66d8a881ba 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -14,7 +14,11 @@ ** memory allocation subsystem. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include #include diff --git a/src/test_multiplex.c b/src/test_multiplex.c index ba4e61b090..dffdb44941 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -1229,7 +1229,11 @@ int sqlite3_multiplex_shutdown(int eForce){ /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif extern const char *sqlite3ErrName(int); diff --git a/src/test_mutex.c b/src/test_mutex.c index 995b89a4c6..22375197b7 100644 --- a/src/test_mutex.c +++ b/src/test_mutex.c @@ -12,7 +12,11 @@ ** This file contains test logic for the sqlite3_mutex interfaces. */ -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include "sqlite3.h" #include "sqliteInt.h" #include diff --git a/src/test_osinst.c b/src/test_osinst.c index e51ce77ef8..5ab8ed5c93 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -1104,7 +1104,11 @@ int sqlite3_vfslog_register(sqlite3 *db){ #if defined(SQLITE_TEST) || defined(TCLSH) -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif static int test_vfslog( void *clientData, diff --git a/src/test_quota.c b/src/test_quota.c index e8e0b34072..8ea48e5b53 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -1278,7 +1278,11 @@ int sqlite3_quota_remove(const char *zFilename){ /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif /* ** Argument passed to a TCL quota-over-limit callback. diff --git a/src/test_rtree.c b/src/test_rtree.c index 797ec0026c..1f15566f97 100644 --- a/src/test_rtree.c +++ b/src/test_rtree.c @@ -14,7 +14,11 @@ */ #include "sqlite3.h" -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif /* Solely for the UNUSED_PARAMETER() macro. */ #include "sqliteInt.h" @@ -353,7 +357,11 @@ static int bfs_query_func(sqlite3_rtree_query_info *p){ *************************************************************************/ #include -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif typedef struct Cube Cube; struct Cube { diff --git a/src/test_schema.c b/src/test_schema.c index 4ee18193b0..f2bd3b3520 100644 --- a/src/test_schema.c +++ b/src/test_schema.c @@ -35,10 +35,14 @@ ** to be compiled into an sqlite dynamic extension. */ #ifdef SQLITE_TEST - #include "sqliteInt.h" - #include "tcl.h" +# include "sqliteInt.h" +# if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +# else +# include "tcl.h" +# endif #else - #include "sqlite3ext.h" +# include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #endif diff --git a/src/test_superlock.c b/src/test_superlock.c index cac789842d..cad5b51f0f 100644 --- a/src/test_superlock.c +++ b/src/test_superlock.c @@ -256,7 +256,11 @@ int sqlite3demo_superlock( #ifdef SQLITE_TEST -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif struct InterpAndScript { Tcl_Interp *interp; diff --git a/src/test_syscall.c b/src/test_syscall.c index f1d5c61bc3..eab9895186 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -76,7 +76,11 @@ #include "sqliteInt.h" #include "sqlite3.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include #include diff --git a/src/test_tclvar.c b/src/test_tclvar.c index 63ed394734..95a065c853 100644 --- a/src/test_tclvar.c +++ b/src/test_tclvar.c @@ -17,7 +17,11 @@ ** access to TCL variables. */ #include "sqliteInt.h" -#include "tcl.h" +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #include #include diff --git a/src/test_thread.c b/src/test_thread.c index a4d96e1942..1fd646e769 100644 --- a/src/test_thread.c +++ b/src/test_thread.c @@ -16,7 +16,11 @@ */ #include "sqliteInt.h" -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif #if SQLITE_THREADSAFE diff --git a/src/test_vfs.c b/src/test_vfs.c index b476a42cb4..acc1c6682e 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -28,7 +28,11 @@ #include "sqlite3.h" #include "sqliteInt.h" -#include +#if defined(INCLUDE_SQLITE_TCL_H) +# include "sqlite_tcl.h" +#else +# include "tcl.h" +#endif typedef struct Testvfs Testvfs; typedef struct TestvfsShm TestvfsShm; diff --git a/tool/replace.tcl b/tool/replace.tcl index b01a83accb..1ecc6dc7b5 100644 --- a/tool/replace.tcl +++ b/tool/replace.tcl @@ -7,13 +7,14 @@ set mode [string tolower [lindex $argv 0]] set from [lindex $argv 1] set to [lindex $argv 2] -if {$mode ni [list exact include]} {exit 1} +if {$mode ni [list exact regsub include]} {exit 1} if {[string length $from]==0} {exit 2} while {![eof stdin]} { set line [gets stdin] if {[eof stdin]} break switch -exact $mode { exact {set line [string map [list $from $to] $line]} + regsub {regsub -all -- $from $line $to line} include {if {[regsub -all -- $from $line $to line]==0} continue} } puts stdout $line From 4194ff65989d436a22699faac29e6f98d1beb414 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Jul 2016 15:09:02 +0000 Subject: [PATCH 243/302] Change mksqlite3h.tcl to automatically insert the SQLITE_CALLBACK calling convention macros. FossilOrigin-Name: 11ab9c9ab562df98c20abf126a8bac178aef77a8 --- manifest | 16 +-- manifest.uuid | 2 +- src/sqlite.h.in | 326 ++++++++++++++++++++------------------------ tool/mksqlite3h.tcl | 3 + 4 files changed, 159 insertions(+), 188 deletions(-) diff --git a/manifest b/manifest index 8f0151d5f2..49f48174ea 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sthe\s'testfixture.exe'\starget\sto\sbe\scompiled\swith\sthe\s__stdcall\scalling\sconvention. -D 2016-07-28T14:37:04.758 +C Change\smksqlite3h.tcl\sto\sautomatically\sinsert\sthe\sSQLITE_CALLBACK\scalling\nconvention\smacros. +D 2016-07-28T15:09:02.696 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc da4c9f5bc46f6f12d7313d12be18a2d2c55e06c0 @@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 -F src/sqlite.h.in a0760a3f7b1939e395a3e74d245e5bb03cd54fb1 +F src/sqlite.h.in a03063e698a43cc5c996cd341f39439a6ce58304 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 F src/sqliteInt.h d25c18c1272a7811e2569c39bfc2fca96156eead @@ -1450,7 +1450,7 @@ F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl aa58ea3be311c81821c2cd3209f55e46b07ab656 F tool/mksqlite3c.tcl a52ead27e2ac5d4b616e945a0601f628f4328329 -F tool/mksqlite3h.tcl fab97967314e63384a3ed23fd35f0d8188352400 +F tool/mksqlite3h.tcl abaf6af11e184c0b69f117fc47ecfa351d81c219 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 02b8040e1add02734d2dbc6c59737ab74ff8fb18 -R ccdbec6a43a33ea0f78bbd174bf27dd8 -U mistachkin -Z 9a093adb6bae045a3c1e5e0de6859957 +P e8be3dfeabaa31b3490793cf8230faae1204be15 +R 44253432508e9739e51133f1558c85ed +U drh +Z 863aa68feeed694e590c235a245cfae1 diff --git a/manifest.uuid b/manifest.uuid index 8d4ac6e27c..617643d254 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8be3dfeabaa31b3490793cf8230faae1204be15 \ No newline at end of file +11ab9c9ab562df98c20abf126a8bac178aef77a8 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 009f080a86..02ae22c346 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -67,7 +67,6 @@ extern "C" { # define SQLITE_SYSAPI #endif - /* ** These no-op macros are used in front of interfaces to mark those ** interfaces as either deprecated or experimental. New applications @@ -328,7 +327,7 @@ int sqlite3_close_v2(sqlite3*); ** This is legacy and deprecated. It is included for historical ** compatibility and is not documented. */ -typedef int (SQLITE_CALLBACK *sqlite3_callback)(void*,int,char**, char**); +typedef int (*sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface @@ -395,7 +394,7 @@ typedef int (SQLITE_CALLBACK *sqlite3_callback)(void*,int,char**, char**); int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluated */ - int (SQLITE_CALLBACK *callback)(void*,int,char**,char**), /* Callback func */ + int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); @@ -743,30 +742,26 @@ struct sqlite3_file { typedef struct sqlite3_io_methods sqlite3_io_methods; struct sqlite3_io_methods { int iVersion; - int (SQLITE_CALLBACK *xClose)(sqlite3_file*); - int (SQLITE_CALLBACK *xRead)(sqlite3_file*, void*, int iAmt, - sqlite3_int64 iOfst); - int (SQLITE_CALLBACK *xWrite)(sqlite3_file*, const void*, int iAmt, - sqlite3_int64 iOfst); - int (SQLITE_CALLBACK *xTruncate)(sqlite3_file*, sqlite3_int64 size); - int (SQLITE_CALLBACK *xSync)(sqlite3_file*, int flags); - int (SQLITE_CALLBACK *xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); - int (SQLITE_CALLBACK *xLock)(sqlite3_file*, int); - int (SQLITE_CALLBACK *xUnlock)(sqlite3_file*, int); - int (SQLITE_CALLBACK *xCheckReservedLock)(sqlite3_file*, int *pResOut); - int (SQLITE_CALLBACK *xFileControl)(sqlite3_file*, int op, void *pArg); - int (SQLITE_CALLBACK *xSectorSize)(sqlite3_file*); - int (SQLITE_CALLBACK *xDeviceCharacteristics)(sqlite3_file*); + int (*xClose)(sqlite3_file*); + int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); + int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); + int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); + int (*xSync)(sqlite3_file*, int flags); + int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); + int (*xLock)(sqlite3_file*, int); + int (*xUnlock)(sqlite3_file*, int); + int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); + int (*xFileControl)(sqlite3_file*, int op, void *pArg); + int (*xSectorSize)(sqlite3_file*); + int (*xDeviceCharacteristics)(sqlite3_file*); /* Methods above are valid for version 1 */ - int (SQLITE_CALLBACK *xShmMap)(sqlite3_file*, int iPg, int pgsz, int, - void volatile**); - int (SQLITE_CALLBACK *xShmLock)(sqlite3_file*, int offset, int n, int flags); - void (SQLITE_CALLBACK *xShmBarrier)(sqlite3_file*); - int (SQLITE_CALLBACK *xShmUnmap)(sqlite3_file*, int deleteFlag); + int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); + int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); + void (*xShmBarrier)(sqlite3_file*); + int (*xShmUnmap)(sqlite3_file*, int deleteFlag); /* Methods above are valid for version 2 */ - int (SQLITE_CALLBACK *xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, - void **pp); - int (SQLITE_CALLBACK *xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); + int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); + int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); /* Methods above are valid for version 3 */ /* Additional methods may be added in future releases */ }; @@ -1208,7 +1203,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; ** any of these methods if the iVersion of the VFS is less than 3. */ typedef struct sqlite3_vfs sqlite3_vfs; -typedef void (SQLITE_SYSAPI *sqlite3_syscall_ptr)(void); +typedef void (*sqlite3_syscall_ptr)(void); struct sqlite3_vfs { int iVersion; /* Structure version number (currently 3) */ int szOsFile; /* Size of subclassed sqlite3_file */ @@ -1216,37 +1211,31 @@ struct sqlite3_vfs { sqlite3_vfs *pNext; /* Next registered VFS */ const char *zName; /* Name of this virtual file system */ void *pAppData; /* Pointer to application-specific data */ - int (SQLITE_CALLBACK *xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, + int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, int flags, int *pOutFlags); - int (SQLITE_CALLBACK *xDelete)(sqlite3_vfs*, const char *zName, int syncDir); - int (SQLITE_CALLBACK *xAccess)(sqlite3_vfs*, const char *zName, int flags, - int *pResOut); - int (SQLITE_CALLBACK *xFullPathname)(sqlite3_vfs*, const char *zName, - int nOut, char *zOut); - void *(SQLITE_CALLBACK *xDlOpen)(sqlite3_vfs*, const char *zFilename); - void (SQLITE_CALLBACK *xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); - void (*(SQLITE_CALLBACK *xDlSym)(sqlite3_vfs*,void*, - const char *zSymbol))(void); - void (SQLITE_CALLBACK *xDlClose)(sqlite3_vfs*, void*); - int (SQLITE_CALLBACK *xRandomness)(sqlite3_vfs*, int nByte, char *zOut); - int (SQLITE_CALLBACK *xSleep)(sqlite3_vfs*, int microseconds); - int (SQLITE_CALLBACK *xCurrentTime)(sqlite3_vfs*, double*); - int (SQLITE_CALLBACK *xGetLastError)(sqlite3_vfs*, int, char *); + int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); + int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); + int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); + void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); + void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); + void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); + void (*xDlClose)(sqlite3_vfs*, void*); + int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); + int (*xSleep)(sqlite3_vfs*, int microseconds); + int (*xCurrentTime)(sqlite3_vfs*, double*); + int (*xGetLastError)(sqlite3_vfs*, int, char *); /* ** The methods above are in version 1 of the sqlite_vfs object ** definition. Those that follow are added in version 2 or later */ - int (SQLITE_CALLBACK *xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); + int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); /* ** The methods above are in versions 1 and 2 of the sqlite_vfs object. ** Those below are for version 3 and greater. */ - int (SQLITE_CALLBACK *xSetSystemCall)(sqlite3_vfs*, const char *zName, - sqlite3_syscall_ptr); - sqlite3_syscall_ptr (SQLITE_CALLBACK *xGetSystemCall)(sqlite3_vfs*, - const char *zName); - const char *(SQLITE_CALLBACK *xNextSystemCall)(sqlite3_vfs*, - const char *zName); + int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr); + sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName); + const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName); /* ** The methods above are in versions 1 through 3 of the sqlite_vfs object. ** New fields may be appended in future versions. The iVersion @@ -1513,13 +1502,13 @@ int sqlite3_db_config(sqlite3*, int op, ...); */ typedef struct sqlite3_mem_methods sqlite3_mem_methods; struct sqlite3_mem_methods { - void *(SQLITE_CALLBACK *xMalloc)(int); /* Memory allocation function */ - void (SQLITE_CALLBACK *xFree)(void*); /* Free a prior allocation */ - void *(SQLITE_CALLBACK *xRealloc)(void*,int); /* Resize an allocation */ - int (SQLITE_CALLBACK *xSize)(void*); /* Return the size of an allocation */ - int (SQLITE_CALLBACK *xRoundup)(int); /* Round up size to allocation size */ - int (SQLITE_CALLBACK *xInit)(void*); /* Initialize the memory allocator */ - void (SQLITE_CALLBACK *xShutdown)(void*); /* Deinitialize memory allocator */ + void *(*xMalloc)(int); /* Memory allocation function */ + void (*xFree)(void*); /* Free a prior allocation */ + void *(*xRealloc)(void*,int); /* Resize an allocation */ + int (*xSize)(void*); /* Return the size of an allocation */ + int (*xRoundup)(int); /* Round up request size to allocation size */ + int (*xInit)(void*); /* Initialize the memory allocator */ + void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; @@ -2253,7 +2242,7 @@ int sqlite3_complete16(const void *sql); ** A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ -int sqlite3_busy_handler(sqlite3*, int(SQLITE_CALLBACK *)(void*,int), void*); +int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout @@ -2697,8 +2686,7 @@ void sqlite3_randomness(int N, void *P); */ int sqlite3_set_authorizer( sqlite3*, - int (SQLITE_CALLBACK *xAuth)(void*,int,const char*,const char*,const char*, - const char*), + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), void *pUserData ); @@ -2805,9 +2793,9 @@ int sqlite3_set_authorizer( ** subject to change in future versions of SQLite. */ SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*, - void(SQLITE_CALLBACK *xTrace)(void*,const char*), void*); + void(*xTrace)(void*,const char*), void*); SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, - void(SQLITE_CALLBACK *xProfile)(void*,const char*,sqlite3_uint64), void*); + void(*xProfile)(void*,const char*,sqlite3_uint64), void*); /* ** CAPI3REF: SQL Trace Event Codes @@ -2898,7 +2886,7 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, int sqlite3_trace_v2( sqlite3*, unsigned uMask, - int(SQLITE_CALLBACK *xCallback)(unsigned,void*,void*,void*), + int(*xCallback)(unsigned,void*,void*,void*), void *pCtx ); @@ -2934,7 +2922,7 @@ int sqlite3_trace_v2( ** database connections for the meaning of "modify" in this paragraph. ** */ -void sqlite3_progress_handler(sqlite3*,int,int(SQLITE_CALLBACK *)(void*),void*); +void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection @@ -3765,20 +3753,17 @@ typedef struct sqlite3_context sqlite3_context; ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ -int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, - void(SQLITE_CALLBACK *)(void*)); +int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, - void(SQLITE_CALLBACK *)(void*)); + void(*)(void*)); int sqlite3_bind_double(sqlite3_stmt*, int, double); int sqlite3_bind_int(sqlite3_stmt*, int, int); int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); int sqlite3_bind_null(sqlite3_stmt*, int); -int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int, - void(SQLITE_CALLBACK *)(void*)); -int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, - void(SQLITE_CALLBACK *)(void*)); +int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); +int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, - void(SQLITE_CALLBACK *)(void*), unsigned char encoding); + void(*)(void*), unsigned char encoding); int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); @@ -4446,9 +4431,9 @@ int sqlite3_create_function( int nArg, int eTextRep, void *pApp, - void (SQLITE_CALLBACK *xFunc)(sqlite3_context*,int,sqlite3_value**), - void (SQLITE_CALLBACK *xStep)(sqlite3_context*,int,sqlite3_value**), - void (SQLITE_CALLBACK *xFinal)(sqlite3_context*) + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) ); int sqlite3_create_function16( sqlite3 *db, @@ -4456,9 +4441,9 @@ int sqlite3_create_function16( int nArg, int eTextRep, void *pApp, - void (SQLITE_CALLBACK *xFunc)(sqlite3_context*,int,sqlite3_value**), - void (SQLITE_CALLBACK *xStep)(sqlite3_context*,int,sqlite3_value**), - void (SQLITE_CALLBACK *xFinal)(sqlite3_context*) + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) ); int sqlite3_create_function_v2( sqlite3 *db, @@ -4466,10 +4451,10 @@ int sqlite3_create_function_v2( int nArg, int eTextRep, void *pApp, - void (SQLITE_CALLBACK *xFunc)(sqlite3_context*,int,sqlite3_value**), - void (SQLITE_CALLBACK *xStep)(sqlite3_context*,int,sqlite3_value**), - void (SQLITE_CALLBACK *xFinal)(sqlite3_context*), - void (SQLITE_CALLBACK *xDestroy)(void*) + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*), + void(*xDestroy)(void*) ); /* @@ -4511,9 +4496,8 @@ SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); SQLITE_DEPRECATED int sqlite3_global_recover(void); SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); -SQLITE_DEPRECATED int sqlite3_memory_alarm( - void(SQLITE_CALLBACK *)(void*,sqlite3_int64,int), - void*,sqlite3_int64); +SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), + void*,sqlite3_int64); #endif /* @@ -4732,8 +4716,7 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** the SQL function is running. */ void *sqlite3_get_auxdata(sqlite3_context*, int N); -void sqlite3_set_auxdata(sqlite3_context*, int N, void*, - void (SQLITE_CALLBACK *)(void*)); +void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); /* @@ -4750,7 +4733,7 @@ void sqlite3_set_auxdata(sqlite3_context*, int N, void*, ** The typedef is necessary to work around problems in certain ** C++ compilers. */ -typedef void (SQLITE_CALLBACK *sqlite3_destructor_type)(void*); +typedef void (*sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) @@ -4869,10 +4852,9 @@ typedef void (SQLITE_CALLBACK *sqlite3_destructor_type)(void*); ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ -void sqlite3_result_blob(sqlite3_context*, const void*, int, - void(SQLITE_CALLBACK *)(void*)); +void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); void sqlite3_result_blob64(sqlite3_context*,const void*, - sqlite3_uint64,void(SQLITE_CALLBACK *)(void*)); + sqlite3_uint64,void(*)(void*)); void sqlite3_result_double(sqlite3_context*, double); void sqlite3_result_error(sqlite3_context*, const char*, int); void sqlite3_result_error16(sqlite3_context*, const void*, int); @@ -4882,17 +4864,12 @@ void sqlite3_result_error_code(sqlite3_context*, int); void sqlite3_result_int(sqlite3_context*, int); void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); void sqlite3_result_null(sqlite3_context*); -void sqlite3_result_text(sqlite3_context*, const char*, int, - void(SQLITE_CALLBACK *)(void*)); +void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, - void(SQLITE_CALLBACK *)(void*), - unsigned char encoding); -void sqlite3_result_text16(sqlite3_context*, const void*, int, - void(SQLITE_CALLBACK *)(void*)); -void sqlite3_result_text16le(sqlite3_context*, const void*, int, - void(SQLITE_CALLBACK *)(void*)); -void sqlite3_result_text16be(sqlite3_context*, const void*, int, - void(SQLITE_CALLBACK *)(void*)); + void(*)(void*), unsigned char encoding); +void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); +void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); +void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); void sqlite3_result_value(sqlite3_context*, sqlite3_value*); void sqlite3_result_zeroblob(sqlite3_context*, int n); int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); @@ -4997,22 +4974,22 @@ int sqlite3_create_collation( const char *zName, int eTextRep, void *pArg, - int(SQLITE_CALLBACK *xCompare)(void*,int,const void*,int,const void*) + int(*xCompare)(void*,int,const void*,int,const void*) ); int sqlite3_create_collation_v2( sqlite3*, const char *zName, int eTextRep, void *pArg, - int(SQLITE_CALLBACK *xCompare)(void*,int,const void*,int,const void*), - void(SQLITE_CALLBACK *xDestroy)(void*) + int(*xCompare)(void*,int,const void*,int,const void*), + void(*xDestroy)(void*) ); int sqlite3_create_collation16( sqlite3*, const void *zName, int eTextRep, void *pArg, - int(SQLITE_CALLBACK *xCompare)(void*,int,const void*,int,const void*) + int(*xCompare)(void*,int,const void*,int,const void*) ); /* @@ -5045,12 +5022,12 @@ int sqlite3_create_collation16( int sqlite3_collation_needed( sqlite3*, void*, - void(SQLITE_CALLBACK *)(void*,sqlite3*,int eTextRep,const char*) + void(*)(void*,sqlite3*,int eTextRep,const char*) ); int sqlite3_collation_needed16( sqlite3*, void*, - void(SQLITE_CALLBACK *)(void*,sqlite3*,int eTextRep,const void*) + void(*)(void*,sqlite3*,int eTextRep,const void*) ); #ifdef SQLITE_HAS_CODEC @@ -5349,8 +5326,8 @@ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); ** ** See also the [sqlite3_update_hook()] interface. */ -void *sqlite3_commit_hook(sqlite3*, int(SQLITE_CALLBACK *)(void*), void*); -void *sqlite3_rollback_hook(sqlite3*, void(SQLITE_CALLBACK *)(void *), void*); +void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); +void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks @@ -5403,7 +5380,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(SQLITE_CALLBACK *)(void *), void*); */ void *sqlite3_update_hook( sqlite3*, - void(SQLITE_CALLBACK *)(void *,int ,char const *,char const *,sqlite3_int64), + void(*)(void *,int ,char const *,char const *,sqlite3_int64), void* ); @@ -5730,7 +5707,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] */ -int sqlite3_auto_extension(void (SQLITE_CALLBACK *xEntryPoint)(void)); +int sqlite3_auto_extension(void (*xEntryPoint)(void)); /* ** CAPI3REF: Cancel Automatic Extension Loading @@ -5742,7 +5719,7 @@ int sqlite3_auto_extension(void (SQLITE_CALLBACK *xEntryPoint)(void)); ** unregistered and it returns 0 if X was not on the list of initialization ** routines. */ -int sqlite3_cancel_auto_extension(void (SQLITE_CALLBACK *xEntryPoint)(void)); +int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); /* ** CAPI3REF: Reset Automatic Extension Loading @@ -5787,41 +5764,37 @@ typedef struct sqlite3_module sqlite3_module; */ struct sqlite3_module { int iVersion; - int (SQLITE_CALLBACK *xCreate)(sqlite3*, void *pAux, + int (*xCreate)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); - int (SQLITE_CALLBACK *xConnect)(sqlite3*, void *pAux, + int (*xConnect)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); - int (SQLITE_CALLBACK *xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); - int (SQLITE_CALLBACK *xDisconnect)(sqlite3_vtab *pVTab); - int (SQLITE_CALLBACK *xDestroy)(sqlite3_vtab *pVTab); - int (SQLITE_CALLBACK *xOpen)(sqlite3_vtab *pVTab, - sqlite3_vtab_cursor **ppCursor); - int (SQLITE_CALLBACK *xClose)(sqlite3_vtab_cursor*); - int (SQLITE_CALLBACK *xFilter)(sqlite3_vtab_cursor*, - int idxNum, const char *idxStr, - int argc, sqlite3_value **argv); - int (SQLITE_CALLBACK *xNext)(sqlite3_vtab_cursor*); - int (SQLITE_CALLBACK *xEof)(sqlite3_vtab_cursor*); - int (SQLITE_CALLBACK *xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); - int (SQLITE_CALLBACK *xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); - int (SQLITE_CALLBACK *xUpdate)(sqlite3_vtab *, int, sqlite3_value **, - sqlite3_int64 *); - int (SQLITE_CALLBACK *xBegin)(sqlite3_vtab *pVTab); - int (SQLITE_CALLBACK *xSync)(sqlite3_vtab *pVTab); - int (SQLITE_CALLBACK *xCommit)(sqlite3_vtab *pVTab); - int (SQLITE_CALLBACK *xRollback)(sqlite3_vtab *pVTab); - int (SQLITE_CALLBACK *xFindFunction)(sqlite3_vtab *pVtab, - int nArg, const char *zName, - void (SQLITE_CALLBACK **pxFunc)(sqlite3_context*,int,sqlite3_value**), - void **ppArg); - int (SQLITE_CALLBACK *xRename)(sqlite3_vtab *pVtab, const char *zNew); + int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); + int (*xDisconnect)(sqlite3_vtab *pVTab); + int (*xDestroy)(sqlite3_vtab *pVTab); + int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); + int (*xClose)(sqlite3_vtab_cursor*); + int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, + int argc, sqlite3_value **argv); + int (*xNext)(sqlite3_vtab_cursor*); + int (*xEof)(sqlite3_vtab_cursor*); + int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); + int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); + int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); + int (*xBegin)(sqlite3_vtab *pVTab); + int (*xSync)(sqlite3_vtab *pVTab); + int (*xCommit)(sqlite3_vtab *pVTab); + int (*xRollback)(sqlite3_vtab *pVTab); + int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), + void **ppArg); + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); /* The methods above are in version 1 of the sqlite_module object. Those ** below are for version 2 and greater. */ - int (SQLITE_CALLBACK *xSavepoint)(sqlite3_vtab *pVTab, int); - int (SQLITE_CALLBACK *xRelease)(sqlite3_vtab *pVTab, int); - int (SQLITE_CALLBACK *xRollbackTo)(sqlite3_vtab *pVTab, int); + int (*xSavepoint)(sqlite3_vtab *pVTab, int); + int (*xRelease)(sqlite3_vtab *pVTab, int); + int (*xRollbackTo)(sqlite3_vtab *pVTab, int); }; /* @@ -6010,7 +5983,7 @@ int sqlite3_create_module_v2( const char *zName, /* Name of the module */ const sqlite3_module *p, /* Methods for the module */ void *pClientData, /* Client data for xCreate/xConnect */ - void(SQLITE_CALLBACK *xDestroy)(void*) /* Module destructor function */ + void(*xDestroy)(void*) /* Module destructor function */ ); /* @@ -6551,15 +6524,15 @@ void sqlite3_mutex_leave(sqlite3_mutex*); */ typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; struct sqlite3_mutex_methods { - int (SQLITE_CALLBACK *xMutexInit)(void); - int (SQLITE_CALLBACK *xMutexEnd)(void); - sqlite3_mutex *(SQLITE_CALLBACK *xMutexAlloc)(int); - void (SQLITE_CALLBACK *xMutexFree)(sqlite3_mutex *); - void (SQLITE_CALLBACK *xMutexEnter)(sqlite3_mutex *); - int (SQLITE_CALLBACK *xMutexTry)(sqlite3_mutex *); - void (SQLITE_CALLBACK *xMutexLeave)(sqlite3_mutex *); - int (SQLITE_CALLBACK *xMutexHeld)(sqlite3_mutex *); - int (SQLITE_CALLBACK *xMutexNotheld)(sqlite3_mutex *); + int (*xMutexInit)(void); + int (*xMutexEnd)(void); + sqlite3_mutex *(*xMutexAlloc)(int); + void (*xMutexFree)(sqlite3_mutex *); + void (*xMutexEnter)(sqlite3_mutex *); + int (*xMutexTry)(sqlite3_mutex *); + void (*xMutexLeave)(sqlite3_mutex *); + int (*xMutexHeld)(sqlite3_mutex *); + int (*xMutexNotheld)(sqlite3_mutex *); }; /* @@ -7255,21 +7228,18 @@ typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; struct sqlite3_pcache_methods2 { int iVersion; void *pArg; - int (SQLITE_CALLBACK *xInit)(void*); - void (SQLITE_CALLBACK *xShutdown)(void*); - sqlite3_pcache *(SQLITE_CALLBACK *xCreate)(int szPage, int szExtra, - int bPurgeable); - void (SQLITE_CALLBACK *xCachesize)(sqlite3_pcache*, int nCachesize); - int (SQLITE_CALLBACK *xPagecount)(sqlite3_pcache*); - sqlite3_pcache_page *(SQLITE_CALLBACK *xFetch)(sqlite3_pcache*, unsigned key, - int createFlag); - void (SQLITE_CALLBACK *xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, - int discard); - void (SQLITE_CALLBACK *xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, - unsigned oldKey, unsigned newKey); - void (SQLITE_CALLBACK *xTruncate)(sqlite3_pcache*, unsigned iLimit); - void (SQLITE_CALLBACK *xDestroy)(sqlite3_pcache*); - void (SQLITE_CALLBACK *xShrink)(sqlite3_pcache*); + int (*xInit)(void*); + void (*xShutdown)(void*); + sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable); + void (*xCachesize)(sqlite3_pcache*, int nCachesize); + int (*xPagecount)(sqlite3_pcache*); + sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); + void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, + unsigned oldKey, unsigned newKey); + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (*xDestroy)(sqlite3_pcache*); + void (*xShrink)(sqlite3_pcache*); }; /* @@ -7280,18 +7250,16 @@ struct sqlite3_pcache_methods2 { typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; struct sqlite3_pcache_methods { void *pArg; - int (SQLITE_CALLBACK *xInit)(void*); - void (SQLITE_CALLBACK *xShutdown)(void*); - sqlite3_pcache *(SQLITE_CALLBACK *xCreate)(int szPage, int bPurgeable); - void (SQLITE_CALLBACK *xCachesize)(sqlite3_pcache*, int nCachesize); - int (SQLITE_CALLBACK *xPagecount)(sqlite3_pcache*); - void *(SQLITE_CALLBACK *xFetch)(sqlite3_pcache*, unsigned key, - int createFlag); - void (SQLITE_CALLBACK *xUnpin)(sqlite3_pcache*, void*, int discard); - void (SQLITE_CALLBACK *xRekey)(sqlite3_pcache*, void*, unsigned oldKey, - unsigned newKey); - void (SQLITE_CALLBACK *xTruncate)(sqlite3_pcache*, unsigned iLimit); - void (SQLITE_CALLBACK *xDestroy)(sqlite3_pcache*); + int (*xInit)(void*); + void (*xShutdown)(void*); + sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + void (*xCachesize)(sqlite3_pcache*, int nCachesize); + int (*xPagecount)(sqlite3_pcache*); + void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + void (*xUnpin)(sqlite3_pcache*, void*, int discard); + void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (*xDestroy)(sqlite3_pcache*); }; @@ -7621,7 +7589,7 @@ int sqlite3_backup_pagecount(sqlite3_backup *p); */ int sqlite3_unlock_notify( sqlite3 *pBlocked, /* Waiting connection */ - void (SQLITE_CALLBACK *xNotify)(void **apArg, int nArg), /* Callback func */ + void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ void *pNotifyArg /* Argument to pass to xNotify */ ); @@ -7736,7 +7704,7 @@ void sqlite3_log(int iErrCode, const char *zFormat, ...); */ void *sqlite3_wal_hook( sqlite3*, - int(SQLITE_CALLBACK *)(void *,sqlite3*,const char*,int), + int(*)(void *,sqlite3*,const char*,int), void* ); @@ -8209,7 +8177,7 @@ int sqlite3_db_cacheflush(sqlite3*); */ SQLITE_EXPERIMENTAL void *sqlite3_preupdate_hook( sqlite3 *db, - void(SQLITE_CALLBACK *xPreUpdate)( + void(*xPreUpdate)( void *pCtx, /* Copy of third arg to preupdate_hook() */ sqlite3 *db, /* Database handle */ int op, /* SQLITE_UPDATE, DELETE or INSERT */ diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index d0ddba9cfa..4b7d10b69f 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -21,6 +21,8 @@ # formatted as an integer (e.g. "3006017"). # 5) Replaces the string --SOURCE-ID-- with the date and time and sha1 # hash of the fossil-scm manifest for the source tree. +# 6) Adds the SQLITE_CALLBACK calling convention macro in front of all +# callback declarations. # # This script outputs to stdout. # @@ -125,6 +127,7 @@ foreach file $filelist { append line " " $funcname $rest } } + regsub {\(\*} $line {(SQLITE_CALLBACK *} line puts $line } close $in From fe0c0d2088cedf1c2e46d2ddf85938251fcb52de Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 15:38:34 +0000 Subject: [PATCH 244/302] Modify the mksqlite3h.tcl tool to handle the syscall typedef specially. FossilOrigin-Name: 478a84efa6ea13629227ba8970c8ef8545d31074 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mksqlite3h.tcl | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 49f48174ea..3195058bae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\smksqlite3h.tcl\sto\sautomatically\sinsert\sthe\sSQLITE_CALLBACK\scalling\nconvention\smacros. -D 2016-07-28T15:09:02.696 +C Modify\sthe\smksqlite3h.tcl\stool\sto\shandle\sthe\ssyscall\stypedef\sspecially. +D 2016-07-28T15:38:34.103 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc da4c9f5bc46f6f12d7313d12be18a2d2c55e06c0 @@ -1450,7 +1450,7 @@ F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl aa58ea3be311c81821c2cd3209f55e46b07ab656 F tool/mksqlite3c.tcl a52ead27e2ac5d4b616e945a0601f628f4328329 -F tool/mksqlite3h.tcl abaf6af11e184c0b69f117fc47ecfa351d81c219 +F tool/mksqlite3h.tcl cf5cd68028e69a51ed5c76042672664201f0f756 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e8be3dfeabaa31b3490793cf8230faae1204be15 -R 44253432508e9739e51133f1558c85ed -U drh -Z 863aa68feeed694e590c235a245cfae1 +P 11ab9c9ab562df98c20abf126a8bac178aef77a8 +R a69c68c4276ee266722a065a80ccdc75 +U mistachkin +Z 9a266ac1c40bfd5d57e83258cb2d1dad diff --git a/manifest.uuid b/manifest.uuid index 617643d254..f316f522bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11ab9c9ab562df98c20abf126a8bac178aef77a8 \ No newline at end of file +478a84efa6ea13629227ba8970c8ef8545d31074 \ No newline at end of file diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index 4b7d10b69f..9a4e7d2985 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -127,6 +127,8 @@ foreach file $filelist { append line " " $funcname $rest } } + set line [string map [list (*sqlite3_syscall_ptr) \ + "(SQLITE_SYSAPI *sqlite3_syscall_ptr)"] $line] regsub {\(\*} $line {(SQLITE_CALLBACK *} line puts $line } From f27a80cf185c97e66a5808e2634d41fe30942fed Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 16:09:52 +0000 Subject: [PATCH 245/302] More work on getting the 'testfixture.exe' target to work correctly. FossilOrigin-Name: 36b72fd609cf151f3db0e65b450d7cd515f2ac49 --- Makefile.msc | 22 +++++++++++++++++++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index c3f7f3a2b0..4a8283731d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -466,22 +466,30 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) !IF "$(PLATFORM)"=="x86" CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +# <> TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl +# <> !ELSE !IFNDEF PLATFORM CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall +# <> TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl +# <> !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = +# <> TEST_CCONV_OPTS = +# <> !ENDIF !ENDIF !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = +# <> TEST_CCONV_OPTS = +# <> !ENDIF # These are additional compiler options used for the core library. @@ -1983,12 +1991,20 @@ TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC1) sqlite_tclDecls.h: echo #ifndef SQLITE_TCLAPI > sqlite_tclDecls.h - echo # define SQLITE_TCLAPI __cdecl >> sqlite_tclDecls.h + echo # define SQLITE_TCLAPI >> sqlite_tclDecls.h echo #endif >> sqlite_tclDecls.h - type "$(TCLINCDIR)\tclDecls.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?.*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" >> sqlite_tclDecls.h + type "$(TCLINCDIR)\tclDecls.h" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?.*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tcl_" "(SQLITE_TCLAPI *tcl_" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tclFreeObj" "(SQLITE_TCLAPI *tclFreeObj" >> sqlite_tclDecls.h sqlite_tcl.h: sqlite_tclDecls.h - type "$(TCLINCDIR)\tcl.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact tclDecls.h sqlite_tclDecls.h >> sqlite_tcl.h + type "$(TCLINCDIR)\tcl.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact tclDecls.h sqlite_tclDecls.h \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "typedef (.*?)\(Tcl_" "typedef \1 (SQLITE_TCLAPI Tcl_" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "void (*freeProc)" "void (SQLITE_TCLAPI *freeProc)" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*findProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *findProc)" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*createProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *createProc)" >> sqlite_tcl.h testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) sqlite_tcl.h $(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \ diff --git a/manifest b/manifest index 3195058bae..cb678be722 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Modify\sthe\smksqlite3h.tcl\stool\sto\shandle\sthe\ssyscall\stypedef\sspecially. -D 2016-07-28T15:38:34.103 +C More\swork\son\sgetting\sthe\s'testfixture.exe'\starget\sto\swork\scorrectly. +D 2016-07-28T16:09:52.017 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc da4c9f5bc46f6f12d7313d12be18a2d2c55e06c0 +F Makefile.msc 1e5399407885d69150e2659f4710b5712a1e6cef F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 11ab9c9ab562df98c20abf126a8bac178aef77a8 -R a69c68c4276ee266722a065a80ccdc75 +P 478a84efa6ea13629227ba8970c8ef8545d31074 +R 88324b2461565133820c548ccb01cb7e U mistachkin -Z 9a266ac1c40bfd5d57e83258cb2d1dad +Z 92e347019c063e4a6ca0b5b196166511 diff --git a/manifest.uuid b/manifest.uuid index f316f522bd..132e64c427 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -478a84efa6ea13629227ba8970c8ef8545d31074 \ No newline at end of file +36b72fd609cf151f3db0e65b450d7cd515f2ac49 \ No newline at end of file From 7617e4a8a4564689a839cf116dae0012b4753a65 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 17:11:20 +0000 Subject: [PATCH 246/302] Make sure the SQLITE_TCLAPI macro is always defined. FossilOrigin-Name: f2f1323cc4d2ad2d6794dbfae8d50b747213e85d --- ext/fts3/fts3_test.c | 11 +- manifest | 82 +++++----- manifest.uuid | 2 +- src/sqliteInt.h | 8 + src/tclsqlite.c | 47 ++++-- src/test1.c | 360 +++++++++++++++++++++---------------------- src/test2.c | 40 ++--- src/test3.c | 30 ++-- src/test4.c | 30 ++-- src/test5.c | 8 +- src/test6.c | 14 +- src/test7.c | 26 ++-- src/test8.c | 4 +- src/test9.c | 6 +- src/test_async.c | 13 +- src/test_autoext.c | 17 +- src/test_backup.c | 9 +- src/test_bestindex.c | 2 +- src/test_blob.c | 10 +- src/test_btree.c | 2 +- src/test_demovfs.c | 7 +- src/test_fs.c | 2 +- src/test_func.c | 4 +- src/test_hexio.c | 14 +- src/test_init.c | 8 +- src/test_intarray.c | 7 +- src/test_malloc.c | 64 ++++---- src/test_multiplex.c | 11 +- src/test_mutex.c | 22 +-- src/test_osinst.c | 5 +- src/test_quota.c | 73 ++++----- src/test_rtree.c | 4 +- src/test_schema.c | 2 +- src/test_superlock.c | 9 +- src/test_syscall.c | 20 +-- src/test_tclvar.c | 2 +- src/test_thread.c | 18 +-- src/test_vfs.c | 6 +- 38 files changed, 530 insertions(+), 469 deletions(-) diff --git a/ext/fts3/fts3_test.c b/ext/fts3/fts3_test.c index c3b71284ec..a48a556c98 100644 --- a/ext/fts3/fts3_test.c +++ b/ext/fts3/fts3_test.c @@ -22,6 +22,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #include #include @@ -147,7 +150,7 @@ static int nm_match_count( /* ** Tclcmd: fts3_near_match DOCUMENT EXPR ?OPTIONS? */ -static int fts3_near_match_cmd( +static int SQLITE_TCLAPI fts3_near_match_cmd( ClientData clientData, Tcl_Interp *interp, int objc, @@ -282,7 +285,7 @@ static int fts3_near_match_cmd( ** # Restore initial incr-load settings: ** eval fts3_configure_incr_load $cfg */ -static int fts3_configure_incr_load_cmd( +static int SQLITE_TCLAPI fts3_configure_incr_load_cmd( ClientData clientData, Tcl_Interp *interp, int objc, @@ -492,7 +495,7 @@ static int testTokenizerLanguage( } #endif -static int fts3_test_tokenizer_cmd( +static int SQLITE_TCLAPI fts3_test_tokenizer_cmd( ClientData clientData, Tcl_Interp *interp, int objc, @@ -521,7 +524,7 @@ static int fts3_test_tokenizer_cmd( return TCL_OK; } -static int fts3_test_varint_cmd( +static int SQLITE_TCLAPI fts3_test_varint_cmd( ClientData clientData, Tcl_Interp *interp, int objc, diff --git a/manifest b/manifest index cb678be722..1be1262c7e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\swork\son\sgetting\sthe\s'testfixture.exe'\starget\sto\swork\scorrectly. -D 2016-07-28T16:09:52.017 +C Make\ssure\sthe\sSQLITE_TCLAPI\smacro\sis\salways\sdefined. +D 2016-07-28T17:11:20.162 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 1e5399407885d69150e2659f4710b5712a1e6cef @@ -81,7 +81,7 @@ F ext/fts3/fts3_icu.c deb46f7020d87ea7a14a433fb7a7f4bef42a9652 F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009 F ext/fts3/fts3_snippet.c 68ae118b0f834ea53d2b89e4087fc0f0b8c4ee4e F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7 -F ext/fts3/fts3_test.c 7d8c9e17bc11cc245c91585ef5a47ee4a600f7b2 +F ext/fts3/fts3_test.c 79f2a7fbb3f672fa032e5a432ca274ea3ee93c34 F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860 F ext/fts3/fts3_tokenizer.c a22bf311a71f3efa9d7012d8cc48fc9b0f3dace7 F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 @@ -388,55 +388,55 @@ F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in a03063e698a43cc5c996cd341f39439a6ce58304 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 -F src/sqliteInt.h d25c18c1272a7811e2569c39bfc2fca96156eead +F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c e348648c28fcaa04ab8da98bf7e8a37b3629e634 -F src/test1.c a625e4d2857e0b08a9d66bdb737ce95b02326a9f -F src/test2.c ce1e56fd0983866df1dbaf6c0558f3ad726ec222 -F src/test3.c 68b6b3b17df3028deda0a79607af70ff4ac5fc52 -F src/test4.c a305bb93783fa0db03b9e5e899ec5367cf139903 -F src/test5.c 3ca6874d52d658607d2f25bb6ed88fd03ad78a6c -F src/test6.c 4fc2c870b4f41d46f11a24b5c7dcff89486442b8 -F src/test7.c 57b6dae963ff12cb6ef8389285427f07e8b042ff -F src/test8.c 33cefbf2911e12c74c6adb798cc0c8ee3287a58d -F src/test9.c 6b9792e8a692a67fcce77dfe4a2ca4744c4ece54 -F src/test_async.c 233536b7e364a4a95597d6aa6fdf07fa9351de67 -F src/test_autoext.c 2a2343174ff46477dd081b7582dc1e72c69330bc -F src/test_backup.c 7fe86c0be6c1a05a254b845a6aa32294dbdab012 -F src/test_bestindex.c 832b9968bf15d60029c1700905d56cefeb0f5dd7 -F src/test_blob.c 6af2552a059f326a107214fb13917f31a1606caf -F src/test_btree.c 3d2abd96336f1cbb760c7c5a758e74eaae98aed6 +F src/tclsqlite.c a9c6e33c44efa93d176ce5e0887d5d533c98b429 +F src/test1.c 906a04b649c7139e943193a3905d583e325c30c7 +F src/test2.c b7174313e993754303a8b33c43df7c44b46857ab +F src/test3.c 1339a40be39650ae83894b6578f971dc7f96ea8a +F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 +F src/test5.c 328aae2c010c57a9829d255dc099d6899311672d +F src/test6.c 55aa2775c154415dcf4ed7cd1e19a193122b3a02 +F src/test7.c 5612e9aecf934d6df7bba6ce861fdf5ba5456010 +F src/test8.c 4f4904721167b32f7a4fa8c7b32a07a673d6cc86 +F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 +F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a +F src/test_autoext.c 6c8fe00caa3f38396f0990467179e9d1adb39ddd +F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 +F src/test_bestindex.c d23f80d334c59662af69191854c76b8d3d0c8c96 +F src/test_blob.c a0f7ad49a0c9d4b72f693fe2a71c58d7e507174d +F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c 4d3d4a886416f369771d69a6dba926866deda788 -F src/test_demovfs.c ed337b14964a5f5ba08bf9472c94c64e88c547a7 +F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 -F src/test_fs.c 39086f99413e73f60afe2280a0ff27dfab63ab47 -F src/test_func.c 4197173afb7d8453d3d0c7f7b109226dcef52997 -F src/test_hexio.c 2ab200d91f77085bd69c721dcb2b649f036d608b -F src/test_init.c a55015461868ca979d819f8db72aa682ba068185 -F src/test_intarray.c 9fee7f930ff988dd0fc20315da4c762f77f01a78 +F src/test_fs.c ac62ce7d5c0c23aa6932891cad5746945564c91c +F src/test_func.c 9cea6fee7ece5f46aa26e060b35e10dc6ba708cf +F src/test_hexio.c 1d4469ca61ab202a1fcec6543f584d2407205e8d +F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664 +F src/test_intarray.c 988fc61cb0ff539f4172c0d95f15287c92516f64 F src/test_intarray.h f3b7672f5d1056eac563c0d6ea8480a660b1475c F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd -F src/test_malloc.c 90cbc63ebab11d16b440d394e77bc26629829f11 -F src/test_multiplex.c a0bcea72bc981f64c9c71edf22cc503cf83e0348 +F src/test_malloc.c c05f6c40bd6c8bfe5f1718212f81fd5687f91766 +F src/test_multiplex.c af2792ec4436d442d1bd00b8803470a25111bad3 F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635 -F src/test_mutex.c 85021f2ffe67cdb4dfa6089f3f55f5e01cd76aea +F src/test_mutex.c 7f4337ba23ee6b1d2ec81c189653608cb069926a F src/test_onefile.c 416f87a28d6d673352d33fc4b1c7d39db878e50f -F src/test_osinst.c 4e21c7b2709955f9907b80bfc874afb81ce1b4a7 +F src/test_osinst.c 98ef31ff03d55497829ca0f6c74a9f4e1aa48690 F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 -F src/test_quota.c 7c2bb6d302f9cab9d4782b1a37dd01f0c7bde071 +F src/test_quota.c 6cb9297115b551f433a9ad1741817a9831abed99 F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d -F src/test_rtree.c 0aad72f4854b01957b20c3c325eecd8512e9731d -F src/test_schema.c ab94aeab8a94486de3d2ce06567b7ee35f3a59b8 +F src/test_rtree.c 671f3fae50ff116ef2e32a3bf1fe21b5615b4b7b +F src/test_schema.c f575932cb6274d12147a77e13ea4b49d52408513 F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b -F src/test_superlock.c 9389ee2aa8f8fa7487ea2e3bf01c033c65eaf21a -F src/test_syscall.c 8313aa5d43989913c2dfd42b987e6ed29d6b8770 -F src/test_tclvar.c 0239df9e83f9adc7b21ae01dce20229dd8592e71 -F src/test_thread.c 30ae6818d21a168ef8cbceb9456411751c714cd9 -F src/test_vfs.c 2edd39d413301baf15c1d7384f21c2e8b3fca2dd +F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e +F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939 +F src/test_tclvar.c df9fe1213c2634687a9ca0b0bec0d2119d359ae3 +F src/test_thread.c c7c40494b7a0603ebb6eb97c904545c0dceca5ff +F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 F src/test_windirent.h b12055cab6227f7be10f5c19296f67c60cc5e2a5 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 478a84efa6ea13629227ba8970c8ef8545d31074 -R 88324b2461565133820c548ccb01cb7e +P 36b72fd609cf151f3db0e65b450d7cd515f2ac49 +R cb104ece8c53bb381905efecad762caf U mistachkin -Z 92e347019c063e4a6ca0b5b196166511 +Z 5c80ddf3854cd75da2e73aafdf02283f diff --git a/manifest.uuid b/manifest.uuid index 132e64c427..1a85a325af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36b72fd609cf151f3db0e65b450d7cd515f2ac49 \ No newline at end of file +f2f1323cc4d2ad2d6794dbfae8d50b747213e85d \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c5b1eccc03..35be76dfb0 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -42,6 +42,14 @@ ** asterisks and the comment text. */ +/* +** Make sure the Tcl calling convention macro is defined. This macro is +** only used by test code and Tcl integration code. +*/ +#ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +#endif + /* ** Make sure that rand_s() is available on Windows systems with MSVC 2005 ** or higher. diff --git a/src/tclsqlite.c b/src/tclsqlite.c index d26c622859..527dc488ee 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -37,6 +37,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #include @@ -208,7 +211,10 @@ static void closeIncrblobChannels(SqliteDb *pDb){ /* ** Close an incremental blob channel. */ -static int incrblobClose(ClientData instanceData, Tcl_Interp *interp){ +static int SQLITE_TCLAPI incrblobClose( + ClientData instanceData, + Tcl_Interp *interp +){ IncrblobChannel *p = (IncrblobChannel *)instanceData; int rc = sqlite3_blob_close(p->pBlob); sqlite3 *db = p->pDb->db; @@ -237,7 +243,7 @@ static int incrblobClose(ClientData instanceData, Tcl_Interp *interp){ /* ** Read data from an incremental blob channel. */ -static int incrblobInput( +static int SQLITE_TCLAPI incrblobInput( ClientData instanceData, char *buf, int bufSize, @@ -269,7 +275,7 @@ static int incrblobInput( /* ** Write data to an incremental blob channel. */ -static int incrblobOutput( +static int SQLITE_TCLAPI incrblobOutput( ClientData instanceData, CONST char *buf, int toWrite, @@ -302,7 +308,7 @@ static int incrblobOutput( /* ** Seek an incremental blob channel. */ -static int incrblobSeek( +static int SQLITE_TCLAPI incrblobSeek( ClientData instanceData, long offset, int seekMode, @@ -328,10 +334,17 @@ static int incrblobSeek( } -static void incrblobWatch(ClientData instanceData, int mode){ +static void SQLITE_TCLAPI incrblobWatch( + ClientData instanceData, + int mode +){ /* NO-OP */ } -static int incrblobHandle(ClientData instanceData, int dir, ClientData *hPtr){ +static int SQLITE_TCLAPI incrblobHandle( + ClientData instanceData, + int dir, + ClientData *hPtr +){ return TCL_ERROR; } @@ -490,7 +503,7 @@ static void flushStmtCache(SqliteDb *pDb){ ** TCL calls this procedure when an sqlite3 database command is ** deleted. */ -static void DbDeleteCmd(void *db){ +static void SQLITE_TCLAPI DbDeleteCmd(void *db){ SqliteDb *pDb = (SqliteDb*)db; flushStmtCache(pDb); closeIncrblobChannels(pDb); @@ -1795,7 +1808,12 @@ static void DbHookCmd( ** and calls that connection "db1". The second command causes this ** subroutine to be invoked. */ -static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ +static int SQLITE_TCLAPI DbObjCmd( + void *cd, + Tcl_Interp *interp, + int objc, + Tcl_Obj *const*objv +){ SqliteDb *pDb = (SqliteDb*)cd; int choice; int rc = TCL_OK; @@ -3263,7 +3281,12 @@ static int DbObjCmdAdaptor( ** The second argument is the name of the database file. ** */ -static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ +static int SQLITE_TCLAPI DbMain( + void *cd, + Tcl_Interp *interp, + int objc, + Tcl_Obj *const*objv +){ SqliteDb *p; const char *zArg; char *zErrMsg; @@ -3935,7 +3958,7 @@ static const char *tclsh_main_loop(void); #ifdef SQLITE_TEST static void init_all(Tcl_Interp *); -static int init_all_cmd( +static int SQLITE_TCLAPI init_all_cmd( ClientData cd, Tcl_Interp *interp, int objc, @@ -3965,7 +3988,7 @@ static int init_all_cmd( ** to use the sqlite3_prepare_v2() function to prepare statements. If it ** is false, sqlite3_prepare(). */ -static int db_use_legacy_prepare_cmd( +static int SQLITE_TCLAPI db_use_legacy_prepare_cmd( ClientData cd, Tcl_Interp *interp, int objc, @@ -4002,7 +4025,7 @@ static int db_use_legacy_prepare_cmd( ** return the text representation of the most recently used statement ** handle. */ -static int db_last_stmt_ptr( +static int SQLITE_TCLAPI db_last_stmt_ptr( ClientData cd, Tcl_Interp *interp, int objc, diff --git a/src/test1.c b/src/test1.c index e1b4fc0f31..ec6d8ecff3 100644 --- a/src/test1.c +++ b/src/test1.c @@ -79,7 +79,7 @@ void *sqlite3TestTextToPtr(const char *z){ ** for an sqlite connection instance. Bad things happen if the ** input is not an sqlite connection. */ -static int get_sqlite_pointer( +static int SQLITE_TCLAPI get_sqlite_pointer( void * clientData, Tcl_Interp *interp, int objc, @@ -225,7 +225,7 @@ static void io_trace_callback(const char *zFormat, ...){ ** I/O tracing begins going into FILENAME. If FILENAME is an empty ** string, I/O tracing is turned off. */ -static int test_io_trace( +static int SQLITE_TCLAPI test_io_trace( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -266,7 +266,7 @@ static int test_io_trace( ** ** Also return true if the OMIT_MISUSE environment variable exists. */ -static int clang_sanitize_address( +static int SQLITE_TCLAPI clang_sanitize_address( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -293,7 +293,7 @@ static int clang_sanitize_address( ** DB. The SQL is the string FORMAT. The format string should contain ** one %s or %q. STRING is the value inserted into %s or %q. */ -static int test_exec_printf( +static int SQLITE_TCLAPI test_exec_printf( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -331,7 +331,7 @@ static int test_exec_printf( ** HEX into ASCII. Most characters are translated as is. %HH becomes ** a hex character. */ -static int test_exec_hex( +static int SQLITE_TCLAPI test_exec_hex( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -377,7 +377,7 @@ static int test_exec_hex( ** ** Enter or leave the mutex on a database connection. */ -static int db_enter( +static int SQLITE_TCLAPI db_enter( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -393,7 +393,7 @@ static int db_enter( sqlite3_mutex_enter(db->mutex); return TCL_OK; } -static int db_leave( +static int SQLITE_TCLAPI db_leave( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -415,7 +415,7 @@ static int db_leave( ** ** Invoke the sqlite3_exec interface using the open database DB */ -static int test_exec( +static int SQLITE_TCLAPI test_exec( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -462,7 +462,7 @@ static int test_exec( ** Invoke the sqlite3_exec interface using the open database DB. Discard ** all results */ -static int test_exec_nr( +static int SQLITE_TCLAPI test_exec_nr( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -489,7 +489,7 @@ static int test_exec_nr( ** concatenate arg0 through argn using separator as the separator. ** Return the result. */ -static int test_mprintf_z( +static int SQLITE_TCLAPI test_mprintf_z( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -512,7 +512,7 @@ static int test_mprintf_z( ** Test the %n format of sqlite_mprintf(). Return the length of the ** input string. */ -static int test_mprintf_n( +static int SQLITE_TCLAPI test_mprintf_n( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -536,7 +536,7 @@ static int test_mprintf_n( ** You pass in a format string that requires more than one argument, ** bad things will happen. */ -static int test_snprintf_int( +static int SQLITE_TCLAPI test_snprintf_int( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -562,7 +562,7 @@ static int test_snprintf_int( ** DB. The SQL is the string FORMAT. The format string should contain ** one %s or %q. STRING is the value inserted into %s or %q. */ -static int test_get_table_printf( +static int SQLITE_TCLAPI test_get_table_printf( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -625,7 +625,7 @@ static int test_get_table_printf( ** ** Returns the integer ROWID of the most recent insert. */ -static int test_last_rowid( +static int SQLITE_TCLAPI test_last_rowid( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -649,7 +649,7 @@ static int test_last_rowid( ** ** Set the codec key. */ -static int test_key( +static int SQLITE_TCLAPI test_key( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -677,7 +677,7 @@ static int test_key( ** ** Change the codec key. */ -static int test_rekey( +static int SQLITE_TCLAPI test_rekey( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -705,7 +705,7 @@ static int test_rekey( ** ** Closes the database opened by sqlite3_open. */ -static int sqlite_test_close( +static int SQLITE_TCLAPI sqlite_test_close( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -729,7 +729,7 @@ static int sqlite_test_close( ** ** Closes the database opened by sqlite3_open. */ -static int sqlite_test_close_v2( +static int SQLITE_TCLAPI sqlite_test_close_v2( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1013,7 +1013,7 @@ static void nondeterministicFunction( ** sqlite3_create_function function while a query is in progress in order ** to test the SQLITE_MISUSE detection logic. */ -static int test_create_function( +static int SQLITE_TCLAPI test_create_function( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1170,7 +1170,7 @@ static void legacyCountFinalize(sqlite3_context *context){ ** "legacy_count()" with the supplied database handle. This is used ** to test the deprecated sqlite3_aggregate_count() API. */ -static int test_create_aggregate( +static int SQLITE_TCLAPI test_create_aggregate( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1211,7 +1211,7 @@ static int test_create_aggregate( ** Puts uses a separate buffer and debugging statements will be out of ** sequence if it is used. */ -static int test_printf( +static int SQLITE_TCLAPI test_printf( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1233,7 +1233,7 @@ static int test_printf( ** ** Call mprintf with three integer arguments */ -static int sqlite3_mprintf_int( +static int SQLITE_TCLAPI sqlite3_mprintf_int( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1260,7 +1260,7 @@ static int sqlite3_mprintf_int( ** ** Call mprintf with three 64-bit integer arguments */ -static int sqlite3_mprintf_int64( +static int SQLITE_TCLAPI sqlite3_mprintf_int64( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1293,7 +1293,7 @@ static int sqlite3_mprintf_int64( ** same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on ** platform. */ -static int sqlite3_mprintf_long( +static int SQLITE_TCLAPI sqlite3_mprintf_long( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1324,7 +1324,7 @@ static int sqlite3_mprintf_long( ** ** Call mprintf with two integer arguments and one string argument */ -static int sqlite3_mprintf_str( +static int SQLITE_TCLAPI sqlite3_mprintf_str( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1351,7 +1351,7 @@ static int sqlite3_mprintf_str( ** ** Call mprintf with two integer arguments and one string argument */ -static int sqlite3_snprintf_str( +static int SQLITE_TCLAPI sqlite3_snprintf_str( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1385,7 +1385,7 @@ static int sqlite3_snprintf_str( ** ** Call mprintf with two integer arguments and one double argument */ -static int sqlite3_mprintf_double( +static int SQLITE_TCLAPI sqlite3_mprintf_double( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1416,7 +1416,7 @@ static int sqlite3_mprintf_double( ** two arguments given above. This is used to generate overflow and underflow ** doubles to test that they are converted properly. */ -static int sqlite3_mprintf_scaled( +static int SQLITE_TCLAPI sqlite3_mprintf_scaled( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1446,7 +1446,7 @@ static int sqlite3_mprintf_scaled( ** two arguments given above. This is used to generate overflow and underflow ** doubles to test that they are converted properly. */ -static int sqlite3_mprintf_stronly( +static int SQLITE_TCLAPI sqlite3_mprintf_stronly( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1470,7 +1470,7 @@ static int sqlite3_mprintf_stronly( ** Call mprintf with a single double argument which is derived from the ** hexadecimal encoding of an IEEE double. */ -static int sqlite3_mprintf_hexdouble( +static int SQLITE_TCLAPI sqlite3_mprintf_hexdouble( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -1503,7 +1503,7 @@ static int sqlite3_mprintf_hexdouble( ** */ #if !defined(SQLITE_OMIT_SHARED_CACHE) -static int test_enable_shared( +static int SQLITE_TCLAPI test_enable_shared( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1540,7 +1540,7 @@ static int test_enable_shared( ** Usage: sqlite3_extended_result_codes DB BOOLEAN ** */ -static int test_extended_result_codes( +static int SQLITE_TCLAPI test_extended_result_codes( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1563,7 +1563,7 @@ static int test_extended_result_codes( ** Usage: sqlite3_libversion_number ** */ -static int test_libversion_number( +static int SQLITE_TCLAPI test_libversion_number( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1577,7 +1577,7 @@ static int test_libversion_number( ** Usage: sqlite3_table_column_metadata DB dbname tblname colname ** */ -static int test_table_column_metadata( +static int SQLITE_TCLAPI test_table_column_metadata( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1628,7 +1628,7 @@ static int test_table_column_metadata( #ifndef SQLITE_OMIT_INCRBLOB -static int blobHandleFromObj( +static int SQLITE_TCLAPI blobHandleFromObj( Tcl_Interp *interp, Tcl_Obj *pObj, sqlite3_blob **ppBlob @@ -1657,7 +1657,7 @@ static int blobHandleFromObj( return TCL_OK; } -static int test_blob_reopen( +static int SQLITE_TCLAPI test_blob_reopen( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1733,7 +1733,7 @@ static int testCreateCollationCmp( return iRes; } -static int test_create_collation_v2( +static int SQLITE_TCLAPI test_create_collation_v2( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1808,7 +1808,7 @@ static void cf2Destroy(void *pUser){ if( p->pDestroy ) Tcl_DecrRefCount(p->pDestroy); sqlite3_free(p); } -static int test_create_function_v2( +static int SQLITE_TCLAPI test_create_function_v2( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The invoking TCL interpreter */ int objc, /* Number of arguments */ @@ -1896,7 +1896,7 @@ static int test_create_function_v2( /* ** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC? */ -static int test_load_extension( +static int SQLITE_TCLAPI test_load_extension( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1954,7 +1954,7 @@ static int test_load_extension( /* ** Usage: sqlite3_enable_load_extension DB-HANDLE ONOFF */ -static int test_enable_load( +static int SQLITE_TCLAPI test_enable_load( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -2000,7 +2000,7 @@ static int test_enable_load( ** This command is used to test the recoverability of a database in ** the event of a program crash. */ -static int sqlite_abort( +static int SQLITE_TCLAPI sqlite_abort( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -2059,7 +2059,7 @@ error_out: ** ** Register the test SQL function on the database DB under the name NAME. */ -static int test_register_func( +static int SQLITE_TCLAPI test_register_func( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -2088,7 +2088,7 @@ static int test_register_func( ** ** Finalize a statement handle. */ -static int test_finalize( +static int SQLITE_TCLAPI test_finalize( void * clientData, Tcl_Interp *interp, int objc, @@ -2120,7 +2120,7 @@ static int test_finalize( ** ** Get the value of a status counter from a statement. */ -static int test_stmt_status( +static int SQLITE_TCLAPI test_stmt_status( void * clientData, Tcl_Interp *interp, int objc, @@ -2165,7 +2165,7 @@ static int test_stmt_status( /* ** Usage: sqlite3_stmt_scanstatus STMT IDX */ -static int test_stmt_scanstatus( +static int SQLITE_TCLAPI test_stmt_scanstatus( void * clientData, Tcl_Interp *interp, int objc, @@ -2215,7 +2215,7 @@ static int test_stmt_scanstatus( /* ** Usage: sqlite3_stmt_scanstatus_reset STMT */ -static int test_stmt_scanstatus_reset( +static int SQLITE_TCLAPI test_stmt_scanstatus_reset( void * clientData, Tcl_Interp *interp, int objc, @@ -2238,7 +2238,7 @@ static int test_stmt_scanstatus_reset( ** ** Zero the SQLITE_CONFIG_SQLLOG configuration */ -static int test_config_sqllog( +static int SQLITE_TCLAPI test_config_sqllog( void * clientData, Tcl_Interp *interp, int objc, @@ -2258,7 +2258,7 @@ static int test_config_sqllog( ** ** Return the value returned by the default VFS's xCurrentTimeInt64 method. */ -static int vfsCurrentTimeInt64( +static int SQLITE_TCLAPI vfsCurrentTimeInt64( void * clientData, Tcl_Interp *interp, int objc, @@ -2279,7 +2279,7 @@ static int vfsCurrentTimeInt64( /* ** Usage: sqlite3_snapshot_get DB DBNAME */ -static int test_snapshot_get( +static int SQLITE_TCLAPI test_snapshot_get( void * clientData, Tcl_Interp *interp, int objc, @@ -2314,7 +2314,7 @@ static int test_snapshot_get( /* ** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT */ -static int test_snapshot_open( +static int SQLITE_TCLAPI test_snapshot_open( void * clientData, Tcl_Interp *interp, int objc, @@ -2346,7 +2346,7 @@ static int test_snapshot_open( /* ** Usage: sqlite3_snapshot_free SNAPSHOT */ -static int test_snapshot_free( +static int SQLITE_TCLAPI test_snapshot_free( void * clientData, Tcl_Interp *interp, int objc, @@ -2367,7 +2367,7 @@ static int test_snapshot_free( /* ** Usage: sqlite3_snapshot_cmp SNAPSHOT1 SNAPSHOT2 */ -static int test_snapshot_cmp( +static int SQLITE_TCLAPI test_snapshot_cmp( void * clientData, Tcl_Interp *interp, int objc, @@ -2393,7 +2393,7 @@ static int test_snapshot_cmp( ** ** Return the next statment in sequence after STMT. */ -static int test_next_stmt( +static int SQLITE_TCLAPI test_next_stmt( void * clientData, Tcl_Interp *interp, int objc, @@ -2425,7 +2425,7 @@ static int test_next_stmt( ** Return true if STMT is a NULL pointer or a pointer to a statement ** that is guaranteed to leave the database unmodified. */ -static int test_stmt_readonly( +static int SQLITE_TCLAPI test_stmt_readonly( void * clientData, Tcl_Interp *interp, int objc, @@ -2452,7 +2452,7 @@ static int test_stmt_readonly( ** Return true if STMT is a non-NULL pointer to a statement ** that has been stepped but not to completion. */ -static int test_stmt_busy( +static int SQLITE_TCLAPI test_stmt_busy( void * clientData, Tcl_Interp *interp, int objc, @@ -2478,7 +2478,7 @@ static int test_stmt_busy( ** ** Return true if STMT uses a statement journal. */ -static int uses_stmt_journal( +static int SQLITE_TCLAPI uses_stmt_journal( void * clientData, Tcl_Interp *interp, int objc, @@ -2504,7 +2504,7 @@ static int uses_stmt_journal( ** ** Reset a statement handle. */ -static int test_reset( +static int SQLITE_TCLAPI test_reset( void * clientData, Tcl_Interp *interp, int objc, @@ -2539,7 +2539,7 @@ static int test_reset( ** ** Return TRUE if a recompilation of the statement is recommended. */ -static int test_expired( +static int SQLITE_TCLAPI test_expired( void * clientData, Tcl_Interp *interp, int objc, @@ -2563,7 +2563,7 @@ static int test_expired( ** ** Transfer all bindings from FROMSTMT over to TOSTMT */ -static int test_transfer_bind( +static int SQLITE_TCLAPI test_transfer_bind( void * clientData, Tcl_Interp *interp, int objc, @@ -2590,7 +2590,7 @@ static int test_transfer_bind( ** Return the number of changes made to the database by the last SQL ** execution. */ -static int test_changes( +static int SQLITE_TCLAPI test_changes( void * clientData, Tcl_Interp *interp, int objc, @@ -2625,7 +2625,7 @@ static int sqlite_static_bind_nbyte = 0; ** of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored ** an a 10-byte blob "abc\000xyz\000pq" is inserted. */ -static int test_bind( +static int SQLITE_TCLAPI test_bind( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -2747,7 +2747,7 @@ static int test_collate_func( Tcl_GetIntFromObj(i, Tcl_GetObjResult(i), &res); return res; } -static int test_collate( +static int SQLITE_TCLAPI test_collate( void * clientData, Tcl_Interp *interp, int objc, @@ -2821,7 +2821,7 @@ static int test_utf16bin_collate_func( if( res==0 ) res = nA - nB; return res; } -static int test_utf16bin_collate( +static int SQLITE_TCLAPI test_utf16bin_collate( void * clientData, Tcl_Interp *interp, int objc, @@ -2878,7 +2878,7 @@ static void test_collate_needed_cb( /* ** Usage: add_test_collate_needed DB */ -static int test_collate_needed( +static int SQLITE_TCLAPI test_collate_needed( void * clientData, Tcl_Interp *interp, int objc, @@ -2929,7 +2929,7 @@ static int alignmentCollFunc( } return rc; } -static int add_alignment_test_collations( +static int SQLITE_TCLAPI add_alignment_test_collations( void * clientData, Tcl_Interp *interp, int objc, @@ -3047,7 +3047,7 @@ static void test_function_utf16be( sqlite3ValueFree(pVal); } #endif /* SQLITE_OMIT_UTF16 */ -static int test_function( +static int SQLITE_TCLAPI test_function( void * clientData, Tcl_Interp *interp, int objc, @@ -3092,7 +3092,7 @@ bad_args: ** The result is a list of two elements, the string representation of the ** error code and the english language explanation. */ -static int test_errstr( +static int SQLITE_TCLAPI test_errstr( void * clientData, Tcl_Interp *interp, int objc, @@ -3125,7 +3125,7 @@ static int test_errstr( ** Then run testfixture in the debugger and wait for the breakpoint to ** fire. Then additional breakpoints can be set to trace down the bug. */ -static int test_breakpoint( +static int SQLITE_TCLAPI test_breakpoint( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -3141,7 +3141,7 @@ static int test_breakpoint( ** IDX is the index of a wildcard in the prepared statement. This command ** binds a N-byte zero-filled BLOB to the wildcard. */ -static int test_bind_zeroblob( +static int SQLITE_TCLAPI test_bind_zeroblob( void * clientData, Tcl_Interp *interp, int objc, @@ -3177,7 +3177,7 @@ static int test_bind_zeroblob( ** IDX is the index of a wildcard in the prepared statement. This command ** binds a N-byte zero-filled BLOB to the wildcard. */ -static int test_bind_zeroblob64( +static int SQLITE_TCLAPI test_bind_zeroblob64( void * clientData, Tcl_Interp *interp, int objc, @@ -3214,7 +3214,7 @@ static int test_bind_zeroblob64( ** N is the index of a wildcard in the prepared statement. This command ** binds a 32-bit integer VALUE to that wildcard. */ -static int test_bind_int( +static int SQLITE_TCLAPI test_bind_int( void * clientData, Tcl_Interp *interp, int objc, @@ -3254,7 +3254,7 @@ static int test_bind_int( ** with no arguments in order to release memory. Each call to this procedure ** overwrites the previous array. */ -static int test_intarray_addr( +static int SQLITE_TCLAPI test_intarray_addr( void * clientData, Tcl_Interp *interp, int objc, @@ -3288,7 +3288,7 @@ static int test_intarray_addr( ** with no arguments in order to release memory. Each call to this procedure ** overwrites the previous array. */ -static int test_int64array_addr( +static int SQLITE_TCLAPI test_int64array_addr( void * clientData, Tcl_Interp *interp, int objc, @@ -3324,7 +3324,7 @@ static int test_int64array_addr( ** with no arguments in order to release memory. Each call to this procedure ** overwrites the previous array. */ -static int test_doublearray_addr( +static int SQLITE_TCLAPI test_doublearray_addr( void * clientData, Tcl_Interp *interp, int objc, @@ -3358,7 +3358,7 @@ static int test_doublearray_addr( ** with no arguments in order to release memory. Each call to this procedure ** overwrites the previous array. */ -static int test_textarray_addr( +static int SQLITE_TCLAPI test_textarray_addr( void * clientData, Tcl_Interp *interp, int objc, @@ -3391,7 +3391,7 @@ static int test_textarray_addr( ** N is the index of a wildcard in the prepared statement. This command ** binds a 64-bit integer VALUE to that wildcard. */ -static int test_bind_int64( +static int SQLITE_TCLAPI test_bind_int64( void * clientData, Tcl_Interp *interp, int objc, @@ -3429,7 +3429,7 @@ static int test_bind_int64( ** N is the index of a wildcard in the prepared statement. This command ** binds a 64-bit integer VALUE to that wildcard. */ -static int test_bind_double( +static int SQLITE_TCLAPI test_bind_double( void * clientData, Tcl_Interp *interp, int objc, @@ -3505,7 +3505,7 @@ static int test_bind_double( ** N is the index of a wildcard in the prepared statement. This command ** binds a NULL to the wildcard. */ -static int test_bind_null( +static int SQLITE_TCLAPI test_bind_null( void * clientData, Tcl_Interp *interp, int objc, @@ -3541,7 +3541,7 @@ static int test_bind_null( ** binds a UTF-8 string STRING to the wildcard. The string is BYTES bytes ** long. */ -static int test_bind_text( +static int SQLITE_TCLAPI test_bind_text( void * clientData, Tcl_Interp *interp, int objc, @@ -3582,7 +3582,7 @@ static int test_bind_text( ** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes ** long. */ -static int test_bind_text16( +static int SQLITE_TCLAPI test_bind_text16( void * clientData, Tcl_Interp *interp, int objc, @@ -3630,7 +3630,7 @@ static int test_bind_text16( ** N is the index of a wildcard in the prepared statement. This command ** binds a BLOB to the wildcard. The BLOB is BYTES bytes in size. */ -static int test_bind_blob( +static int SQLITE_TCLAPI test_bind_blob( void * clientData, Tcl_Interp *interp, int objc, @@ -3682,7 +3682,7 @@ static int test_bind_blob( ** ** Return the number of wildcards in the given statement. */ -static int test_bind_parameter_count( +static int SQLITE_TCLAPI test_bind_parameter_count( void * clientData, Tcl_Interp *interp, int objc, @@ -3706,7 +3706,7 @@ static int test_bind_parameter_count( ** An empty string is returned if N is out of range or if the wildcard ** is nameless. */ -static int test_bind_parameter_name( +static int SQLITE_TCLAPI test_bind_parameter_name( void * clientData, Tcl_Interp *interp, int objc, @@ -3733,7 +3733,7 @@ static int test_bind_parameter_name( ** Return the index of the wildcard called NAME. Return 0 if there is ** no such wildcard. */ -static int test_bind_parameter_index( +static int SQLITE_TCLAPI test_bind_parameter_index( void * clientData, Tcl_Interp *interp, int objc, @@ -3758,7 +3758,7 @@ static int test_bind_parameter_index( ** Usage: sqlite3_clear_bindings STMT ** */ -static int test_clear_bindings( +static int SQLITE_TCLAPI test_clear_bindings( void * clientData, Tcl_Interp *interp, int objc, @@ -3778,7 +3778,7 @@ static int test_clear_bindings( /* ** Usage: sqlite3_sleep MILLISECONDS */ -static int test_sleep( +static int SQLITE_TCLAPI test_sleep( void * clientData, Tcl_Interp *interp, int objc, @@ -3803,7 +3803,7 @@ static int test_sleep( ** Return the string representation of the most recent sqlite3_* API ** error code. e.g. "SQLITE_ERROR". */ -static int test_ex_errcode( +static int SQLITE_TCLAPI test_ex_errcode( void * clientData, Tcl_Interp *interp, int objc, @@ -3830,7 +3830,7 @@ static int test_ex_errcode( ** Return the string representation of the most recent sqlite3_* API ** error code. e.g. "SQLITE_ERROR". */ -static int test_errcode( +static int SQLITE_TCLAPI test_errcode( void * clientData, Tcl_Interp *interp, int objc, @@ -3856,7 +3856,7 @@ static int test_errcode( ** Returns the UTF-8 representation of the error message string for the ** most recent sqlite3_* API call. */ -static int test_errmsg( +static int SQLITE_TCLAPI test_errmsg( void * clientData, Tcl_Interp *interp, int objc, @@ -3885,7 +3885,7 @@ static int test_errmsg( ** level, and it includes the 0x00 0x00 terminator bytes at the end of the ** UTF-16 string. */ -static int test_errmsg16( +static int SQLITE_TCLAPI test_errmsg16( void * clientData, Tcl_Interp *interp, int objc, @@ -3922,7 +3922,7 @@ static int test_errmsg16( ** variable that is set to the unused portion of (if any). A ** STMT handle is returned. */ -static int test_prepare( +static int SQLITE_TCLAPI test_prepare( void * clientData, Tcl_Interp *interp, int objc, @@ -3979,7 +3979,7 @@ static int test_prepare( ** variable that is set to the unused portion of (if any). A ** STMT handle is returned. */ -static int test_prepare_v2( +static int SQLITE_TCLAPI test_prepare_v2( void * clientData, Tcl_Interp *interp, int objc, @@ -4047,7 +4047,7 @@ static int test_prepare_v2( ** Generate a prepared statement for a zero-byte string as a test ** for ticket #3134. The string should be preceded by a zero byte. */ -static int test_prepare_tkt3134( +static int SQLITE_TCLAPI test_prepare_tkt3134( void * clientData, Tcl_Interp *interp, int objc, @@ -4090,7 +4090,7 @@ static int test_prepare_tkt3134( ** variable that is set to the unused portion of (if any). A ** STMT handle is returned. */ -static int test_prepare16( +static int SQLITE_TCLAPI test_prepare16( void * clientData, Tcl_Interp *interp, int objc, @@ -4150,7 +4150,7 @@ static int test_prepare16( ** variable that is set to the unused portion of (if any). A ** STMT handle is returned. */ -static int test_prepare16_v2( +static int SQLITE_TCLAPI test_prepare16_v2( void * clientData, Tcl_Interp *interp, int objc, @@ -4205,7 +4205,7 @@ static int test_prepare16_v2( /* ** Usage: sqlite3_open filename ?options-list? */ -static int test_open( +static int SQLITE_TCLAPI test_open( void * clientData, Tcl_Interp *interp, int objc, @@ -4232,7 +4232,7 @@ static int test_open( /* ** Usage: sqlite3_open_v2 FILENAME FLAGS VFS */ -static int test_open_v2( +static int SQLITE_TCLAPI test_open_v2( void * clientData, Tcl_Interp *interp, int objc, @@ -4302,7 +4302,7 @@ static int test_open_v2( /* ** Usage: sqlite3_open16 filename options */ -static int test_open16( +static int SQLITE_TCLAPI test_open16( void * clientData, Tcl_Interp *interp, int objc, @@ -4334,7 +4334,7 @@ static int test_open16( ** Return 1 if the supplied argument is a complete SQL statement, or zero ** otherwise. */ -static int test_complete16( +static int SQLITE_TCLAPI test_complete16( void * clientData, Tcl_Interp *interp, int objc, @@ -4359,7 +4359,7 @@ static int test_complete16( ** ** Advance the statement to the next row. */ -static int test_step( +static int SQLITE_TCLAPI test_step( void * clientData, Tcl_Interp *interp, int objc, @@ -4382,7 +4382,7 @@ static int test_step( return TCL_OK; } -static int test_sql( +static int SQLITE_TCLAPI test_sql( void * clientData, Tcl_Interp *interp, int objc, @@ -4399,7 +4399,7 @@ static int test_sql( Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE); return TCL_OK; } -static int test_ex_sql( +static int SQLITE_TCLAPI test_ex_sql( void * clientData, Tcl_Interp *interp, int objc, @@ -4425,7 +4425,7 @@ static int test_ex_sql( ** ** Return the number of columns returned by the sql statement STMT. */ -static int test_column_count( +static int SQLITE_TCLAPI test_column_count( void * clientData, Tcl_Interp *interp, int objc, @@ -4450,7 +4450,7 @@ static int test_column_count( ** ** Return the type of the data in column 'column' of the current row. */ -static int test_column_type( +static int SQLITE_TCLAPI test_column_type( void * clientData, Tcl_Interp *interp, int objc, @@ -4499,7 +4499,7 @@ static int test_column_type( ** Return the data in column 'column' of the current row cast as an ** wide (64-bit) integer. */ -static int test_column_int64( +static int SQLITE_TCLAPI test_column_int64( void * clientData, Tcl_Interp *interp, int objc, @@ -4526,7 +4526,7 @@ static int test_column_int64( /* ** Usage: sqlite3_column_blob STMT column */ -static int test_column_blob( +static int SQLITE_TCLAPI test_column_blob( void * clientData, Tcl_Interp *interp, int objc, @@ -4558,7 +4558,7 @@ static int test_column_blob( ** ** Return the data in column 'column' of the current row cast as a double. */ -static int test_column_double( +static int SQLITE_TCLAPI test_column_double( void * clientData, Tcl_Interp *interp, int objc, @@ -4587,7 +4587,7 @@ static int test_column_double( ** ** Return the number of columns returned by the sql statement STMT. */ -static int test_data_count( +static int SQLITE_TCLAPI test_data_count( void * clientData, Tcl_Interp *interp, int objc, @@ -4614,7 +4614,7 @@ static int test_data_count( ** ** Usage: sqlite3_column_name STMT column */ -static int test_stmt_utf8( +static int SQLITE_TCLAPI test_stmt_utf8( void * clientData, /* Pointer to SQLite API function to be invoke */ Tcl_Interp *interp, int objc, @@ -4641,7 +4641,7 @@ static int test_stmt_utf8( return TCL_OK; } -static int test_global_recover( +static int SQLITE_TCLAPI test_global_recover( void * clientData, Tcl_Interp *interp, int objc, @@ -4666,7 +4666,7 @@ static int test_global_recover( ** ** Usage: sqlite3_column_name STMT column */ -static int test_stmt_utf16( +static int SQLITE_TCLAPI test_stmt_utf16( void * clientData, /* Pointer to SQLite API function to be invoked */ Tcl_Interp *interp, int objc, @@ -4710,7 +4710,7 @@ static int test_stmt_utf16( ** Usage: sqlite3_column_bytes16 STMT column ** */ -static int test_stmt_int( +static int SQLITE_TCLAPI test_stmt_int( void * clientData, /* Pointer to SQLite API function to be invoked */ Tcl_Interp *interp, int objc, @@ -4739,7 +4739,7 @@ static int test_stmt_int( ** ** Set the db->magic value. This is used to test error recovery logic. */ -static int sqlite_set_magic( +static int SQLITE_TCLAPI sqlite_set_magic( void * clientData, Tcl_Interp *interp, int argc, @@ -4771,7 +4771,7 @@ static int sqlite_set_magic( ** ** Trigger an interrupt on DB */ -static int test_interrupt( +static int SQLITE_TCLAPI test_interrupt( void * clientData, Tcl_Interp *interp, int argc, @@ -4812,7 +4812,7 @@ u64 sqlite3StackDepth(void){ ** ** Try to measure the amount of stack space used by a call to sqlite3_exec */ -static int test_stack_used( +static int SQLITE_TCLAPI test_stack_used( void * clientData, Tcl_Interp *interp, int argc, @@ -4840,7 +4840,7 @@ static int test_stack_used( ** is assumed that the user function was created as UTF8, any number of ** arguments (the way the TCL interface does it). */ -static int delete_function( +static int SQLITE_TCLAPI delete_function( void * clientData, Tcl_Interp *interp, int argc, @@ -4866,7 +4866,7 @@ static int delete_function( ** DB. It is assumed that the collation sequence was created as UTF8 (the ** way the TCL interface does it). */ -static int delete_collation( +static int SQLITE_TCLAPI delete_collation( void * clientData, Tcl_Interp *interp, int argc, @@ -4891,7 +4891,7 @@ static int delete_collation( ** Return true if the database DB is currently in auto-commit mode. ** Return false if not. */ -static int get_autocommit( +static int SQLITE_TCLAPI get_autocommit( void * clientData, Tcl_Interp *interp, int argc, @@ -4917,7 +4917,7 @@ static int get_autocommit( ** method of the TCL interface. But we need a way to test the case ** where it returns SQLITE_MISUSE. */ -static int test_busy_timeout( +static int SQLITE_TCLAPI test_busy_timeout( void * clientData, Tcl_Interp *interp, int argc, @@ -4943,7 +4943,7 @@ static int test_busy_timeout( ** Return the name of the internal representation for the ** value of the given variable. */ -static int tcl_variable_type( +static int SQLITE_TCLAPI tcl_variable_type( void * clientData, Tcl_Interp *interp, int objc, @@ -4969,7 +4969,7 @@ static int tcl_variable_type( ** The integer N is the number of bytes we are trying to release. The ** return value is the amount of memory actually released. */ -static int test_release_memory( +static int SQLITE_TCLAPI test_release_memory( void * clientData, Tcl_Interp *interp, int objc, @@ -5000,7 +5000,7 @@ static int test_release_memory( ** Attempt to release memory currently held by database DB. Return the ** result code (which in the current implementation is always zero). */ -static int test_db_release_memory( +static int SQLITE_TCLAPI test_db_release_memory( void * clientData, Tcl_Interp *interp, int objc, @@ -5023,7 +5023,7 @@ static int test_db_release_memory( ** ** Attempt to flush any dirty pages to disk. */ -static int test_db_cacheflush( +static int SQLITE_TCLAPI test_db_cacheflush( void * clientData, Tcl_Interp *interp, int objc, @@ -5051,7 +5051,7 @@ static int test_db_cacheflush( ** ** Return the low-level system errno value. */ -static int test_system_errno( +static int SQLITE_TCLAPI test_system_errno( void * clientData, Tcl_Interp *interp, int objc, @@ -5074,7 +5074,7 @@ static int test_system_errno( ** ** Return the name of a file associated with a database. */ -static int test_db_filename( +static int SQLITE_TCLAPI test_db_filename( void * clientData, Tcl_Interp *interp, int objc, @@ -5098,7 +5098,7 @@ static int test_db_filename( ** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does ** not exist. */ -static int test_db_readonly( +static int SQLITE_TCLAPI test_db_readonly( void * clientData, Tcl_Interp *interp, int objc, @@ -5123,7 +5123,7 @@ static int test_db_readonly( ** limit is only changed if the N is present. The previous limit ** is returned. */ -static int test_soft_heap_limit( +static int SQLITE_TCLAPI test_soft_heap_limit( void * clientData, Tcl_Interp *interp, int objc, @@ -5148,7 +5148,7 @@ static int test_soft_heap_limit( ** ** Call the sqlite3_thread_cleanup API. */ -static int test_thread_cleanup( +static int SQLITE_TCLAPI test_thread_cleanup( void * clientData, Tcl_Interp *interp, int objc, @@ -5166,7 +5166,7 @@ static int test_thread_cleanup( ** Return a list of numbers which are the PagerRefcount for all ** pagers on each database connection. */ -static int test_pager_refcounts( +static int SQLITE_TCLAPI test_pager_refcounts( void * clientData, Tcl_Interp *interp, int objc, @@ -5212,7 +5212,7 @@ static int test_pager_refcounts( ** and that the errors they are seeing in the test scripts might be ** a result of their defective TCL rather than problems in SQLite. */ -static int working_64bit_int( +static int SQLITE_TCLAPI working_64bit_int( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5237,7 +5237,7 @@ static int working_64bit_int( ** VFS when none are previously registered, and the ability to ** unregister the only available VFS. Ticket #2738 */ -static int vfs_unlink_test( +static int SQLITE_TCLAPI vfs_unlink_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5339,7 +5339,7 @@ static int vfs_unlink_test( ** This TCL command attempts to vfs_find and vfs_register when the ** sqlite3_initialize() interface is failing. All calls should fail. */ -static int vfs_initfail_test( +static int SQLITE_TCLAPI vfs_initfail_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5367,7 +5367,7 @@ static int nVfs = 0; ** ** Unregister all VFSes. */ -static int vfs_unregister_all( +static int SQLITE_TCLAPI vfs_unregister_all( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5389,7 +5389,7 @@ static int vfs_unregister_all( ** care to put the linked list back together in the same order as it was ** in before vfs_unregister_all was invoked. */ -static int vfs_reregister_all( +static int SQLITE_TCLAPI vfs_reregister_all( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5409,7 +5409,7 @@ static int vfs_reregister_all( ** This TCL command runs the sqlite3_file_control interface and ** verifies correct operation of the same. */ -static int file_control_test( +static int SQLITE_TCLAPI file_control_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5444,7 +5444,7 @@ static int file_control_test( ** This TCL command runs the sqlite3_file_control interface and ** verifies correct operation of the SQLITE_LAST_ERRNO verb. */ -static int file_control_lasterrno_test( +static int SQLITE_TCLAPI file_control_lasterrno_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5482,7 +5482,7 @@ static int file_control_lasterrno_test( ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and ** SQLITE_SET_LOCKPROXYFILE verbs. */ -static int file_control_chunksize_test( +static int SQLITE_TCLAPI file_control_chunksize_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5519,7 +5519,7 @@ static int file_control_chunksize_test( ** This TCL command runs the sqlite3_file_control interface ** with SQLITE_FCNTL_SIZE_HINT */ -static int file_control_sizehint_test( +static int SQLITE_TCLAPI file_control_sizehint_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5557,7 +5557,7 @@ static int file_control_sizehint_test( ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and ** SQLITE_SET_LOCKPROXYFILE verbs. */ -static int file_control_lockproxy_test( +static int SQLITE_TCLAPI file_control_lockproxy_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5627,7 +5627,7 @@ static int file_control_lockproxy_test( ** This TCL command runs the sqlite3_file_control interface with ** the SQLITE_FCNTL_WIN32_AV_RETRY opcode. */ -static int file_control_win32_av_retry( +static int SQLITE_TCLAPI file_control_win32_av_retry( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5660,7 +5660,7 @@ static int file_control_win32_av_retry( ** This TCL command runs the sqlite3_file_control interface with ** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode. */ -static int file_control_win32_set_handle( +static int SQLITE_TCLAPI file_control_win32_set_handle( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5696,7 +5696,7 @@ static int file_control_win32_set_handle( ** This TCL command runs the sqlite3_file_control interface with ** the SQLITE_FCNTL_PERSIST_WAL opcode. */ -static int file_control_persist_wal( +static int SQLITE_TCLAPI file_control_persist_wal( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5728,7 +5728,7 @@ static int file_control_persist_wal( ** This TCL command runs the sqlite3_file_control interface with ** the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode. */ -static int file_control_powersafe_overwrite( +static int SQLITE_TCLAPI file_control_powersafe_overwrite( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5760,7 +5760,7 @@ static int file_control_powersafe_overwrite( ** ** Return a string that describes the stack of VFSes. */ -static int file_control_vfsname( +static int SQLITE_TCLAPI file_control_vfsname( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5792,7 +5792,7 @@ static int file_control_vfsname( ** ** Return a string that is a temporary filename */ -static int file_control_tempfilename( +static int SQLITE_TCLAPI 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 */ @@ -5825,7 +5825,7 @@ static int file_control_tempfilename( ** ** Return a tcl list containing the names of all registered vfs's. */ -static int vfs_list( +static int SQLITE_TCLAPI vfs_list( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5850,7 +5850,7 @@ static int vfs_list( ** This TCL command runs the sqlite3_limit interface and ** verifies correct operation of the same. */ -static int test_limit( +static int SQLITE_TCLAPI test_limit( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5913,7 +5913,7 @@ static int test_limit( ** At the same time, verify that sqlite3_test_control works even when ** called with an out-of-range opcode. */ -static int save_prng_state( +static int SQLITE_TCLAPI save_prng_state( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5929,7 +5929,7 @@ static int save_prng_state( /* ** tclcmd: restore_prng_state */ -static int restore_prng_state( +static int SQLITE_TCLAPI restore_prng_state( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5941,7 +5941,7 @@ static int restore_prng_state( /* ** tclcmd: reset_prng_state */ -static int reset_prng_state( +static int SQLITE_TCLAPI reset_prng_state( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5957,7 +5957,7 @@ static int reset_prng_state( ** Indicate that database files might be corrupt. In other words, set the normal ** state of operation. */ -static int database_may_be_corrupt( +static int SQLITE_TCLAPI database_may_be_corrupt( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5972,7 +5972,7 @@ static int database_may_be_corrupt( ** Indicate that database files are always well-formed. This enables extra assert() ** statements that test conditions that are always true for well-formed databases. */ -static int database_never_corrupt( +static int SQLITE_TCLAPI database_never_corrupt( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -5985,7 +5985,7 @@ static int database_never_corrupt( /* ** tclcmd: pcache_stats */ -static int test_pcache_stats( +static int SQLITE_TCLAPI test_pcache_stats( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6027,7 +6027,7 @@ static void test_unlock_notify_cb(void **aArg, int nArg){ ** tclcmd: sqlite3_unlock_notify db */ #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY -static int test_unlock_notify( +static int SQLITE_TCLAPI test_unlock_notify( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6053,7 +6053,7 @@ static int test_unlock_notify( /* ** tclcmd: sqlite3_wal_checkpoint db ?NAME? */ -static int test_wal_checkpoint( +static int SQLITE_TCLAPI test_wal_checkpoint( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6097,7 +6097,7 @@ static int test_wal_checkpoint( ** the number of frames in the log and the number of frames in the log ** that have been checkpointed. */ -static int test_wal_checkpoint_v2( +static int SQLITE_TCLAPI test_wal_checkpoint_v2( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6153,7 +6153,7 @@ static int test_wal_checkpoint_v2( /* ** tclcmd: sqlite3_wal_autocheckpoint db VALUE */ -static int test_wal_autocheckpoint( +static int SQLITE_TCLAPI test_wal_autocheckpoint( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6204,7 +6204,7 @@ static void xLogcallback(void *unused, int err, char *zMsg){ Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); Tcl_DecrRefCount(pNew); } -static int test_sqlite3_log( +static int SQLITE_TCLAPI test_sqlite3_log( ClientData clientData, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6235,7 +6235,7 @@ static int test_sqlite3_log( ** Run a TCL command using its objProc interface. Throw an error if ** the command has no objProc interface. */ -static int runAsObjProc( +static int SQLITE_TCLAPI runAsObjProc( void * clientData, Tcl_Interp *interp, int objc, @@ -6298,7 +6298,7 @@ int printExplainQueryPlan(sqlite3_stmt *pStmt){ return sqlite3_finalize(pExplain); } -static int test_print_eqp( +static int SQLITE_TCLAPI test_print_eqp( void * clientData, Tcl_Interp *interp, int objc, @@ -6326,7 +6326,7 @@ static int test_print_eqp( /* ** sqlite3_test_control VERB ARGS... */ -static int test_test_control( +static int SQLITE_TCLAPI test_test_control( void * clientData, Tcl_Interp *interp, int objc, @@ -6405,7 +6405,7 @@ static int test_test_control( #include #include -static int test_getrusage( +static int SQLITE_TCLAPI test_getrusage( void * clientData, Tcl_Interp *interp, int objc, @@ -6479,7 +6479,7 @@ static void SQLITE_CDECL win32_file_locker(void *pAppData){ ** Get an exclusive manditory lock on file for DELAY2 milliseconds. ** Wait DELAY1 milliseconds before acquiring the lock. */ -static int win32_file_lock( +static int SQLITE_TCLAPI win32_file_lock( void * clientData, Tcl_Interp *interp, int objc, @@ -6543,7 +6543,7 @@ static int win32_file_lock( ** Returns non-zero if the specified path exists, whose fully qualified name ** may exceed 260 characters if it is prefixed with "\\?\". */ -static int win32_exists_path( +static int SQLITE_TCLAPI win32_exists_path( void *clientData, Tcl_Interp *interp, int objc, @@ -6565,7 +6565,7 @@ static int win32_exists_path( ** whose fully qualified name may exceed 248 characters if it is prefixed with ** "\\?\". */ -static int win32_find_file( +static int SQLITE_TCLAPI win32_find_file( void *clientData, Tcl_Interp *interp, int objc, @@ -6610,7 +6610,7 @@ static int win32_find_file( ** Deletes the specified file, whose fully qualified name may exceed 260 ** characters if it is prefixed with "\\?\". */ -static int win32_delete_file( +static int SQLITE_TCLAPI win32_delete_file( void *clientData, Tcl_Interp *interp, int objc, @@ -6634,7 +6634,7 @@ static int win32_delete_file( ** Creates the specified directory, whose fully qualified name may exceed 248 ** characters if it is prefixed with "\\?\". */ -static int win32_mkdir( +static int SQLITE_TCLAPI win32_mkdir( void *clientData, Tcl_Interp *interp, int objc, @@ -6658,7 +6658,7 @@ static int win32_mkdir( ** Removes the specified directory, whose fully qualified name may exceed 248 ** characters if it is prefixed with "\\?\". */ -static int win32_rmdir( +static int SQLITE_TCLAPI win32_rmdir( void *clientData, Tcl_Interp *interp, int objc, @@ -6685,7 +6685,7 @@ static int win32_rmdir( ** interface. Disable if BOOLEAN is false and enable if BOOLEAN is true. ** OPT is the name of the optimization to be disabled. */ -static int optimization_control( +static int SQLITE_TCLAPI optimization_control( void * clientData, Tcl_Interp *interp, int objc, @@ -6748,7 +6748,7 @@ typedef struct sqlite3_api_routines sqlite3_api_routines; ** ** Load one or more statically linked extensions. */ -static int tclLoadStaticExtensionCmd( +static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -6826,7 +6826,7 @@ static int tclLoadStaticExtensionCmd( ** sorter_test_fakeheap BOOL ** */ -static int sorter_test_fakeheap( +static int SQLITE_TCLAPI sorter_test_fakeheap( void * clientData, Tcl_Interp *interp, int objc, @@ -6866,7 +6866,7 @@ static int sorter_test_fakeheap( ** Then execute statement $SQL2. Check that the statement returns the same ** set of integers in the same order as in the previous step (using $SQL1). */ -static int sorter_test_sort4_helper( +static int SQLITE_TCLAPI sorter_test_sort4_helper( void * clientData, Tcl_Interp *interp, int objc, @@ -6935,7 +6935,7 @@ static int sorter_test_sort4_helper( /* ** tclcmd: sqlite3_user_authenticate DB USERNAME PASSWORD */ -static int test_user_authenticate( +static int SQLITE_TCLAPI test_user_authenticate( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6966,7 +6966,7 @@ static int test_user_authenticate( /* ** tclcmd: sqlite3_user_add DB USERNAME PASSWORD ISADMIN */ -static int test_user_add( +static int SQLITE_TCLAPI test_user_add( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -6999,7 +6999,7 @@ static int test_user_add( /* ** tclcmd: sqlite3_user_change DB USERNAME PASSWORD ISADMIN */ -static int test_user_change( +static int SQLITE_TCLAPI test_user_change( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -7032,7 +7032,7 @@ static int test_user_change( /* ** tclcmd: sqlite3_user_delete DB USERNAME */ -static int test_user_delete( +static int SQLITE_TCLAPI test_user_delete( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -7069,7 +7069,7 @@ static int test_user_delete( ** 3 Read after free ** 4 Panic */ -static int test_bad_behavior( +static int SQLITE_TCLAPI test_bad_behavior( ClientData clientData, /* Pointer to an integer containing zero */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -7119,7 +7119,7 @@ static int test_bad_behavior( ** ** Cause the dbstat virtual table to be available on the connection DB */ -static int test_register_dbstat_vtab( +static int SQLITE_TCLAPI test_register_dbstat_vtab( void *clientData, Tcl_Interp *interp, int objc, @@ -7153,7 +7153,7 @@ static int test_register_dbstat_vtab( ** ** Invoke sqlite3_db_config() for one of the setting values. */ -static int test_sqlite3_db_config( +static int SQLITE_TCLAPI test_sqlite3_db_config( void *clientData, Tcl_Interp *interp, int objc, @@ -7210,7 +7210,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_hostid_num; #endif extern int sqlite3_max_blobsize; - extern int sqlite3BtreeSharedCacheReport(void*, + extern int SQLITE_TCLAPI sqlite3BtreeSharedCacheReport(void*, Tcl_Interp*,int,Tcl_Obj*CONST*); static int iZero = 0; static struct { diff --git a/src/test2.c b/src/test2.c index 8946196ff3..dfca1d2b31 100644 --- a/src/test2.c +++ b/src/test2.c @@ -42,7 +42,7 @@ static void pager_test_reiniter(DbPage *pNotUsed){ ** ** Open a new pager */ -static int pager_open( +static int SQLITE_TCLAPI pager_open( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -79,7 +79,7 @@ static int pager_open( ** ** Close the given pager. */ -static int pager_close( +static int SQLITE_TCLAPI pager_close( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -106,7 +106,7 @@ static int pager_close( ** ** Rollback changes */ -static int pager_rollback( +static int SQLITE_TCLAPI pager_rollback( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -133,7 +133,7 @@ static int pager_rollback( ** ** Commit all changes */ -static int pager_commit( +static int SQLITE_TCLAPI pager_commit( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -165,7 +165,7 @@ static int pager_commit( ** ** Start a new checkpoint. */ -static int pager_stmt_begin( +static int SQLITE_TCLAPI pager_stmt_begin( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -192,7 +192,7 @@ static int pager_stmt_begin( ** ** Rollback changes to a checkpoint */ -static int pager_stmt_rollback( +static int SQLITE_TCLAPI pager_stmt_rollback( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -220,7 +220,7 @@ static int pager_stmt_rollback( ** ** Commit changes to a checkpoint */ -static int pager_stmt_commit( +static int SQLITE_TCLAPI pager_stmt_commit( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -247,7 +247,7 @@ static int pager_stmt_commit( ** ** Return pager statistics. */ -static int pager_stats( +static int SQLITE_TCLAPI pager_stats( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -280,7 +280,7 @@ static int pager_stats( ** ** Return the size of the database file. */ -static int pager_pagecount( +static int SQLITE_TCLAPI pager_pagecount( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -306,7 +306,7 @@ static int pager_pagecount( ** ** Return a pointer to a page from the database. */ -static int page_get( +static int SQLITE_TCLAPI page_get( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -343,7 +343,7 @@ static int page_get( ** Return a pointer to a page if the page is already in cache. ** If not in cache, return an empty string. */ -static int page_lookup( +static int SQLITE_TCLAPI page_lookup( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -371,7 +371,7 @@ static int page_lookup( /* ** Usage: pager_truncate ID PGNO */ -static int pager_truncate( +static int SQLITE_TCLAPI pager_truncate( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -396,7 +396,7 @@ static int pager_truncate( ** ** Drop a pointer to a page. */ -static int page_unref( +static int SQLITE_TCLAPI page_unref( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -418,7 +418,7 @@ static int page_unref( ** ** Return the content of a page */ -static int page_read( +static int SQLITE_TCLAPI page_read( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -442,7 +442,7 @@ static int page_read( ** ** Return the page number for a page. */ -static int page_number( +static int SQLITE_TCLAPI page_number( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -466,7 +466,7 @@ static int page_number( ** ** Write something into a page. */ -static int page_write( +static int SQLITE_TCLAPI page_write( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -502,7 +502,7 @@ static int page_write( ** new pages after N. If N is 2096 or bigger, this will test the ** ability of SQLite to write to large files. */ -static int fake_big_file( +static int SQLITE_TCLAPI fake_big_file( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -555,7 +555,7 @@ static int fake_big_file( ** ** Set the PENDING_BYTE using the sqlite3_test_control() interface. */ -static int testPendingByte( +static int SQLITE_TCLAPI testPendingByte( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -620,7 +620,7 @@ static int faultSimCallback(int x){ ** appended, whenever sqlite3FaultSim() is called. Or, if SCRIPT is the ** empty string, cancel the sqlite3FaultSim() callback. */ -static int faultInstallCmd( +static int SQLITE_TCLAPI faultInstallCmd( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -663,7 +663,7 @@ static int faultInstallCmd( ** Invoke the SQLITE_TESTCTRL_BITVEC_TEST operator on test_control. ** See comments on sqlite3BitvecBuiltinTest() for additional information. */ -static int testBitvecBuiltinTest( +static int SQLITE_TCLAPI testBitvecBuiltinTest( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ diff --git a/src/test3.c b/src/test3.c index f1b9f37924..6995684c29 100644 --- a/src/test3.c +++ b/src/test3.c @@ -37,7 +37,7 @@ static int nRefSqlite3 = 0; ** ** Open a new database */ -static int btree_open( +static int SQLITE_TCLAPI btree_open( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -83,7 +83,7 @@ static int btree_open( ** ** Close the given database. */ -static int btree_close( +static int SQLITE_TCLAPI btree_close( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -118,7 +118,7 @@ static int btree_close( ** ** Start a new transaction */ -static int btree_begin_transaction( +static int SQLITE_TCLAPI btree_begin_transaction( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -147,7 +147,7 @@ static int btree_begin_transaction( ** ** Returns pager statistics */ -static int btree_pager_stats( +static int SQLITE_TCLAPI btree_pager_stats( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -197,7 +197,7 @@ static int btree_pager_stats( ** ** Create a new cursor. Return the ID for the cursor. */ -static int btree_cursor( +static int SQLITE_TCLAPI btree_cursor( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -246,7 +246,7 @@ static int btree_cursor( ** ** Close a cursor opened using btree_cursor. */ -static int btree_close_cursor( +static int SQLITE_TCLAPI btree_close_cursor( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -283,7 +283,7 @@ static int btree_close_cursor( ** or 1 if the cursor was already on the last entry in the table or if ** the table is empty. */ -static int btree_next( +static int SQLITE_TCLAPI btree_next( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -318,7 +318,7 @@ static int btree_next( ** Move the cursor to the first entry in the table. Return 0 if the ** cursor was left point to something and 1 if the table is empty. */ -static int btree_first( +static int SQLITE_TCLAPI btree_first( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -353,7 +353,7 @@ static int btree_first( ** Return TRUE if the given cursor is not pointing at a valid entry. ** Return FALSE if the cursor does point to a valid entry. */ -static int btree_eof( +static int SQLITE_TCLAPI btree_eof( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -382,7 +382,7 @@ static int btree_eof( ** ** Return the number of bytes of payload */ -static int btree_payload_size( +static int SQLITE_TCLAPI btree_payload_size( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -420,7 +420,7 @@ static int btree_payload_size( ** This command returns nothing if it works. It returns an error message ** if something goes wrong. */ -static int btree_varint_test( +static int SQLITE_TCLAPI btree_varint_test( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -504,7 +504,7 @@ static int btree_varint_test( ** sqlite3 db test.db ** set bt [btree_from_db db] */ -static int btree_from_db( +static int SQLITE_TCLAPI btree_from_db( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -544,7 +544,7 @@ static int btree_from_db( ** ** Return true if the B-Tree is currently stored entirely in memory. */ -static int btree_ismemdb( +static int SQLITE_TCLAPI btree_ismemdb( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -575,7 +575,7 @@ static int btree_ismemdb( ** ** Set the size of the cache used by btree $ID. */ -static int btree_set_cache_size( +static int SQLITE_TCLAPI btree_set_cache_size( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -605,7 +605,7 @@ static int btree_set_cache_size( ** ** Set the size of the cache used by btree $ID. */ -static int btree_insert( +static int SQLITE_TCLAPI btree_insert( ClientData clientData, Tcl_Interp *interp, int objc, diff --git a/src/test4.c b/src/test4.c index 85b521b060..c5b5ec12cc 100644 --- a/src/test4.c +++ b/src/test4.c @@ -125,7 +125,7 @@ static int parse_thread_id(Tcl_Interp *interp, const char *zArg){ ** NAME should be an upper case letter. Start the thread running with ** an open connection to the given database. */ -static int tcl_thread_create( +static int SQLITE_TCLAPI tcl_thread_create( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -174,7 +174,7 @@ static void thread_wait(Thread *p){ ** ** Wait on thread ID to reach its idle state. */ -static int tcl_thread_wait( +static int SQLITE_TCLAPI tcl_thread_wait( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -218,7 +218,7 @@ static void stop_thread(Thread *p){ ** Cause a thread to shut itself down. Wait for the shutdown to be ** completed. If ID is "*" then stop all threads. */ -static int tcl_thread_halt( +static int SQLITE_TCLAPI tcl_thread_halt( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -253,7 +253,7 @@ static int tcl_thread_halt( ** Wait on the most recent thread_step to complete, then return the ** number of columns in the result set. */ -static int tcl_thread_argc( +static int SQLITE_TCLAPI tcl_thread_argc( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -285,7 +285,7 @@ static int tcl_thread_argc( ** Wait on the most recent thread_step to complete, then return the ** value of the N-th columns in the result set. */ -static int tcl_thread_argv( +static int SQLITE_TCLAPI tcl_thread_argv( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -321,7 +321,7 @@ static int tcl_thread_argv( ** Wait on the most recent thread_step to complete, then return the ** name of the N-th columns in the result set. */ -static int tcl_thread_colname( +static int SQLITE_TCLAPI tcl_thread_colname( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -357,7 +357,7 @@ static int tcl_thread_colname( ** Wait on the most recent operation to complete, then return the ** result code from that operation. */ -static int tcl_thread_result( +static int SQLITE_TCLAPI tcl_thread_result( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -389,7 +389,7 @@ static int tcl_thread_result( ** Wait on the most recent operation to complete, then return the ** error string. */ -static int tcl_thread_error( +static int SQLITE_TCLAPI tcl_thread_error( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -434,7 +434,7 @@ static void do_compile(Thread *p){ ** ** Compile a new virtual machine. */ -static int tcl_thread_compile( +static int SQLITE_TCLAPI tcl_thread_compile( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -487,7 +487,7 @@ static void do_step(Thread *p){ ** ** Advance the virtual machine by one step */ -static int tcl_thread_step( +static int SQLITE_TCLAPI tcl_thread_step( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -529,7 +529,7 @@ static void do_finalize(Thread *p){ ** ** Finalize the virtual machine. */ -static int tcl_thread_finalize( +static int SQLITE_TCLAPI tcl_thread_finalize( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -560,7 +560,7 @@ static int tcl_thread_finalize( ** ** Interchange the sqlite* pointer between two threads. */ -static int tcl_thread_swap( +static int SQLITE_TCLAPI tcl_thread_swap( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -600,7 +600,7 @@ static int tcl_thread_swap( ** remove the pointer from the thread itself. Afterwards, the thread ** can be stopped and the connection can be used by the main thread. */ -static int tcl_thread_db_get( +static int SQLITE_TCLAPI tcl_thread_db_get( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -631,7 +631,7 @@ static int tcl_thread_db_get( ** Usage: thread_db_put ID DB ** */ -static int tcl_thread_db_put( +static int SQLITE_TCLAPI tcl_thread_db_put( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -663,7 +663,7 @@ static int tcl_thread_db_put( ** Return the database stmt pointer for the given thread. Then ** remove the pointer from the thread itself. */ -static int tcl_thread_stmt_get( +static int SQLITE_TCLAPI tcl_thread_stmt_get( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ diff --git a/src/test5.c b/src/test5.c index 2b49e408b6..0d9242862b 100644 --- a/src/test5.c +++ b/src/test5.c @@ -30,7 +30,7 @@ ** object with the encoded representation of the string, including ** the NULL terminator. */ -static int binarize( +static int SQLITE_TCLAPI binarize( void * clientData, Tcl_Interp *interp, int objc, @@ -58,7 +58,7 @@ static int binarize( ** If is 0, then the calls to sqlite3_value_text() are not ** actually made. */ -static int test_value_overhead( +static int SQLITE_TCLAPI test_value_overhead( void * clientData, Tcl_Interp *interp, int objc, @@ -122,7 +122,7 @@ static u8 name_to_enc(Tcl_Interp *interp, Tcl_Obj *pObj){ ** Usage: test_translate ?? ** */ -static int test_translate( +static int SQLITE_TCLAPI test_translate( void * clientData, Tcl_Interp *interp, int objc, @@ -186,7 +186,7 @@ static int test_translate( ** translation. If there is a problem an assert() will fail. **/ void sqlite3UtfSelfTest(void); -static int test_translate_selftest( +static int SQLITE_TCLAPI test_translate_selftest( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test6.c b/src/test6.c index e6eabf996a..5304bcc31f 100644 --- a/src/test6.c +++ b/src/test6.c @@ -811,7 +811,7 @@ static int processDevSymArgs( ** Simulate a crash immediately. This function does not return ** (writeListSync() calls exit(-1)). */ -static int crashNowCmd( +static int SQLITE_TCLAPI crashNowCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -832,7 +832,7 @@ static int crashNowCmd( ** Parameter ENABLE must be a boolean value. If true, then the "crash" ** vfs is added to the system. If false, it is removed. */ -static int crashEnableCmd( +static int SQLITE_TCLAPI crashEnableCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -907,7 +907,7 @@ static int crashEnableCmd( ** sqlite_crashparams -sect 1024 -char {atomic sequential} ./test.db 1 ** */ -static int crashParamsObjCmd( +static int SQLITE_TCLAPI crashParamsObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -954,7 +954,7 @@ error: return TCL_ERROR; } -static int devSymObjCmd( +static int SQLITE_TCLAPI devSymObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -977,7 +977,7 @@ static int devSymObjCmd( /* ** tclcmd: unregister_devsim */ -static int dsUnregisterObjCmd( +static int SQLITE_TCLAPI dsUnregisterObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -997,7 +997,7 @@ static int dsUnregisterObjCmd( /* ** tclcmd: register_jt_vfs ?-default? PARENT-VFS */ -static int jtObjCmd( +static int SQLITE_TCLAPI jtObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -1035,7 +1035,7 @@ static int jtObjCmd( /* ** tclcmd: unregister_jt_vfs */ -static int jtUnregisterObjCmd( +static int SQLITE_TCLAPI jtUnregisterObjCmd( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test7.c b/src/test7.c index d3b789e967..d57e4b826b 100644 --- a/src/test7.c +++ b/src/test7.c @@ -153,7 +153,7 @@ static int parse_client_id(Tcl_Interp *interp, const char *zArg){ ** NAME should be an upper case letter. Start the thread running with ** an open connection to the given database. */ -static int tcl_client_create( +static int SQLITE_TCLAPI tcl_client_create( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -206,7 +206,7 @@ static void client_wait(Thread *p){ ** ** Wait on thread ID to reach its idle state. */ -static int tcl_client_wait( +static int SQLITE_TCLAPI tcl_client_wait( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -250,7 +250,7 @@ static void stop_thread(Thread *p){ ** Cause a client thread to shut itself down. Wait for the shutdown to be ** completed. If ID is "*" then stop all client threads. */ -static int tcl_client_halt( +static int SQLITE_TCLAPI tcl_client_halt( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -298,7 +298,7 @@ static int tcl_client_halt( ** Wait on the most recent client_step to complete, then return the ** number of columns in the result set. */ -static int tcl_client_argc( +static int SQLITE_TCLAPI tcl_client_argc( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -330,7 +330,7 @@ static int tcl_client_argc( ** Wait on the most recent client_step to complete, then return the ** value of the N-th columns in the result set. */ -static int tcl_client_argv( +static int SQLITE_TCLAPI tcl_client_argv( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -366,7 +366,7 @@ static int tcl_client_argv( ** Wait on the most recent client_step to complete, then return the ** name of the N-th columns in the result set. */ -static int tcl_client_colname( +static int SQLITE_TCLAPI tcl_client_colname( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -404,7 +404,7 @@ extern const char *sqlite3ErrName(int); ** Wait on the most recent operation to complete, then return the ** result code from that operation. */ -static int tcl_client_result( +static int SQLITE_TCLAPI tcl_client_result( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -436,7 +436,7 @@ static int tcl_client_result( ** Wait on the most recent operation to complete, then return the ** error string. */ -static int tcl_client_error( +static int SQLITE_TCLAPI tcl_client_error( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -481,7 +481,7 @@ static void do_compile(Thread *p){ ** ** Compile a new virtual machine. */ -static int tcl_client_compile( +static int SQLITE_TCLAPI tcl_client_compile( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -534,7 +534,7 @@ static void do_step(Thread *p){ ** ** Advance the virtual machine by one step */ -static int tcl_client_step( +static int SQLITE_TCLAPI tcl_client_step( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -576,7 +576,7 @@ static void do_finalize(Thread *p){ ** ** Finalize the virtual machine. */ -static int tcl_client_finalize( +static int SQLITE_TCLAPI tcl_client_finalize( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -620,7 +620,7 @@ static void do_reset(Thread *p){ ** ** Finalize the virtual machine. */ -static int tcl_client_reset( +static int SQLITE_TCLAPI tcl_client_reset( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ @@ -651,7 +651,7 @@ static int tcl_client_reset( ** ** Interchange the sqlite* pointer between two threads. */ -static int tcl_client_swap( +static int SQLITE_TCLAPI tcl_client_swap( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ diff --git a/src/test8.c b/src/test8.c index e635d5ed2c..daab504e4e 100644 --- a/src/test8.c +++ b/src/test8.c @@ -1357,7 +1357,7 @@ static void moduleDestroy(void *p){ /* ** Register the echo virtual table module. */ -static int register_echo_module( +static int SQLITE_TCLAPI register_echo_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -1397,7 +1397,7 @@ static int register_echo_module( ** ** sqlite3_declare_vtab DB SQL */ -static int declare_vtab( +static int SQLITE_TCLAPI declare_vtab( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test9.c b/src/test9.c index 3c3629c0a7..5b139e8a56 100644 --- a/src/test9.c +++ b/src/test9.c @@ -26,7 +26,7 @@ /* ** c_collation_test */ -static int c_collation_test( +static int SQLITE_TCLAPI c_collation_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -67,7 +67,7 @@ error_out: /* ** c_realloc_test */ -static int c_realloc_test( +static int SQLITE_TCLAPI c_realloc_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -108,7 +108,7 @@ error_out: /* ** c_misuse_test */ -static int c_misuse_test( +static int SQLITE_TCLAPI c_misuse_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_async.c b/src/test_async.c index 8389e75dbd..c32c74c660 100644 --- a/src/test_async.c +++ b/src/test_async.c @@ -19,6 +19,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #ifdef SQLITE_ENABLE_ASYNCIO @@ -40,7 +43,7 @@ TCL_DECLARE_MUTEX(testasync_g_writerMutex); /* ** sqlite3async_initialize PARENT-VFS ISDEFAULT */ -static int testAsyncInit( +static int SQLITE_TCLAPI testAsyncInit( void * clientData, Tcl_Interp *interp, int objc, @@ -73,7 +76,7 @@ static int testAsyncInit( /* ** sqlite3async_shutdown */ -static int testAsyncShutdown( +static int SQLITE_TCLAPI testAsyncShutdown( void * clientData, Tcl_Interp *interp, int objc, @@ -97,7 +100,7 @@ static Tcl_ThreadCreateType tclWriterThread(ClientData pIsStarted){ ** ** Start a new writer thread. */ -static int testAsyncStart( +static int SQLITE_TCLAPI testAsyncStart( void * clientData, Tcl_Interp *interp, int objc, @@ -129,7 +132,7 @@ static int testAsyncStart( ** If the current writer thread is set to run forever then this ** command would block forever. To prevent that, an error is returned. */ -static int testAsyncWait( +static int SQLITE_TCLAPI testAsyncWait( void * clientData, Tcl_Interp *interp, int objc, @@ -155,7 +158,7 @@ static int testAsyncWait( /* ** sqlite3async_control OPTION ?VALUE? */ -static int testAsyncControl( +static int SQLITE_TCLAPI testAsyncControl( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_autoext.c b/src/test_autoext.c index b536cd7321..94a3223e65 100644 --- a/src/test_autoext.c +++ b/src/test_autoext.c @@ -15,6 +15,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #include "sqlite3ext.h" @@ -91,7 +94,7 @@ static int broken_init( ** ** Register the "sqr" extension to be loaded automatically. */ -static int autoExtSqrObjCmd( +static int SQLITE_TCLAPI autoExtSqrObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -107,7 +110,7 @@ static int autoExtSqrObjCmd( ** ** Unregister the "sqr" extension. */ -static int cancelAutoExtSqrObjCmd( +static int SQLITE_TCLAPI cancelAutoExtSqrObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -123,7 +126,7 @@ static int cancelAutoExtSqrObjCmd( ** ** Register the "cube" extension to be loaded automatically. */ -static int autoExtCubeObjCmd( +static int SQLITE_TCLAPI autoExtCubeObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -139,7 +142,7 @@ static int autoExtCubeObjCmd( ** ** Unregister the "cube" extension. */ -static int cancelAutoExtCubeObjCmd( +static int SQLITE_TCLAPI cancelAutoExtCubeObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -155,7 +158,7 @@ static int cancelAutoExtCubeObjCmd( ** ** Register the broken extension to be loaded automatically. */ -static int autoExtBrokenObjCmd( +static int SQLITE_TCLAPI autoExtBrokenObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -171,7 +174,7 @@ static int autoExtBrokenObjCmd( ** ** Unregister the broken extension. */ -static int cancelAutoExtBrokenObjCmd( +static int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd( void * clientData, Tcl_Interp *interp, int objc, @@ -190,7 +193,7 @@ static int cancelAutoExtBrokenObjCmd( ** ** Reset all auto-extensions */ -static int resetAutoExtObjCmd( +static int SQLITE_TCLAPI resetAutoExtObjCmd( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_backup.c b/src/test_backup.c index 3e91f1f219..9b684a28f6 100644 --- a/src/test_backup.c +++ b/src/test_backup.c @@ -17,6 +17,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #include "sqlite3.h" #include @@ -27,7 +30,7 @@ extern const char *sqlite3ErrName(int); /* These functions are implemented in test1.c. */ extern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **); -static int backupTestCmd( +static int SQLITE_TCLAPI backupTestCmd( ClientData clientData, Tcl_Interp *interp, int objc, @@ -102,7 +105,7 @@ static int backupTestCmd( return TCL_OK; } -static void backupTestFinish(ClientData clientData){ +static void SQLITE_TCLAPI backupTestFinish(ClientData clientData){ sqlite3_backup *pBackup = (sqlite3_backup *)clientData; sqlite3_backup_finish(pBackup); } @@ -111,7 +114,7 @@ static void backupTestFinish(ClientData clientData){ ** sqlite3_backup CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME ** */ -static int backupTestInit( +static int SQLITE_TCLAPI backupTestInit( ClientData clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_bestindex.c b/src/test_bestindex.c index 8e0ff00b52..94017f0349 100644 --- a/src/test_bestindex.c +++ b/src/test_bestindex.c @@ -567,7 +567,7 @@ extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); /* ** Register the echo virtual table module. */ -static int register_tcl_module( +static int SQLITE_TCLAPI register_tcl_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_blob.c b/src/test_blob.c index 703664190b..3ac6c11421 100644 --- a/src/test_blob.c +++ b/src/test_blob.c @@ -99,7 +99,7 @@ static char *blobStringFromObj(Tcl_Obj *pObj){ ** ** Tcl test harness for the sqlite3_blob_open() function. */ -static int test_blob_open( +static int SQLITE_TCLAPI test_blob_open( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* Calling TCL interpreter */ int objc, /* Number of arguments */ @@ -150,7 +150,7 @@ static int test_blob_open( /* ** sqlite3_blob_close HANDLE */ -static int test_blob_close( +static int SQLITE_TCLAPI test_blob_close( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -178,7 +178,7 @@ static int test_blob_close( /* ** sqlite3_blob_bytes HANDLE */ -static int test_blob_bytes( +static int SQLITE_TCLAPI test_blob_bytes( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -214,7 +214,7 @@ static int test_blob_bytes( ** text representation of the returned error code (i.e. "SQLITE_NOMEM") ** and a Tcl exception is thrown. */ -static int test_blob_read( +static int SQLITE_TCLAPI test_blob_read( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -266,7 +266,7 @@ static int test_blob_read( ** result is set to the text representation of the returned error code ** (i.e. "SQLITE_NOMEM") and a Tcl exception is thrown. */ -static int test_blob_write( +static int SQLITE_TCLAPI test_blob_write( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_btree.c b/src/test_btree.c index 46860afb30..03b8b207c9 100644 --- a/src/test_btree.c +++ b/src/test_btree.c @@ -26,7 +26,7 @@ ** Return a list of file that are shared and the number of ** references to each file. */ -int sqlite3BtreeSharedCacheReport( +int SQLITE_TCLAPI sqlite3BtreeSharedCacheReport( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_demovfs.c b/src/test_demovfs.c index 9cc0eb0309..ba7af863cd 100644 --- a/src/test_demovfs.c +++ b/src/test_demovfs.c @@ -645,10 +645,13 @@ sqlite3_vfs *sqlite3_demovfs(void){ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #if SQLITE_OS_UNIX -static int register_demovfs( +static int SQLITE_TCLAPI register_demovfs( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -657,7 +660,7 @@ static int register_demovfs( sqlite3_vfs_register(sqlite3_demovfs(), 1); return TCL_OK; } -static int unregister_demovfs( +static int SQLITE_TCLAPI unregister_demovfs( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_fs.c b/src/test_fs.c index 329594a5ab..87088bdae7 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -875,7 +875,7 @@ extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); /* ** Register the echo virtual table module. */ -static int register_fs_module( +static int SQLITE_TCLAPI register_fs_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_func.c b/src/test_func.c index 08ea98fb7a..6a714ef3eb 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -693,7 +693,7 @@ static int registerTestFunctions(sqlite3 *db){ ** the standard set of test functions to be loaded into each new ** database connection. */ -static int autoinstall_test_funcs( +static int SQLITE_TCLAPI autoinstall_test_funcs( void * clientData, Tcl_Interp *interp, int objc, @@ -721,7 +721,7 @@ static void tFinal(sqlite3_context *a){} ** Make various calls to sqlite3_create_function that do not have valid ** parameters. Verify that the error condition is detected and reported. */ -static int abuse_create_function( +static int SQLITE_TCLAPI abuse_create_function( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_hexio.c b/src/test_hexio.c index 88f5ed7bfa..7b62ea08bc 100644 --- a/src/test_hexio.c +++ b/src/test_hexio.c @@ -98,7 +98,7 @@ int sqlite3TestHexToBin(const unsigned char *zIn, int N, unsigned char *aOut){ ** beginning of the file. Convert that information to hexadecimal ** and return the resulting HEX string. */ -static int hexio_read( +static int SQLITE_TCLAPI hexio_read( void * clientData, Tcl_Interp *interp, int objc, @@ -148,7 +148,7 @@ static int hexio_read( ** Write DATA into file FILENAME beginning at OFFSET from the ** beginning of the file. DATA is expressed in hexadecimal. */ -static int hexio_write( +static int SQLITE_TCLAPI hexio_write( void * clientData, Tcl_Interp *interp, int objc, @@ -196,7 +196,7 @@ static int hexio_write( ** the value of that integer. HEXDATA can contain between 2 and 8 ** hexadecimal digits. */ -static int hexio_get_int( +static int SQLITE_TCLAPI hexio_get_int( void * clientData, Tcl_Interp *interp, int objc, @@ -236,7 +236,7 @@ static int hexio_get_int( ** ** Render INTEGER has a 16-bit big-endian integer in hexadecimal. */ -static int hexio_render_int16( +static int SQLITE_TCLAPI hexio_render_int16( void * clientData, Tcl_Interp *interp, int objc, @@ -263,7 +263,7 @@ static int hexio_render_int16( ** ** Render INTEGER has a 32-bit big-endian integer in hexadecimal. */ -static int hexio_render_int32( +static int SQLITE_TCLAPI hexio_render_int32( void * clientData, Tcl_Interp *interp, int objc, @@ -293,7 +293,7 @@ static int hexio_render_int32( ** The UTF8 might not be well-formed. Run this string through ** sqlite3Utf8to8() convert it back to hex and return the result. */ -static int utf8_to_utf8( +static int SQLITE_TCLAPI utf8_to_utf8( void * clientData, Tcl_Interp *interp, int objc, @@ -344,7 +344,7 @@ static int getFts3Varint(const char *p, sqlite_int64 *v){ ** Read a varint from the start of BLOB. Set variable VARNAME to contain ** the interpreted value. Return the number of bytes of BLOB consumed. */ -static int read_fts3varint( +static int SQLITE_TCLAPI read_fts3varint( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_init.c b/src/test_init.c index c66b5785d0..58465785d8 100644 --- a/src/test_init.c +++ b/src/test_init.c @@ -188,7 +188,7 @@ static void installInitWrappers(void){ sqlite3_config(SQLITE_CONFIG_PCACHE2, &pcachemethods); } -static int init_wrapper_install( +static int SQLITE_TCLAPI init_wrapper_install( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -212,7 +212,7 @@ static int init_wrapper_install( return TCL_OK; } -static int init_wrapper_uninstall( +static int SQLITE_TCLAPI init_wrapper_uninstall( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -230,7 +230,7 @@ static int init_wrapper_uninstall( return TCL_OK; } -static int init_wrapper_clear( +static int SQLITE_TCLAPI init_wrapper_clear( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -247,7 +247,7 @@ static int init_wrapper_clear( return TCL_OK; } -static int init_wrapper_query( +static int SQLITE_TCLAPI init_wrapper_query( ClientData clientData, /* Unused */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_intarray.c b/src/test_intarray.c index c27b4597c0..ddfb13fe20 100644 --- a/src/test_intarray.c +++ b/src/test_intarray.c @@ -274,6 +274,9 @@ SQLITE_API int sqlite3_intarray_bind( # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif /* @@ -290,7 +293,7 @@ extern const char *sqlite3ErrName(int); ** Invoke the sqlite3_intarray_create interface. A string that becomes ** the first parameter to sqlite3_intarray_bind. */ -static int test_intarray_create( +static int SQLITE_TCLAPI test_intarray_create( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ @@ -326,7 +329,7 @@ static int test_intarray_create( ** ** Invoke the sqlite3_intarray_bind interface on the given array of integers. */ -static int test_intarray_bind( +static int SQLITE_TCLAPI test_intarray_bind( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_malloc.c b/src/test_malloc.c index 66d8a881ba..e8c248f958 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -310,7 +310,7 @@ static int textToPointer(const char *z, void **pp){ ** ** Raw test interface for sqlite3_malloc(). */ -static int test_malloc( +static int SQLITE_TCLAPI test_malloc( void * clientData, Tcl_Interp *interp, int objc, @@ -335,7 +335,7 @@ static int test_malloc( ** ** Raw test interface for sqlite3_realloc(). */ -static int test_realloc( +static int SQLITE_TCLAPI test_realloc( void * clientData, Tcl_Interp *interp, int objc, @@ -364,7 +364,7 @@ static int test_realloc( ** ** Raw test interface for sqlite3_free(). */ -static int test_free( +static int SQLITE_TCLAPI test_free( void * clientData, Tcl_Interp *interp, int objc, @@ -395,7 +395,7 @@ int sqlite3TestBinToHex(char*,int); ** Set a chunk of memory (obtained from malloc, probably) to a ** specified hex pattern. */ -static int test_memset( +static int SQLITE_TCLAPI test_memset( void * clientData, Tcl_Interp *interp, int objc, @@ -441,7 +441,7 @@ static int test_memset( ** ** Return memory as hexadecimal text. */ -static int test_memget( +static int SQLITE_TCLAPI test_memget( void * clientData, Tcl_Interp *interp, int objc, @@ -488,7 +488,7 @@ static int test_memget( ** ** Raw test interface for sqlite3_memory_used(). */ -static int test_memory_used( +static int SQLITE_TCLAPI test_memory_used( void * clientData, Tcl_Interp *interp, int objc, @@ -503,7 +503,7 @@ static int test_memory_used( ** ** Raw test interface for sqlite3_memory_highwater(). */ -static int test_memory_highwater( +static int SQLITE_TCLAPI test_memory_highwater( void * clientData, Tcl_Interp *interp, int objc, @@ -528,7 +528,7 @@ static int test_memory_highwater( ** Set the depth of backtracing. If SQLITE_MEMDEBUG is not defined ** then this routine is a no-op. */ -static int test_memdebug_backtrace( +static int SQLITE_TCLAPI test_memdebug_backtrace( void * clientData, Tcl_Interp *interp, int objc, @@ -554,7 +554,7 @@ static int test_memdebug_backtrace( ** ** Write a summary of unfreed memory to FILENAME. */ -static int test_memdebug_dump( +static int SQLITE_TCLAPI test_memdebug_dump( void * clientData, Tcl_Interp *interp, int objc, @@ -579,7 +579,7 @@ static int test_memdebug_dump( ** ** Return the total number of times malloc() has been called. */ -static int test_memdebug_malloc_count( +static int SQLITE_TCLAPI test_memdebug_malloc_count( void * clientData, Tcl_Interp *interp, int objc, @@ -619,7 +619,7 @@ static int test_memdebug_malloc_count( ** ** To disable simulated failures, use a COUNTER of -1. */ -static int test_memdebug_fail( +static int SQLITE_TCLAPI test_memdebug_fail( void * clientData, Tcl_Interp *interp, int objc, @@ -685,7 +685,7 @@ static int test_memdebug_fail( ** simulated failure occurs. A negative return value indicates that ** no malloc() failure is scheduled. */ -static int test_memdebug_pending( +static int SQLITE_TCLAPI test_memdebug_pending( void * clientData, Tcl_Interp *interp, int objc, @@ -718,7 +718,7 @@ static int sqlite3_memdebug_title_count = 0; ** ** Each title overwrite the previous. */ -static int test_memdebug_settitle( +static int SQLITE_TCLAPI test_memdebug_settitle( void * clientData, Tcl_Interp *interp, int objc, @@ -799,7 +799,7 @@ static void test_memdebug_log_clear(void){ Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS); } -static int test_memdebug_log( +static int SQLITE_TCLAPI test_memdebug_log( void * clientData, Tcl_Interp *interp, int objc, @@ -897,7 +897,7 @@ static int test_memdebug_log( ** ** A negative SIZE causes the buffer pointer to be NULL. */ -static int test_config_scratch( +static int SQLITE_TCLAPI test_config_scratch( void * clientData, Tcl_Interp *interp, int objc, @@ -937,7 +937,7 @@ static int test_config_scratch( ** ** A negative SIZE causes the buffer pointer to be NULL. */ -static int test_config_pagecache( +static int SQLITE_TCLAPI test_config_pagecache( void * clientData, Tcl_Interp *interp, int objc, @@ -980,7 +980,7 @@ static int test_config_pagecache( ** is certainty. 0 is never. PRNG_SEED is the pseudo-random number generator ** seed. */ -static int test_alt_pcache( +static int SQLITE_TCLAPI test_alt_pcache( void * clientData, Tcl_Interp *interp, int objc, @@ -1021,7 +1021,7 @@ static int test_alt_pcache( ** ** Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS. */ -static int test_config_memstatus( +static int SQLITE_TCLAPI test_config_memstatus( void * clientData, Tcl_Interp *interp, int objc, @@ -1042,7 +1042,7 @@ static int test_config_memstatus( ** Usage: sqlite3_config_lookaside SIZE COUNT ** */ -static int test_config_lookaside( +static int SQLITE_TCLAPI test_config_lookaside( void * clientData, Tcl_Interp *interp, int objc, @@ -1076,7 +1076,7 @@ static int test_config_lookaside( ** is 10KB in size. A BUFID of 0 indicates that the buffer should be NULL ** which will cause sqlite3_db_config() to allocate space on its own. */ -static int test_db_config_lookaside( +static int SQLITE_TCLAPI test_db_config_lookaside( void * clientData, Tcl_Interp *interp, int objc, @@ -1111,7 +1111,7 @@ static int test_db_config_lookaside( /* ** Usage: sqlite3_config_heap NBYTE NMINALLOC */ -static int test_config_heap( +static int SQLITE_TCLAPI test_config_heap( void * clientData, Tcl_Interp *interp, int objc, @@ -1148,7 +1148,7 @@ static int test_config_heap( /* ** Usage: sqlite3_config_heap_size NBYTE */ -static int test_config_heap_size( +static int SQLITE_TCLAPI test_config_heap_size( void * clientData, Tcl_Interp *interp, int objc, @@ -1178,7 +1178,7 @@ static int test_config_heap_size( ** Invoke sqlite3_config() or sqlite3_db_config() with invalid ** opcodes and verify that they return errors. */ -static int test_config_error( +static int SQLITE_TCLAPI test_config_error( void * clientData, Tcl_Interp *interp, int objc, @@ -1216,7 +1216,7 @@ static int test_config_error( ** Enables or disables interpretation of URI parameters by default using ** SQLITE_CONFIG_URI. */ -static int test_config_uri( +static int SQLITE_TCLAPI test_config_uri( void * clientData, Tcl_Interp *interp, int objc, @@ -1245,7 +1245,7 @@ static int test_config_uri( ** Enables or disables the use of the covering-index scan optimization. ** SQLITE_CONFIG_COVERING_INDEX_SCAN. */ -static int test_config_cis( +static int SQLITE_TCLAPI test_config_cis( void * clientData, Tcl_Interp *interp, int objc, @@ -1273,7 +1273,7 @@ static int test_config_cis( ** ** Set the minimum PMA size. */ -static int test_config_pmasz( +static int SQLITE_TCLAPI test_config_pmasz( void * clientData, Tcl_Interp *interp, int objc, @@ -1303,7 +1303,7 @@ static int test_config_pmasz( ** ** Write a summary of unfreed memsys3 allocations to FILENAME. */ -static int test_dump_memsys3( +static int SQLITE_TCLAPI test_dump_memsys3( void * clientData, Tcl_Interp *interp, int objc, @@ -1339,7 +1339,7 @@ static int test_dump_memsys3( ** Return a list of three elements which are the sqlite3_status() return ** code, the current value, and the high-water mark value. */ -static int test_status( +static int SQLITE_TCLAPI test_status( void * clientData, Tcl_Interp *interp, int objc, @@ -1396,7 +1396,7 @@ static int test_status( ** Return a list of three elements which are the sqlite3_db_status() return ** code, the current value, and the high-water mark value. */ -static int test_db_status( +static int SQLITE_TCLAPI test_db_status( void * clientData, Tcl_Interp *interp, int objc, @@ -1457,7 +1457,7 @@ static int test_db_status( /* ** install_malloc_faultsim BOOLEAN */ -static int test_install_malloc_faultsim( +static int SQLITE_TCLAPI test_install_malloc_faultsim( void * clientData, Tcl_Interp *interp, int objc, @@ -1481,7 +1481,7 @@ static int test_install_malloc_faultsim( /* ** sqlite3_install_memsys3 */ -static int test_install_memsys3( +static int SQLITE_TCLAPI test_install_memsys3( void * clientData, Tcl_Interp *interp, int objc, @@ -1496,7 +1496,7 @@ static int test_install_memsys3( return TCL_OK; } -static int test_vfs_oom_test( +static int SQLITE_TCLAPI test_vfs_oom_test( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_multiplex.c b/src/test_multiplex.c index dffdb44941..e7ffa63a56 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -1233,6 +1233,9 @@ int sqlite3_multiplex_shutdown(int eForce){ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif extern const char *sqlite3ErrName(int); @@ -1240,7 +1243,7 @@ extern const char *sqlite3ErrName(int); /* ** tclcmd: sqlite3_multiplex_initialize NAME MAKEDEFAULT */ -static int test_multiplex_initialize( +static int SQLITE_TCLAPI test_multiplex_initialize( void * clientData, Tcl_Interp *interp, int objc, @@ -1271,7 +1274,7 @@ static int test_multiplex_initialize( /* ** tclcmd: sqlite3_multiplex_shutdown */ -static int test_multiplex_shutdown( +static int SQLITE_TCLAPI test_multiplex_shutdown( void * clientData, Tcl_Interp *interp, int objc, @@ -1299,7 +1302,7 @@ static int test_multiplex_shutdown( /* ** tclcmd: sqlite3_multiplex_dump */ -static int test_multiplex_dump( +static int SQLITE_TCLAPI test_multiplex_dump( void * clientData, Tcl_Interp *interp, int objc, @@ -1354,7 +1357,7 @@ static int test_multiplex_dump( /* ** Tclcmd: test_multiplex_control HANDLE DBNAME SUB-COMMAND ?INT-VALUE? */ -static int test_multiplex_control( +static int SQLITE_TCLAPI test_multiplex_control( ClientData cd, Tcl_Interp *interp, int objc, diff --git a/src/test_mutex.c b/src/test_mutex.c index 22375197b7..8f43e5ad30 100644 --- a/src/test_mutex.c +++ b/src/test_mutex.c @@ -156,7 +156,7 @@ static void counterMutexLeave(sqlite3_mutex *p){ /* ** sqlite3_shutdown */ -static int test_shutdown( +static int SQLITE_TCLAPI test_shutdown( void * clientData, Tcl_Interp *interp, int objc, @@ -177,7 +177,7 @@ static int test_shutdown( /* ** sqlite3_initialize */ -static int test_initialize( +static int SQLITE_TCLAPI test_initialize( void * clientData, Tcl_Interp *interp, int objc, @@ -198,7 +198,7 @@ static int test_initialize( /* ** install_mutex_counters BOOLEAN */ -static int test_install_mutex_counters( +static int SQLITE_TCLAPI test_install_mutex_counters( void * clientData, Tcl_Interp *interp, int objc, @@ -259,7 +259,7 @@ static int test_install_mutex_counters( /* ** read_mutex_counters */ -static int test_read_mutex_counters( +static int SQLITE_TCLAPI test_read_mutex_counters( void * clientData, Tcl_Interp *interp, int objc, @@ -288,7 +288,7 @@ static int test_read_mutex_counters( /* ** clear_mutex_counters */ -static int test_clear_mutex_counters( +static int SQLITE_TCLAPI test_clear_mutex_counters( void * clientData, Tcl_Interp *interp, int objc, @@ -312,7 +312,7 @@ static int test_clear_mutex_counters( ** will be invalid since the mutex has already been freed. The ** return pointer just checks to see if the mutex really was allocated. */ -static int test_alloc_mutex( +static int SQLITE_TCLAPI test_alloc_mutex( void * clientData, Tcl_Interp *interp, int objc, @@ -339,7 +339,7 @@ static int test_alloc_mutex( ** ** Or OPTION can be an raw integer. */ -static int test_config( +static int SQLITE_TCLAPI test_config( void * clientData, Tcl_Interp *interp, int objc, @@ -401,7 +401,7 @@ static sqlite3_mutex *getStaticMutexPointer( return counterMutexAlloc(iMutex); } -static int test_enter_static_mutex( +static int SQLITE_TCLAPI test_enter_static_mutex( void * clientData, Tcl_Interp *interp, int objc, @@ -420,7 +420,7 @@ static int test_enter_static_mutex( return TCL_OK; } -static int test_leave_static_mutex( +static int SQLITE_TCLAPI test_leave_static_mutex( void * clientData, Tcl_Interp *interp, int objc, @@ -439,7 +439,7 @@ static int test_leave_static_mutex( return TCL_OK; } -static int test_enter_db_mutex( +static int SQLITE_TCLAPI test_enter_db_mutex( void * clientData, Tcl_Interp *interp, int objc, @@ -458,7 +458,7 @@ static int test_enter_db_mutex( return TCL_OK; } -static int test_leave_db_mutex( +static int SQLITE_TCLAPI test_leave_db_mutex( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_osinst.c b/src/test_osinst.c index 5ab8ed5c93..a008baba45 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -1108,9 +1108,12 @@ int sqlite3_vfslog_register(sqlite3 *db){ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif -static int test_vfslog( +static int SQLITE_TCLAPI test_vfslog( void *clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_quota.c b/src/test_quota.c index 8ea48e5b53..e87e9772f6 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -111,7 +111,7 @@ struct quotaFile { /* ** An instance of the following object represents each open connection -** to a file that participates in quota tracking. This object is a +** to a file that participates in quota tracking. This object is a ** subclass of sqlite3_file. The sqlite3_file object for the underlying ** VFS is appended to this structure. */ @@ -154,11 +154,11 @@ static struct { */ sqlite3_vfs sThisVfs; - /* The sIoMethods defines the methods used by sqlite3_file objects + /* The sIoMethods defines the methods used by sqlite3_file objects ** associated with this shim. It is initialized at start-time and does ** not require a mutex. ** - ** When the underlying VFS is called to open a file, it might return + ** When the underlying VFS is called to open a file, it might return ** either a version 1 or a version 2 sqlite3_file object. This shim ** has to create a wrapper sqlite3_file of the same version. Hence ** there are two I/O method structures, one for version 1 and the other @@ -190,7 +190,7 @@ static struct { static void quotaEnter(void){ sqlite3_mutex_enter(gQuota.pMutex); } static void quotaLeave(void){ sqlite3_mutex_leave(gQuota.pMutex); } -/* Count the number of open files in a quotaGroup +/* Count the number of open files in a quotaGroup */ static int quotaGroupOpenFileCount(quotaGroup *pGroup){ int N = 0; @@ -399,7 +399,7 @@ static char *quota_utf8_to_mbcs(const char *zUtf8){ return zMbcs; #else return (char*)zUtf8; /* No-op on unix */ -#endif +#endif } /* @@ -410,7 +410,7 @@ static void quota_mbcs_free(char *zOld){ sqlite3_free(zOld); #else /* No-op on unix */ -#endif +#endif } /************************* VFS Method Wrappers *****************************/ @@ -428,7 +428,7 @@ static int quotaOpen( int flags, /* Flags to control the opening */ int *pOutFlags /* Flags showing results of opening */ ){ - int rc; /* Result code */ + int rc; /* Result code */ quotaConn *pQuotaOpen; /* The new quota file descriptor */ quotaFile *pFile; /* Corresponding quotaFile obj */ quotaGroup *pGroup; /* The group file belongs to */ @@ -488,7 +488,7 @@ static int quotaDelete( const char *zName, /* Name of file to be deleted */ int syncDir /* Do a directory sync after deleting */ ){ - int rc; /* Result code */ + int rc; /* Result code */ quotaFile *pFile; /* Files in the quota */ quotaGroup *pGroup; /* The group file belongs to */ sqlite3_vfs *pOrigVfs = gQuota.pOrigVfs; /* Real VFS */ @@ -581,7 +581,7 @@ static int quotaWrite( szNew = pGroup->iSize - pFile->iSize + iEnd; if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){ if( pGroup->xCallback ){ - pGroup->xCallback(pFile->zFilename, &pGroup->iLimit, szNew, + pGroup->xCallback(pFile->zFilename, &pGroup->iLimit, szNew, pGroup->pArg); } if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){ @@ -738,7 +738,7 @@ static int quotaShmUnmap(sqlite3_file *pConn, int deleteFlag){ /* ** Initialize the quota VFS shim. Use the VFS named zOrigVfsName ** as the VFS that does the actual work. Use the default if -** zOrigVfsName==NULL. +** zOrigVfsName==NULL. ** ** The quota VFS shim is named "quota". It will become the default ** VFS if makeDefault is non-zero. @@ -908,7 +908,7 @@ int sqlite3_quota_file(const char *zFilename){ if( rc==SQLITE_OK ){ zFull[strlen(zFull)+1] = '\0'; - rc = quotaOpen(&gQuota.sThisVfs, zFull, fd, + rc = quotaOpen(&gQuota.sThisVfs, zFull, fd, SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_DB, &outFlags); if( rc==SQLITE_OK ){ fd->pMethods->xFileSize(fd, &iSize); @@ -1016,7 +1016,7 @@ size_t sqlite3_quota_fwrite( szNew = pGroup->iSize - pFile->iSize + iEnd; if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){ if( pGroup->xCallback ){ - pGroup->xCallback(pFile->zFilename, &pGroup->iLimit, szNew, + pGroup->xCallback(pFile->zFilename, &pGroup->iLimit, szNew, pGroup->pArg); } if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){ @@ -1203,7 +1203,7 @@ sqlite3_int64 sqlite3_quota_file_truesize(quota_FILE *p){ sqlite3_int64 sqlite3_quota_file_size(quota_FILE *p){ return p->pFile ? p->pFile->iSize : -1; } - + /* ** Determine the amount of data in bytes available for reading ** in the given file. @@ -1275,13 +1275,16 @@ int sqlite3_quota_remove(const char *zFilename){ sqlite3_free(zFull); return rc; } - + /***************************** Test Code ***********************************/ #ifdef SQLITE_TEST #if defined(INCLUDE_SQLITE_TCL_H) # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif /* @@ -1354,7 +1357,7 @@ static void tclCallbackDestructor(void *pObj){ /* ** tclcmd: sqlite3_quota_initialize NAME MAKEDEFAULT */ -static int test_quota_initialize( +static int SQLITE_TCLAPI test_quota_initialize( void * clientData, Tcl_Interp *interp, int objc, @@ -1383,7 +1386,7 @@ static int test_quota_initialize( /* ** tclcmd: sqlite3_quota_shutdown */ -static int test_quota_shutdown( +static int SQLITE_TCLAPI test_quota_shutdown( void * clientData, Tcl_Interp *interp, int objc, @@ -1406,7 +1409,7 @@ static int test_quota_shutdown( /* ** tclcmd: sqlite3_quota_set PATTERN LIMIT SCRIPT */ -static int test_quota_set( +static int SQLITE_TCLAPI test_quota_set( void * clientData, Tcl_Interp *interp, int objc, @@ -1460,7 +1463,7 @@ static int test_quota_set( /* ** tclcmd: sqlite3_quota_file FILENAME */ -static int test_quota_file( +static int SQLITE_TCLAPI test_quota_file( void * clientData, Tcl_Interp *interp, int objc, @@ -1486,7 +1489,7 @@ static int test_quota_file( /* ** tclcmd: sqlite3_quota_dump */ -static int test_quota_dump( +static int SQLITE_TCLAPI test_quota_dump( void * clientData, Tcl_Interp *interp, int objc, @@ -1534,7 +1537,7 @@ static int test_quota_dump( /* ** tclcmd: sqlite3_quota_fopen FILENAME MODE */ -static int test_quota_fopen( +static int SQLITE_TCLAPI test_quota_fopen( void * clientData, Tcl_Interp *interp, int objc, @@ -1564,7 +1567,7 @@ extern void *sqlite3TestTextToPtr(const char*); /* ** tclcmd: sqlite3_quota_fread HANDLE SIZE NELEM */ -static int test_quota_fread( +static int SQLITE_TCLAPI test_quota_fread( void * clientData, Tcl_Interp *interp, int objc, @@ -1598,7 +1601,7 @@ static int test_quota_fread( /* ** tclcmd: sqlite3_quota_fwrite HANDLE SIZE NELEM CONTENT */ -static int test_quota_fwrite( +static int SQLITE_TCLAPI test_quota_fwrite( void * clientData, Tcl_Interp *interp, int objc, @@ -1626,7 +1629,7 @@ static int test_quota_fwrite( /* ** tclcmd: sqlite3_quota_fclose HANDLE */ -static int test_quota_fclose( +static int SQLITE_TCLAPI test_quota_fclose( void * clientData, Tcl_Interp *interp, int objc, @@ -1648,7 +1651,7 @@ static int test_quota_fclose( /* ** tclcmd: sqlite3_quota_fflush HANDLE ?HARDSYNC? */ -static int test_quota_fflush( +static int SQLITE_TCLAPI test_quota_fflush( void * clientData, Tcl_Interp *interp, int objc, @@ -1674,7 +1677,7 @@ static int test_quota_fflush( /* ** tclcmd: sqlite3_quota_fseek HANDLE OFFSET WHENCE */ -static int test_quota_fseek( +static int SQLITE_TCLAPI test_quota_fseek( void * clientData, Tcl_Interp *interp, int objc, @@ -1712,7 +1715,7 @@ static int test_quota_fseek( /* ** tclcmd: sqlite3_quota_rewind HANDLE */ -static int test_quota_rewind( +static int SQLITE_TCLAPI test_quota_rewind( void * clientData, Tcl_Interp *interp, int objc, @@ -1731,7 +1734,7 @@ static int test_quota_rewind( /* ** tclcmd: sqlite3_quota_ftell HANDLE */ -static int test_quota_ftell( +static int SQLITE_TCLAPI test_quota_ftell( void * clientData, Tcl_Interp *interp, int objc, @@ -1752,7 +1755,7 @@ static int test_quota_ftell( /* ** tclcmd: sqlite3_quota_ftruncate HANDLE SIZE */ -static int test_quota_ftruncate( +static int SQLITE_TCLAPI test_quota_ftruncate( void * clientData, Tcl_Interp *interp, int objc, @@ -1777,7 +1780,7 @@ static int test_quota_ftruncate( /* ** tclcmd: sqlite3_quota_file_size HANDLE */ -static int test_quota_file_size( +static int SQLITE_TCLAPI test_quota_file_size( void * clientData, Tcl_Interp *interp, int objc, @@ -1798,7 +1801,7 @@ static int test_quota_file_size( /* ** tclcmd: sqlite3_quota_file_truesize HANDLE */ -static int test_quota_file_truesize( +static int SQLITE_TCLAPI test_quota_file_truesize( void * clientData, Tcl_Interp *interp, int objc, @@ -1819,7 +1822,7 @@ static int test_quota_file_truesize( /* ** tclcmd: sqlite3_quota_file_mtime HANDLE */ -static int test_quota_file_mtime( +static int SQLITE_TCLAPI test_quota_file_mtime( void * clientData, Tcl_Interp *interp, int objc, @@ -1842,7 +1845,7 @@ static int test_quota_file_mtime( /* ** tclcmd: sqlite3_quota_remove FILENAME */ -static int test_quota_remove( +static int SQLITE_TCLAPI test_quota_remove( void * clientData, Tcl_Interp *interp, int objc, @@ -1866,7 +1869,7 @@ static int test_quota_remove( ** Test the glob pattern matching. Return 1 if TEXT matches PATTERN ** and return 0 if it does not. */ -static int test_quota_glob( +static int SQLITE_TCLAPI test_quota_glob( void * clientData, Tcl_Interp *interp, int objc, @@ -1892,7 +1895,7 @@ static int test_quota_glob( ** Return the number of bytes from the current file point to the end of ** the file. */ -static int test_quota_file_available( +static int SQLITE_TCLAPI test_quota_file_available( void * clientData, Tcl_Interp *interp, int objc, @@ -1915,7 +1918,7 @@ static int test_quota_file_available( ** ** Return true if the file handle is in the error state. */ -static int test_quota_ferror( +static int SQLITE_TCLAPI test_quota_ferror( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_rtree.c b/src/test_rtree.c index 1f15566f97..0c6dbf3cd7 100644 --- a/src/test_rtree.c +++ b/src/test_rtree.c @@ -440,7 +440,7 @@ static int cube_geom( } #endif /* SQLITE_ENABLE_RTREE */ -static int register_cube_geom( +static int SQLITE_TCLAPI register_cube_geom( void * clientData, Tcl_Interp *interp, int objc, @@ -468,7 +468,7 @@ static int register_cube_geom( return TCL_OK; } -static int register_circle_geom( +static int SQLITE_TCLAPI register_circle_geom( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_schema.c b/src/test_schema.c index f2bd3b3520..cdf085797f 100644 --- a/src/test_schema.c +++ b/src/test_schema.c @@ -306,7 +306,7 @@ extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); /* ** Register the schema virtual table module. */ -static int register_schema_module( +static int SQLITE_TCLAPI register_schema_module( ClientData clientData, /* Not used */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_superlock.c b/src/test_superlock.c index cad5b51f0f..45d0d623a0 100644 --- a/src/test_superlock.c +++ b/src/test_superlock.c @@ -260,6 +260,9 @@ int sqlite3demo_superlock( # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif struct InterpAndScript { @@ -268,11 +271,11 @@ struct InterpAndScript { }; typedef struct InterpAndScript InterpAndScript; -static void superunlock_del(ClientData cd){ +static void SQLITE_TCLAPI superunlock_del(ClientData cd){ sqlite3demo_superunlock((void *)cd); } -static int superunlock_cmd( +static int SQLITE_TCLAPI superunlock_cmd( ClientData cd, Tcl_Interp *interp, int objc, @@ -304,7 +307,7 @@ static int superlock_busy(void *pCtx, int nBusy){ /* ** Tclcmd: sqlite3demo_superlock CMDNAME PATH VFS BUSY-HANDLER-SCRIPT */ -static int superlock_cmd( +static int SQLITE_TCLAPI superlock_cmd( ClientData cd, Tcl_Interp *interp, int objc, diff --git a/src/test_syscall.c b/src/test_syscall.c index eab9895186..947f9a9d9d 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -422,7 +422,7 @@ static void *ts_mremap(void *a, size_t b, size_t c, int d, ...){ return orig_mremap(a, b, c, d, pArg); } -static int test_syscall_install( +static int SQLITE_TCLAPI test_syscall_install( void * clientData, Tcl_Interp *interp, int objc, @@ -458,7 +458,7 @@ static int test_syscall_install( return TCL_OK; } -static int test_syscall_uninstall( +static int SQLITE_TCLAPI test_syscall_uninstall( void * clientData, Tcl_Interp *interp, int objc, @@ -482,7 +482,7 @@ static int test_syscall_uninstall( return TCL_OK; } -static int test_syscall_reset( +static int SQLITE_TCLAPI test_syscall_reset( void * clientData, Tcl_Interp *interp, int objc, @@ -520,7 +520,7 @@ static int test_syscall_reset( return TCL_OK; } -static int test_syscall_exists( +static int SQLITE_TCLAPI test_syscall_exists( void * clientData, Tcl_Interp *interp, int objc, @@ -541,7 +541,7 @@ static int test_syscall_exists( return TCL_OK; } -static int test_syscall_fault( +static int SQLITE_TCLAPI test_syscall_fault( void * clientData, Tcl_Interp *interp, int objc, @@ -570,7 +570,7 @@ static int test_syscall_fault( return TCL_OK; } -static int test_syscall_errno( +static int SQLITE_TCLAPI test_syscall_errno( void * clientData, Tcl_Interp *interp, int objc, @@ -616,7 +616,7 @@ static int test_syscall_errno( return TCL_OK; } -static int test_syscall_list( +static int SQLITE_TCLAPI test_syscall_list( void * clientData, Tcl_Interp *interp, int objc, @@ -646,7 +646,7 @@ static int test_syscall_list( return TCL_OK; } -static int test_syscall_defaultvfs( +static int SQLITE_TCLAPI test_syscall_defaultvfs( void * clientData, Tcl_Interp *interp, int objc, @@ -668,7 +668,7 @@ static int ts_getpagesize(void){ return gSyscall.pgsz; } -static int test_syscall_pagesize( +static int SQLITE_TCLAPI test_syscall_pagesize( void * clientData, Tcl_Interp *interp, int objc, @@ -703,7 +703,7 @@ static int test_syscall_pagesize( return TCL_OK; } -static int test_syscall( +static int SQLITE_TCLAPI test_syscall( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_tclvar.c b/src/test_tclvar.c index 95a065c853..8f7352112d 100644 --- a/src/test_tclvar.c +++ b/src/test_tclvar.c @@ -411,7 +411,7 @@ extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); /* ** Register the echo virtual table module. */ -static int register_tclvar_module( +static int SQLITE_TCLAPI register_tclvar_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ diff --git a/src/test_thread.c b/src/test_thread.c index 1fd646e769..d67b4be10b 100644 --- a/src/test_thread.c +++ b/src/test_thread.c @@ -76,7 +76,7 @@ extern int sqlite3TestErrCode(Tcl_Interp *, sqlite3 *, int); /* ** Handler for events of type EvalEvent. */ -static int tclScriptEvent(Tcl_Event *evPtr, int flags){ +static int SQLITE_TCLAPI tclScriptEvent(Tcl_Event *evPtr, int flags){ int rc; EvalEvent *p = (EvalEvent *)evPtr; rc = Tcl_Eval(p->interp, p->zScript); @@ -171,7 +171,7 @@ static Tcl_ThreadCreateType tclScriptThread(ClientData pSqlThread){ ** ** The caller can wait for the script to terminate using [vwait VARNAME]. */ -static int sqlthread_spawn( +static int SQLITE_TCLAPI sqlthread_spawn( ClientData clientData, Tcl_Interp *interp, int objc, @@ -224,7 +224,7 @@ static int sqlthread_spawn( ** ** NOTE: At the moment, this doesn't work. FIXME. */ -static int sqlthread_parent( +static int SQLITE_TCLAPI sqlthread_parent( ClientData clientData, Tcl_Interp *interp, int objc, @@ -269,7 +269,7 @@ static int xBusy(void *pArg, int nBusy){ ** Open a database handle and return the string representation of ** the pointer value. */ -static int sqlthread_open( +static int SQLITE_TCLAPI sqlthread_open( ClientData clientData, Tcl_Interp *interp, int objc, @@ -319,7 +319,7 @@ static int sqlthread_open( ** Return the current thread-id (Tcl_GetCurrentThread()) cast to ** an integer. */ -static int sqlthread_id( +static int SQLITE_TCLAPI sqlthread_id( ClientData clientData, Tcl_Interp *interp, int objc, @@ -337,7 +337,7 @@ static int sqlthread_id( /* ** Dispatch routine for the sub-commands of [sqlthread]. */ -static int sqlthread_proc( +static int SQLITE_TCLAPI sqlthread_proc( ClientData clientData, Tcl_Interp *interp, int objc, @@ -385,7 +385,7 @@ static int sqlthread_proc( ** implemented as a script in Tcl 8.5, it is not usually available to ** testfixture. */ -static int clock_seconds_proc( +static int SQLITE_TCLAPI clock_seconds_proc( ClientData clientData, Tcl_Interp *interp, int objc, @@ -547,7 +547,7 @@ int sqlite3_blocking_prepare_v2( ** ** Advance the statement to the next row. */ -static int blocking_step_proc( +static int SQLITE_TCLAPI blocking_step_proc( void * clientData, Tcl_Interp *interp, int objc, @@ -573,7 +573,7 @@ static int blocking_step_proc( ** Usage: sqlite3_blocking_prepare_v2 DB sql bytes ?tailvar? ** Usage: sqlite3_nonblocking_prepare_v2 DB sql bytes ?tailvar? */ -static int blocking_prepare_v2_proc( +static int SQLITE_TCLAPI blocking_prepare_v2_proc( void * clientData, Tcl_Interp *interp, int objc, diff --git a/src/test_vfs.c b/src/test_vfs.c index acc1c6682e..fb987a6163 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -1040,7 +1040,7 @@ static int tvfsUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *p){ return sqlite3OsUnfetch(pFd->pReal, iOfst, p); } -static int testvfs_obj_cmd( +static int SQLITE_TCLAPI testvfs_obj_cmd( ClientData cd, Tcl_Interp *interp, int objc, @@ -1352,7 +1352,7 @@ static int testvfs_obj_cmd( return TCL_OK; } -static void testvfs_obj_del(ClientData cd){ +static void SQLITE_TCLAPI testvfs_obj_del(ClientData cd){ Testvfs *p = (Testvfs *)cd; if( p->pScript ) Tcl_DecrRefCount(p->pScript); sqlite3_vfs_unregister(p->pVfs); @@ -1395,7 +1395,7 @@ static void testvfs_obj_del(ClientData cd){ ** ** where LOCK is of the form "OFFSET NBYTE lock/unlock shared/exclusive" */ -static int testvfs_cmd( +static int SQLITE_TCLAPI testvfs_cmd( ClientData cd, Tcl_Interp *interp, int objc, From aa0325872fa725d1c2622d3bd4f8b87a7c137bc3 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Jul 2016 17:24:16 +0000 Subject: [PATCH 247/302] Improvements to the way the COMPILER compile-time option is set when compiling with Clang. FossilOrigin-Name: 81f9cf86c48f3cd43755ded4dc97388ec650f8af --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/ctime.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d4a4aa1bdd..c71c10048d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\stest\scase\sto\sinsure\slegacy\sCREATE\sTABLE\ssyntax\sis\ssupported. -D 2016-07-28T12:52:30.552 +C Improvements\sto\sthe\sway\sthe\sCOMPILER\scompile-time\soption\sis\sset\swhen\scompiling\nwith\sClang. +D 2016-07-28T17:24:16.495 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -333,7 +333,7 @@ F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 61949e83c4c36e37195a8398ebc752780b534d95 +F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7 F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9e2b26811452a5011d0a97a689636fa4409da856 -R d76a2fc86bbf1915af6bf1dd54a28237 +P 6feff15cae8f0427be790355841d49c479c1c586 +R 675b3da4289ec2d84ea94ee475054664 U drh -Z 803b725d666d5af434be7409c67eabe6 +Z 0881f39f36c917424fb94c651f3aec11 diff --git a/manifest.uuid b/manifest.uuid index f4495ea5c1..060502d932 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6feff15cae8f0427be790355841d49c479c1c586 \ No newline at end of file +81f9cf86c48f3cd43755ded4dc97388ec650f8af \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 1a7c69f3bf..09587ea88e 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -45,8 +45,10 @@ static const char * const azCompileOpt[] = { #if SQLITE_CHECK_PAGES "CHECK_PAGES", #endif -#if defined(__clang__) && defined(__clang_version__) - "COMPILER=clang-" __clang_version__, +#if defined(__clang__) && defined(__clang_major__) + "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "." + CTIMEOPT_VAL(__clang_minor__) "." + CTIMEOPT_VAL(__clang_patchlevel__), #elif defined(_MSC_VER) "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), #elif defined(__GNUC__) && defined(__VERSION__) From a121cc7c60e13e5dae02176631a72e3333f70302 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 18:06:52 +0000 Subject: [PATCH 248/302] Adjustments to get 'testfixture.exe' compiling with Tcl 8.6 when __stdcall is enabled. FossilOrigin-Name: 90e89ec9c8efff057a9e43c612427fc5c97ab52d --- Makefile.msc | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 4a8283731d..ca3e19aab8 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1994,7 +1994,7 @@ sqlite_tclDecls.h: echo # define SQLITE_TCLAPI >> sqlite_tclDecls.h echo #endif >> sqlite_tclDecls.h type "$(TCLINCDIR)\tclDecls.h" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?.*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN(?: CONST\d+?)?\s+?[^\(]*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tcl_" "(SQLITE_TCLAPI *tcl_" \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tclFreeObj" "(SQLITE_TCLAPI *tclFreeObj" >> sqlite_tclDecls.h diff --git a/manifest b/manifest index 1be1262c7e..4e202a429f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Make\ssure\sthe\sSQLITE_TCLAPI\smacro\sis\salways\sdefined. -D 2016-07-28T17:11:20.162 +C Adjustments\sto\sget\s'testfixture.exe'\scompiling\swith\sTcl\s8.6\swhen\s__stdcall\sis\senabled. +D 2016-07-28T18:06:52.992 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 1e5399407885d69150e2659f4710b5712a1e6cef +F Makefile.msc c7934e2d3ef07c440ad48e2233c0cc8364e72aff F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -392,7 +392,7 @@ F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c a9c6e33c44efa93d176ce5e0887d5d533c98b429 +F src/tclsqlite.c 342379845d52c62a778c76c3dd0a2695af723e04 F src/test1.c 906a04b649c7139e943193a3905d583e325c30c7 F src/test2.c b7174313e993754303a8b33c43df7c44b46857ab F src/test3.c 1339a40be39650ae83894b6578f971dc7f96ea8a @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 36b72fd609cf151f3db0e65b450d7cd515f2ac49 -R cb104ece8c53bb381905efecad762caf +P f2f1323cc4d2ad2d6794dbfae8d50b747213e85d +R f48b462f2c7e74ed51a21c0e6f026658 U mistachkin -Z 5c80ddf3854cd75da2e73aafdf02283f +Z 339efe4a28b4c084d0a9150e8c742a8a diff --git a/manifest.uuid b/manifest.uuid index 1a85a325af..e9bf450c4c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f2f1323cc4d2ad2d6794dbfae8d50b747213e85d \ No newline at end of file +90e89ec9c8efff057a9e43c612427fc5c97ab52d \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 527dc488ee..bc94a5ff7f 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1151,7 +1151,7 @@ static char *local_getline(char *zPrompt, FILE *in){ ** It is invoked after evaluating the script SCRIPT to commit or rollback ** the transaction or savepoint opened by the [transaction] command. */ -static int DbTransPostCmd( +static int SQLITE_TCLAPI DbTransPostCmd( ClientData data[], /* data[0] is the Sqlite3Db* for $db */ Tcl_Interp *interp, /* Tcl interpreter */ int result /* Result of evaluating SCRIPT */ @@ -1698,7 +1698,7 @@ static int DbUseNre(void){ ** ** $db eval SQL ?ARRAYNAME? SCRIPT */ -static int DbEvalNextCmd( +static int SQLITE_TCLAPI DbEvalNextCmd( ClientData data[], /* data[0] is the (DbEvalContext*) */ Tcl_Interp *interp, /* Tcl interpreter */ int result /* Result so far */ @@ -3256,7 +3256,7 @@ static int SQLITE_TCLAPI DbObjCmd( ** Adaptor that provides an objCmd interface to the NRE-enabled ** interface implementation. */ -static int DbObjCmdAdaptor( +static int SQLITE_TCLAPI DbObjCmdAdaptor( void *cd, Tcl_Interp *interp, int objc, From 7c60b266913db65ced9210a9cc4e50d15356f48c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 18:18:53 +0000 Subject: [PATCH 249/302] Fixup reserved function pointers in the Tcl stubs table and several macros containing Tcl function pointers. FossilOrigin-Name: 959cd0131a5c717679b6e250229794679efe7f69 --- Makefile.msc | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index ca3e19aab8..1257ce2ba3 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1997,7 +1997,8 @@ sqlite_tclDecls.h: | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN(?: CONST\d+?)?\s+?[^\(]*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tcl_" "(SQLITE_TCLAPI *tcl_" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tclFreeObj" "(SQLITE_TCLAPI *tclFreeObj" >> sqlite_tclDecls.h + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tclFreeObj" "(SQLITE_TCLAPI *tclFreeObj" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_TCLAPI *" >> sqlite_tclDecls.h sqlite_tcl.h: sqlite_tclDecls.h type "$(TCLINCDIR)\tcl.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact tclDecls.h sqlite_tclDecls.h \ diff --git a/manifest b/manifest index 4e202a429f..990660b97b 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Adjustments\sto\sget\s'testfixture.exe'\scompiling\swith\sTcl\s8.6\swhen\s__stdcall\sis\senabled. -D 2016-07-28T18:06:52.992 +C Fixup\sreserved\sfunction\spointers\sin\sthe\sTcl\sstubs\stable\sand\sseveral\smacros\scontaining\sTcl\sfunction\spointers. +D 2016-07-28T18:18:53.411 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc c7934e2d3ef07c440ad48e2233c0cc8364e72aff +F Makefile.msc 959d56a9c117c3dc6f407a71aaa9fbad2df0b3c7 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f2f1323cc4d2ad2d6794dbfae8d50b747213e85d -R f48b462f2c7e74ed51a21c0e6f026658 +P 90e89ec9c8efff057a9e43c612427fc5c97ab52d +R d171dcc0a06f2c3b789ca76207152f9d U mistachkin -Z 339efe4a28b4c084d0a9150e8c742a8a +Z 48ca1d4dc91e624fdf594bf2bfd310c3 diff --git a/manifest.uuid b/manifest.uuid index e9bf450c4c..1992938c42 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90e89ec9c8efff057a9e43c612427fc5c97ab52d \ No newline at end of file +959cd0131a5c717679b6e250229794679efe7f69 \ No newline at end of file From a8914faaaa981c87f193eb62477e7ba7d0affeed Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 28 Jul 2016 18:38:13 +0000 Subject: [PATCH 250/302] Disable the authorizer callback when reparsing the schema. This avoids undesirable authorization failures following an ALTER TABLE. FossilOrigin-Name: 805d01cdabb48a69eb986a7f084e53eb25d76b7f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/auth.c | 1 + test/auth2.test | 12 ------------ test/auth3.test | 21 +++++++++++++++++++-- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index c71c10048d..b3d969ce87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sway\sthe\sCOMPILER\scompile-time\soption\sis\sset\swhen\scompiling\nwith\sClang. -D 2016-07-28T17:24:16.495 +C Disable\sthe\sauthorizer\scallback\swhen\sreparsing\sthe\sschema.\s\sThis\savoids\nundesirable\sauthorization\sfailures\sfollowing\san\sALTER\sTABLE. +D 2016-07-28T18:38:13.187 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -323,7 +323,7 @@ F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c cc28ab933ae615b22add0d609794ffb6596b42ea F src/analyze.c 37fedc80ac966ce1745811746e68e4d8fa64c7fe F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22 -F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 +F src/auth.c 5c8e0f37f785f935f589496801edd19840485853 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 @@ -506,8 +506,8 @@ F test/attach3.test 359eb65d00102cdfcef6fa4e81dc1648f8f80b27 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0 F test/auth.test 872a122b3977c1d1bb9fd637dc20016e5c01880f -F test/auth2.test 264c6af53cad9aba5218c68bbe18036e39007bfa -F test/auth3.test 5cfa94ed90c6617c42b7ba4b133fd79678b251c7 +F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1 +F test/auth3.test b810826b193831929951c0d50783a200e5ef6b72 F test/autoinc.test c58912526998a39e11f66b533e23cfabea7f25b7 F test/autoindex1.test 14b63a9f1e405fe6d5bfc8c8d00249c2ebaf13ea F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6feff15cae8f0427be790355841d49c479c1c586 -R 675b3da4289ec2d84ea94ee475054664 +P 81f9cf86c48f3cd43755ded4dc97388ec650f8af +R ae8bfc7314166cec8de9b44e7e9859e8 U drh -Z 0881f39f36c917424fb94c651f3aec11 +Z 7b0f6930a62d02daa8f4147d6dafd3a6 diff --git a/manifest.uuid b/manifest.uuid index 060502d932..53827a1161 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -81f9cf86c48f3cd43755ded4dc97388ec650f8af \ No newline at end of file +805d01cdabb48a69eb986a7f084e53eb25d76b7f \ No newline at end of file diff --git a/src/auth.c b/src/auth.c index 9768fc2fc0..8a3f8e7d08 100644 --- a/src/auth.c +++ b/src/auth.c @@ -111,6 +111,7 @@ int sqlite3AuthReadCol( char *zDb = db->aDb[iDb].zName; /* Name of attached database */ int rc; /* Auth callback return code */ + if( db->init.busy ) return SQLITE_OK; rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext #ifdef SQLITE_USER_AUTHENTICATION ,db->auth.zAuthUser diff --git a/test/auth2.test b/test/auth2.test index a9d64d08af..08d46cac57 100644 --- a/test/auth2.test +++ b/test/auth2.test @@ -98,12 +98,6 @@ SQLITE_UPDATE sqlite_master tbl_name main {} SQLITE_UPDATE sqlite_master rootpage main {} SQLITE_UPDATE sqlite_master sql main {} SQLITE_READ sqlite_master ROWID main {} -SQLITE_READ sqlite_master name main {} -SQLITE_READ sqlite_master rootpage main {} -SQLITE_READ sqlite_master sql main {} -SQLITE_READ sqlite_master tbl_name main {} -SQLITE_READ sqlite_master type main {} -SQLITE_READ sqlite_master ROWID main {} } do_test auth2-2.2 { set ::authargs {} @@ -119,12 +113,6 @@ SQLITE_UPDATE sqlite_master tbl_name main {} SQLITE_UPDATE sqlite_master rootpage main {} SQLITE_UPDATE sqlite_master sql main {} SQLITE_READ sqlite_master ROWID main {} -SQLITE_READ sqlite_master name main {} -SQLITE_READ sqlite_master rootpage main {} -SQLITE_READ sqlite_master sql main {} -SQLITE_READ sqlite_master tbl_name main {} -SQLITE_READ sqlite_master type main {} -SQLITE_READ sqlite_master ROWID main {} } do_test auth2-2.3 { set ::authargs {} diff --git a/test/auth3.test b/test/auth3.test index eef10b398f..ca7e16c84c 100644 --- a/test/auth3.test +++ b/test/auth3.test @@ -12,8 +12,7 @@ # Test that the truncate optimization is disabled if the SQLITE_DELETE # authorization callback returns SQLITE_IGNORE. # -# $Id: auth3.test,v 1.2 2009/05/04 01:58:31 drh Exp $ -# +# Test that authorizer is disabled during schema parsing. set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -108,4 +107,22 @@ do_test auth3-2.2 { set sqlite_search_count } {1} +# 2016-07-28. A problem report from a private client complaining about +# an authorizer failure during an ALTER TABLE. The solution (I think) is +# to disable the authorizer during schema parsing. +# +proc auth {code args} { + if {$code=="SQLITE_READ" && [regexp {DoNotRead} $args]} { + return SQLITE_DENY + } + return SQLITE_OK +} +do_execsql_test auth3-3.0 { + CREATE TEMPORARY TABLE TempTable ( + key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, + value TEXT NOT NULL ON CONFLICT FAIL); + ALTER TABLE TempTable RENAME TO DoNotRead; + SELECT name FROM sqlite_temp_master; +} {DoNotRead sqlite_autoindex_DoNotRead_1} + finish_test From c0bebc1dcfe7711b80d3a3333d35c991849785ed Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 18:49:20 +0000 Subject: [PATCH 251/302] All SQLite API functions and callbacks in the 'sqlite3ext.h' header file must be decorated with the calling convention. FossilOrigin-Name: 97fc6e4328fe72cdd10f11a4b4bc9ce14bdc537f --- Makefile.msc | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 1257ce2ba3..d2c53a0385 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1846,7 +1846,8 @@ $(SQLITE3H): $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > $(SQLITE3H) sqlite3ext.h: .target_source - copy tsrc\sqlite3ext.h . + type tsrc\sqlite3ext.h | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*\)" "(SQLITE_CALLBACK *)" \ + | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_APICALL *" > sqlite3ext.h mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c $(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) \ diff --git a/manifest b/manifest index 990660b97b..bcfd6a51fa 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Fixup\sreserved\sfunction\spointers\sin\sthe\sTcl\sstubs\stable\sand\sseveral\smacros\scontaining\sTcl\sfunction\spointers. -D 2016-07-28T18:18:53.411 +C All\sSQLite\sAPI\sfunctions\sand\scallbacks\sin\sthe\s'sqlite3ext.h'\sheader\sfile\smust\sbe\sdecorated\swith\sthe\scalling\sconvention. +D 2016-07-28T18:49:20.480 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 959d56a9c117c3dc6f407a71aaa9fbad2df0b3c7 +F Makefile.msc b8894e579e4a5f32d61eb9309dbdbd7c883d2e87 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 90e89ec9c8efff057a9e43c612427fc5c97ab52d -R d171dcc0a06f2c3b789ca76207152f9d +P 959cd0131a5c717679b6e250229794679efe7f69 +R 5c0ac8119f9b9a2ca4c809f0833a7b7c U mistachkin -Z 48ca1d4dc91e624fdf594bf2bfd310c3 +Z 4646b26f0f26be9837f9ae84f1defbff diff --git a/manifest.uuid b/manifest.uuid index 1992938c42..d28a372fd5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -959cd0131a5c717679b6e250229794679efe7f69 \ No newline at end of file +97fc6e4328fe72cdd10f11a4b4bc9ce14bdc537f \ No newline at end of file From e37f7397c97c75bc9c124564568f12253ee4533d Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 19:28:35 +0000 Subject: [PATCH 252/302] The 'sqlite3ext.h' content should be processed before being included in the amalgamation. FossilOrigin-Name: cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 --- Makefile.msc | 3 ++- manifest | 17 ++++++++--------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index d2c53a0385..b4cb94a5b8 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1359,7 +1359,7 @@ HDR = \ parse.h \ $(TOP)\src\pragma.h \ $(SQLITE3H) \ - $(TOP)\src\sqlite3ext.h \ + sqlite3ext.h \ $(TOP)\src\sqliteInt.h \ $(TOP)\src\sqliteLimit.h \ $(TOP)\src\vdbe.h \ @@ -1848,6 +1848,7 @@ $(SQLITE3H): $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION sqlite3ext.h: .target_source type tsrc\sqlite3ext.h | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*\)" "(SQLITE_CALLBACK *)" \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_APICALL *" > sqlite3ext.h + copy /Y sqlite3ext.h tsrc\sqlite3ext.h mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c $(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) \ diff --git a/manifest b/manifest index 7b451988d9..4df76977b0 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Decorate\sall\sinterfaces\swith\scalling\sconvention\smacros. -D 2016-07-28T18:55:57.809 +C The\s'sqlite3ext.h'\scontent\sshould\sbe\sprocessed\sbefore\sbeing\sincluded\sin\sthe\samalgamation. +D 2016-07-28T19:28:35.475 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc b8894e579e4a5f32d61eb9309dbdbd7c883d2e87 +F Makefile.msc eefec7a26bf73bb04f2241058e23a3ec8a43f656 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1449,7 +1449,7 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl aa58ea3be311c81821c2cd3209f55e46b07ab656 -F tool/mksqlite3c.tcl a52ead27e2ac5d4b616e945a0601f628f4328329 +F tool/mksqlite3c.tcl 655181fb25f69b3524b30efd0750c43513415216 F tool/mksqlite3h.tcl cf5cd68028e69a51ed5c76042672664201f0f756 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7 @@ -1508,8 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 805d01cdabb48a69eb986a7f084e53eb25d76b7f 97fc6e4328fe72cdd10f11a4b4bc9ce14bdc537f -R 8897711bcf29ba23a6ba0e1e7c3853bd -T +closed 97fc6e4328fe72cdd10f11a4b4bc9ce14bdc537f -U drh -Z 6ec050f366e0cbc18c7d1fd514c95e5b +P fd784887e125bf95f4799ad09cbcba6795173487 +R 159053f8c66afb3fed693021893388d2 +U mistachkin +Z 1fc3620b6fdad23d7ecfea7d673497bf diff --git a/manifest.uuid b/manifest.uuid index 76c400fd3d..ad3e416aac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd784887e125bf95f4799ad09cbcba6795173487 \ No newline at end of file +cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index b7561cfa5b..c5f765ed1c 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -112,7 +112,6 @@ foreach hdr { pragma.h rtree.h sqlite3session.h - sqlite3ext.h sqlite3.h sqlite3ext.h sqlite3rbu.h From 44e95d4f028e537c411e746e312af658b6153dff Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 22:23:26 +0000 Subject: [PATCH 253/302] Make the extension auto-loading mechanism work with the __stdcall calling convention. Also, fix a couple Tcl command calling conventions missed in the previous check-in. FossilOrigin-Name: 3ea567c4b07b2a7a027b9b5cb8250ab687803698 --- Makefile.msc | 11 +++++++++++ ext/misc/vfsstat.c | 2 +- manifest | 30 +++++++++++++++--------------- manifest.uuid | 2 +- src/loadext.c | 44 ++++++++++++++++++++++++++++++-------------- src/sqlite.h.in | 8 ++++++-- src/sqlite3ext.h | 14 ++++++++++++-- src/tclsqlite.c | 20 +++++++++++++++++--- src/test_autoext.c | 12 ++++++------ src/test_func.c | 18 +++++++++++------- src/test_multiplex.c | 2 +- src/test_thread.c | 4 ++-- 12 files changed, 113 insertions(+), 54 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index b4cb94a5b8..527efd8f7d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -24,6 +24,13 @@ USE_AMALGAMATION = 1 USE_FULLWARN = 0 !ENDIF +# Set this non-0 to enable full runtime error checks (-RTC1, etc). This +# has no effect if (any) optimizations are enabled. +# +!IFNDEF USE_RUNTIME_CHECKS +USE_RUNTIME_CHECKS = 0 +!ENDIF + # Set this non-0 to use "stdcall" calling convention for the core library # and shell executable. # @@ -847,6 +854,10 @@ RCC = $(RCC) -D_DEBUG !IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0 TCC = $(TCC) -Od BCC = $(BCC) -Od +!IF $(USE_RUNTIME_CHECKS)!=0 +TCC = $(TCC) -RTC1 +BCC = $(BCC) -RTC1 +!ENDIF !ELSEIF $(OPTIMIZATIONS)>=3 TCC = $(TCC) -Ox BCC = $(BCC) -Ox diff --git a/ext/misc/vfsstat.c b/ext/misc/vfsstat.c index af088d6655..14753d277d 100644 --- a/ext/misc/vfsstat.c +++ b/ext/misc/vfsstat.c @@ -809,7 +809,7 @@ int sqlite3_vfsstat_init( vstat_vfs.base.szOsFile = sizeof(VStatFile) + vstat_vfs.pVfs->szOsFile; rc = sqlite3_vfs_register(&vstat_vfs.base, 1); if( rc==SQLITE_OK ){ - rc = sqlite3_auto_extension((void(*)(void))vstatRegister); + rc = sqlite3_auto_extension(vstatRegister); } if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY; return rc; diff --git a/manifest b/manifest index 4df76977b0..36d529bb7a 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C The\s'sqlite3ext.h'\scontent\sshould\sbe\sprocessed\sbefore\sbeing\sincluded\sin\sthe\samalgamation. -D 2016-07-28T19:28:35.475 +C Make\sthe\sextension\sauto-loading\smechanism\swork\swith\sthe\s__stdcall\scalling\sconvention.\s\sAlso,\sfix\sa\scouple\sTcl\scommand\scalling\sconventions\smissed\sin\sthe\sprevious\scheck-in. +D 2016-07-28T22:23:26.522 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc eefec7a26bf73bb04f2241058e23a3ec8a43f656 +F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -223,7 +223,7 @@ F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 -F ext/misc/vfsstat.c 6110aeeaab2f1df17a923c8a8acef3c74f6dc515 +F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rbu/rbu.c b2c0b5e6ae1a89affc0edfc127ebfa5f637a0ce4 @@ -347,7 +347,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c 5dd8b5a67d32a98bb75657c2a9e48b2cedbf13a4 +F src/loadext.c 4e26039f8d2e91acd57e55fcc31477aa37a3aa80 F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -385,14 +385,14 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 -F src/sqlite.h.in a03063e698a43cc5c996cd341f39439a6ce58304 +F src/sqlite.h.in 856ab22cfcec0ba94d2f0139a72a9797343687b3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 46f300b6e300e0fa916d7d58c44b53415b8471a9 +F src/sqlite3ext.h 978c062d3fa59a22c6d57305b9f290e3a26110c3 F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 342379845d52c62a778c76c3dd0a2695af723e04 +F src/tclsqlite.c 2ca362fa9c9762f705169aa5b2e75d688f4391f7 F src/test1.c 906a04b649c7139e943193a3905d583e325c30c7 F src/test2.c b7174313e993754303a8b33c43df7c44b46857ab F src/test3.c 1339a40be39650ae83894b6578f971dc7f96ea8a @@ -403,7 +403,7 @@ F src/test7.c 5612e9aecf934d6df7bba6ce861fdf5ba5456010 F src/test8.c 4f4904721167b32f7a4fa8c7b32a07a673d6cc86 F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a -F src/test_autoext.c 6c8fe00caa3f38396f0990467179e9d1adb39ddd +F src/test_autoext.c cc69375c006b7bac6094ec602f52525350fd5229 F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 F src/test_bestindex.c d23f80d334c59662af69191854c76b8d3d0c8c96 F src/test_blob.c a0f7ad49a0c9d4b72f693fe2a71c58d7e507174d @@ -412,7 +412,7 @@ F src/test_config.c 4d3d4a886416f369771d69a6dba926866deda788 F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 F src/test_fs.c ac62ce7d5c0c23aa6932891cad5746945564c91c -F src/test_func.c 9cea6fee7ece5f46aa26e060b35e10dc6ba708cf +F src/test_func.c 7dceef0e0556933a751af9b73478519b6dc12f0f F src/test_hexio.c 1d4469ca61ab202a1fcec6543f584d2407205e8d F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664 F src/test_intarray.c 988fc61cb0ff539f4172c0d95f15287c92516f64 @@ -420,7 +420,7 @@ F src/test_intarray.h f3b7672f5d1056eac563c0d6ea8480a660b1475c F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd F src/test_malloc.c c05f6c40bd6c8bfe5f1718212f81fd5687f91766 -F src/test_multiplex.c af2792ec4436d442d1bd00b8803470a25111bad3 +F src/test_multiplex.c 371d3874fd6365f18468d1c131e153e5c9abe95e F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635 F src/test_mutex.c 7f4337ba23ee6b1d2ec81c189653608cb069926a F src/test_onefile.c 416f87a28d6d673352d33fc4b1c7d39db878e50f @@ -435,7 +435,7 @@ F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939 F src/test_tclvar.c df9fe1213c2634687a9ca0b0bec0d2119d359ae3 -F src/test_thread.c c7c40494b7a0603ebb6eb97c904545c0dceca5ff +F src/test_thread.c a122592c2b857c79eb4ee4bacb62a5a6c8fe4c6f F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fd784887e125bf95f4799ad09cbcba6795173487 -R 159053f8c66afb3fed693021893388d2 +P cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 +R bda25e48e90849454c6e864127930d74 U mistachkin -Z 1fc3620b6fdad23d7ecfea7d673497bf +Z 008c4b78efecf8010a475c91e6246b39 diff --git a/manifest.uuid b/manifest.uuid index ad3e416aac..0a08bdb4e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 \ No newline at end of file +3ea567c4b07b2a7a027b9b5cb8250ab687803698 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index ce1f5317c6..525272d7fe 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -21,6 +21,14 @@ #include #ifndef SQLITE_OMIT_LOAD_EXTENSION +/* +** This is the function signature used for all extension entry points. +*/ +typedef int (*sqlite3_loadext_entry)( + sqlite3 *db, /* Handle to the database. */ + char **pzErrMsg, /* Used to set error string on failure. */ + const sqlite3_api_routines *pThunk /* Extension API function pointers. */ +); /* ** Some API routines are omitted when various features are @@ -111,6 +119,10 @@ #define sqlite3_blob_reopen 0 #endif +#if defined(SQLITE_OMIT_TRACE) +# define sqlite3_trace_v2 0 +#endif + /* ** The following structure contains pointers to all SQLite API routines. ** A pointer to this structure is passed into extensions when they are @@ -416,7 +428,10 @@ static const sqlite3_api_routines sqlite3Apis = { sqlite3_strlike, sqlite3_db_cacheflush, /* Version 3.12.0 and later */ - sqlite3_system_errno + sqlite3_system_errno, + /* Version 3.14.0 and later */ + sqlite3_trace_v2, + sqlite3_expanded_sql }; /* @@ -439,7 +454,7 @@ static int sqlite3LoadExtension( ){ sqlite3_vfs *pVfs = db->pVfs; void *handle; - int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); + sqlite3_loadext_entry xInit; char *zErrmsg = 0; const char *zEntry; char *zAltEntry = 0; @@ -498,8 +513,7 @@ static int sqlite3LoadExtension( } return SQLITE_ERROR; } - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) - sqlite3OsDlSym(pVfs, handle, zEntry); + xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); /* If no entry point was specified and the default legacy ** entry point name "sqlite3_extension_init" was not found, then @@ -531,8 +545,7 @@ static int sqlite3LoadExtension( } memcpy(zAltEntry+iEntry, "_init", 6); zEntry = zAltEntry; - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) - sqlite3OsDlSym(pVfs, handle, zEntry); + xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); } if( xInit==0 ){ if( pzErrMsg ){ @@ -662,7 +675,9 @@ static SQLITE_WSD struct sqlite3AutoExtList { ** Register a statically linked extension that is automatically ** loaded by every new database connection. */ -int sqlite3_auto_extension(void (*xInit)(void)){ +int sqlite3_auto_extension( + void (*xInit)(sqlite3 *, char **, const void *) /* Extension entry point */ +){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); @@ -678,7 +693,7 @@ int sqlite3_auto_extension(void (*xInit)(void)){ wsdAutoextInit; sqlite3_mutex_enter(mutex); for(i=0; i=0; i--){ - if( wsdAutoext.aExt[i]==xInit ){ + if( wsdAutoext.aExt[i]==(void*)xInit ){ wsdAutoext.nExt--; wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt]; n++; @@ -756,7 +773,7 @@ void sqlite3AutoLoadExtensions(sqlite3 *db){ u32 i; int go = 1; int rc; - int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); + sqlite3_loadext_entry xInit; wsdAutoextInit; if( wsdAutoext.nExt==0 ){ @@ -773,8 +790,7 @@ void sqlite3AutoLoadExtensions(sqlite3 *db){ xInit = 0; go = 0; }else{ - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) - wsdAutoext.aExt[i]; + xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i]; } sqlite3_mutex_leave(mutex); zErrmsg = 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 02ae22c346..104e465467 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5707,7 +5707,9 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] */ -int sqlite3_auto_extension(void (*xEntryPoint)(void)); +int sqlite3_auto_extension( + void (*xEntryPoint)(sqlite3 *, char **, const void *) +); /* ** CAPI3REF: Cancel Automatic Extension Loading @@ -5719,7 +5721,9 @@ int sqlite3_auto_extension(void (*xEntryPoint)(void)); ** unregistered and it returns 0 if X was not on the list of initialization ** routines. */ -int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); +int sqlite3_cancel_auto_extension( + void (*xEntryPoint)(sqlite3 *, char **, const void *) +); /* ** CAPI3REF: Reset Automatic Extension Loading diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 338e1becd5..d79ca826de 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -251,12 +251,12 @@ struct sqlite3_api_routines { char *(*vsnprintf)(int,char*,const char*,va_list); int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); /* Version 3.8.7 and later */ - int (*auto_extension)(void(*)(void)); + int (*auto_extension)(void(*)(sqlite3*,char**,const void*)); int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, void(*)(void*)); int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, void(*)(void*),unsigned char); - int (*cancel_auto_extension)(void(*)(void)); + int (*cancel_auto_extension)(void(*)(sqlite3*,char**,const void*)); int (*load_extension)(sqlite3*,const char*,const char*,char**); void *(*malloc64)(sqlite3_uint64); sqlite3_uint64 (*msize)(void*); @@ -286,6 +286,16 @@ struct sqlite3_api_routines { char *(*expanded_sql)(sqlite3_stmt*); }; +/* +** This is the function signature used for all extension entry points. It +** is also defined in the file "loadext.c". +*/ +typedef int (*sqlite3_loadext_entry)( + sqlite3 *db, /* Handle to the database. */ + char **pzErrMsg, /* Used to set error string on failure. */ + const sqlite3_api_routines *pThunk /* Extension API function pointers. */ +); + /* ** The following macros redefine the API routines so that they are ** redirected through the global sqlite3_api structure. diff --git a/src/tclsqlite.c b/src/tclsqlite.c index bc94a5ff7f..dd4e42e8a9 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3806,7 +3806,12 @@ static void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){ ** A TCL command for md5. The argument is the text to be hashed. The ** Result is the hash in base64. */ -static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ +static int SQLITE_TCLAPI md5_cmd( + void*cd, + Tcl_Interp *interp, + int argc, + const char **argv +){ MD5Context ctx; unsigned char digest[16]; char zBuf[50]; @@ -3830,7 +3835,12 @@ static int md5_cmd(void*cd, Tcl_Interp *interp, int argc, const char **argv){ ** A TCL command to take the md5 hash of a file. The argument is the ** name of the file. */ -static int md5file_cmd(void*cd, Tcl_Interp*interp, int argc, const char **argv){ +static int SQLITE_TCLAPI md5file_cmd( + void*cd, + Tcl_Interp *interp, + int argc, + const char **argv +){ FILE *in; MD5Context ctx; void (*converter)(unsigned char*, char*); @@ -3910,7 +3920,11 @@ static void md5finalize(sqlite3_context *context){ MD5DigestToBase16(digest, zBuf); sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } -int Md5_Register(sqlite3 *db){ +int Md5_Register( + sqlite3 *db, + char **pzErrMsg, + const void *pThunk +){ int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize); sqlite3_overload_function(db, "md5sum", -1); /* To exercise this API */ diff --git a/src/test_autoext.c b/src/test_autoext.c index 94a3223e65..f962a51d6b 100644 --- a/src/test_autoext.c +++ b/src/test_autoext.c @@ -100,7 +100,7 @@ static int SQLITE_TCLAPI autoExtSqrObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_auto_extension((void*)sqr_init); + int rc = sqlite3_auto_extension(sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -116,7 +116,7 @@ static int SQLITE_TCLAPI cancelAutoExtSqrObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_cancel_auto_extension((void*)sqr_init); + int rc = sqlite3_cancel_auto_extension(sqr_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -132,7 +132,7 @@ static int SQLITE_TCLAPI autoExtCubeObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_auto_extension((void*)cube_init); + int rc = sqlite3_auto_extension(cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -148,7 +148,7 @@ static int SQLITE_TCLAPI cancelAutoExtCubeObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_cancel_auto_extension((void*)cube_init); + int rc = sqlite3_cancel_auto_extension(cube_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -164,7 +164,7 @@ static int SQLITE_TCLAPI autoExtBrokenObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_auto_extension((void*)broken_init); + int rc = sqlite3_auto_extension(broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } @@ -180,7 +180,7 @@ static int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd( int objc, Tcl_Obj *CONST objv[] ){ - int rc = sqlite3_cancel_auto_extension((void*)broken_init); + int rc = sqlite3_cancel_auto_extension(broken_init); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return SQLITE_OK; } diff --git a/src/test_func.c b/src/test_func.c index 6a714ef3eb..fff1990128 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -644,7 +644,11 @@ static void test_setsubtype( sqlite3_result_subtype(context, (unsigned int)sqlite3_value_int(argv[1])); } -static int registerTestFunctions(sqlite3 *db){ +static int registerTestFunctions( + sqlite3 *db, + char **pzErrMsg, + const void *pThunk +){ static const struct { char *zName; signed char nArg; @@ -699,10 +703,10 @@ static int SQLITE_TCLAPI autoinstall_test_funcs( int objc, Tcl_Obj *CONST objv[] ){ - extern int Md5_Register(sqlite3*); - int rc = sqlite3_auto_extension((void*)registerTestFunctions); + extern int Md5_Register(sqlite3 *, char **, const void *); + int rc = sqlite3_auto_extension(registerTestFunctions); if( rc==SQLITE_OK ){ - rc = sqlite3_auto_extension((void*)Md5_Register); + rc = sqlite3_auto_extension(Md5_Register); } Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return TCL_OK; @@ -799,13 +803,13 @@ int Sqlitetest_func_Init(Tcl_Interp *interp){ { "abuse_create_function", abuse_create_function }, }; int i; - extern int Md5_Register(sqlite3*); + extern int Md5_Register(sqlite3 *, char **, const void *); for(i=0; i Date: Thu, 28 Jul 2016 22:38:31 +0000 Subject: [PATCH 254/302] Make sure all the auto-extension mechanism function signatures match up precisely. FossilOrigin-Name: 87ba69b5ca4a8e4ef2bbaaf07a0ff13fc5cd4721 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/loadext.c | 4 ++-- src/sqlite.h.in | 5 +++-- src/sqlite3ext.h | 5 +++-- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 36d529bb7a..0fd8b5e7cf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sextension\sauto-loading\smechanism\swork\swith\sthe\s__stdcall\scalling\sconvention.\s\sAlso,\sfix\sa\scouple\sTcl\scommand\scalling\sconventions\smissed\sin\sthe\sprevious\scheck-in. -D 2016-07-28T22:23:26.522 +C Make\ssure\sall\sthe\sauto-extension\smechanism\sfunction\ssignatures\smatch\sup\sprecisely. +D 2016-07-28T22:38:31.788 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -347,7 +347,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c 4e26039f8d2e91acd57e55fcc31477aa37a3aa80 +F src/loadext.c 74a66e96c9b6beafbbc345d9045727e2bd7fd483 F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -385,9 +385,9 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 -F src/sqlite.h.in 856ab22cfcec0ba94d2f0139a72a9797343687b3 +F src/sqlite.h.in acd078b5b18d7ceecd9f2bbffc30109a758a73b0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 978c062d3fa59a22c6d57305b9f290e3a26110c3 +F src/sqlite3ext.h ebbcfcc6200d04f04b4e2252327b14c50cd9d49a F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 -R bda25e48e90849454c6e864127930d74 +P 3ea567c4b07b2a7a027b9b5cb8250ab687803698 +R 51ed71c50a5a0dd10fef4650340d6be2 U mistachkin -Z 008c4b78efecf8010a475c91e6246b39 +Z 81fd56db162c30680657ddae99c1b31b diff --git a/manifest.uuid b/manifest.uuid index 0a08bdb4e1..428fb337c6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3ea567c4b07b2a7a027b9b5cb8250ab687803698 \ No newline at end of file +87ba69b5ca4a8e4ef2bbaaf07a0ff13fc5cd4721 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 525272d7fe..c3d91eed33 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -676,7 +676,7 @@ static SQLITE_WSD struct sqlite3AutoExtList { ** loaded by every new database connection. */ int sqlite3_auto_extension( - void (*xInit)(sqlite3 *, char **, const void *) /* Extension entry point */ + void (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) ){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_AUTOINIT @@ -723,7 +723,7 @@ int sqlite3_auto_extension( ** was not on the list. */ int sqlite3_cancel_auto_extension( - void (*xInit)(sqlite3 *, char **, const void *) /* Extension entry point */ + void (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) ){ #if SQLITE_THREADSAFE sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 104e465467..9fec987d8c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5707,8 +5707,9 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** See also: [sqlite3_reset_auto_extension()] ** and [sqlite3_cancel_auto_extension()] */ +typedef struct sqlite3_api_routines sqlite3_api_routines; int sqlite3_auto_extension( - void (*xEntryPoint)(sqlite3 *, char **, const void *) + void (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *) ); /* @@ -5722,7 +5723,7 @@ int sqlite3_auto_extension( ** routines. */ int sqlite3_cancel_auto_extension( - void (*xEntryPoint)(sqlite3 *, char **, const void *) + void (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *) ); /* diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index d79ca826de..8ee8e2d576 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -251,12 +251,13 @@ struct sqlite3_api_routines { char *(*vsnprintf)(int,char*,const char*,va_list); int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); /* Version 3.8.7 and later */ - int (*auto_extension)(void(*)(sqlite3*,char**,const void*)); + int (*auto_extension)(void(*)(sqlite3*,char**,const sqlite3_api_routines*)); int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, void(*)(void*)); int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, void(*)(void*),unsigned char); - int (*cancel_auto_extension)(void(*)(sqlite3*,char**,const void*)); + int (*cancel_auto_extension)(void(*)(sqlite3*,char**, + const sqlite3_api_routines*)); int (*load_extension)(sqlite3*,const char*,const char*,char**); void *(*malloc64)(sqlite3_uint64); sqlite3_uint64 (*msize)(void*); From 78d5e02f99c1e555212da6e8699eead360cf314c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 22:46:53 +0000 Subject: [PATCH 255/302] The return type used by the auto-extension entry points is 'int', not 'void'. FossilOrigin-Name: bf9c86c74f30136a106f37603a6c7dcc76caf41d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/loadext.c | 4 ++-- src/sqlite.h.in | 4 ++-- src/sqlite3ext.h | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 0fd8b5e7cf..17a1dd2ca9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sall\sthe\sauto-extension\smechanism\sfunction\ssignatures\smatch\sup\sprecisely. -D 2016-07-28T22:38:31.788 +C The\sreturn\stype\sused\sby\sthe\sauto-extension\sentry\spoints\sis\s'int',\snot\s'void'. +D 2016-07-28T22:46:53.241 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -347,7 +347,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c 74a66e96c9b6beafbbc345d9045727e2bd7fd483 +F src/loadext.c c3c2a37e4ce940d17c73971738754d412c79e09d F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -385,9 +385,9 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 -F src/sqlite.h.in acd078b5b18d7ceecd9f2bbffc30109a758a73b0 +F src/sqlite.h.in cd10e4206b91c4bf03f121ab9209a14af0b48f14 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h ebbcfcc6200d04f04b4e2252327b14c50cd9d49a +F src/sqlite3ext.h f4206565eb5f5cef9a1544d32a076b5f47af1bdc F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3ea567c4b07b2a7a027b9b5cb8250ab687803698 -R 51ed71c50a5a0dd10fef4650340d6be2 +P 87ba69b5ca4a8e4ef2bbaaf07a0ff13fc5cd4721 +R fe55b3414e54e3c3fe825e99e626bb4c U mistachkin -Z 81fd56db162c30680657ddae99c1b31b +Z 6282b6a783a4676d4515222e105ea01c diff --git a/manifest.uuid b/manifest.uuid index 428fb337c6..b5a2549c02 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87ba69b5ca4a8e4ef2bbaaf07a0ff13fc5cd4721 \ No newline at end of file +bf9c86c74f30136a106f37603a6c7dcc76caf41d \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index c3d91eed33..163141bf73 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -676,7 +676,7 @@ static SQLITE_WSD struct sqlite3AutoExtList { ** loaded by every new database connection. */ int sqlite3_auto_extension( - void (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) + int (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) ){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_AUTOINIT @@ -723,7 +723,7 @@ int sqlite3_auto_extension( ** was not on the list. */ int sqlite3_cancel_auto_extension( - void (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) + int (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) ){ #if SQLITE_THREADSAFE sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9fec987d8c..9d28cdc05a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5709,7 +5709,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); */ typedef struct sqlite3_api_routines sqlite3_api_routines; int sqlite3_auto_extension( - void (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *) + int (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *) ); /* @@ -5723,7 +5723,7 @@ int sqlite3_auto_extension( ** routines. */ int sqlite3_cancel_auto_extension( - void (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *) + int (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *) ); /* diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 8ee8e2d576..689a5c4856 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -251,12 +251,12 @@ struct sqlite3_api_routines { char *(*vsnprintf)(int,char*,const char*,va_list); int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); /* Version 3.8.7 and later */ - int (*auto_extension)(void(*)(sqlite3*,char**,const sqlite3_api_routines*)); + int (*auto_extension)(int(*)(sqlite3*,char**,const sqlite3_api_routines*)); int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, void(*)(void*)); int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, void(*)(void*),unsigned char); - int (*cancel_auto_extension)(void(*)(sqlite3*,char**, + int (*cancel_auto_extension)(int(*)(sqlite3*,char**, const sqlite3_api_routines*)); int (*load_extension)(sqlite3*,const char*,const char*,char**); void *(*malloc64)(sqlite3_uint64); From 85bd982ba02750aa927c2b80e5d7f888d58fb2fb Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 22:53:10 +0000 Subject: [PATCH 256/302] More compiler warning fixes for GCC related to the auto-extension mechanism. FossilOrigin-Name: b8218129bc848c61fa6910feae4141dac6ad86fc --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/tclsqlite.c | 2 +- src/test_func.c | 6 +++--- src/test_thread.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 17a1dd2ca9..07a36a9f51 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sreturn\stype\sused\sby\sthe\sauto-extension\sentry\spoints\sis\s'int',\snot\s'void'. -D 2016-07-28T22:46:53.241 +C More\scompiler\swarning\sfixes\sfor\sGCC\srelated\sto\sthe\sauto-extension\smechanism. +D 2016-07-28T22:53:10.716 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -392,7 +392,7 @@ F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 -F src/tclsqlite.c 2ca362fa9c9762f705169aa5b2e75d688f4391f7 +F src/tclsqlite.c bdae822f21e229b6daced15938b6343ce44ef454 F src/test1.c 906a04b649c7139e943193a3905d583e325c30c7 F src/test2.c b7174313e993754303a8b33c43df7c44b46857ab F src/test3.c 1339a40be39650ae83894b6578f971dc7f96ea8a @@ -412,7 +412,7 @@ F src/test_config.c 4d3d4a886416f369771d69a6dba926866deda788 F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 F src/test_fs.c ac62ce7d5c0c23aa6932891cad5746945564c91c -F src/test_func.c 7dceef0e0556933a751af9b73478519b6dc12f0f +F src/test_func.c 6f34b19ae097e3cf0b0fe5d6904cb9900e67f2ff F src/test_hexio.c 1d4469ca61ab202a1fcec6543f584d2407205e8d F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664 F src/test_intarray.c 988fc61cb0ff539f4172c0d95f15287c92516f64 @@ -435,7 +435,7 @@ F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939 F src/test_tclvar.c df9fe1213c2634687a9ca0b0bec0d2119d359ae3 -F src/test_thread.c a122592c2b857c79eb4ee4bacb62a5a6c8fe4c6f +F src/test_thread.c 89f0e47dac64e7ab15ca0a4fc87e0882c495ae21 F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87ba69b5ca4a8e4ef2bbaaf07a0ff13fc5cd4721 -R fe55b3414e54e3c3fe825e99e626bb4c +P bf9c86c74f30136a106f37603a6c7dcc76caf41d +R 664c66de93f8212f17433a2724631f1d U mistachkin -Z 6282b6a783a4676d4515222e105ea01c +Z 34c982f036e48065c3f321d45916961b diff --git a/manifest.uuid b/manifest.uuid index b5a2549c02..2806d535ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf9c86c74f30136a106f37603a6c7dcc76caf41d \ No newline at end of file +b8218129bc848c61fa6910feae4141dac6ad86fc \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index dd4e42e8a9..3db4a32c4d 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3923,7 +3923,7 @@ static void md5finalize(sqlite3_context *context){ int Md5_Register( sqlite3 *db, char **pzErrMsg, - const void *pThunk + const sqlite3_api_routines *pThunk ){ int rc = sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize); diff --git a/src/test_func.c b/src/test_func.c index fff1990128..6bfa862464 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -647,7 +647,7 @@ static void test_setsubtype( static int registerTestFunctions( sqlite3 *db, char **pzErrMsg, - const void *pThunk + const sqlite3_api_routines *pThunk ){ static const struct { char *zName; @@ -703,7 +703,7 @@ static int SQLITE_TCLAPI autoinstall_test_funcs( int objc, Tcl_Obj *CONST objv[] ){ - extern int Md5_Register(sqlite3 *, char **, const void *); + extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *); int rc = sqlite3_auto_extension(registerTestFunctions); if( rc==SQLITE_OK ){ rc = sqlite3_auto_extension(Md5_Register); @@ -803,7 +803,7 @@ int Sqlitetest_func_Init(Tcl_Interp *interp){ { "abuse_create_function", abuse_create_function }, }; int i; - extern int Md5_Register(sqlite3 *, char **, const void *); + extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *); for(i=0; i Date: Thu, 28 Jul 2016 23:54:45 +0000 Subject: [PATCH 257/302] Use the SQLITE_TCLAPI macro in several extensions that were missed in the previous check-in. FossilOrigin-Name: df2543652b835353c03956dfbd3e35e5b191372e --- ext/fts5/fts5_tcl.c | 20 ++++++++++---------- ext/rbu/test_rbu.c | 12 ++++++------ ext/session/test_session.c | 14 +++++++------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index dee9bc7f18..9a7077b61d 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -82,7 +82,7 @@ static int f5tResultToErrorCode(const char *zRes){ return SQLITE_ERROR; } -static int f5tDbAndApi( +static int SQLITE_TCLAPI f5tDbAndApi( Tcl_Interp *interp, Tcl_Obj *pObj, sqlite3 **ppDb, @@ -213,7 +213,7 @@ static void xSetAuxdataDestructor(void *p){ ** ** Description... */ -static int xF5tApi( +static int SQLITE_TCLAPI xF5tApi( void * clientData, Tcl_Interp *interp, int objc, @@ -606,7 +606,7 @@ static void xF5tDestroy(void *pCtx){ ** ** Description... */ -static int f5tCreateFunction( +static int SQLITE_TCLAPI f5tCreateFunction( void * clientData, Tcl_Interp *interp, int objc, @@ -676,7 +676,7 @@ static int xTokenizeCb2( ** ** Description... */ -static int f5tTokenize( +static int SQLITE_TCLAPI f5tTokenize( void * clientData, Tcl_Interp *interp, int objc, @@ -882,7 +882,7 @@ static int f5tTokenizerTokenize( /* ** sqlite3_fts5_token ?-colocated? TEXT START END */ -static int f5tTokenizerReturn( +static int SQLITE_TCLAPI f5tTokenizerReturn( void * clientData, Tcl_Interp *interp, int objc, @@ -953,7 +953,7 @@ static void f5tDelTokenizer(void *pCtx){ ** SCRIPT2 should invoke the [sqlite3_fts5_token] command once for each ** token within the tokenized text. */ -static int f5tCreateTokenizer( +static int SQLITE_TCLAPI f5tCreateTokenizer( ClientData clientData, Tcl_Interp *interp, int objc, @@ -1005,7 +1005,7 @@ static void xF5tFree(ClientData clientData){ ** ** Set or clear the global "may-be-corrupt" flag. Return the old value. */ -static int f5tMayBeCorrupt( +static int SQLITE_TCLAPI f5tMayBeCorrupt( void * clientData, Tcl_Interp *interp, int objc, @@ -1037,7 +1037,7 @@ static unsigned int f5t_fts5HashKey(int nSlot, const char *p, int n){ return (h % nSlot); } -static int f5tTokenHash( +static int SQLITE_TCLAPI f5tTokenHash( void * clientData, Tcl_Interp *interp, int objc, @@ -1062,7 +1062,7 @@ static int f5tTokenHash( return TCL_OK; } -static int f5tRegisterMatchinfo( +static int SQLITE_TCLAPI f5tRegisterMatchinfo( void * clientData, Tcl_Interp *interp, int objc, @@ -1087,7 +1087,7 @@ static int f5tRegisterMatchinfo( return TCL_OK; } -static int f5tRegisterTok( +static int SQLITE_TCLAPI f5tRegisterTok( void * clientData, Tcl_Interp *interp, int objc, diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index 671f16c553..548954d7f1 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -53,7 +53,7 @@ void test_rbu_delta(sqlite3_context *pCtx, int nArg, sqlite3_value **apVal){ } -static int test_sqlite3rbu_cmd( +static int SQLITE_TCLAPI test_sqlite3rbu_cmd( ClientData clientData, Tcl_Interp *interp, int objc, @@ -196,7 +196,7 @@ static int test_sqlite3rbu_cmd( /* ** Tclcmd: sqlite3rbu CMD ?? */ -static int test_sqlite3rbu( +static int SQLITE_TCLAPI test_sqlite3rbu( ClientData clientData, Tcl_Interp *interp, int objc, @@ -226,7 +226,7 @@ static int test_sqlite3rbu( /* ** Tclcmd: sqlite3rbu_vacuum CMD */ -static int test_sqlite3rbu_vacuum( +static int SQLITE_TCLAPI test_sqlite3rbu_vacuum( ClientData clientData, Tcl_Interp *interp, int objc, @@ -254,7 +254,7 @@ static int test_sqlite3rbu_vacuum( /* ** Tclcmd: sqlite3rbu_create_vfs ?-default? NAME PARENT */ -static int test_sqlite3rbu_create_vfs( +static int SQLITE_TCLAPI test_sqlite3rbu_create_vfs( ClientData clientData, Tcl_Interp *interp, int objc, @@ -289,7 +289,7 @@ static int test_sqlite3rbu_create_vfs( /* ** Tclcmd: sqlite3rbu_destroy_vfs NAME */ -static int test_sqlite3rbu_destroy_vfs( +static int SQLITE_TCLAPI test_sqlite3rbu_destroy_vfs( ClientData clientData, Tcl_Interp *interp, int objc, @@ -310,7 +310,7 @@ static int test_sqlite3rbu_destroy_vfs( /* ** Tclcmd: sqlite3rbu_internal_test */ -static int test_sqlite3rbu_internal_test( +static int SQLITE_TCLAPI test_sqlite3rbu_internal_test( ClientData clientData, Tcl_Interp *interp, int objc, diff --git a/ext/session/test_session.c b/ext/session/test_session.c index 9f6bc3f70d..b273565455 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -111,7 +111,7 @@ static int testStreamOutput( ** $session patchset ** $session table_filter SCRIPT */ -static int test_session_cmd( +static int SQLITE_TCLAPI test_session_cmd( void *clientData, Tcl_Interp *interp, int objc, @@ -254,7 +254,7 @@ static void test_session_del(void *clientData){ /* ** Tclcmd: sqlite3session CMD DB-HANDLE DB-NAME */ -static int test_sqlite3session( +static int SQLITE_TCLAPI test_sqlite3session( void * clientData, Tcl_Interp *interp, int objc, @@ -610,7 +610,7 @@ static int testStreamInput( /* ** sqlite3changeset_apply DB CHANGESET CONFLICT-SCRIPT ?FILTER-SCRIPT? */ -static int test_sqlite3changeset_apply( +static int SQLITE_TCLAPI test_sqlite3changeset_apply( void * clientData, Tcl_Interp *interp, int objc, @@ -665,7 +665,7 @@ static int test_sqlite3changeset_apply( /* ** sqlite3changeset_apply_replace_all DB CHANGESET */ -static int test_sqlite3changeset_apply_replace_all( +static int SQLITE_TCLAPI test_sqlite3changeset_apply_replace_all( void * clientData, Tcl_Interp *interp, int objc, @@ -700,7 +700,7 @@ static int test_sqlite3changeset_apply_replace_all( /* ** sqlite3changeset_invert CHANGESET */ -static int test_sqlite3changeset_invert( +static int SQLITE_TCLAPI test_sqlite3changeset_invert( void * clientData, Tcl_Interp *interp, int objc, @@ -739,7 +739,7 @@ static int test_sqlite3changeset_invert( /* ** sqlite3changeset_concat LEFT RIGHT */ -static int test_sqlite3changeset_concat( +static int SQLITE_TCLAPI test_sqlite3changeset_concat( void * clientData, Tcl_Interp *interp, int objc, @@ -787,7 +787,7 @@ static int test_sqlite3changeset_concat( /* ** sqlite3session_foreach VARNAME CHANGESET SCRIPT */ -static int test_sqlite3session_foreach( +static int SQLITE_TCLAPI test_sqlite3session_foreach( void * clientData, Tcl_Interp *interp, int objc, diff --git a/manifest b/manifest index 07a36a9f51..4738abe8bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\scompiler\swarning\sfixes\sfor\sGCC\srelated\sto\sthe\sauto-extension\smechanism. -D 2016-07-28T22:53:10.716 +C Use\sthe\sSQLITE_TCLAPI\smacro\sin\sseveral\sextensions\sthat\swere\smissed\sin\sthe\sprevious\scheck-in. +D 2016-07-28T23:54:45.174 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -107,7 +107,7 @@ F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 -F ext/fts5/fts5_tcl.c b41f04600936a2b910b5dff179e8bd050ccb34c7 +F ext/fts5/fts5_tcl.c caede54ed5eade83e1f455356e6dd2b849e1c703 F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -255,7 +255,7 @@ F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab F ext/rbu/sqlite3rbu.c 948677ee0ec57da51148e6c5f64ac68afcf36ab2 F ext/rbu/sqlite3rbu.h db8858120c9be14b60c9225f9da28221f5f6b945 -F ext/rbu/test_rbu.c c2c1859dfd69f1a55125d38009d0d49e36895780 +F ext/rbu/test_rbu.c fc84cd6aae50cfd8b2b2d5e9cdfc85e1925c303c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c d26a815b0df1c412a6881dae8d7fd3c9c08cce68 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -301,7 +301,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 F ext/session/sqlite3session.h 69bf73cfd71e58f2ae5d2aa935b2c1a541aee555 -F ext/session/test_session.c ebf9acf2bd70885e6245512427f800693b65dc9c +F ext/session/test_session.c 5f9b1da42c5771fbe5948acd816ae9e8ae781353 F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf9c86c74f30136a106f37603a6c7dcc76caf41d -R 664c66de93f8212f17433a2724631f1d +P b8218129bc848c61fa6910feae4141dac6ad86fc +R 66ac7539129e9f0d2a57c9cf5f4708c1 U mistachkin -Z 34c982f036e48065c3f321d45916961b +Z abcb763c1fb15cc18b4555018b76e16c diff --git a/manifest.uuid b/manifest.uuid index 2806d535ae..b5d59b835c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8218129bc848c61fa6910feae4141dac6ad86fc \ No newline at end of file +df2543652b835353c03956dfbd3e35e5b191372e \ No newline at end of file From 2d45d7bfab45fc3488017f9573e2ccae423d5828 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 28 Jul 2016 23:58:25 +0000 Subject: [PATCH 258/302] Missed a couple Tcl command deletion callbacks. FossilOrigin-Name: fc5c187602acceedf7152b6927616d134f779a8f --- ext/fts5/fts5_tcl.c | 4 ++-- ext/session/test_session.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 9a7077b61d..77e4a6cf35 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -168,7 +168,7 @@ static int xTokenizeCb( return rc; } -static int xF5tApi(void*, Tcl_Interp*, int, Tcl_Obj *CONST []); +static int SQLITE_TCLAPI xF5tApi(void*, Tcl_Interp*, int, Tcl_Obj *CONST []); static int xQueryPhraseCb( const Fts5ExtensionApi *pApi, @@ -996,7 +996,7 @@ static int SQLITE_TCLAPI f5tCreateTokenizer( return TCL_OK; } -static void xF5tFree(ClientData clientData){ +static void SQLITE_TCLAPI xF5tFree(ClientData clientData){ ckfree(clientData); } diff --git a/ext/session/test_session.c b/ext/session/test_session.c index b273565455..df34d84445 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -244,7 +244,7 @@ static int SQLITE_TCLAPI test_session_cmd( return TCL_OK; } -static void test_session_del(void *clientData){ +static void SQLITE_TCLAPI test_session_del(void *clientData){ TestSession *p = (TestSession*)clientData; if( p->pFilterScript ) Tcl_DecrRefCount(p->pFilterScript); sqlite3session_delete(p->pSession); diff --git a/manifest b/manifest index 4738abe8bf..74d5fa504c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\sSQLITE_TCLAPI\smacro\sin\sseveral\sextensions\sthat\swere\smissed\sin\sthe\sprevious\scheck-in. -D 2016-07-28T23:54:45.174 +C Missed\sa\scouple\sTcl\scommand\sdeletion\scallbacks. +D 2016-07-28T23:58:25.315 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -107,7 +107,7 @@ F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 -F ext/fts5/fts5_tcl.c caede54ed5eade83e1f455356e6dd2b849e1c703 +F ext/fts5/fts5_tcl.c 6805005886d6d9c83bb9b68bb69d32af4b37797e F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -301,7 +301,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 F ext/session/sqlite3session.h 69bf73cfd71e58f2ae5d2aa935b2c1a541aee555 -F ext/session/test_session.c 5f9b1da42c5771fbe5948acd816ae9e8ae781353 +F ext/session/test_session.c d0754c65952cc7c729efd63374e3d61fbd1ae94c F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8218129bc848c61fa6910feae4141dac6ad86fc -R 66ac7539129e9f0d2a57c9cf5f4708c1 +P df2543652b835353c03956dfbd3e35e5b191372e +R 4f030271e7adab35739e0e6bab6a4279 U mistachkin -Z abcb763c1fb15cc18b4555018b76e16c +Z 7e68b7e2d6cc6fdfea65df6524031184 diff --git a/manifest.uuid b/manifest.uuid index b5d59b835c..ff4fc72f71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df2543652b835353c03956dfbd3e35e5b191372e \ No newline at end of file +fc5c187602acceedf7152b6927616d134f779a8f \ No newline at end of file From c08556844e97b3b1c3ee19eca99e6cc98ff537ac Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 29 Jul 2016 01:31:49 +0000 Subject: [PATCH 259/302] Add macro necessary for building several extensions when the __stdcall calling convention is not in use. FossilOrigin-Name: bc8c9b55ddf5227dc6b2116486f4a19bf54fce2b --- ext/fts5/fts5_tcl.c | 3 +++ ext/rbu/test_rbu.c | 3 +++ ext/session/test_session.c | 3 +++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 77e4a6cf35..5fe690f6b7 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -18,6 +18,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #ifdef SQLITE_ENABLE_FTS5 diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index 548954d7f1..bc4c800331 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -21,6 +21,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif #include diff --git a/ext/session/test_session.c b/ext/session/test_session.c index df34d84445..103a1c2d7a 100644 --- a/ext/session/test_session.c +++ b/ext/session/test_session.c @@ -9,6 +9,9 @@ # include "sqlite_tcl.h" #else # include "tcl.h" +# ifndef SQLITE_TCLAPI +# define SQLITE_TCLAPI +# endif #endif typedef struct TestSession TestSession; diff --git a/manifest b/manifest index 74d5fa504c..3a567d4deb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Missed\sa\scouple\sTcl\scommand\sdeletion\scallbacks. -D 2016-07-28T23:58:25.315 +C Add\smacro\snecessary\sfor\sbuilding\sseveral\sextensions\swhen\sthe\s__stdcall\scalling\sconvention\sis\snot\sin\suse. +D 2016-07-29T01:31:49.222 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -107,7 +107,7 @@ F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 -F ext/fts5/fts5_tcl.c 6805005886d6d9c83bb9b68bb69d32af4b37797e +F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a F ext/fts5/fts5_test_mi.c 783b86697ebf773c18fc109992426c0173a055bc F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -255,7 +255,7 @@ F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab F ext/rbu/sqlite3rbu.c 948677ee0ec57da51148e6c5f64ac68afcf36ab2 F ext/rbu/sqlite3rbu.h db8858120c9be14b60c9225f9da28221f5f6b945 -F ext/rbu/test_rbu.c fc84cd6aae50cfd8b2b2d5e9cdfc85e1925c303c +F ext/rbu/test_rbu.c 1a6bbc6982e32485a48df111d0bb1934d537eabd F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c d26a815b0df1c412a6881dae8d7fd3c9c08cce68 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -301,7 +301,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32 F ext/session/sqlite3session.h 69bf73cfd71e58f2ae5d2aa935b2c1a541aee555 -F ext/session/test_session.c d0754c65952cc7c729efd63374e3d61fbd1ae94c +F ext/session/test_session.c 2caed9a659586428c63ca46e4900347b374487d4 F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P df2543652b835353c03956dfbd3e35e5b191372e -R 4f030271e7adab35739e0e6bab6a4279 +P fc5c187602acceedf7152b6927616d134f779a8f +R d16dc76cf59643dacfea9f5d3d7324b6 U mistachkin -Z 7e68b7e2d6cc6fdfea65df6524031184 +Z 029d2b66c80fad0a70d5e0c29c8d9e88 diff --git a/manifest.uuid b/manifest.uuid index ff4fc72f71..3703d2538c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc5c187602acceedf7152b6927616d134f779a8f \ No newline at end of file +bc8c9b55ddf5227dc6b2116486f4a19bf54fce2b \ No newline at end of file From 99bbcc8287832d65fc954f29c5c340e1226292d5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 29 Jul 2016 01:32:36 +0000 Subject: [PATCH 260/302] Undo some unhelpful changes to skip-scan scoring that were added by the check-in [9e2b2681] that improved scoring of index scan. FossilOrigin-Name: c7d51934a4f30d096bb79fc509fc9dd0df5d89a4 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/where.c | 4 ++-- test/scanstatus.test | 4 ++-- test/skipscan1.test | 16 ++++++++-------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 4df76977b0..fdc9dbc32a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s'sqlite3ext.h'\scontent\sshould\sbe\sprocessed\sbefore\sbeing\sincluded\sin\sthe\samalgamation. -D 2016-07-28T19:28:35.475 +C Undo\ssome\sunhelpful\schanges\sto\sskip-scan\sscoring\sthat\swere\sadded\nby\sthe\scheck-in\s[9e2b2681]\sthat\simproved\sscoring\sof\sindex\sscan. +D 2016-07-29T01:32:36.387 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc eefec7a26bf73bb04f2241058e23a3ec8a43f656 @@ -463,7 +463,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 8ccc01f9227d41bfaf09360f108583be4a36d3b1 +F src/where.c fcaa38d19c2a7bb450cc57810bdc3d4eb36e00b0 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 @@ -1027,7 +1027,7 @@ F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd F test/savepoint6.test f41279c5e137139fa5c21485773332c7adb98cd7 F test/savepoint7.test cde525ea3075283eb950cdcdefe23ead4f700daa F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2 -F test/scanstatus.test 030acbbdcea6a3fc676fee99edc84f6f16c0cf92 +F test/scanstatus.test 5253c219e331318a437f436268e0e82345700285 F test/schema.test 8f7999be894260f151adf15c2c7540f1c6d6a481 F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5 F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38 @@ -1074,7 +1074,7 @@ F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 -F test/skipscan1.test d37a75b4be4eb9dedeb69b4f38b1d0a74b5021d7 +F test/skipscan1.test f2d4482f195f018c3732374d3985fc34bcc3ae1a F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fd784887e125bf95f4799ad09cbcba6795173487 -R 159053f8c66afb3fed693021893388d2 -U mistachkin -Z 1fc3620b6fdad23d7ecfea7d673497bf +P cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 +R 69cbd4ac65697876502fdf627dd430d9 +U drh +Z b3c6b81889b1e6498dbf215474f399c6 diff --git a/manifest.uuid b/manifest.uuid index ad3e416aac..e200b2ca41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbe1de4799df4d512bc175f51ed99c6ec6d5a4d1 \ No newline at end of file +c7d51934a4f30d096bb79fc509fc9dd0df5d89a4 \ No newline at end of file diff --git a/src/where.c b/src/where.c index ca406a8172..da41c142fa 100644 --- a/src/where.c +++ b/src/where.c @@ -2478,11 +2478,11 @@ static int whereLoopAddBtreeIndex( pNew->nSkip++; pNew->aLTerm[pNew->nLTerm++] = 0; pNew->wsFlags |= WHERE_SKIPSCAN; - nIter = pProbe->aiRowLogEst[saved_nEq]+1 - pProbe->aiRowLogEst[saved_nEq+1]; + nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1]; pNew->nOut -= nIter; /* TUNING: Because uncertainties in the estimates for skip-scan queries, ** add a 1.375 fudge factor to make skip-scan slightly less likely. */ - nIter += 4; + nIter += 5; whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul); pNew->nOut = saved_nOut; pNew->u.btree.nEq = saved_nEq; diff --git a/test/scanstatus.test b/test/scanstatus.test index 48365a8794..ed24d97437 100644 --- a/test/scanstatus.test +++ b/test/scanstatus.test @@ -333,7 +333,7 @@ do_execsql_test 5.3.2 { SELECT count(*) FROM t2 WHERE y = 'j'; } {19} do_scanstatus_test 5.3.3 { - nLoop 1 nVisit 19 nEst 52.0 zName t2xy zExplain + nLoop 1 nVisit 19 nEst 56.0 zName t2xy zExplain {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)} } @@ -349,7 +349,7 @@ do_execsql_test 5.4.2 { do_scanstatus_test 5.4.3 { nLoop 1 nVisit 10 nEst 10.0 zName t1bc zExplain {SCAN TABLE t1 USING COVERING INDEX t1bc} - nLoop 10 nVisit 200 nEst 52.0 zName t2xy + nLoop 10 nVisit 200 nEst 56.0 zName t2xy zExplain {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)} } diff --git a/test/skipscan1.test b/test/skipscan1.test index ac26711603..6d77e63498 100644 --- a/test/skipscan1.test +++ b/test/skipscan1.test @@ -43,23 +43,23 @@ do_execsql_test skipscan1-1.2 { } {abc 345 7 8 | def 345 9 10 |} do_execsql_test skipscan1-1.2eqp { EXPLAIN QUERY PLAN - SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a; } {/* USING INDEX t1abc (ANY(a) AND b=?)*/} do_execsql_test skipscan1-1.2sort { EXPLAIN QUERY PLAN - SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a; } {~/*ORDER BY*/} do_execsql_test skipscan1-1.3 { - SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a DESC; + SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC; } {def 345 9 10 | abc 345 7 8 |} do_execsql_test skipscan1-1.3eqp { EXPLAIN QUERY PLAN - SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC; } {/* USING INDEX t1abc (ANY(a) AND b=?)*/} do_execsql_test skipscan1-1.3sort { EXPLAIN QUERY PLAN - SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC; } {~/*ORDER BY*/} do_execsql_test skipscan1-1.4 { @@ -150,15 +150,15 @@ do_execsql_test skipscan1-2.1 { } {} do_execsql_test skipscan1-2.2 { - SELECT a,b,c,d,'|' FROM t2 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a; } {abc 345 7 8 | def 345 9 10 |} do_execsql_test skipscan1-2.2eqp { EXPLAIN QUERY PLAN - SELECT a,b,c,d,'|' FROM t2 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a; } {/* USING INDEX sqlite_autoindex_t2_1 (ANY(a) AND b=?)*/} do_execsql_test skipscan1-2.2sort { EXPLAIN QUERY PLAN - SELECT a,b,c,d,'|' FROM t2 WHERE b=345 ORDER BY a; + SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a; } {~/*ORDER BY*/} From fefe82876c71bb9433a2474236916d95997ec2e3 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 29 Jul 2016 01:46:57 +0000 Subject: [PATCH 261/302] Update the autoconf makefile for MSVC. FossilOrigin-Name: 2daf20980d4cb9ed36372778ae1f3e595e503549 --- autoconf/Makefile.msc | 11 +++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index 2f7447383f..d3bbc6b4d2 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -24,6 +24,13 @@ TOP = . USE_FULLWARN = 0 !ENDIF +# Set this non-0 to enable full runtime error checks (-RTC1, etc). This +# has no effect if (any) optimizations are enabled. +# +!IFNDEF USE_RUNTIME_CHECKS +USE_RUNTIME_CHECKS = 0 +!ENDIF + # Set this non-0 to use "stdcall" calling convention for the core library # and shell executable. # @@ -740,6 +747,10 @@ RCC = $(RCC) -D_DEBUG !IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0 TCC = $(TCC) -Od BCC = $(BCC) -Od +!IF $(USE_RUNTIME_CHECKS)!=0 +TCC = $(TCC) -RTC1 +BCC = $(BCC) -RTC1 +!ENDIF !ELSEIF $(OPTIMIZATIONS)>=3 TCC = $(TCC) -Ox BCC = $(BCC) -Ox diff --git a/manifest b/manifest index 3a567d4deb..02ee3f6e46 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smacro\snecessary\sfor\sbuilding\sseveral\sextensions\swhen\sthe\s__stdcall\scalling\sconvention\sis\snot\sin\suse. -D 2016-07-29T01:31:49.222 +C Update\sthe\sautoconf\smakefile\sfor\sMSVC. +D 2016-07-29T01:46:57.427 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -11,7 +11,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 -F autoconf/Makefile.msc 05a99e98a8895461574ccb9604444d9e97c1f0b6 +F autoconf/Makefile.msc 7a909aa9b538138a21c0626e3ffc4b1f4519f50e F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac cacf2616abf6e4a569bde2ef365c143caeec40bc @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fc5c187602acceedf7152b6927616d134f779a8f -R d16dc76cf59643dacfea9f5d3d7324b6 +P bc8c9b55ddf5227dc6b2116486f4a19bf54fce2b +R 81c2da6dd9132e2ceb1da7d33d25fdb6 U mistachkin -Z 029d2b66c80fad0a70d5e0c29c8d9e88 +Z 72b9cccf5e1018e731ec3108866ee753 diff --git a/manifest.uuid b/manifest.uuid index 3703d2538c..b2d11c5e33 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc8c9b55ddf5227dc6b2116486f4a19bf54fce2b \ No newline at end of file +2daf20980d4cb9ed36372778ae1f3e595e503549 \ No newline at end of file From d62c07d42ebd9b12db27c89019a596745548e399 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 29 Jul 2016 02:04:36 +0000 Subject: [PATCH 262/302] Fix typo in a test file interactive output string. FossilOrigin-Name: 4fedd7902371935e1374ca7df3ffd4c4cf93959b --- manifest | 15 +++++++-------- manifest.uuid | 2 +- test/walprotocol.test | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index da1d23e9ba..37d9dc7dd2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sadditional\slinkage\smacro\schanges\sfrom\sthe\sbranch. -D 2016-07-29T01:55:42.841 +C Fix\stypo\sin\sa\stest\sfile\sinteractive\soutput\sstring. +D 2016-07-29T02:04:36.873 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -1374,7 +1374,7 @@ F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 -F test/walprotocol.test 059cb75484a1ecf6357a2c1b3324b8156749221e +F test/walprotocol.test 0b92feb132ccebd855494d917d3f6c2d717ace20 F test/walro.test 4ab7ac01b77c2f894235c699d59e3e3c7f15a160 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f @@ -1508,8 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 45588de385d2a721b3e9f04beb6c7b789dd27d42 71ffa195f5a48280ee522d80ab82e8cdea636961 -R 092b06ead5aa5690fab5536515621278 -T +closed 71ffa195f5a48280ee522d80ab82e8cdea636961 -U drh -Z 3d26d07289768bac8aea9d48f7d64298 +P 8b0eb22ee12b23421dcb8dbeb46909d813788a0b +R 1c5c6cdbf6280e0f07ddb24f0c5484bf +U mistachkin +Z 2e0de3b0c7e8ecb85c119417abdb6170 diff --git a/manifest.uuid b/manifest.uuid index e13e9140e9..becc573de8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b0eb22ee12b23421dcb8dbeb46909d813788a0b \ No newline at end of file +4fedd7902371935e1374ca7df3ffd4c4cf93959b \ No newline at end of file diff --git a/test/walprotocol.test b/test/walprotocol.test index d658de9d7c..ee8d0b72a5 100644 --- a/test/walprotocol.test +++ b/test/walprotocol.test @@ -69,7 +69,7 @@ proc lock_callback {method filename handle lock} { if {$lock == "1 7 lock exclusive"} { return SQLITE_BUSY } return SQLITE_OK } -puts "# Warning: This next test case causes SQLite to call xSlee(1) 100 times." +puts "# Warning: This next test case causes SQLite to call xSleep(1) 100 times." puts "# Normally this equates to a delay of roughly 10 seconds, but if SQLite" puts "# is built on unix without HAVE_USLEEP defined, it may be much longer." do_test 1.3 { From be56ad31b742d21496863b4b4105b137e7df712e Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 29 Jul 2016 04:12:18 +0000 Subject: [PATCH 263/302] For test 'shell1-5.0', disable round-trip testing for characters in the range 0xE0 to 0xEF on Linux, due to intermittent shell portability issues. FossilOrigin-Name: 544c990afd3b64064cc4d970ec5d7eb23eeb9914 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/shell1.test | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 37d9dc7dd2..4056580492 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\sa\stest\sfile\sinteractive\soutput\sstring. -D 2016-07-29T02:04:36.873 +C For\stest\s'shell1-5.0',\sdisable\sround-trip\stesting\sfor\scharacters\sin\sthe\srange\s0xE0\sto\s0xEF\son\sLinux,\sdue\sto\sintermittent\sshell\sportability\sissues. +D 2016-07-29T04:12:18.810 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -1065,7 +1065,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 2f2aee20db294b9924e81f6ccbe60f19e21e8506 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 77896b65f1cde4ee79e38b2c0ed8578a8f4000e5 +F test/shell1.test 65b10cd8a90cda9b5af9100a45689a57dcc01a31 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b0eb22ee12b23421dcb8dbeb46909d813788a0b -R 1c5c6cdbf6280e0f07ddb24f0c5484bf +P 4fedd7902371935e1374ca7df3ffd4c4cf93959b +R 85f77acfa5a811a346c23b19da557acb U mistachkin -Z 2e0de3b0c7e8ecb85c119417abdb6170 +Z a69746948670b38e6b2794c69171ee54 diff --git a/manifest.uuid b/manifest.uuid index becc573de8..3a0d9eb7fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fedd7902371935e1374ca7df3ffd4c4cf93959b \ No newline at end of file +544c990afd3b64064cc4d970ec5d7eb23eeb9914 \ No newline at end of file diff --git a/test/shell1.test b/test/shell1.test index 03c2dee1d1..9a966fd8db 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -871,6 +871,7 @@ do_test shell1-5.0 { continue } if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue + if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue set hex [format %02X $i] set char [subst \\x$hex]; set oldChar $char set escapes [list] From 11f69b879c5b9f4dcd566fda776e03bc23c94147 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 29 Jul 2016 17:36:27 +0000 Subject: [PATCH 264/302] Using the header file 'intrin.h' requires MSVC 2005 or later. FossilOrigin-Name: 9fae75c08b7d3b3e13734193ad8398ef6971cbac --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4056580492..ddf53b746a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\stest\s'shell1-5.0',\sdisable\sround-trip\stesting\sfor\scharacters\sin\sthe\srange\s0xE0\sto\s0xEF\son\sLinux,\sdue\sto\sintermittent\sshell\sportability\sissues. -D 2016-07-29T04:12:18.810 +C Using\sthe\sheader\sfile\s'intrin.h'\srequires\sMSVC\s2005\sor\slater. +D 2016-07-29T17:36:27.088 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -388,7 +388,7 @@ F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 F src/sqlite.h.in cd10e4206b91c4bf03f121ab9209a14af0b48f14 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h f4206565eb5f5cef9a1544d32a076b5f47af1bdc -F src/sqliteInt.h 14516943867eb2c30ce0e3670299958f59ade052 +F src/sqliteInt.h d6f221a5bd572df935140beda82f357c2185a77c F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fedd7902371935e1374ca7df3ffd4c4cf93959b -R 85f77acfa5a811a346c23b19da557acb +P 544c990afd3b64064cc4d970ec5d7eb23eeb9914 +R ceef2b71453325469cbc16ff7674c4c9 U mistachkin -Z a69746948670b38e6b2794c69171ee54 +Z 0275ffb3719041525e752ce514a5292f diff --git a/manifest.uuid b/manifest.uuid index 3a0d9eb7fe..5827550e55 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -544c990afd3b64064cc4d970ec5d7eb23eeb9914 \ No newline at end of file +9fae75c08b7d3b3e13734193ad8398ef6971cbac \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 35be76dfb0..0ce56ceab1 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -234,7 +234,7 @@ ** the SQLITE_DISABLE_INTRINSIC define. */ #if !defined(SQLITE_DISABLE_INTRINSIC) -# if defined(_MSC_VER) && _MSC_VER>=1300 +# if defined(_MSC_VER) && _MSC_VER>=1400 # if !defined(_WIN32_WCE) # include # pragma intrinsic(_byteswap_ushort) From 19e76b2a7cf4b1b42f2d90ef27ea852603206bb2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 30 Jul 2016 18:54:54 +0000 Subject: [PATCH 265/302] Fix harmless compiler warning seen with MSVC. FossilOrigin-Name: 390a38a142d36d2c57b3f21aab72edcde450125d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ddf53b746a..9657203bbb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Using\sthe\sheader\sfile\s'intrin.h'\srequires\sMSVC\s2005\sor\slater. -D 2016-07-29T17:36:27.088 +C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. +D 2016-07-30T18:54:54.989 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -463,7 +463,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c fcaa38d19c2a7bb450cc57810bdc3d4eb36e00b0 +F src/where.c bb1444f6ae6bc3cbd086cc61cd9c6e3a6168d89b F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 544c990afd3b64064cc4d970ec5d7eb23eeb9914 -R ceef2b71453325469cbc16ff7674c4c9 +P 9fae75c08b7d3b3e13734193ad8398ef6971cbac +R 20430021b7d310aa0691f2edba10b981 U mistachkin -Z 0275ffb3719041525e752ce514a5292f +Z 1a5ea8a378b7c26f7d4d45026b5640de diff --git a/manifest.uuid b/manifest.uuid index 5827550e55..dedb9c60d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9fae75c08b7d3b3e13734193ad8398ef6971cbac \ No newline at end of file +390a38a142d36d2c57b3f21aab72edcde450125d \ No newline at end of file diff --git a/src/where.c b/src/where.c index da41c142fa..9b3c281efc 100644 --- a/src/where.c +++ b/src/where.c @@ -2786,9 +2786,9 @@ static int whereLoopAddBtree( LogEst nLookup = rSize + 16; /* Base cost: N*3 */ int ii; int iCur = pSrc->iCursor; - WhereClause *pWC = &pWInfo->sWC; - for(ii=0; iinTerm; ii++){ - WhereTerm *pTerm = &pWC->a[ii]; + WhereClause *pWC2 = &pWInfo->sWC; + for(ii=0; iinTerm; ii++){ + WhereTerm *pTerm = &pWC2->a[ii]; if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){ break; } From 32c83c8b9e4fc3a5af99856ae6db15694dbe0414 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 1 Aug 2016 14:35:48 +0000 Subject: [PATCH 266/302] Avoid making unnecessary changes to the signatures of the sqlite3_auto_extension() and sqlite3_cancel_auto_extension() interfaces. FossilOrigin-Name: b6ea2f21f602031ef4dbd47462ac11b0bb0d5de6 --- manifest | 28 ++++++++++++++-------------- manifest.uuid | 2 +- src/loadext.c | 4 ++-- src/sqlite.h.in | 23 ++++++++++++++--------- src/sqlite3ext.h | 7 ++----- src/test1.c | 1 - src/test_autoext.c | 12 ++++++------ src/test_func.c | 10 +++++----- src/test_multiplex.c | 2 +- src/test_thread.c | 2 +- 10 files changed, 46 insertions(+), 45 deletions(-) diff --git a/manifest b/manifest index 9657203bbb..76e84155ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. -D 2016-07-30T18:54:54.989 +C Avoid\smaking\sunnecessary\schanges\sto\sthe\ssignatures\sof\sthe\nsqlite3_auto_extension()\sand\ssqlite3_cancel_auto_extension()\sinterfaces. +D 2016-08-01T14:35:48.519 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -347,7 +347,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e -F src/loadext.c c3c2a37e4ce940d17c73971738754d412c79e09d +F src/loadext.c 0ac0030646e4ec3c775b5c40d1818ec9a7e1ca95 F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -385,15 +385,15 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5 -F src/sqlite.h.in cd10e4206b91c4bf03f121ab9209a14af0b48f14 +F src/sqlite.h.in b41cf2d1deb59db570f20e8ed7ade4716c6dc613 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h f4206565eb5f5cef9a1544d32a076b5f47af1bdc +F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h d6f221a5bd572df935140beda82f357c2185a77c F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c bdae822f21e229b6daced15938b6343ce44ef454 -F src/test1.c 906a04b649c7139e943193a3905d583e325c30c7 +F src/test1.c 0a0909cf7962d2359db329c08d15b90b4b6e724f F src/test2.c b7174313e993754303a8b33c43df7c44b46857ab F src/test3.c 1339a40be39650ae83894b6578f971dc7f96ea8a F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -403,7 +403,7 @@ F src/test7.c 5612e9aecf934d6df7bba6ce861fdf5ba5456010 F src/test8.c 4f4904721167b32f7a4fa8c7b32a07a673d6cc86 F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a -F src/test_autoext.c cc69375c006b7bac6094ec602f52525350fd5229 +F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871 F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0 F src/test_bestindex.c d23f80d334c59662af69191854c76b8d3d0c8c96 F src/test_blob.c a0f7ad49a0c9d4b72f693fe2a71c58d7e507174d @@ -412,7 +412,7 @@ F src/test_config.c 4d3d4a886416f369771d69a6dba926866deda788 F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 F src/test_fs.c ac62ce7d5c0c23aa6932891cad5746945564c91c -F src/test_func.c 6f34b19ae097e3cf0b0fe5d6904cb9900e67f2ff +F src/test_func.c a2b4993da973b0ea60dd5d51a7066238ede8c329 F src/test_hexio.c 1d4469ca61ab202a1fcec6543f584d2407205e8d F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664 F src/test_intarray.c 988fc61cb0ff539f4172c0d95f15287c92516f64 @@ -420,7 +420,7 @@ F src/test_intarray.h f3b7672f5d1056eac563c0d6ea8480a660b1475c F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd F src/test_malloc.c c05f6c40bd6c8bfe5f1718212f81fd5687f91766 -F src/test_multiplex.c 371d3874fd6365f18468d1c131e153e5c9abe95e +F src/test_multiplex.c 7c5b218d855cd0505a43185d55283b3fc257c8da F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635 F src/test_mutex.c 7f4337ba23ee6b1d2ec81c189653608cb069926a F src/test_onefile.c 416f87a28d6d673352d33fc4b1c7d39db878e50f @@ -435,7 +435,7 @@ F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939 F src/test_tclvar.c df9fe1213c2634687a9ca0b0bec0d2119d359ae3 -F src/test_thread.c 89f0e47dac64e7ab15ca0a4fc87e0882c495ae21 +F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858 F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 @@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9fae75c08b7d3b3e13734193ad8398ef6971cbac -R 20430021b7d310aa0691f2edba10b981 -U mistachkin -Z 1a5ea8a378b7c26f7d4d45026b5640de +P 390a38a142d36d2c57b3f21aab72edcde450125d +R 65e7d16d0e1a0cbde00eb39308479bd3 +U drh +Z ed98f4241335140747349246aea331ad diff --git a/manifest.uuid b/manifest.uuid index dedb9c60d3..6b01792124 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -390a38a142d36d2c57b3f21aab72edcde450125d \ No newline at end of file +b6ea2f21f602031ef4dbd47462ac11b0bb0d5de6 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 163141bf73..26ba7e6491 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -676,7 +676,7 @@ static SQLITE_WSD struct sqlite3AutoExtList { ** loaded by every new database connection. */ int sqlite3_auto_extension( - int (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) + void (*xInit)(void) ){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_AUTOINIT @@ -723,7 +723,7 @@ int sqlite3_auto_extension( ** was not on the list. */ int sqlite3_cancel_auto_extension( - int (*xInit)(sqlite3 *, char **, const sqlite3_api_routines *) + void (*xInit)(void) ){ #if SQLITE_THREADSAFE sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9d28cdc05a..27ca6ef4ad 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1045,6 +1045,16 @@ struct sqlite3_io_methods { */ typedef struct sqlite3_mutex sqlite3_mutex; +/* +** CAPI3REF: Loadable Extension Thunk +** +** A pointer to the opaque sqlite3_api_routines structure is passed as +** the third parameter to entry points of [loadable extensions]. This +** structure must be typedefed in order to work around compiler warnings +** on some platforms. +*/ +typedef struct sqlite3_api_routines sqlite3_api_routines; + /* ** CAPI3REF: OS Interface Object ** @@ -2242,7 +2252,7 @@ int sqlite3_complete16(const void *sql); ** A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ -int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); +int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*); /* ** CAPI3REF: Set A Busy Timeout @@ -5681,7 +5691,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff); ** ** ^(Even though the function prototype shows that xEntryPoint() takes ** no arguments and returns void, SQLite invokes xEntryPoint() with three -** arguments and expects and integer result as if the signature of the +** arguments and expects an integer result as if the signature of the ** entry point where as follows: ** **
@@ -5707,10 +5717,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
 ** See also: [sqlite3_reset_auto_extension()]
 ** and [sqlite3_cancel_auto_extension()]
 */
-typedef struct sqlite3_api_routines sqlite3_api_routines;
-int sqlite3_auto_extension(
-  int (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *)
-);
+int sqlite3_auto_extension(void(*xEntryPoint)(void));
 
 /*
 ** CAPI3REF: Cancel Automatic Extension Loading
@@ -5722,9 +5729,7 @@ int sqlite3_auto_extension(
 ** unregistered and it returns 0 if X was not on the list of initialization
 ** routines.
 */
-int sqlite3_cancel_auto_extension(
-  int (*xEntryPoint)(sqlite3 *, char **, const sqlite3_api_routines *)
-);
+int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
 
 /*
 ** CAPI3REF: Reset Automatic Extension Loading
diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h
index 689a5c4856..ce87e74690 100644
--- a/src/sqlite3ext.h
+++ b/src/sqlite3ext.h
@@ -19,8 +19,6 @@
 #define SQLITE3EXT_H
 #include "sqlite3.h"
 
-typedef struct sqlite3_api_routines sqlite3_api_routines;
-
 /*
 ** The following structure holds pointers to all of the SQLite API
 ** routines.
@@ -251,13 +249,12 @@ struct sqlite3_api_routines {
   char *(*vsnprintf)(int,char*,const char*,va_list);
   int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
   /* Version 3.8.7 and later */
-  int (*auto_extension)(int(*)(sqlite3*,char**,const sqlite3_api_routines*));
+  int (*auto_extension)(void(*)(void));
   int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
                      void(*)(void*));
   int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
                       void(*)(void*),unsigned char);
-  int (*cancel_auto_extension)(int(*)(sqlite3*,char**,
-                                       const sqlite3_api_routines*));
+  int (*cancel_auto_extension)(void(*)(void));
   int (*load_extension)(sqlite3*,const char*,const char*,char**);
   void *(*malloc64)(sqlite3_uint64);
   sqlite3_uint64 (*msize)(void*);
diff --git a/src/test1.c b/src/test1.c
index ec6d8ecff3..aced552173 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -6742,7 +6742,6 @@ static int SQLITE_TCLAPI optimization_control(
   return TCL_OK;
 }
 
-typedef struct sqlite3_api_routines sqlite3_api_routines;
 /*
 **     load_static_extension DB NAME ...
 **
diff --git a/src/test_autoext.c b/src/test_autoext.c
index f962a51d6b..e23e41a08a 100644
--- a/src/test_autoext.c
+++ b/src/test_autoext.c
@@ -100,7 +100,7 @@ static int SQLITE_TCLAPI autoExtSqrObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-  int rc = sqlite3_auto_extension(sqr_init);
+  int rc = sqlite3_auto_extension((void(*)(void))sqr_init);
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return SQLITE_OK;
 }
@@ -116,7 +116,7 @@ static int SQLITE_TCLAPI cancelAutoExtSqrObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-  int rc = sqlite3_cancel_auto_extension(sqr_init);
+  int rc = sqlite3_cancel_auto_extension((void(*)(void))sqr_init);
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return SQLITE_OK;
 }
@@ -132,7 +132,7 @@ static int SQLITE_TCLAPI autoExtCubeObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-  int rc = sqlite3_auto_extension(cube_init);
+  int rc = sqlite3_auto_extension((void(*)(void))cube_init);
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return SQLITE_OK;
 }
@@ -148,7 +148,7 @@ static int SQLITE_TCLAPI cancelAutoExtCubeObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-  int rc = sqlite3_cancel_auto_extension(cube_init);
+  int rc = sqlite3_cancel_auto_extension((void(*)(void))cube_init);
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return SQLITE_OK;
 }
@@ -164,7 +164,7 @@ static int SQLITE_TCLAPI autoExtBrokenObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-  int rc = sqlite3_auto_extension(broken_init);
+  int rc = sqlite3_auto_extension((void(*)(void))broken_init);
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return SQLITE_OK;
 }
@@ -180,7 +180,7 @@ static int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd(
   int objc,
   Tcl_Obj *CONST objv[]
 ){
-  int rc = sqlite3_cancel_auto_extension(broken_init);
+  int rc = sqlite3_cancel_auto_extension((void(*)(void))broken_init);
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return SQLITE_OK;
 }
diff --git a/src/test_func.c b/src/test_func.c
index 6bfa862464..26f0d369ef 100644
--- a/src/test_func.c
+++ b/src/test_func.c
@@ -25,7 +25,6 @@
 #include "sqliteInt.h"
 #include "vdbeInt.h"
 
-
 /*
 ** Allocate nByte bytes of space using sqlite3_malloc(). If the
 ** allocation fails, call sqlite3_result_error_nomem() to notify
@@ -704,9 +703,9 @@ static int SQLITE_TCLAPI autoinstall_test_funcs(
   Tcl_Obj *CONST objv[]
 ){
   extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);
-  int rc = sqlite3_auto_extension(registerTestFunctions);
+  int rc = sqlite3_auto_extension((void(*)(void))registerTestFunctions);
   if( rc==SQLITE_OK ){
-    rc = sqlite3_auto_extension(Md5_Register);
+    rc = sqlite3_auto_extension((void(*)(void))Md5_Register);
   }
   Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
   return TCL_OK;
@@ -791,6 +790,7 @@ abuse_err:
   return TCL_ERROR;
 }
 
+
 /*
 ** Register commands with the TCL interpreter.
 */
@@ -809,7 +809,7 @@ int Sqlitetest_func_Init(Tcl_Interp *interp){
     Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);
   }
   sqlite3_initialize();
-  sqlite3_auto_extension(registerTestFunctions);
-  sqlite3_auto_extension(Md5_Register);
+  sqlite3_auto_extension((void(*)(void))registerTestFunctions);
+  sqlite3_auto_extension((void(*)(void))Md5_Register);
   return TCL_OK;
 }
diff --git a/src/test_multiplex.c b/src/test_multiplex.c
index a7820975d6..1027aa1326 100644
--- a/src/test_multiplex.c
+++ b/src/test_multiplex.c
@@ -1197,7 +1197,7 @@ int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault){
   gMultiplex.sIoMethodsV2.xShmUnmap = multiplexShmUnmap;
   sqlite3_vfs_register(&gMultiplex.sThisVfs, makeDefault);
 
-  sqlite3_auto_extension(multiplexFuncInit);
+  sqlite3_auto_extension((void(*)(void))multiplexFuncInit);
 
   return SQLITE_OK;
 }
diff --git a/src/test_thread.c b/src/test_thread.c
index 927fee1f56..20b4cf148b 100644
--- a/src/test_thread.c
+++ b/src/test_thread.c
@@ -280,7 +280,7 @@ static int SQLITE_TCLAPI sqlthread_open(
   const char *zFilename;
   sqlite3 *db;
   char zBuf[100];
-  extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);
+  extern int Md5_Register(sqlite3*,char**,const sqlite3_api_routines*);
 
   UNUSED_PARAMETER(clientData);
   UNUSED_PARAMETER(objc);

From 8ef24b8debb430e0f22d65ffeba018e576be4ee6 Mon Sep 17 00:00:00 2001
From: drh 
Date: Mon, 1 Aug 2016 15:00:00 +0000
Subject: [PATCH 267/302] Update releasetest.tcl to automatically do one round
 of tests with USE_STDCALL=1 when running on Windows with MSVC.

FossilOrigin-Name: a6a112de485eb9d15f6fa75568dcb876f00abb64
---
 manifest             | 12 ++++++------
 manifest.uuid        |  2 +-
 test/releasetest.tcl |  9 +++++++++
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/manifest b/manifest
index 76e84155ee..67dc23aac2 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Avoid\smaking\sunnecessary\schanges\sto\sthe\ssignatures\sof\sthe\nsqlite3_auto_extension()\sand\ssqlite3_cancel_auto_extension()\sinterfaces.
-D 2016-08-01T14:35:48.519
+C Update\sreleasetest.tcl\sto\sautomatically\sdo\sone\sround\sof\stests\swith\nUSE_STDCALL=1\swhen\srunning\son\sWindows\swith\sMSVC.
+D 2016-08-01T15:00:00.879
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -1010,7 +1010,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8
 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8
 F test/regexp2.test aa7ffcc21350007a78361b82bcf3b74d12227144
 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
-F test/releasetest.tcl 3a66c7b8fbe55bcd97c907217c3d812d1d3c6b93
+F test/releasetest.tcl 53560b838b79c468ec9973e0dfa3d8892628887f
 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
 F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea
 F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5
@@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 390a38a142d36d2c57b3f21aab72edcde450125d
-R 65e7d16d0e1a0cbde00eb39308479bd3
+P b6ea2f21f602031ef4dbd47462ac11b0bb0d5de6
+R 8c53f29684f1c5a6b809ef407293ad87
 U drh
-Z ed98f4241335140747349246aea331ad
+Z efd5176c6b70600d1d70a952504ac1b9
diff --git a/manifest.uuid b/manifest.uuid
index 6b01792124..45a5d2cc7d 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-b6ea2f21f602031ef4dbd47462ac11b0bb0d5de6
\ No newline at end of file
+a6a112de485eb9d15f6fa75568dcb876f00abb64
\ No newline at end of file
diff --git a/test/releasetest.tcl b/test/releasetest.tcl
index e13a3d7340..f670c8bef4 100644
--- a/test/releasetest.tcl
+++ b/test/releasetest.tcl
@@ -58,6 +58,10 @@ array set ::Configs [strip_comments {
     -DSQLITE_ENABLE_STAT4
     --enable-session
   }
+  "Stdcall" {
+    -DUSE_STDCALL=1
+    -O2
+  }
   "Have-Not" {
     # The "Have-Not" configuration sets all possible -UHAVE_feature options
     # in order to verify that the code works even on platforms that lack
@@ -298,10 +302,12 @@ array set ::Platforms [strip_comments {
     "Apple"                   "threadtest fulltest"
   }
   "Windows NT-intel" {
+    "Stdcall"                 test
     "Have-Not"                test
     "Default"                 "mptest fulltestonly"
   }
   "Windows NT-amd64" {
+    "Stdcall"                 test
     "Have-Not"                test
     "Default"                 "mptest fulltestonly"
   }
@@ -725,6 +731,9 @@ proc makeCommand { targets makeOpts cflags opts } {
     set nmakeDir [file nativename $::SRCDIR]
     set nmakeFile [file nativename [file join $nmakeDir Makefile.msc]]
     lappend result nmake /f $nmakeFile TOP=$nmakeDir
+    if {[regexp {USE_STDCALL=1} $cflags]} {
+      lappend result USE_STDCALL=1
+    }
   } else {
     lappend result make
   }

From d7d19b7137b659537dc4bc0622f6cc88384e008f Mon Sep 17 00:00:00 2001
From: dan 
Date: Mon, 1 Aug 2016 16:50:50 +0000
Subject: [PATCH 268/302] Add an extra compiler switch to loadext.test to
 ensure that it picks up the correct version of sqlite3.h when building a test
 extension.

FossilOrigin-Name: e57fa6af32a1d1bf7be64b26850730f7e714b6c6
---
 manifest          | 14 +++++++-------
 manifest.uuid     |  2 +-
 test/loadext.test |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/manifest b/manifest
index 67dc23aac2..ad8c64f8c0 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\sreleasetest.tcl\sto\sautomatically\sdo\sone\sround\sof\stests\swith\nUSE_STDCALL=1\swhen\srunning\son\sWindows\swith\sMSVC.
-D 2016-08-01T15:00:00.879
+C Add\san\sextra\scompiler\sswitch\sto\sloadext.test\sto\sensure\sthat\sit\spicks\sup\sthe\scorrect\sversion\sof\ssqlite3.h\swhen\sbuilding\sa\stest\sextension.
+D 2016-08-01T16:50:50.941
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -889,7 +889,7 @@ F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
 F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4
 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e
 F test/limit2.test 55c9f4d08c89311e00afd75045ee1a2aca205cb4
-F test/loadext.test 42a3b8166dfcadcb0e0c8710dc520d97c31a8b98
+F test/loadext.test d077450695ddb5c1ea3ad7d48e5f5850fe732ad9
 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7
 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db
 F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff
@@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b6ea2f21f602031ef4dbd47462ac11b0bb0d5de6
-R 8c53f29684f1c5a6b809ef407293ad87
-U drh
-Z efd5176c6b70600d1d70a952504ac1b9
+P a6a112de485eb9d15f6fa75568dcb876f00abb64
+R b52843774fa6a1a75de37b3a2fbcc9cb
+U dan
+Z 4c7b22bb74a34454d19b7a6d615357b5
diff --git a/manifest.uuid b/manifest.uuid
index 45a5d2cc7d..309a3154e8 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-a6a112de485eb9d15f6fa75568dcb876f00abb64
\ No newline at end of file
+e57fa6af32a1d1bf7be64b26850730f7e714b6c6
\ No newline at end of file
diff --git a/test/loadext.test b/test/loadext.test
index e6ba21e187..24ee7a6802 100644
--- a/test/loadext.test
+++ b/test/loadext.test
@@ -81,7 +81,7 @@ if {![file exists $testextension]} {
   set testextsrc $srcdir/test_loadext.c
 
   set cmdline [concat exec gcc $gcc_shared]
-  lappend cmdline -Wall -I$srcdir -I. -g $testextsrc -o $testextension
+  lappend cmdline -Wall -I$srcdir -I. -I.. -g $testextsrc -o $testextension
   
   if {[catch $cmdline msg]} {
     puts "Skipping loadext tests: Test extension not built..."

From 4df049faec84a2287f9ec3b556da4da3f703b23d Mon Sep 17 00:00:00 2001
From: dan 
Date: Mon, 1 Aug 2016 16:57:30 +0000
Subject: [PATCH 269/302] Remove a duplicate typedef from loadext.c (remaining
 copy is in sqlite3ext.h).

FossilOrigin-Name: fd184e5a8f4577aa9a817eb55e771d8d1021b946
---
 manifest      | 12 ++++++------
 manifest.uuid |  2 +-
 src/loadext.c |  9 ---------
 3 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/manifest b/manifest
index ad8c64f8c0..12abe5c148 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\san\sextra\scompiler\sswitch\sto\sloadext.test\sto\sensure\sthat\sit\spicks\sup\sthe\scorrect\sversion\sof\ssqlite3.h\swhen\sbuilding\sa\stest\sextension.
-D 2016-08-01T16:50:50.941
+C Remove\sa\sduplicate\stypedef\sfrom\sloadext.c\s(remaining\scopy\sis\sin\ssqlite3ext.h).
+D 2016-08-01T16:57:30.301
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -347,7 +347,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
 F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b
 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
-F src/loadext.c 0ac0030646e4ec3c775b5c40d1818ec9a7e1ca95
+F src/loadext.c ab2870487f4313a69816f15cb66d6c116051d895
 F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3
 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
@@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P a6a112de485eb9d15f6fa75568dcb876f00abb64
-R b52843774fa6a1a75de37b3a2fbcc9cb
+P e57fa6af32a1d1bf7be64b26850730f7e714b6c6
+R 95d57e7a20ef51e72dadff0e39b4eac0
 U dan
-Z 4c7b22bb74a34454d19b7a6d615357b5
+Z dd3eec4e4b9fe5243b233856e0e2f91d
diff --git a/manifest.uuid b/manifest.uuid
index 309a3154e8..564b2f8413 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-e57fa6af32a1d1bf7be64b26850730f7e714b6c6
\ No newline at end of file
+fd184e5a8f4577aa9a817eb55e771d8d1021b946
\ No newline at end of file
diff --git a/src/loadext.c b/src/loadext.c
index 26ba7e6491..c2125f35e2 100644
--- a/src/loadext.c
+++ b/src/loadext.c
@@ -21,15 +21,6 @@
 #include 
 
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
-/*
-** This is the function signature used for all extension entry points.
-*/
-typedef int (*sqlite3_loadext_entry)(
-  sqlite3 *db,                       /* Handle to the database. */
-  char **pzErrMsg,                   /* Used to set error string on failure. */
-  const sqlite3_api_routines *pThunk /* Extension API function pointers. */
-);
-
 /*
 ** Some API routines are omitted when various features are
 ** excluded from a build of SQLite.  Substitute a NULL pointer

From b0df540d7a5537ba239d00911444096474f28ed0 Mon Sep 17 00:00:00 2001
From: drh 
Date: Mon, 1 Aug 2016 17:06:44 +0000
Subject: [PATCH 270/302] Fix other harmless compiler warnings.

FossilOrigin-Name: 90d2c490fc2ed4e073711b84f989ca4d496dcfb5
---
 ext/misc/json1.c |  1 +
 manifest         | 18 +++++++++---------
 manifest.uuid    |  2 +-
 src/loadext.c    |  6 +++---
 src/shell.c      |  2 ++
 5 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/ext/misc/json1.c b/ext/misc/json1.c
index a9452b0191..61c52ebe61 100644
--- a/ext/misc/json1.c
+++ b/ext/misc/json1.c
@@ -1223,6 +1223,7 @@ static void jsonQuoteFunc(
   sqlite3_value **argv
 ){
   JsonString jx;
+  UNUSED_PARAM(argc);
 
   jsonInit(&jx, ctx);
   jsonAppendValue(&jx, argv[0]);
diff --git a/manifest b/manifest
index 12abe5c148..fc5ee826f4 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sa\sduplicate\stypedef\sfrom\sloadext.c\s(remaining\scopy\sis\sin\ssqlite3ext.h).
-D 2016-08-01T16:57:30.301
+C Fix\sother\sharmless\scompiler\swarnings.
+D 2016-08-01T17:06:44.553
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -212,7 +212,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c
-F ext/misc/json1.c d51a764ba43a49e191bc3536238bfab3def258ca
+F ext/misc/json1.c 9799e4252b305edcbe659329eec3ca80ed85f968
 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
 F ext/misc/percentile.c 92699c8cd7d517ff610e6037e56506f8904dae2e
 F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
@@ -347,7 +347,7 @@ F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
 F src/insert.c 8f4e9fcbd8e95e85f15647ba8b413b18d556ec2b
 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
-F src/loadext.c ab2870487f4313a69816f15cb66d6c116051d895
+F src/loadext.c dd7a2b77902cc66c22555aef02e1a682554b7aec
 F src/main.c 16c1b2114eae8804caf3a8de8cb47bf2c6d83ad3
 F src/malloc.c 1443d1ad95d67c21d77af7ae3f44678252f0efec
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
@@ -384,7 +384,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
 F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4
-F src/shell.c 9351fc6de11e1d908648c0a92d85627138e3dee5
+F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7
 F src/sqlite.h.in b41cf2d1deb59db570f20e8ed7ade4716c6dc613
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
@@ -1508,7 +1508,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P e57fa6af32a1d1bf7be64b26850730f7e714b6c6
-R 95d57e7a20ef51e72dadff0e39b4eac0
-U dan
-Z dd3eec4e4b9fe5243b233856e0e2f91d
+P fd184e5a8f4577aa9a817eb55e771d8d1021b946
+R ee6ea998e955e1020bf52b2850224f49
+U drh
+Z 082f7342c6c06c2add554ab4b05f638a
diff --git a/manifest.uuid b/manifest.uuid
index 564b2f8413..0a3df4be92 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-fd184e5a8f4577aa9a817eb55e771d8d1021b946
\ No newline at end of file
+90d2c490fc2ed4e073711b84f989ca4d496dcfb5
\ No newline at end of file
diff --git a/src/loadext.c b/src/loadext.c
index c2125f35e2..9feabbd045 100644
--- a/src/loadext.c
+++ b/src/loadext.c
@@ -684,7 +684,7 @@ int sqlite3_auto_extension(
     wsdAutoextInit;
     sqlite3_mutex_enter(mutex);
     for(i=0; i=0; i--){
-    if( wsdAutoext.aExt[i]==(void*)xInit ){
+    if( wsdAutoext.aExt[i]==xInit ){
       wsdAutoext.nExt--;
       wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];
       n++;
diff --git a/src/shell.c b/src/shell.c
index e8d215b95a..18c6ef7197 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2550,6 +2550,8 @@ static int sql_trace_callback(
   void *pX
 ){
   FILE *f = (FILE*)pArg;
+  UNUSED_PARAMETER(mType);
+  UNUSED_PARAMETER(pP);
   if( f ){
     const char *z = (const char*)pX;
     int i = (int)strlen(z);

From 19eb77bbe044fec2f74ec411b745ed83598b7551 Mon Sep 17 00:00:00 2001
From: drh 
Date: Mon, 1 Aug 2016 21:17:53 +0000
Subject: [PATCH 271/302] Update the wordcount.c test program and add a new
 script "time-wordcount.sh" for additional performance testing.

FossilOrigin-Name: d8ef9f58643f13dd3d16dcde0d829ae08324f04b
---
 manifest               | 13 +++++-----
 manifest.uuid          |  2 +-
 test/time-wordcount.sh | 34 ++++++++++++++++++++++++++
 test/wordcount.c       | 54 ++++++++++++++++++++++++------------------
 4 files changed, 73 insertions(+), 30 deletions(-)
 create mode 100644 test/time-wordcount.sh

diff --git a/manifest b/manifest
index fc5ee826f4..15cc8e1381 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sother\sharmless\scompiler\swarnings.
-D 2016-08-01T17:06:44.553
+C Update\sthe\swordcount.c\stest\sprogram\sand\sadd\sa\snew\sscript\s"time-wordcount.sh"\nfor\sadditional\sperformance\stesting.
+D 2016-08-01T21:17:53.023
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -1142,6 +1142,7 @@ F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
 F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8
 F test/threadtest3.c 38a612ea62854349ed66372f330a40d73c5cf956
 F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925
+F test/time-wordcount.sh 8e0b0f8109367827ad5d58f5cc849705731e4b90
 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c
 F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660
 F test/tkt-2a5629202f.test 0521bd25658428baa26665aa53ffed9367d33af2
@@ -1416,7 +1417,7 @@ F test/without_rowid3.test aad4f9d383e199349b6c7e508a778f7dff5dff79
 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
 F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a
 F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e
-F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf
+F test/wordcount.c 97856eec21fd00d77da720007b1888c383f63dcf
 F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa
 F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e
 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5
@@ -1508,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P fd184e5a8f4577aa9a817eb55e771d8d1021b946
-R ee6ea998e955e1020bf52b2850224f49
+P 90d2c490fc2ed4e073711b84f989ca4d496dcfb5
+R 785c152fa91bad6599d646e4e2f00927
 U drh
-Z 082f7342c6c06c2add554ab4b05f638a
+Z e82d6de7fe92cf55ce862dce0d383efb
diff --git a/manifest.uuid b/manifest.uuid
index 0a3df4be92..a4b3d0224f 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-90d2c490fc2ed4e073711b84f989ca4d496dcfb5
\ No newline at end of file
+d8ef9f58643f13dd3d16dcde0d829ae08324f04b
\ No newline at end of file
diff --git a/test/time-wordcount.sh b/test/time-wordcount.sh
new file mode 100644
index 0000000000..df9edc6f2c
--- /dev/null
+++ b/test/time-wordcount.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# This script runs the wordcount program in different ways and generates
+# an output useful for performance comparisons.
+#
+
+# Select the source text to be analyzed.
+#
+if test "x$1" = "x";
+then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
+fi
+
+# Do test runs
+#
+rm -f wcdb1.db
+./wordcount --tag A: --timer --summary wcdb1.db $* --insert
+rm -f wcdb2.db
+./wordcount --tag B: --timer --summary wcdb2.db $* --insert --without-rowid
+rm -f wcdb1.db
+./wordcount --tag C: --timer --summary wcdb1.db $* --replace
+rm -f wcdb2.db
+./wordcount --tag D: --timer --summary wcdb2.db $* --replace --without-rowid
+rm -f wcdb1.db
+./wordcount --tag E: --timer --summary wcdb1.db $* --select
+rm -f wcdb2.db
+./wordcount --tag F: --timer --summary wcdb2.db $* --select --without-rowid
+./wordcount --tag G: --timer --summary wcdb1.db $* --query
+./wordcount --tag H: --timer --summary wcdb1.db $* --query --without-rowid
+./wordcount --tag I: --timer --summary wcdb1.db $* --delete
+./wordcount --tag J: --timer --summary wcdb2.db $* --delete --without-rowid
+
+# Clean up temporary files created.
+#
+rm -f wcdb1.db wcdb2.db
diff --git a/test/wordcount.c b/test/wordcount.c
index 72aa6b2f0b..5002918c5e 100644
--- a/test/wordcount.c
+++ b/test/wordcount.c
@@ -30,6 +30,7 @@
 **     --nosync             Use PRAGMA synchronous=OFF
 **     --journal MMMM       Use PRAGMA journal_mode=MMMM
 **     --timer              Time the operation of this program
+**     --tag NAME           Tag all output using NAME.  Use only stdout.
 **
 ** Modes:
 **
@@ -82,6 +83,9 @@
 #include "sqlite3.h"
 #define ISALPHA(X) isalpha((unsigned char)(X))
 
+/* Output tag */
+char *zTag = "--";
+
 /* Return the current wall-clock time */
 static sqlite3_int64 realTime(void){
   static sqlite3_vfs *clockVfs = 0;
@@ -115,7 +119,7 @@ static void traceCallback(void *NotUsed, const char *zSql){
 ** each column separated by a single space. */
 static int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){
   int i;
-  printf("--");
+  printf("%s", zTag);
   for(i=0; i
Date: Tue, 2 Aug 2016 08:45:26 +0000
Subject: [PATCH 272/302] Fix harmless compiler warnings in sqlite3_status().

FossilOrigin-Name: 7c38a79cdd42aaa45715aea330d10ca859098837
---
 manifest      | 12 ++++++------
 manifest.uuid |  2 +-
 src/status.c  |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/manifest b/manifest
index 15cc8e1381..02f0e10029 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\sthe\swordcount.c\stest\sprogram\sand\sadd\sa\snew\sscript\s"time-wordcount.sh"\nfor\sadditional\sperformance\stesting.
-D 2016-08-01T21:17:53.023
+C Fix\sharmless\scompiler\swarnings\sin\ssqlite3_status().
+D 2016-08-02T08:45:26.626
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -390,7 +390,7 @@ F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
 F src/sqliteInt.h d6f221a5bd572df935140beda82f357c2185a77c
 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
-F src/status.c 5b18f9526900f61189ab0b83f1ef41d9f871a2ab
+F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
 F src/tclsqlite.c bdae822f21e229b6daced15938b6343ce44ef454
 F src/test1.c 0a0909cf7962d2359db329c08d15b90b4b6e724f
@@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 90d2c490fc2ed4e073711b84f989ca4d496dcfb5
-R 785c152fa91bad6599d646e4e2f00927
+P d8ef9f58643f13dd3d16dcde0d829ae08324f04b
+R 043c924e3262ae632c6a04160549d94d
 U drh
-Z e82d6de7fe92cf55ce862dce0d383efb
+Z c53a56bb9efce70acc3af43de2ff893c
diff --git a/manifest.uuid b/manifest.uuid
index a4b3d0224f..a43f3794d8 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-d8ef9f58643f13dd3d16dcde0d829ae08324f04b
\ No newline at end of file
+7c38a79cdd42aaa45715aea330d10ca859098837
\ No newline at end of file
diff --git a/src/status.c b/src/status.c
index 949908ed23..24dcad4572 100644
--- a/src/status.c
+++ b/src/status.c
@@ -158,7 +158,7 @@ int sqlite3_status64(
   return SQLITE_OK;
 }
 int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
-  sqlite3_int64 iCur, iHwtr;
+  sqlite3_int64 iCur = 0, iHwtr = 0;
   int rc;
 #ifdef SQLITE_ENABLE_API_ARMOR
   if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;

From 914b7e4238a6d777c54d26e6b75a6893dd1b95fc Mon Sep 17 00:00:00 2001
From: dan 
Date: Tue, 2 Aug 2016 11:29:16 +0000
Subject: [PATCH 273/302] Fix a problem introduced by [77948b5eceab92a7]
 causing duplicate calls to be made to the xSavepoint() method of virtual
 tables under some circumstances.

FossilOrigin-Name: e64a4173d2899acf13b73e6e28f2e164fd638a75
---
 manifest           | 16 ++++++++--------
 manifest.uuid      |  2 +-
 src/vtab.c         |  5 ++++-
 test/fts3conf.test | 38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/manifest b/manifest
index 02f0e10029..79a50d4114 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sharmless\scompiler\swarnings\sin\ssqlite3_status().
-D 2016-08-02T08:45:26.626
+C Fix\sa\sproblem\sintroduced\sby\s[77948b5eceab92a7]\scausing\sduplicate\scalls\sto\sbe\smade\sto\sthe\sxSavepoint()\smethod\sof\svirtual\stables\sunder\ssome\scircumstances.
+D 2016-08-02T11:29:16.818
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -458,7 +458,7 @@ F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b
 F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1
 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c
 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
-F src/vtab.c 948d2d4984219eee37a7bf427d6667e21e6eb92e
+F src/vtab.c 6fece06fdd50eb2b0673e37e627ce6710e4af5be
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a
 F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2
@@ -746,7 +746,7 @@ F test/fts3aux2.test 7ae2b2c13aefdf4169279a27a5f51780ce57f6ba
 F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984
 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
 F test/fts3comp1.test a0f5b16a2df44dd0b15751787130af2183167c0c
-F test/fts3conf.test 1c8b8adb0ab28a41b68d1514df44380bd7353402
+F test/fts3conf.test 60317efd562080e198b5bdc9fcd222ce32cf01d7
 F test/fts3corrupt.test 2710b77983cc7789295ddbffea52c1d3b7506dbb
 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba
 F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7
@@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P d8ef9f58643f13dd3d16dcde0d829ae08324f04b
-R 043c924e3262ae632c6a04160549d94d
-U drh
-Z c53a56bb9efce70acc3af43de2ff893c
+P 7c38a79cdd42aaa45715aea330d10ca859098837
+R dce642e9ffc5d2b7ba510a82ce70adfa
+U dan
+Z 723af27ecacb58bb0a83305d88f4583f
diff --git a/manifest.uuid b/manifest.uuid
index a43f3794d8..003f16e3e2 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-7c38a79cdd42aaa45715aea330d10ca859098837
\ No newline at end of file
+e64a4173d2899acf13b73e6e28f2e164fd638a75
\ No newline at end of file
diff --git a/src/vtab.c b/src/vtab.c
index e81079a050..f37eb261aa 100644
--- a/src/vtab.c
+++ b/src/vtab.c
@@ -947,7 +947,10 @@ int sqlite3VtabBegin(sqlite3 *db, VTable *pVTab){
       if( rc==SQLITE_OK ){
         int iSvpt = db->nStatement + db->nSavepoint;
         addToVTrans(db, pVTab);
-        if( iSvpt ) rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, iSvpt-1);
+        if( iSvpt && pModule->xSavepoint ){
+          pVTab->iSavepoint = iSvpt;
+          rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);
+        }
       }
     }
   }
diff --git a/test/fts3conf.test b/test/fts3conf.test
index f9698770cc..6766a95408 100644
--- a/test/fts3conf.test
+++ b/test/fts3conf.test
@@ -211,4 +211,42 @@ do_execsql_test 4.2.2 {
   INSERT INTO t01(t01) VALUES('integrity-check');
 } {}
 
+do_execsql_test 4.3.1 {
+  CREATE VIRTUAL TABLE t02 USING fts4;
+  INSERT INTO t01 VALUES('1 1 1');
+  INSERT INTO t02 VALUES('2 2 2');
+  BEGIN;
+    SAVEPOINT abc;
+      INSERT INTO t01 VALUES('a b c');
+      INSERT INTO t02 VALUES('a b c');
+    ROLLBACK TO abc;
+  COMMIT;
+}
+do_execsql_test 4.3.2 {
+  SELECT * FROM t01 WHERE t01 MATCH 'b';
+  INSERT INTO t01(t01) VALUES('integrity-check');
+} {}
+
+do_execsql_test 4.4.1 {
+  CREATE TABLE A(ID INTEGER PRIMARY KEY, AnotherID INTEGER, Notes TEXT);
+  CREATE VIRTUAL TABLE AFTS USING FTS4 (Notes);
+  CREATE TRIGGER A_DeleteTrigger AFTER DELETE ON A FOR EACH ROW BEGIN 
+    DELETE FROM AFTS WHERE rowid=OLD.ID; 
+  END;
+  CREATE TABLE B(ID INTEGER PRIMARY KEY,Notes TEXT);
+  CREATE VIRTUAL TABLE BFTS USING FTS3 (Notes);
+  CREATE TRIGGER B_DeleteTrigger AFTER DELETE ON B FOR EACH ROW BEGIN 
+    DELETE FROM BFTS WHERE rowid=OLD.ID; 
+  END;
+}
+		
+do_execsql_test 4.4.2 {
+  BEGIN TRANSACTION;
+    DELETE FROM A WHERE AnotherID=1;
+    DELETE FROM B WHERE ID=1;
+  COMMIT;
+}
+		
+
+
 finish_test

From b7203cde291ec15324bf0150484df81ba7b8bced Mon Sep 17 00:00:00 2001
From: drh 
Date: Tue, 2 Aug 2016 13:26:34 +0000
Subject: [PATCH 274/302] Updates to requirements marks.  No changes to code.

FossilOrigin-Name: b23c10ac8f65bc88a6c7d88e140217222eb4cbe5
---
 manifest        | 14 +++++++-------
 manifest.uuid   |  2 +-
 src/sqlite.h.in | 17 +++++++++--------
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/manifest b/manifest
index 79a50d4114..dcecb8eb96 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\sintroduced\sby\s[77948b5eceab92a7]\scausing\sduplicate\scalls\sto\sbe\smade\sto\sthe\sxSavepoint()\smethod\sof\svirtual\stables\sunder\ssome\scircumstances.
-D 2016-08-02T11:29:16.818
+C Updates\sto\srequirements\smarks.\s\sNo\schanges\sto\scode.
+D 2016-08-02T13:26:34.987
 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
@@ -385,7 +385,7 @@ F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
 F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4
 F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7
-F src/sqlite.h.in b41cf2d1deb59db570f20e8ed7ade4716c6dc613
+F src/sqlite.h.in e011dcc3942e6ddc8dd7b894e9e6702e4269161e
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
 F src/sqliteInt.h d6f221a5bd572df935140beda82f357c2185a77c
@@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 7c38a79cdd42aaa45715aea330d10ca859098837
-R dce642e9ffc5d2b7ba510a82ce70adfa
-U dan
-Z 723af27ecacb58bb0a83305d88f4583f
+P e64a4173d2899acf13b73e6e28f2e164fd638a75
+R 2f7c4e993e0eb7bb61a5a37266251c67
+U drh
+Z 9edc5e5cd5ca93c7d8faa216313b72e1
diff --git a/manifest.uuid b/manifest.uuid
index 003f16e3e2..ac57330bc6 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-e64a4173d2899acf13b73e6e28f2e164fd638a75
\ No newline at end of file
+b23c10ac8f65bc88a6c7d88e140217222eb4cbe5
\ No newline at end of file
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index 27ca6ef4ad..f60ccaf55c 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -4704,12 +4704,13 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
 ** SQLite will invoke the destructor function X with parameter P exactly
 ** once, when the metadata is discarded.
 ** SQLite is free to discard the metadata at any time, including: 
    -**
  • when the corresponding function parameter changes, or -**
  • when [sqlite3_reset()] or [sqlite3_finalize()] is called for the -** SQL statement, or -**
  • when sqlite3_set_auxdata() is invoked again on the same parameter, or -**
  • during the original sqlite3_set_auxdata() call when a memory -** allocation error occurs.
)^ +**
  • ^(when the corresponding function parameter changes)^, or +**
  • ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the +** SQL statement)^, or +**
  • ^(when sqlite3_set_auxdata() is invoked again on the same +** parameter)^, or +**
  • ^(during the original sqlite3_set_auxdata() call when a memory +** allocation error occurs.)^ ** ** Note the last bullet in particular. The destructor X in ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the @@ -5670,8 +5671,8 @@ int sqlite3_load_extension( ** ** ^This interface enables or disables both the C-API ** [sqlite3_load_extension()] and the SQL function [load_extension()]. -** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) -** to enable or disable only the C-API. +** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) +** to enable or disable only the C-API.)^ ** ** Security warning: It is recommended that extension loading ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method From 3dffcf911fbda3b84a902e716ed0b8db6647d6df Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 2 Aug 2016 19:29:56 +0000 Subject: [PATCH 275/302] The 'replace.tcl' tool should use Unix line-endings. FossilOrigin-Name: 50de96314f75494dc1f5b14d62c595a70c4e0638 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/replace.tcl | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index dcecb8eb96..b092c43c87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\srequirements\smarks.\s\sNo\schanges\sto\scode. -D 2016-08-02T13:26:34.987 +C The\s'replace.tcl'\stool\sshould\suse\sUnix\sline-endings. +D 2016-08-02T19:29:56.543 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -1458,7 +1458,7 @@ F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97 F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b -F tool/replace.tcl 3856f87247dde5418d16dac92fa4060813431778 +F tool/replace.tcl 60f91e8dd06ab81f74d213ecbd9c9945f32ac048 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/run-speed-test.sh f95d19fd669b68c4c38b6b475242841d47c66076 @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e64a4173d2899acf13b73e6e28f2e164fd638a75 -R 2f7c4e993e0eb7bb61a5a37266251c67 -U drh -Z 9edc5e5cd5ca93c7d8faa216313b72e1 +P b23c10ac8f65bc88a6c7d88e140217222eb4cbe5 +R c637e4e7f2506406f1e6f5b4d9531797 +U mistachkin +Z d4fd0c8d72e7f688d1f1613e04849643 diff --git a/manifest.uuid b/manifest.uuid index ac57330bc6..f5829a3ed7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b23c10ac8f65bc88a6c7d88e140217222eb4cbe5 \ No newline at end of file +50de96314f75494dc1f5b14d62c595a70c4e0638 \ No newline at end of file diff --git a/tool/replace.tcl b/tool/replace.tcl index 1ecc6dc7b5..5a1ac5983c 100644 --- a/tool/replace.tcl +++ b/tool/replace.tcl @@ -4,6 +4,8 @@ # only lines successfully modified with a regular # expression. # +fconfigure stdout -translation binary -encoding binary +fconfigure stderr -translation binary -encoding binary set mode [string tolower [lindex $argv 0]] set from [lindex $argv 1] set to [lindex $argv 2] From c330887291f376837c13a54abd4b9f593085d0bf Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 2 Aug 2016 20:42:24 +0000 Subject: [PATCH 276/302] Fix a unused variable that comes up with -DSQLITE_OMIT_DATETIME_FUNCS. FossilOrigin-Name: e2f9919e34c70761e4e275eeffca8ccf9159223c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b092c43c87..592c083bb1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s'replace.tcl'\stool\sshould\suse\sUnix\sline-endings. -D 2016-08-02T19:29:56.543 +C Fix\sa\sunused\svariable\sthat\scomes\sup\swith\s-DSQLITE_OMIT_DATETIME_FUNCS. +D 2016-08-02T20:42:24.701 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -334,7 +334,7 @@ F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7 -F src/date.c 1cc9fb516ec9932c6fd4d2a0d2f8bc4480145c39 +F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f F src/expr.c fbc17c717a80b5b61158ea8f25b5af6f8cad66f8 @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b23c10ac8f65bc88a6c7d88e140217222eb4cbe5 -R c637e4e7f2506406f1e6f5b4d9531797 -U mistachkin -Z d4fd0c8d72e7f688d1f1613e04849643 +P 50de96314f75494dc1f5b14d62c595a70c4e0638 +R bccad16ef0c054ea297f2741dafcd976 +U drh +Z 284a9c0bc53e79a17d5b080e8200faff diff --git a/manifest.uuid b/manifest.uuid index f5829a3ed7..9ebb47b886 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -50de96314f75494dc1f5b14d62c595a70c4e0638 \ No newline at end of file +e2f9919e34c70761e4e275eeffca8ccf9159223c \ No newline at end of file diff --git a/src/date.c b/src/date.c index cce16305a3..8b2f2fa717 100644 --- a/src/date.c +++ b/src/date.c @@ -1112,7 +1112,6 @@ static void currentTimeFunc( ){ time_t t; char *zFormat = (char *)sqlite3_user_data(context); - sqlite3 *db; sqlite3_int64 iT; struct tm *pTm; struct tm sNow; From a36e01a7723ebb700fec0b9e3d428d24998e0035 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 3 Aug 2016 13:40:54 +0000 Subject: [PATCH 277/302] Fix the --help output on fuzzcheck so that it fix in an 80-character window. FossilOrigin-Name: b91444b5db8465f09d112455e722c888b3f94329 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/fuzzcheck.c | 34 +++++++++++++++++----------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 592c083bb1..5028978397 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sunused\svariable\sthat\scomes\sup\swith\s-DSQLITE_OMIT_DATETIME_FUNCS. -D 2016-08-02T20:42:24.701 +C Fix\sthe\s--help\soutput\son\sfuzzcheck\sso\sthat\sit\sfix\sin\san\s80-character\swindow. +D 2016-08-03T13:40:54.644 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -807,7 +807,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test b47377143f0c80f91ed29d722861077ff34415d5 F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c f01d432d001ba29e7916df8411be7d4e7cddc574 +F test/fuzzcheck.c f2e8102f7829f7b946ebdb6f1a16c6f942d9de66 F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 50de96314f75494dc1f5b14d62c595a70c4e0638 -R bccad16ef0c054ea297f2741dafcd976 +P e2f9919e34c70761e4e275eeffca8ccf9159223c +R 6ce4351ec9908162cf69cba24dd464d6 U drh -Z 284a9c0bc53e79a17d5b080e8200faff +Z fde490c34eba36f3f6bb820fe63440a5 diff --git a/manifest.uuid b/manifest.uuid index 9ebb47b886..f473a8f752 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e2f9919e34c70761e4e275eeffca8ccf9159223c \ No newline at end of file +b91444b5db8465f09d112455e722c888b3f94329 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 1d11b2986f..fec65881ce 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -782,23 +782,23 @@ static void showHelp(void){ "Read databases and SQL scripts from SOURCE-DB and execute each script against\n" "each database, checking for crashes and memory leaks.\n" "Options:\n" -" --cell-size-check Set the PRAGMA cell_size_check=ON\n" -" --dbid N Use only the database where dbid=N\n" -" --export-db DIR Write databases to files(s) in DIR. Works with --dbid\n" -" --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n" -" --help Show this help text\n" -" -q|--quiet Reduced output\n" -" --limit-mem N Limit memory used by test SQLite instance to N bytes\n" -" --limit-vdbe Panic if an sync SQL runs for more than 100,000 cycles\n" -" --load-sql ARGS... Load SQL scripts fro files into SOURCE-DB\n" -" --load-db ARGS... Load template databases from files into SOURCE_DB\n" -" -m TEXT Add a description to the database\n" -" --native-vfs Use the native VFS for initially empty database files\n" -" --rebuild Rebuild and vacuum the database file\n" -" --result-trace Show the results of each SQL command\n" -" --sqlid N Use only SQL where sqlid=N\n" -" --timeout N Abort if any single test case needs more than N seconds\n" -" -v|--verbose Increased output. Repeat for more output.\n" +" --cell-size-check Set the PRAGMA cell_size_check=ON\n" +" --dbid N Use only the database where dbid=N\n" +" --export-db DIR Write databases to files(s) in DIR. Works with --dbid\n" +" --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n" +" --help Show this help text\n" +" -q|--quiet Reduced output\n" +" --limit-mem N Limit memory used by test SQLite instance to N bytes\n" +" --limit-vdbe Panic if any test runs for more than 100,000 cycles\n" +" --load-sql ARGS... Load SQL scripts fro files into SOURCE-DB\n" +" --load-db ARGS... Load template databases from files into SOURCE_DB\n" +" -m TEXT Add a description to the database\n" +" --native-vfs Use the native VFS for initially empty database files\n" +" --rebuild Rebuild and vacuum the database file\n" +" --result-trace Show the results of each SQL command\n" +" --sqlid N Use only SQL where sqlid=N\n" +" --timeout N Abort if any single test needs more than N seconds\n" +" -v|--verbose Increased output. Repeat for more output.\n" ); } From c0d269e96ca1591110c67ce08958588582abc3cc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 3 Aug 2016 14:51:16 +0000 Subject: [PATCH 278/302] Fix a typo in a comment in btree.c. No changes to code. FossilOrigin-Name: 722c12816347ee9fce7a090cfebef2c5841e7445 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5028978397..558a3d8e2d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s--help\soutput\son\sfuzzcheck\sso\sthat\sit\sfix\sin\san\s80-character\swindow. -D 2016-08-03T13:40:54.644 +C Fix\sa\stypo\sin\sa\scomment\sin\sbtree.c.\s\s\sNo\schanges\sto\scode. +D 2016-08-03T14:51:16.394 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -327,7 +327,7 @@ F src/auth.c 5c8e0f37f785f935f589496801edd19840485853 F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 6a42efa461cf3a0c33e8755e9d236371ac80d1b3 +F src/btree.c 2551bd3ecb8b8988fb8b23aabadfb214dbc38e46 F src/btree.h 075c45707c0f8f8af118f739f36df8098a08b7da F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e2f9919e34c70761e4e275eeffca8ccf9159223c -R 6ce4351ec9908162cf69cba24dd464d6 +P b91444b5db8465f09d112455e722c888b3f94329 +R aa712e9e7089879865bbb38d4c2c515d U drh -Z fde490c34eba36f3f6bb820fe63440a5 +Z 2b4f8b48b03032bd1efbc47f9457218f diff --git a/manifest.uuid b/manifest.uuid index f473a8f752..a6f1d523fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b91444b5db8465f09d112455e722c888b3f94329 \ No newline at end of file +722c12816347ee9fce7a090cfebef2c5841e7445 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 8ea20b9ad0..841aee9463 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6385,7 +6385,7 @@ static void insertCell( /* ** A CellArray object contains a cache of pointers and sizes for a -** consecutive sequence of cells that might be held multiple pages. +** consecutive sequence of cells that might be held on multiple pages. */ typedef struct CellArray CellArray; struct CellArray { From dd545d3bf219c13f839cfb21d0bc122c3b431d2b Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 Aug 2016 09:09:44 +0000 Subject: [PATCH 279/302] Make sure the ORDER BY LIMIT optimization is not applied if the inner-most loop can only have a single iteration and is hence not really a loop. FossilOrigin-Name: 13e3bd3de6b434b6182ef36be108d7ee0be8ca53 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- test/limit2.test | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 558a3d8e2d..3ea36916cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sa\scomment\sin\sbtree.c.\s\s\sNo\schanges\sto\scode. -D 2016-08-03T14:51:16.394 +C Make\ssure\sthe\sORDER\sBY\sLIMIT\soptimization\sis\snot\sapplied\sif\sthe\sinner-most\nloop\scan\sonly\shave\sa\ssingle\siteration\sand\sis\shence\snot\sreally\sa\sloop. +D 2016-08-04T09:09:44.760 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -463,7 +463,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c bb1444f6ae6bc3cbd086cc61cd9c6e3a6168d89b +F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 @@ -888,7 +888,7 @@ F test/like.test 81632c437a947bf1f7130b19537da6a1a844806a F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e -F test/limit2.test 55c9f4d08c89311e00afd75045ee1a2aca205cb4 +F test/limit2.test 40e79f3d95f2077742aa5b7676f58c9af1735d83 F test/loadext.test d077450695ddb5c1ea3ad7d48e5f5850fe732ad9 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b91444b5db8465f09d112455e722c888b3f94329 -R aa712e9e7089879865bbb38d4c2c515d +P 722c12816347ee9fce7a090cfebef2c5841e7445 +R fd11dfb179ebaeb65493cf49055d4419 U drh -Z 2b4f8b48b03032bd1efbc47f9457218f +Z c8d986adc7b509414bb3aed9ed932c87 diff --git a/manifest.uuid b/manifest.uuid index a6f1d523fa..832eed621e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -722c12816347ee9fce7a090cfebef2c5841e7445 \ No newline at end of file +13e3bd3de6b434b6182ef36be108d7ee0be8ca53 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 9b3c281efc..c2706dc5dd 100644 --- a/src/where.c +++ b/src/where.c @@ -3971,7 +3971,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pWInfo->revMask = pFrom->revLoop; if( pWInfo->nOBSat<=0 ){ pWInfo->nOBSat = 0; - if( nLoop>0 ){ + if( nLoop>0 && (pFrom->aLoop[nLoop-1]->wsFlags & WHERE_ONEROW)==0 ){ Bitmask m = 0; int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m); diff --git a/test/limit2.test b/test/limit2.test index f415f3263b..fb4c89644f 100644 --- a/test/limit2.test +++ b/test/limit2.test @@ -77,6 +77,28 @@ do_test limit2-120.3 { expr {$fast_count < 0.02*$slow_count} } {1} +# Bug report against the new ORDER BY LIMIT optimization just prior to +# release. (Unreleased so there is no ticket). +# +# Make sure the optimization is not applied if the inner loop can only +# provide a single row of output. +# +do_execsql_test limit2-200 { + CREATE TABLE t200(a, b); + WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000) + INSERT INTO t200(a,b) SELECT x, x FROM c; + CREATE TABLE t201(x INTEGER PRIMARY KEY, y); + INSERT INTO t201(x,y) VALUES(2,12345); + + SELECT *, '|' FROM t200, t201 WHERE x=b ORDER BY y LIMIT 3; +} {2 2 2 12345 |} +do_execsql_test limit2-210 { + SELECT *, '|' FROM t200 LEFT JOIN t201 ON x=b ORDER BY y LIMIT 3; +} {1 1 {} {} | 3 3 {} {} | 4 4 {} {} |} + + + + finish_test From cc15313cc9a8b6713dc9f995ccc4d4c088da55d7 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 Aug 2016 12:35:17 +0000 Subject: [PATCH 280/302] Add the experimental SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION compile-time option. When enabled, the "unknown function" error is suppressed for EXPLAIN and a no-op function named "unknown()" is substituted. This facilitiates using the command-line shell to analyze queries from applications that contain many application-defined functions that are not normally available to the shell. FossilOrigin-Name: b7f30a9ff20d580fdaecdcf2b644d09ad6c2575e --- Makefile.in | 2 ++ Makefile.msc | 5 ++++- main.mk | 2 ++ manifest | 23 ++++++++++++----------- manifest.uuid | 2 +- src/expr.c | 5 +++++ src/func.c | 29 ++++++++++++++++++++++++++--- src/resolve.c | 6 +++++- 8 files changed, 57 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index fd0ad6b6a7..9b2fe86cf4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -558,7 +558,9 @@ TESTOPTS = --verbose=file --output=test-out.txt # Extra compiler options for various shell tools # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 +# SHELL_OPT += -DSQLITE_ENABLE_FTS5 SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS +SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1 FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 diff --git a/Makefile.msc b/Makefile.msc index 527efd8f7d..5f7643978c 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1424,7 +1424,10 @@ FUZZDATA = \ # when the shell is not being dynamically linked. # !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0 -SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS4 +# SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS5 +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION !ENDIF # <> diff --git a/main.mk b/main.mk index e3da609750..451837ffff 100644 --- a/main.mk +++ b/main.mk @@ -470,6 +470,8 @@ TESTOPTS = --verbose=file --output=test-out.txt # Extra compiler options for various shell tools # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 +SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS +SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1 FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 diff --git a/manifest b/manifest index 3ea36916cc..c4a95c5def 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Make\ssure\sthe\sORDER\sBY\sLIMIT\soptimization\sis\snot\sapplied\sif\sthe\sinner-most\nloop\scan\sonly\shave\sa\ssingle\siteration\sand\sis\shence\snot\sreally\sa\sloop. -D 2016-08-04T09:09:44.760 -F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db +C Add\sthe\sexperimental\sSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\scompile-time\soption.\nWhen\senabled,\sthe\s"unknown\sfunction"\serror\sis\ssuppressed\sfor\sEXPLAIN\sand\na\sno-op\sfunction\snamed\s"unknown()"\sis\ssubstituted.\s\sThis\sfacilitiates\susing\nthe\scommand-line\sshell\sto\sanalyze\squeries\sfrom\sapplications\sthat\scontain\nmany\sapplication-defined\sfunctions\sthat\sare\snot\snormally\savailable\sto\sthe\nshell. +D 2016-08-04T12:35:17.002 +F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 +F Makefile.msc 817e65faf9ad66a8d462e5b5e645be600213efb8 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -308,7 +308,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk e9d66f1b1c4874221d12d940be3ce5f397c10741 +F main.mk 1883ecab643b136e8ab3fdc33785e6ea8b5ceb46 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -337,10 +337,10 @@ F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7 F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b F src/dbstat.c 4f6f7f52b49beb9636ffbd517cfe44a402ba4ad0 F src/delete.c 4aba4214a377ce8ddde2d2e609777bcc8235200f -F src/expr.c fbc17c717a80b5b61158ea8f25b5af6f8cad66f8 +F src/expr.c 9c5eca8602f6c496e8d4eefefe2aae3d831dd510 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c bc4145347595b7770f9a598cff1c848302cf5413 -F src/func.c 61a4114cf7004f10c542cfabbab9f2bcb9033045 +F src/func.c 29cc9acb170ec1387b9f63eb52cd85f8de96c771 F src/global.c c45ea22aff29334f6a9ec549235ac3357c970015 F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36 F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 @@ -381,7 +381,7 @@ F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 +F src/resolve.c 0392c6686586b1d4dac9a4106959f03ddd70e9aa F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7 @@ -1509,7 +1509,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 722c12816347ee9fce7a090cfebef2c5841e7445 -R fd11dfb179ebaeb65493cf49055d4419 +P 13e3bd3de6b434b6182ef36be108d7ee0be8ca53 +Q +4ada023ca075628fdafc3bc4520239b9789cff29 +R f1859801c403afb60ddad5424514cd57 U drh -Z c8d986adc7b509414bb3aed9ed932c87 +Z 688b79edff11cfb7031a01d005983417 diff --git a/manifest.uuid b/manifest.uuid index 832eed621e..ee38509af6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -13e3bd3de6b434b6182ef36be108d7ee0be8ca53 \ No newline at end of file +b7f30a9ff20d580fdaecdcf2b644d09ad6c2575e \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index c6d74cfd32..74f09bbee9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2943,6 +2943,11 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ assert( !ExprHasProperty(pExpr, EP_IntValue) ); zId = pExpr->u.zToken; pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0); +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION + if( pDef==0 && pParse->explain ){ + pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0); + } +#endif if( pDef==0 || pDef->xFinalize!=0 ){ sqlite3ErrorMsg(pParse, "unknown function: %s()", zId); break; diff --git a/src/func.c b/src/func.c index 78c8806456..79bb1e3dd2 100644 --- a/src/func.c +++ b/src/func.c @@ -1316,6 +1316,26 @@ static void trimFunc( } +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION +/* +** The "unknown" function is automatically substituted in place of +** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN +** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used. +** When the "sqlite3" command-line shell is built using this functionality, +** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries +** involving application-defined functions to be examined in a generic +** sqlite3 shell. +*/ +static void unknownFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + /* no-op */ +} +#endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/ + + /* IMP: R-25361-16150 This function is omitted from SQLite by default. It ** is only available if the SQLITE_SOUNDEX compile-time option is used ** when SQLite is built. @@ -1786,13 +1806,16 @@ void sqlite3RegisterBuiltinFunctions(void){ AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize), LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), - #ifdef SQLITE_CASE_SENSITIVE_LIKE +#ifdef SQLITE_CASE_SENSITIVE_LIKE LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), - #else +#else LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE), LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE), - #endif +#endif +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION + FUNCTION(unknown, -1, 0, 0, unknownFunc ), +#endif FUNCTION(coalesce, 1, 0, 0, 0 ), FUNCTION(coalesce, 0, 0, 0, 0 ), FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE), diff --git a/src/resolve.c b/src/resolve.c index 77ce37f6d7..8ae7f0919c 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -718,7 +718,11 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); pNC->nErr++; is_agg = 0; - }else if( no_such_func && pParse->db->init.busy==0 ){ + }else if( no_such_func && pParse->db->init.busy==0 +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION + && pParse->explain==0 +#endif + ){ sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); pNC->nErr++; }else if( wrong_num_args ){ From 70ae0e93ec253557ac9a7379b61c917ddb4786aa Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 Aug 2016 13:23:28 +0000 Subject: [PATCH 281/302] Revert the SQLITE_APICALL changes for now. That changes needs further research before it is released. Deferred until 3.15. FossilOrigin-Name: 9adda385267d1a0ecff259b42a284913668441a2 --- Makefile.msc | 80 ++++++++------------------------------------- manifest | 17 +++++----- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 3 +- tool/mksqlite3h.tcl | 7 +--- 5 files changed, 25 insertions(+), 84 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 5f7643978c..cd866ce4a4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -24,13 +24,6 @@ USE_AMALGAMATION = 1 USE_FULLWARN = 0 !ENDIF -# Set this non-0 to enable full runtime error checks (-RTC1, etc). This -# has no effect if (any) optimizations are enabled. -# -!IFNDEF USE_RUNTIME_CHECKS -USE_RUNTIME_CHECKS = 0 -!ENDIF - # Set this non-0 to use "stdcall" calling convention for the core library # and shell executable. # @@ -471,32 +464,20 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) # !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0 !IF "$(PLATFORM)"=="x86" -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -# <> -TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl -# <> +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall !ELSE !IFNDEF PLATFORM -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -# <> -TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl -# <> +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = -# <> -TEST_CCONV_OPTS = -# <> !ENDIF !ENDIF !ELSE CORE_CCONV_OPTS = SHELL_CCONV_OPTS = -# <> -TEST_CCONV_OPTS = -# <> !ENDIF # These are additional compiler options used for the core library. @@ -854,10 +835,6 @@ RCC = $(RCC) -D_DEBUG !IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0 TCC = $(TCC) -Od BCC = $(BCC) -Od -!IF $(USE_RUNTIME_CHECKS)!=0 -TCC = $(TCC) -RTC1 -BCC = $(BCC) -RTC1 -!ENDIF !ELSEIF $(OPTIMIZATIONS)>=3 TCC = $(TCC) -Ox BCC = $(BCC) -Ox @@ -1258,12 +1235,6 @@ SRC11 = \ parse.h \ $(SQLITE3H) -# Generated Tcl header files -# -SRC12 = \ - sqlite_tcl.h \ - sqlite_tclDecls.h - # All source code files. # SRC = $(SRC00) $(SRC01) $(SRC02) $(SRC03) $(SRC04) $(SRC05) $(SRC06) $(SRC07) $(SRC08) $(SRC09) $(SRC10) $(SRC11) @@ -1370,7 +1341,7 @@ HDR = \ parse.h \ $(TOP)\src\pragma.h \ $(SQLITE3H) \ - sqlite3ext.h \ + $(TOP)\src\sqlite3ext.h \ $(TOP)\src\sqliteInt.h \ $(TOP)\src\sqliteLimit.h \ $(TOP)\src\vdbe.h \ @@ -1424,10 +1395,7 @@ FUZZDATA = \ # when the shell is not being dynamically linked. # !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0 -SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS4 -# SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS5 -SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS -SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS !ENDIF # <> @@ -1531,7 +1499,7 @@ mptest: mptester.exe # files are automatically generated. This target takes care of # all that automatic generation. # -.target_source: $(SRC) $(TOP)\tool\vdbe-compress.tcl fts5.c sqlite_tcl.h +.target_source: $(SRC) $(TOP)\tool\vdbe-compress.tcl fts5.c -rmdir /Q/S tsrc 2>NUL -mkdir tsrc for %i in ($(SRC00)) do copy /Y %i tsrc @@ -1546,7 +1514,6 @@ mptest: mptester.exe for %i in ($(SRC09)) do copy /Y %i tsrc for %i in ($(SRC10)) do copy /Y %i tsrc for %i in ($(SRC11)) do copy /Y %i tsrc - for %i in ($(SRC12)) do copy /Y %i tsrc copy /Y fts5.c tsrc copy /Y fts5.h tsrc del /Q tsrc\sqlite.h.in tsrc\parse.y 2>NUL @@ -1828,10 +1795,10 @@ wherecode.lo: $(TOP)\src\wherecode.c $(HDR) whereexpr.lo: $(TOP)\src\whereexpr.c $(HDR) $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\whereexpr.c -tclsqlite.lo: $(TOP)\src\tclsqlite.c $(HDR) sqlite_tcl.h +tclsqlite.lo: $(TOP)\src\tclsqlite.c $(HDR) $(LTCOMPILE) $(NO_WARN) -DUSE_TCL_STUBS=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c -tclsqlite-shell.lo: $(TOP)\src\tclsqlite.c $(HDR) sqlite_tcl.h +tclsqlite-shell.lo: $(TOP)\src\tclsqlite.c $(HDR) $(LTCOMPILE) $(NO_WARN) -DTCLSH=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c tclsqlite3.exe: tclsqlite-shell.lo $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS) @@ -1860,9 +1827,7 @@ $(SQLITE3H): $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > $(SQLITE3H) sqlite3ext.h: .target_source - type tsrc\sqlite3ext.h | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*\)" "(SQLITE_CALLBACK *)" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_APICALL *" > sqlite3ext.h - copy /Y sqlite3ext.h tsrc\sqlite3ext.h + copy tsrc\sqlite3ext.h . mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c $(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) \ @@ -1995,7 +1960,6 @@ TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_CORE $(NO_WARN) TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERIES_CONSTRAINT_VERIFY=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_DEFAULT_PAGE_SIZE=1024 -TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS) TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) TESTFIXTURE_SRC1 = $(TESTEXT) $(SQLITE3C) @@ -2005,25 +1969,7 @@ TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0) TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC1) !ENDIF -sqlite_tclDecls.h: - echo #ifndef SQLITE_TCLAPI > sqlite_tclDecls.h - echo # define SQLITE_TCLAPI >> sqlite_tclDecls.h - echo #endif >> sqlite_tclDecls.h - type "$(TCLINCDIR)\tclDecls.h" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN(?: CONST\d+?)?\s+?[^\(]*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tcl_" "(SQLITE_TCLAPI *tcl_" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tclFreeObj" "(SQLITE_TCLAPI *tclFreeObj" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_TCLAPI *" >> sqlite_tclDecls.h - -sqlite_tcl.h: sqlite_tclDecls.h - type "$(TCLINCDIR)\tcl.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact tclDecls.h sqlite_tclDecls.h \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "typedef (.*?)\(Tcl_" "typedef \1 (SQLITE_TCLAPI Tcl_" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "void (*freeProc)" "void (SQLITE_TCLAPI *freeProc)" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*findProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *findProc)" \ - | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*createProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *createProc)" >> sqlite_tcl.h - -testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) sqlite_tcl.h +testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) $(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \ -DBUILD_sqlite -I$(TCLINCDIR) \ $(TESTFIXTURE_SRC) \ @@ -2072,7 +2018,7 @@ smoketest: $(TESTPROGS) @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\main.test $(TESTOPTS) -sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl sqlite_tcl.h +sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl echo #define TCLSH 2 > $@ echo #define SQLITE_ENABLE_DBSTAT_VTAB 1 >> $@ copy $@ + $(SQLITE3C) + $(TOP)\src\tclsqlite.c $@ @@ -2152,7 +2098,7 @@ clean: -rmdir /Q/S .libs 2>NUL -rmdir /Q/S tsrc 2>NUL del /Q .target_source 2>NUL - del /Q tclsqlite3.exe sqlite_tcl.h sqlite_tclDecls.h 2>NUL + del /Q tclsqlite3.exe 2>NUL del /Q testloadext.dll 2>NUL del /Q testfixture.exe test.db 2>NUL del /Q LogEst.exe fts3view.exe rollback-test.exe showdb.exe 2>NUL diff --git a/manifest b/manifest index c4a95c5def..5b9bd0d8e5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Add\sthe\sexperimental\sSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\scompile-time\soption.\nWhen\senabled,\sthe\s"unknown\sfunction"\serror\sis\ssuppressed\sfor\sEXPLAIN\sand\na\sno-op\sfunction\snamed\s"unknown()"\sis\ssubstituted.\s\sThis\sfacilitiates\susing\nthe\scommand-line\sshell\sto\sanalyze\squeries\sfrom\sapplications\sthat\scontain\nmany\sapplication-defined\sfunctions\sthat\sare\snot\snormally\savailable\sto\sthe\nshell. -D 2016-08-04T12:35:17.002 +C Revert\sthe\sSQLITE_APICALL\schanges\sfor\snow.\s\sThat\schanges\sneeds\sfurther\nresearch\sbefore\sit\sis\sreleased.\s\sDeferred\suntil\s3.15. +D 2016-08-04T13:23:28.286 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 817e65faf9ad66a8d462e5b5e645be600213efb8 +F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1450,8 +1450,8 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl aa58ea3be311c81821c2cd3209f55e46b07ab656 -F tool/mksqlite3c.tcl 655181fb25f69b3524b30efd0750c43513415216 -F tool/mksqlite3h.tcl cf5cd68028e69a51ed5c76042672664201f0f756 +F tool/mksqlite3c.tcl 63af8429841f08552e6da1d93b3dee4a93ff8071 +F tool/mksqlite3h.tcl e7b106fc4f29fbc258e8ba9b88d9108332ea2ade F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl 4abcaf3267171b2faadaf9b82a0dfbaa6e98f8b7 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1509,8 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 13e3bd3de6b434b6182ef36be108d7ee0be8ca53 -Q +4ada023ca075628fdafc3bc4520239b9789cff29 -R f1859801c403afb60ddad5424514cd57 +P b7f30a9ff20d580fdaecdcf2b644d09ad6c2575e +R 54afa4c645a3de150c21fe8a3504aa0b U drh -Z 688b79edff11cfb7031a01d005983417 +Z 5a54570e253d8550ab3d18086a0dcdce diff --git a/manifest.uuid b/manifest.uuid index ee38509af6..3bacaad736 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b7f30a9ff20d580fdaecdcf2b644d09ad6c2575e \ No newline at end of file +9adda385267d1a0ecff259b42a284913668441a2 \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index c5f765ed1c..7e8558d2ab 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -112,6 +112,7 @@ foreach hdr { pragma.h rtree.h sqlite3session.h + sqlite3ext.h sqlite3.h sqlite3ext.h sqlite3rbu.h @@ -231,7 +232,7 @@ proc copy_file {filename} { if {[lsearch -exact $cdecllist $funcname] >= 0} { append line SQLITE_CDECL } else { - append line SQLITE_APICALL + append line SQLITE_STDCALL } append line " " $funcname $rest puts $out $line diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl index 9a4e7d2985..1af6d75730 100644 --- a/tool/mksqlite3h.tcl +++ b/tool/mksqlite3h.tcl @@ -21,8 +21,6 @@ # formatted as an integer (e.g. "3006017"). # 5) Replaces the string --SOURCE-ID-- with the date and time and sha1 # hash of the fossil-scm manifest for the source tree. -# 6) Adds the SQLITE_CALLBACK calling convention macro in front of all -# callback declarations. # # This script outputs to stdout. # @@ -122,14 +120,11 @@ foreach file $filelist { if {[lsearch -exact $cdecllist $funcname] >= 0} { append line SQLITE_CDECL } else { - append line SQLITE_APICALL + append line SQLITE_STDCALL } append line " " $funcname $rest } } - set line [string map [list (*sqlite3_syscall_ptr) \ - "(SQLITE_SYSAPI *sqlite3_syscall_ptr)"] $line] - regsub {\(\*} $line {(SQLITE_CALLBACK *} line puts $line } close $in From 0aafa9c89c543b6f9bb5c81346bd196d062e05a8 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Aug 2016 14:35:47 +0000 Subject: [PATCH 282/302] Fix a very obscure problem following OOM in sqlite3_declare_vtab(). FossilOrigin-Name: 68eac74874d0646369bef3650c6cb271cca62ab4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 5b9bd0d8e5..ad19c3dbd6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revert\sthe\sSQLITE_APICALL\schanges\sfor\snow.\s\sThat\schanges\sneeds\sfurther\nresearch\sbefore\sit\sis\sreleased.\s\sDeferred\suntil\s3.15. -D 2016-08-04T13:23:28.286 +C Fix\sa\svery\sobscure\sproblem\sfollowing\sOOM\sin\ssqlite3_declare_vtab(). +D 2016-08-05T14:35:47.568 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -330,7 +330,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2551bd3ecb8b8988fb8b23aabadfb214dbc38e46 F src/btree.h 075c45707c0f8f8af118f739f36df8098a08b7da F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c d1fdfd7ab8f5447e494ef15825973bf0719527c6 +F src/build.c 7c3c780b703c09314032c8f6e4e7c1d80241a818 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7 @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b7f30a9ff20d580fdaecdcf2b644d09ad6c2575e -R 54afa4c645a3de150c21fe8a3504aa0b +P 9adda385267d1a0ecff259b42a284913668441a2 +R 36d01c6d4e5d55fe676a3ca2e553d6b8 U drh -Z 5a54570e253d8550ab3d18086a0dcdce +Z 0d50083da402e96d80dd6dfcbaebaad9 diff --git a/manifest.uuid b/manifest.uuid index 3bacaad736..6bcb510d7d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9adda385267d1a0ecff259b42a284913668441a2 \ No newline at end of file +68eac74874d0646369bef3650c6cb271cca62ab4 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 52f6f200f8..b14e6f2fc2 100644 --- a/src/build.c +++ b/src/build.c @@ -3037,6 +3037,13 @@ void sqlite3CreateIndex( if( zName==0 ){ goto exit_create_index; } + + /* Automatic index names generated from within sqlite3_declare_vtab() + ** must have names that are distinct from normal automatic index names. + ** The following statement converts "sqlite3_autoindex..." into + ** "sqlite3_butoindex..." in order to make the names distinct. + ** The "vtab_err.test" test demonstrates the need of this statement. */ + if( IN_DECLARE_VTAB ) zName[7]++; } /* Check for authorization to create an index. From 5360b55c6cc2298b72174871adfe3caabf20bf98 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Aug 2016 15:34:42 +0000 Subject: [PATCH 283/302] Remove an incorrect ALWAYS() statement and add a test case to show when the condition is sometimes false. FossilOrigin-Name: 0f57effa3642e66a863f32cc7fba86d167084af3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vtab.c | 2 +- test/stat.test | 13 +++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ad19c3dbd6..ec9b78cea8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\svery\sobscure\sproblem\sfollowing\sOOM\sin\ssqlite3_declare_vtab(). -D 2016-08-05T14:35:47.568 +C Remove\san\sincorrect\sALWAYS()\sstatement\sand\sadd\sa\stest\scase\sto\sshow\swhen\nthe\scondition\sis\ssometimes\sfalse. +D 2016-08-05T15:34:42.171 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -458,7 +458,7 @@ F src/vdbeblob.c 83d2d266383157b02e2b809350bb197e89d7895b F src/vdbemem.c 1ecaa5ee0caff07255f25d04e8dc88befb6f88d1 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 -F src/vtab.c 6fece06fdd50eb2b0673e37e627ce6710e4af5be +F src/vtab.c 6b3cfaff7e4397739d6b48511e777ca58c6d06d4 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 @@ -1104,7 +1104,7 @@ F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 F test/sqldiff1.test 28cd737cf1b0078b1ec1bbf425e674c47785835e F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142 F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a -F test/stat.test ab95d28503d0f6d98ffd8ce204643c9da090ebf1 +F test/stat.test f8f1279ffffabe6df825723af18cc6e0ae70a893 F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9adda385267d1a0ecff259b42a284913668441a2 -R 36d01c6d4e5d55fe676a3ca2e553d6b8 +P 68eac74874d0646369bef3650c6cb271cca62ab4 +R 8d5524e3947549ded2372df1ac699079 U drh -Z 0d50083da402e96d80dd6dfcbaebaad9 +Z 5feee06a3e8967a54a24fbeb2c1f3aea diff --git a/manifest.uuid b/manifest.uuid index 6bcb510d7d..64c0aece9a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -68eac74874d0646369bef3650c6cb271cca62ab4 \ No newline at end of file +0f57effa3642e66a863f32cc7fba86d167084af3 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index f37eb261aa..45c5e79abd 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -807,7 +807,7 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){ Table *pTab; pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName); - if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){ + if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){ VTable *p; int (*xDestroy)(sqlite3_vtab *); for(p=pTab->pVTable; p; p=p->pNext){ diff --git a/test/stat.test b/test/stat.test index 6a87a629b9..66ca5e2f2b 100644 --- a/test/stat.test +++ b/test/stat.test @@ -34,12 +34,25 @@ register_dbstat_vtab db do_execsql_test stat-0.0 { PRAGMA table_info(dbstat); } {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/} + +# Attempts to drop an eponymous virtual table are a no-op. do_execsql_test stat-0.1 { + DROP TABLE dbstat; + PRAGMA table_info=dbstat; +} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/} + +db close +forcedelete test.db +sqlite3 db test.db +db func a_string a_string +register_dbstat_vtab db +do_execsql_test stat-0.2 { PRAGMA auto_vacuum = OFF; CREATE VIRTUAL TABLE temp.stat USING dbstat; SELECT * FROM stat; } {} + if {[wal_is_capable]} { do_execsql_test stat-0.1 { PRAGMA journal_mode = WAL; From 43c1ce390f25a6d988fb40ef95c2ef1afb1b7182 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 5 Aug 2016 16:16:26 +0000 Subject: [PATCH 284/302] Undo commit [f250166bb]. It is required to handle IO and other errors that occur within a VACUUM of a Zipvfs database. FossilOrigin-Name: ae72513af37cd806a6d94aaa7c47a740e119d3b1 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/backup.c | 6 ++++-- src/pager.c | 12 +++++++++++- src/pager.h | 1 + 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index ec9b78cea8..eab6773070 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sALWAYS()\sstatement\sand\sadd\sa\stest\scase\sto\sshow\swhen\nthe\scondition\sis\ssometimes\sfalse. -D 2016-08-05T15:34:42.171 +C Undo\scommit\s[f250166bb].\sIt\sis\srequired\sto\shandle\sIO\sand\sother\serrors\sthat\soccur\swithin\sa\sVACUUM\sof\sa\sZipvfs\sdatabase. +D 2016-08-05T16:16:26.624 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -324,7 +324,7 @@ F src/alter.c cc28ab933ae615b22add0d609794ffb6596b42ea F src/analyze.c 37fedc80ac966ce1745811746e68e4d8fa64c7fe F src/attach.c 771153bd1f4ab0b97a44a13dde2c7e5e1efeba22 F src/auth.c 5c8e0f37f785f935f589496801edd19840485853 -F src/backup.c 6df65fdd569c901a418887a1a76f82ec35044556 +F src/backup.c 17cd25a36d49330df2bacd2cadf2a61f3b525976 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 2551bd3ecb8b8988fb8b23aabadfb214dbc38e46 @@ -370,8 +370,8 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 F src/os_win.c 520f23475f1de530c435d30b67b7b15fe90874b0 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c c368634b888b1c8740aea83b36bfd266f2443e60 -F src/pager.h 031a87445e5e0afc85312d1c380e123ad6c7aeaf +F src/pager.c 40928c450320da78bb4bd3ae82818f4239e19b7e +F src/pager.h 966d2769e76ae347c8a32c4165faf6e6cb64546d F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 68eac74874d0646369bef3650c6cb271cca62ab4 -R 8d5524e3947549ded2372df1ac699079 -U drh -Z 5feee06a3e8967a54a24fbeb2c1f3aea +P 0f57effa3642e66a863f32cc7fba86d167084af3 +R 7173910e7a14fcd3861af608a7447a5a +U dan +Z 5568e465afb61eecd4219a0cc50c6e2e diff --git a/manifest.uuid b/manifest.uuid index 64c0aece9a..4b900d08a6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f57effa3642e66a863f32cc7fba86d167084af3 \ No newline at end of file +ae72513af37cd806a6d94aaa7c47a740e119d3b1 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 3df56e5384..19c3b2a647 100644 --- a/src/backup.c +++ b/src/backup.c @@ -777,13 +777,15 @@ int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ ** sqlite3_backup_step(), we can guarantee that the copy finishes ** within a single call (unless an error occurs). The assert() statement ** checks this assumption - (p->rc) should be set to either SQLITE_DONE - ** or an error code. - */ + ** or an error code. */ sqlite3_backup_step(&b, 0x7FFFFFFF); assert( b.rc!=SQLITE_OK ); + rc = sqlite3_backup_finish(&b); if( rc==SQLITE_OK ){ pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED; + }else{ + sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); } assert( sqlite3BtreeIsInTrans(pTo)==0 ); diff --git a/src/pager.c b/src/pager.c index 1ae831d148..cd8d1204b3 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7157,6 +7157,17 @@ sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){ return &pPager->pBackup; } +#ifndef SQLITE_OMIT_VACUUM +/* +** Unless this is an in-memory or temporary database, clear the pager cache. +*/ +void sqlite3PagerClearCache(Pager *pPager){ + assert( MEMDB==0 || pPager->tempFile ); + if( pPager->tempFile==0 ) pager_reset(pPager); +} +#endif + + #ifndef SQLITE_OMIT_WAL /* ** This function is called when the user invokes "PRAGMA wal_checkpoint", @@ -7382,5 +7393,4 @@ int sqlite3PagerWalFramesize(Pager *pPager){ } #endif - #endif /* SQLITE_OMIT_DISKIO */ diff --git a/src/pager.h b/src/pager.h index af71d745a8..1046670912 100644 --- a/src/pager.h +++ b/src/pager.h @@ -203,6 +203,7 @@ const char *sqlite3PagerJournalname(Pager*); void *sqlite3PagerTempSpace(Pager*); int sqlite3PagerIsMemdb(Pager*); void sqlite3PagerCacheStat(Pager *, int, int, int *); +void sqlite3PagerClearCache(Pager*); int sqlite3SectorSize(sqlite3_file *); /* Functions used to truncate the database file. */ From e099b67c204286eb7ff45e07169001786dc35971 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 5 Aug 2016 20:54:45 +0000 Subject: [PATCH 285/302] Have the TEA package build without SQLITE_OMIT_DEPRECATED. As it uses recently deprecated interfaces sqlite3_profile() and sqlite3_trace(). FossilOrigin-Name: 95578898835b933901603bd4d5e063f1219a016f --- autoconf/tea/configure.ac | 1 - manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/autoconf/tea/configure.ac b/autoconf/tea/configure.ac index 8df0af6195..7fca05b2e7 100644 --- a/autoconf/tea/configure.ac +++ b/autoconf/tea/configure.ac @@ -78,7 +78,6 @@ TEA_ADD_LIBS([]) TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS3=1]) TEA_ADD_CFLAGS([-DSQLITE_3_SUFFIX_ONLY=1]) TEA_ADD_CFLAGS([-DSQLITE_ENABLE_RTREE=1]) -TEA_ADD_CFLAGS([-DSQLITE_OMIT_DEPRECATED=1]) TEA_ADD_STUB_SOURCES([]) TEA_ADD_TCL_SOURCES([]) diff --git a/manifest b/manifest index eab6773070..8f590c5751 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Undo\scommit\s[f250166bb].\sIt\sis\srequired\sto\shandle\sIO\sand\sother\serrors\sthat\soccur\swithin\sa\sVACUUM\sof\sa\sZipvfs\sdatabase. -D 2016-08-05T16:16:26.624 +C Have\sthe\sTEA\spackage\sbuild\swithout\sSQLITE_OMIT_DEPRECATED.\sAs\sit\suses\srecently\sdeprecated\sinterfaces\ssqlite3_profile()\sand\ssqlite3_trace(). +D 2016-08-05T20:54:45.205 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -18,7 +18,7 @@ F autoconf/configure.ac cacf2616abf6e4a569bde2ef365c143caeec40bc F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 -F autoconf/tea/configure.ac 93d43c79e936fb16556e22498177d7e8571efa04 +F autoconf/tea/configure.ac 8aa16e3f0a5ca7959d4af198f46934ec187d395f F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb F autoconf/tea/license.terms 13bd403c9610fd2b76ece0ab50c4c5eda933d523 F autoconf/tea/pkgIndex.tcl.in 3ef61715cf1c7bdcff56947ffadb26bc991ca39d @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0f57effa3642e66a863f32cc7fba86d167084af3 -R 7173910e7a14fcd3861af608a7447a5a +P ae72513af37cd806a6d94aaa7c47a740e119d3b1 +R 40e4a12455b009781006c09c1ead4d48 U dan -Z 5568e465afb61eecd4219a0cc50c6e2e +Z 73dc717651276499651d605bdf75c66a diff --git a/manifest.uuid b/manifest.uuid index 4b900d08a6..a4b041f403 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ae72513af37cd806a6d94aaa7c47a740e119d3b1 \ No newline at end of file +95578898835b933901603bd4d5e063f1219a016f \ No newline at end of file From 6da466e4f46d820f2751ccbd4d7a685107fcf2b1 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 7 Aug 2016 18:52:11 +0000 Subject: [PATCH 286/302] Fix documentation typos. No changes to code. FossilOrigin-Name: ebc396a19fa79bea208ecda277ffff5d02166d0b --- ext/fts5/fts5.h | 3 +-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index b32e2132dd..a45c145d38 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -318,7 +318,7 @@ struct Fts5ExtensionApi { ** behaviour. The structure methods are expected to function as follows: ** ** xCreate: -** This function is used to allocate and inititalize a tokenizer instance. +** This function is used to allocate and initialize a tokenizer instance. ** A tokenizer instance is required to actually tokenize text. ** ** The first argument passed to this function is a copy of the (void*) @@ -577,4 +577,3 @@ struct fts5_api { #endif #endif /* _FTS5_H */ - diff --git a/manifest b/manifest index 8f590c5751..dd20d64d7b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\sTEA\spackage\sbuild\swithout\sSQLITE_OMIT_DEPRECATED.\sAs\sit\suses\srecently\sdeprecated\sinterfaces\ssqlite3_profile()\sand\ssqlite3_trace(). -D 2016-08-05T20:54:45.205 +C Fix\sdocumentation\stypos.\s\sNo\schanges\sto\scode. +D 2016-08-07T18:52:11.690 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -97,7 +97,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 -F ext/fts5/fts5.h b770c5e0a8d2ee071ddffc7ab722dbf3474a8abe +F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 F ext/fts5/fts5Int.h 9bd0c7c64285b5b368eca0ac63613185c5ad24ba F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd @@ -385,7 +385,7 @@ F src/resolve.c 0392c6686586b1d4dac9a4106959f03ddd70e9aa F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c f3c6e9065fb34f6a23af27ec7f1f717ffbfc2ee4 F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7 -F src/sqlite.h.in e011dcc3942e6ddc8dd7b894e9e6702e4269161e +F src/sqlite.h.in 0f7580280d1b009b507d8beec1ff0f197ba0cc99 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h d6f221a5bd572df935140beda82f357c2185a77c @@ -1509,7 +1509,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ae72513af37cd806a6d94aaa7c47a740e119d3b1 -R 40e4a12455b009781006c09c1ead4d48 -U dan -Z 73dc717651276499651d605bdf75c66a +P 95578898835b933901603bd4d5e063f1219a016f +R e7962d3372d6a1e29e3980753a6f0162 +U drh +Z 69a694206e64a93c59f8e06cf497782d diff --git a/manifest.uuid b/manifest.uuid index a4b041f403..fc541c54b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95578898835b933901603bd4d5e063f1219a016f \ No newline at end of file +ebc396a19fa79bea208ecda277ffff5d02166d0b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index f60ccaf55c..1ee39b6799 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1959,7 +1959,7 @@ struct sqlite3_mem_methods { ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()]. ** There should be two additional arguments. ** When the first argument to this interface is 1, then only the C-API is -** enabled and the SQL function remains disabled. If the first argment to +** enabled and the SQL function remains disabled. If the first argument to ** this interface is 0, then both the C-API and the SQL function are disabled. ** If the first argument is -1, then no changes are made to state of either the ** C-API or the SQL function. @@ -5537,7 +5537,7 @@ SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); ** column exists. ^The sqlite3_table_column_metadata() interface returns ** SQLITE_ERROR and if the specified column does not exist. ** ^If the column-name parameter to sqlite3_table_column_metadata() is a -** NULL pointer, then this routine simply checks for the existance of the +** NULL pointer, then this routine simply checks for the existence of the ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it ** does not. ** @@ -8132,7 +8132,7 @@ int sqlite3_db_cacheflush(sqlite3*); ** ^The second parameter to the preupdate callback is a pointer to ** the [database connection] that registered the preupdate hook. ** ^The third parameter to the preupdate callback is one of the constants -** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the +** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the ** kind of update operation that is about to occur. ** ^(The fourth parameter to the preupdate callback is the name of the ** database within the database connection that is being modified. This From e22c375659d073c435a49635c05f1fcd86aeb815 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 8 Aug 2016 13:40:27 +0000 Subject: [PATCH 287/302] Version 3.14 FossilOrigin-Name: d5e98057028abcf7217d0d2b2e29bbbcdf09d6de --- manifest | 11 +++++++---- manifest.uuid | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/manifest b/manifest index dd20d64d7b..9d5c14e49e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sdocumentation\stypos.\s\sNo\schanges\sto\scode. -D 2016-08-07T18:52:11.690 +C Version\s3.14 +D 2016-08-08T13:40:27.974 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1509,7 +1509,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 95578898835b933901603bd4d5e063f1219a016f +P ebc396a19fa79bea208ecda277ffff5d02166d0b R e7962d3372d6a1e29e3980753a6f0162 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.14.0 * U drh -Z 69a694206e64a93c59f8e06cf497782d +Z ecb9b7072c2b71d36f58909f83563ec2 diff --git a/manifest.uuid b/manifest.uuid index fc541c54b5..732a4af61b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebc396a19fa79bea208ecda277ffff5d02166d0b \ No newline at end of file +d5e98057028abcf7217d0d2b2e29bbbcdf09d6de \ No newline at end of file From 882ef0b8c08fd475df3785b37094b00b4173eeb2 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Aug 2016 19:26:57 +0000 Subject: [PATCH 288/302] Have fts5 interpret column lists that begin with a "-" character as "match any column except" lists. FossilOrigin-Name: e517545650631d1e8a7ee63c6646a8b183a0a894 --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_expr.c | 61 +++++++++++++++++++++++++++++++++++ ext/fts5/fts5_index.c | 12 +++++++ ext/fts5/fts5parse.y | 11 ++++++- ext/fts5/test/fts5colset.test | 59 +++++++++++++++++++++++++++++++++ manifest | 24 +++++++------- manifest.uuid | 2 +- 7 files changed, 155 insertions(+), 15 deletions(-) create mode 100644 ext/fts5/test/fts5colset.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index c7169a113b..9b1316d454 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -737,6 +737,7 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); +void sqlite3Fts5ParseColsetNegative(Fts5Parse*, int); void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 9119813c85..be6d768a68 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -124,6 +124,7 @@ struct Fts5Parse { char *zErr; int rc; int nPhrase; /* Size of apPhrase array */ + int bNegativeCollist; /* Column list being parsed started with - */ Fts5ExprPhrase **apPhrase; /* Array of all phrases */ Fts5ExprNode *pExpr; /* Result of a successful parse */ }; @@ -167,6 +168,7 @@ static int fts5ExprGetToken( case ',': tok = FTS5_COMMA; break; case '+': tok = FTS5_PLUS; break; case '*': tok = FTS5_STAR; break; + case '-': tok = FTS5_MINUS; break; case '\0': tok = FTS5_EOF; break; case '"': { @@ -1793,6 +1795,53 @@ static Fts5Colset *fts5ParseColset( return pNew; } +/* +** The second argument passed to this function may be NULL, or it may be +** an existing Fts5Colset object. If it is passed NULL, this function +** returns a pointer to a new Fts5Colset object containing entries for +** all table columns except column iCol. If an OOM error occurs trying to +** allocate the Fts5Colset object, an error code is stored in pParse and +** NULL returned. +** +** If the second argument is not NULL, a copy of it is returned. Before +** returning, any entry for column iCol is removed. It is not an error +** if the Fts5Colset object does not contain an entry for column iCol +** when this function is called. +*/ +static Fts5Colset *fts5ParseNegativeColset( + Fts5Parse *pParse, /* Store SQLITE_NOMEM here if required */ + Fts5Colset *p, /* Existing colset object */ + int iCol /* New column to add to colset object */ +){ + int i; + Fts5Colset *pRet = p; + + if( pRet==0 ){ + int nCol = pParse->pConfig->nCol; + pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, + sizeof(Fts5Colset) + sizeof(int)*nCol + ); + if( pRet==0 ) return 0; + pRet->nCol = nCol; + for(i=0; iaiCol[i] = i; + } + } + + for(i=0; inCol; i++){ + if( pRet->aiCol[i]==iCol ){ + int nByte = sizeof(int)*(pRet->nCol-i-1); + if( nByte ){ + memmove(&pRet->aiCol[i], &pRet->aiCol[i+1], nByte); + } + pRet->nCol--; + break; + } + } + + return pRet; +} + Fts5Colset *sqlite3Fts5ParseColset( Fts5Parse *pParse, /* Store SQLITE_NOMEM here if required */ Fts5Colset *pColset, /* Existing colset object */ @@ -1811,6 +1860,8 @@ Fts5Colset *sqlite3Fts5ParseColset( } if( iCol==pConfig->nCol ){ sqlite3Fts5ParseError(pParse, "no such column: %s", z); + }else if( pParse->bNegativeCollist ){ + pRet = fts5ParseNegativeColset(pParse, pColset, iCol); }else{ pRet = fts5ParseColset(pParse, pColset, iCol); } @@ -1825,6 +1876,16 @@ Fts5Colset *sqlite3Fts5ParseColset( return pRet; } +/* +** Set (bVal==1) or clear (bVal==0) the Fts5Parse.bNegativeCollist flag. +** +** The parser calls this function as it begins to parse a colset (Fts5Colset +** object) with bVal set to 1 if the colset begins with a "-" or 0 otherwise. +*/ +void sqlite3Fts5ParseColsetNegative(Fts5Parse *pParse, int bVal){ + pParse->bNegativeCollist = bVal; +} + void sqlite3Fts5ParseSetColset( Fts5Parse *pParse, Fts5ExprNearset *pNear, diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 1d5ebe1428..52fdc634a5 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -3195,6 +3195,14 @@ static void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){ } } +/* +** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match +** against no columns at all). +*/ +static void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){ + pIter->base.nData = 0; +} + /* ** xSetOutputs callback used by detail=col when there is a column filter ** and there are 100 or more columns. Also called as a fallback from @@ -3300,6 +3308,10 @@ static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){ pIter->xSetOutputs = fts5IterSetOutputs_Nocolset; } + else if( pIter->pColset->nCol==0 ){ + pIter->xSetOutputs = fts5IterSetOutputs_ZeroColset; + } + else if( pConfig->eDetail==FTS5_DETAIL_FULL ){ pIter->xSetOutputs = fts5IterSetOutputs_Full; } diff --git a/ext/fts5/fts5parse.y b/ext/fts5/fts5parse.y index 1607d3846a..8bc95f7364 100644 --- a/ext/fts5/fts5parse.y +++ b/ext/fts5/fts5parse.y @@ -119,18 +119,27 @@ cnearset(A) ::= colset(X) COLON nearset(Y). { %destructor colset { sqlite3_free($$); } %type colsetlist {Fts5Colset*} %destructor colsetlist { sqlite3_free($$); } +%type minus_opt {int} colset(A) ::= LCP colsetlist(X) RCP. { A = X; } +colset(A) ::= MINUS STRING(X). { + sqlite3Fts5ParseColsetNegative(pParse, 1); + A = sqlite3Fts5ParseColset(pParse, 0, &X); +} colset(A) ::= STRING(X). { + sqlite3Fts5ParseColsetNegative(pParse, 0); A = sqlite3Fts5ParseColset(pParse, 0, &X); } colsetlist(A) ::= colsetlist(Y) STRING(X). { A = sqlite3Fts5ParseColset(pParse, Y, &X); } -colsetlist(A) ::= STRING(X). { +colsetlist(A) ::= minus_opt(M) STRING(X). { + sqlite3Fts5ParseColsetNegative(pParse, M); A = sqlite3Fts5ParseColset(pParse, 0, &X); } +minus_opt(A) ::= MINUS. { A = 1; } +minus_opt(A) ::= . { A = 0; } %type nearset {Fts5ExprNearset*} %type nearphrases {Fts5ExprNearset*} diff --git a/ext/fts5/test/fts5colset.test b/ext/fts5/test/fts5colset.test new file mode 100644 index 0000000000..c09974a742 --- /dev/null +++ b/ext/fts5/test/fts5colset.test @@ -0,0 +1,59 @@ +# 2016 August 10 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5colset + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +foreach_detail_mode $::testprefix { + if {[detail_is_none]} continue + + do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, d, detail=%DETAIL%); + INSERT INTO t1 VALUES('a', 'b', 'c', 'd'); -- 1 + INSERT INTO t1 VALUES('d', 'a', 'b', 'c'); -- 2 + INSERT INTO t1 VALUES('c', 'd', 'a', 'b'); -- 3 + INSERT INTO t1 VALUES('b', 'c', 'd', 'a'); -- 4 + } + + foreach {tn q res} { + 1 "a" {1 2 3 4} + 2 "{a} : a" {1} + 3 "{-a} : a" {2 3 4} + 4 "{-a c} : a" {2 4} + 5 "{-d d c} : a" {1 2} + 6 "{-d c b a} : a" {} + 7 "{-\"a\"} : b" {1 2 3} + 8 "- c : a" {1 2 4} + 9 "-c : a" {1 2 4} + 10 "-\"c\" : a" {1 2 4} + } { + breakpoint + do_execsql_test 1.$tn { + SELECT rowid FROM t1($q) + } $res + } + + +} + + +finish_test + + diff --git a/manifest b/manifest index 9d5c14e49e..df25caa15d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.14 -D 2016-08-08T13:40:27.974 +C Have\sfts5\sinterpret\scolumn\slists\sthat\sbegin\swith\sa\s"-"\scharacter\sas\s"match\sany\scolumn\sexcept"\slists. +D 2016-08-09T19:26:57.822 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -98,13 +98,13 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 -F ext/fts5/fts5Int.h 9bd0c7c64285b5b368eca0ac63613185c5ad24ba +F ext/fts5/fts5Int.h 51eb867d9afbd1a4130fde00c39acf9aacabe1b6 F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 -F ext/fts5/fts5_expr.c bcb238ee4ac1164302ab528487520488516bd030 +F ext/fts5/fts5_expr.c 8e975ae07dbff244adea3a3697f027fa5387a991 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 -F ext/fts5/fts5_index.c b429e23fabb57506f71e406997cc46b89190dc97 +F ext/fts5/fts5_index.c e25ac419fc66f412e6044595b20b4bf8f7cea284 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a @@ -114,7 +114,7 @@ F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 F ext/fts5/fts5_unicode2.c b450b209b157d598f7b9df9f837afb75a14c24bf F ext/fts5/fts5_varint.c a5aceacda04dafcbae725413d7a16818ecd65738 F ext/fts5/fts5_vocab.c dba72ca393d71c2588548b51380387f6b44c77a8 -F ext/fts5/fts5parse.y fcc5e92e570d38cab38488b2109cbf67468923b2 +F ext/fts5/fts5parse.y bc2f2d9a726e69443ca58a5c0164283a63da819e F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl b01c584144b5064f30e6c648145a2dd6bc440841 F ext/fts5/test/fts5aa.test bd2d88182b9f7f30d300044048ad14683306b745 @@ -135,6 +135,7 @@ F ext/fts5/test/fts5aux.test 5dd158a1e7869e27e9762a2a452b189c728d1be3 F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5bigtok.test 017a9397b14e7598883a6328ead4a6539b42d59a +F ext/fts5/test/fts5colset.test ad686cc648264f0334d2cc11b842e99f6e2bc10a F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 F ext/fts5/test/fts5config.test 7788b9c058074d640dfcdd81d97b6a9480000368 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 @@ -1509,10 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ebc396a19fa79bea208ecda277ffff5d02166d0b -R e7962d3372d6a1e29e3980753a6f0162 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.14.0 * -U drh -Z ecb9b7072c2b71d36f58909f83563ec2 +P d5e98057028abcf7217d0d2b2e29bbbcdf09d6de +R bd788c6a4ffbd14fc48e3960d75681eb +U dan +Z 8eb6c4d9289f254e7f02b4786ea43ed2 diff --git a/manifest.uuid b/manifest.uuid index 732a4af61b..0c0e3e4b5b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5e98057028abcf7217d0d2b2e29bbbcdf09d6de \ No newline at end of file +e517545650631d1e8a7ee63c6646a8b183a0a894 \ No newline at end of file From ccf03677a38901d7d21fdd04a9338a31a8b850ab Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Aug 2016 19:48:37 +0000 Subject: [PATCH 289/302] Minor update to the way fts5 column filters are parsed. FossilOrigin-Name: 14864f2b8470fe98dbd17f59963bf1be8d4962f9 --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_expr.c | 66 +++++++++-------------------------- ext/fts5/fts5parse.y | 17 ++++----- ext/fts5/test/fts5colset.test | 10 +++--- manifest | 18 +++++----- manifest.uuid | 2 +- 6 files changed, 40 insertions(+), 74 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 9b1316d454..273b5bba29 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -738,6 +738,7 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); void sqlite3Fts5ParseColsetNegative(Fts5Parse*, int); +Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index be6d768a68..ca795a6b35 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -124,7 +124,6 @@ struct Fts5Parse { char *zErr; int rc; int nPhrase; /* Size of apPhrase array */ - int bNegativeCollist; /* Column list being parsed started with - */ Fts5ExprPhrase **apPhrase; /* Array of all phrases */ Fts5ExprNode *pExpr; /* Result of a successful parse */ }; @@ -1796,49 +1795,30 @@ static Fts5Colset *fts5ParseColset( } /* -** The second argument passed to this function may be NULL, or it may be -** an existing Fts5Colset object. If it is passed NULL, this function -** returns a pointer to a new Fts5Colset object containing entries for -** all table columns except column iCol. If an OOM error occurs trying to -** allocate the Fts5Colset object, an error code is stored in pParse and -** NULL returned. -** -** If the second argument is not NULL, a copy of it is returned. Before -** returning, any entry for column iCol is removed. It is not an error -** if the Fts5Colset object does not contain an entry for column iCol -** when this function is called. +** Allocate and return an Fts5Colset object specifying the inverse of +** the colset passed as the second argument. Free the colset passed +** as the second argument before returning. */ -static Fts5Colset *fts5ParseNegativeColset( - Fts5Parse *pParse, /* Store SQLITE_NOMEM here if required */ - Fts5Colset *p, /* Existing colset object */ - int iCol /* New column to add to colset object */ -){ - int i; - Fts5Colset *pRet = p; +Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse *pParse, Fts5Colset *p){ + Fts5Colset *pRet; + int nCol = pParse->pConfig->nCol; - if( pRet==0 ){ - int nCol = pParse->pConfig->nCol; - pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, - sizeof(Fts5Colset) + sizeof(int)*nCol - ); - if( pRet==0 ) return 0; - pRet->nCol = nCol; + pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, + sizeof(Fts5Colset) + sizeof(int)*nCol + ); + if( pRet ){ + int i; + int iOld = 0; for(i=0; iaiCol[i] = i; - } - } - - for(i=0; inCol; i++){ - if( pRet->aiCol[i]==iCol ){ - int nByte = sizeof(int)*(pRet->nCol-i-1); - if( nByte ){ - memmove(&pRet->aiCol[i], &pRet->aiCol[i+1], nByte); + if( iOld>=p->nCol || p->aiCol[iOld]!=i ){ + pRet->aiCol[pRet->nCol++] = i; + }else{ + iOld++; } - pRet->nCol--; - break; } } + sqlite3_free(p); return pRet; } @@ -1860,8 +1840,6 @@ Fts5Colset *sqlite3Fts5ParseColset( } if( iCol==pConfig->nCol ){ sqlite3Fts5ParseError(pParse, "no such column: %s", z); - }else if( pParse->bNegativeCollist ){ - pRet = fts5ParseNegativeColset(pParse, pColset, iCol); }else{ pRet = fts5ParseColset(pParse, pColset, iCol); } @@ -1876,16 +1854,6 @@ Fts5Colset *sqlite3Fts5ParseColset( return pRet; } -/* -** Set (bVal==1) or clear (bVal==0) the Fts5Parse.bNegativeCollist flag. -** -** The parser calls this function as it begins to parse a colset (Fts5Colset -** object) with bVal set to 1 if the colset begins with a "-" or 0 otherwise. -*/ -void sqlite3Fts5ParseColsetNegative(Fts5Parse *pParse, int bVal){ - pParse->bNegativeCollist = bVal; -} - void sqlite3Fts5ParseSetColset( Fts5Parse *pParse, Fts5ExprNearset *pNear, diff --git a/ext/fts5/fts5parse.y b/ext/fts5/fts5parse.y index 8bc95f7364..1cc4b88e18 100644 --- a/ext/fts5/fts5parse.y +++ b/ext/fts5/fts5parse.y @@ -119,28 +119,25 @@ cnearset(A) ::= colset(X) COLON nearset(Y). { %destructor colset { sqlite3_free($$); } %type colsetlist {Fts5Colset*} %destructor colsetlist { sqlite3_free($$); } -%type minus_opt {int} +colset(A) ::= MINUS LCP colsetlist(X) RCP. { + A = sqlite3Fts5ParseColsetInvert(pParse, X); +} colset(A) ::= LCP colsetlist(X) RCP. { A = X; } -colset(A) ::= MINUS STRING(X). { - sqlite3Fts5ParseColsetNegative(pParse, 1); +colset(A) ::= STRING(X). { A = sqlite3Fts5ParseColset(pParse, 0, &X); } -colset(A) ::= STRING(X). { - sqlite3Fts5ParseColsetNegative(pParse, 0); +colset(A) ::= MINUS STRING(X). { A = sqlite3Fts5ParseColset(pParse, 0, &X); + A = sqlite3Fts5ParseColsetInvert(pParse, A); } colsetlist(A) ::= colsetlist(Y) STRING(X). { A = sqlite3Fts5ParseColset(pParse, Y, &X); } -colsetlist(A) ::= minus_opt(M) STRING(X). { - sqlite3Fts5ParseColsetNegative(pParse, M); +colsetlist(A) ::= STRING(X). { A = sqlite3Fts5ParseColset(pParse, 0, &X); } -minus_opt(A) ::= MINUS. { A = 1; } -minus_opt(A) ::= . { A = 0; } - %type nearset {Fts5ExprNearset*} %type nearphrases {Fts5ExprNearset*} %destructor nearset { sqlite3Fts5ParseNearsetFree($$); } diff --git a/ext/fts5/test/fts5colset.test b/ext/fts5/test/fts5colset.test index c09974a742..e3333241ee 100644 --- a/ext/fts5/test/fts5colset.test +++ b/ext/fts5/test/fts5colset.test @@ -35,11 +35,11 @@ foreach_detail_mode $::testprefix { foreach {tn q res} { 1 "a" {1 2 3 4} 2 "{a} : a" {1} - 3 "{-a} : a" {2 3 4} - 4 "{-a c} : a" {2 4} - 5 "{-d d c} : a" {1 2} - 6 "{-d c b a} : a" {} - 7 "{-\"a\"} : b" {1 2 3} + 3 "-{a} : a" {2 3 4} + 4 "- {a c} : a" {2 4} + 5 " - {d d c} : a" {1 2} + 6 "- {d c b a} : a" {} + 7 "-{\"a\"} : b" {1 2 3} 8 "- c : a" {1 2 4} 9 "-c : a" {1 2 4} 10 "-\"c\" : a" {1 2 4} diff --git a/manifest b/manifest index df25caa15d..ce75d33797 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sfts5\sinterpret\scolumn\slists\sthat\sbegin\swith\sa\s"-"\scharacter\sas\s"match\sany\scolumn\sexcept"\slists. -D 2016-08-09T19:26:57.822 +C Minor\supdate\sto\sthe\sway\sfts5\scolumn\sfilters\sare\sparsed. +D 2016-08-09T19:48:37.555 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -98,11 +98,11 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 -F ext/fts5/fts5Int.h 51eb867d9afbd1a4130fde00c39acf9aacabe1b6 +F ext/fts5/fts5Int.h 17d72c55d6e0d23cd6a3936312a5fd8cddcbd962 F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 -F ext/fts5/fts5_expr.c 8e975ae07dbff244adea3a3697f027fa5387a991 +F ext/fts5/fts5_expr.c df0004b5bffcbe34c329f2992669c6352443f415 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 F ext/fts5/fts5_index.c e25ac419fc66f412e6044595b20b4bf8f7cea284 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 @@ -114,7 +114,7 @@ F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 F ext/fts5/fts5_unicode2.c b450b209b157d598f7b9df9f837afb75a14c24bf F ext/fts5/fts5_varint.c a5aceacda04dafcbae725413d7a16818ecd65738 F ext/fts5/fts5_vocab.c dba72ca393d71c2588548b51380387f6b44c77a8 -F ext/fts5/fts5parse.y bc2f2d9a726e69443ca58a5c0164283a63da819e +F ext/fts5/fts5parse.y e51b375403421b8b37428a89b095d00597129aae F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl b01c584144b5064f30e6c648145a2dd6bc440841 F ext/fts5/test/fts5aa.test bd2d88182b9f7f30d300044048ad14683306b745 @@ -135,7 +135,7 @@ F ext/fts5/test/fts5aux.test 5dd158a1e7869e27e9762a2a452b189c728d1be3 F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5bigtok.test 017a9397b14e7598883a6328ead4a6539b42d59a -F ext/fts5/test/fts5colset.test ad686cc648264f0334d2cc11b842e99f6e2bc10a +F ext/fts5/test/fts5colset.test 1cdf56e079316005aabda790059aee86f2222ee4 F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 F ext/fts5/test/fts5config.test 7788b9c058074d640dfcdd81d97b6a9480000368 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d5e98057028abcf7217d0d2b2e29bbbcdf09d6de -R bd788c6a4ffbd14fc48e3960d75681eb +P e517545650631d1e8a7ee63c6646a8b183a0a894 +R da20bee26e7c2a9f4b1bf24d21e0ff86 U dan -Z 8eb6c4d9289f254e7f02b4786ea43ed2 +Z a6c95b8c36e7e9259f54069259e2a828 diff --git a/manifest.uuid b/manifest.uuid index 0c0e3e4b5b..7cd334dbf2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e517545650631d1e8a7ee63c6646a8b183a0a894 \ No newline at end of file +14864f2b8470fe98dbd17f59963bf1be8d4962f9 \ No newline at end of file From 8d57d7af23f942dd44b16dea77c0045701cc6e5e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 9 Aug 2016 21:01:52 +0000 Subject: [PATCH 290/302] Fix harmless compiler warning. FossilOrigin-Name: 9a5a4f6e3bc265fecf79a7f63d14abbf239da636 --- ext/fts5/fts5Int.h | 1 - manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 273b5bba29..9ef338e821 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -737,7 +737,6 @@ void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); -void sqlite3Fts5ParseColsetNegative(Fts5Parse*, int); Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); diff --git a/manifest b/manifest index ce75d33797..850a297904 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\supdate\sto\sthe\sway\sfts5\scolumn\sfilters\sare\sparsed. -D 2016-08-09T19:48:37.555 +C Fix\sharmless\scompiler\swarning. +D 2016-08-09T21:01:52.333 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -98,7 +98,7 @@ F ext/fts3/unicode/mkunicode.tcl 2debed3f582d77b3fdd0b8830880250021571fd8 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 -F ext/fts5/fts5Int.h 17d72c55d6e0d23cd6a3936312a5fd8cddcbd962 +F ext/fts5/fts5Int.h b2eda36e0f224365c8e23dc8f559311834f1c13f F ext/fts5/fts5_aux.c daa57fb45216491814520bbb587e97bf81ced458 F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e517545650631d1e8a7ee63c6646a8b183a0a894 -R da20bee26e7c2a9f4b1bf24d21e0ff86 -U dan -Z a6c95b8c36e7e9259f54069259e2a828 +P 14864f2b8470fe98dbd17f59963bf1be8d4962f9 +R 3c3d32515aedcf447480f55f3548a5e0 +U drh +Z 4951f1f9d58f89a54689c68080c6d7fb diff --git a/manifest.uuid b/manifest.uuid index 7cd334dbf2..a3c154d615 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14864f2b8470fe98dbd17f59963bf1be8d4962f9 \ No newline at end of file +9a5a4f6e3bc265fecf79a7f63d14abbf239da636 \ No newline at end of file From c83db9e4e1c0cba15effedb4bf5411653b5c9005 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 01:43:30 +0000 Subject: [PATCH 291/302] Performance optimization in the yy_find_shift_action() routine of the Lemon-generated parser. FossilOrigin-Name: ba6663beefcc8060e6f3be6ab37c13fdbb08b7de --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 53 ++++++++++++++++++++++++--------------------------- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index 850a297904..679af7eda6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning. -D 2016-08-09T21:01:52.333 +C Performance\soptimization\sin\sthe\syy_find_shift_action()\sroutine\sof\sthe\nLemon-generated\sparser. +D 2016-08-10T01:43:30.837 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1438,7 +1438,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 57ffa9852901f6abc45981f0d882f31d1ccb06c0 +F tool/lempar.c 321ebbf1c85ab5435434042590eca0616da24b3d F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 14864f2b8470fe98dbd17f59963bf1be8d4962f9 -R 3c3d32515aedcf447480f55f3548a5e0 +P 9a5a4f6e3bc265fecf79a7f63d14abbf239da636 +R fb6cb5f47404a4ca8ae3044e53622029 U drh -Z 4951f1f9d58f89a54689c68080c6d7fb +Z 1ed24d5681cad4ee5c357b2d89914ae1 diff --git a/manifest.uuid b/manifest.uuid index a3c154d615..f5266c615d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a5a4f6e3bc265fecf79a7f63d14abbf239da636 \ No newline at end of file +ba6663beefcc8060e6f3be6ab37c13fdbb08b7de \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index e0d0e88565..74906ae17f 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -450,50 +450,47 @@ static unsigned int yy_find_shift_action( assert( stateno <= YY_SHIFT_COUNT ); do{ i = yy_shift_ofst[stateno]; - if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno]; assert( iLookAhead!=YYNOCODE ); i += iLookAhead; if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - if( iLookAhead>0 ){ #ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ - iLookAhead = iFallback; - continue; + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); } +#endif + assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ + iLookAhead = iFallback; + continue; + } #endif #ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( + { + int j = i - iLookAhead + YYWILDCARD; + if( #if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && + j>=0 && #endif #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j0 + ){ #ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], - yyTokenName[YYWILDCARD]); - } -#endif /* NDEBUG */ - return yy_action[j]; + if( yyTraceFILE ){ + fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", + yyTracePrompt, yyTokenName[iLookAhead], + yyTokenName[YYWILDCARD]); } +#endif /* NDEBUG */ + return yy_action[j]; } -#endif /* YYWILDCARD */ } +#endif /* YYWILDCARD */ return yy_default[stateno]; }else{ return yy_action[i]; From d9fabbcc5beff63ef8eb29d36dee0ffae55b67b6 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 11:50:12 +0000 Subject: [PATCH 292/302] Fix pcache1TruncateUnsafe() run faster for the case where iLimit is very close to iMaxKey. FossilOrigin-Name: b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/pcache1.c | 34 +++++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 679af7eda6..316b95fb86 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\sin\sthe\syy_find_shift_action()\sroutine\sof\sthe\nLemon-generated\sparser. -D 2016-08-10T01:43:30.837 +C Fix\spcache1TruncateUnsafe()\srun\sfaster\sfor\sthe\scase\swhere\siLimit\sis\nvery\sclose\sto\siMaxKey. +D 2016-08-10T11:50:12.345 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -376,7 +376,7 @@ F src/pager.h 966d2769e76ae347c8a32c4165faf6e6cb64546d F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 -F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d +F src/pcache1.c dc8a6052e5136d6b5e6afe51f37485145646f5ab F src/pragma.c c8b499756658cb8b82cfdbb5845c22cf11f297aa F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e @@ -1510,7 +1510,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9a5a4f6e3bc265fecf79a7f63d14abbf239da636 -R fb6cb5f47404a4ca8ae3044e53622029 +P ba6663beefcc8060e6f3be6ab37c13fdbb08b7de +Q +9ab53605d562a926c5620cba9dc96a3b812a432f +R 045183d4dc58e68027bf139105903731 U drh -Z 1ed24d5681cad4ee5c357b2d89914ae1 +Z 7fb6739dae3ac730e38720df5d5c1de9 diff --git a/manifest.uuid b/manifest.uuid index f5266c615d..5bb9a78a83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba6663beefcc8060e6f3be6ab37c13fdbb08b7de \ No newline at end of file +b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 5fe963ad05..1af1ef5bb7 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -632,12 +632,30 @@ static void pcache1TruncateUnsafe( PCache1 *pCache, /* The cache to truncate */ unsigned int iLimit /* Drop pages with this pgno or larger */ ){ - TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */ - unsigned int h; + TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */ + unsigned int h, iStop; assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); - for(h=0; hnHash; h++){ - PgHdr1 **pp = &pCache->apHash[h]; + assert( pCache->iMaxKey >= iLimit ); + assert( pCache->nHash > 0 ); + if( pCache->iMaxKey - iLimit < pCache->nHash/2 ){ + /* If we are just shaving the last few pages off the end of the + ** cache, then there is no point in scanning the entire hash table. + ** Only scan those hash slots that might contain pages that need to + ** be removed. */ + iStop = iLimit % pCache->nHash; + h = pCache->iMaxKey % pCache->nHash; + TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */ + }else{ + /* This is the general case where many pages are being removed. + ** It is necessary to scan the entire hash table */ + iStop = 0; + h = pCache->nHash - 1; + } + for(;;){ + PgHdr1 **pp; PgHdr1 *pPage; + assert( hnHash ); + pp = &pCache->apHash[h]; while( (pPage = *pp)!=0 ){ if( pPage->iKey>=iLimit ){ pCache->nPage--; @@ -646,11 +664,13 @@ static void pcache1TruncateUnsafe( pcache1FreePage(pPage); }else{ pp = &pPage->pNext; - TESTONLY( nPage++; ) + TESTONLY( if( nPage>=0 ) nPage++; ) } } + if( h==iStop ) break; + h = h ? h-1 : pCache->nHash - 1; } - assert( pCache->nPage==nPage ); + assert( nPage<0 || pCache->nPage==(unsigned)nPage ); } /******************************************************************************/ @@ -1127,7 +1147,7 @@ static void pcache1Destroy(sqlite3_pcache *p){ PGroup *pGroup = pCache->pGroup; assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); pcache1EnterMutex(pGroup); - pcache1TruncateUnsafe(pCache, 0); + if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0); assert( pGroup->nMaxPage >= pCache->nMax ); pGroup->nMaxPage -= pCache->nMax; assert( pGroup->nMinPage >= pCache->nMin ); From 701b68879c06620e0e4b7dcbb644fbeb951867ba Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 13:30:43 +0000 Subject: [PATCH 293/302] Improved comments on the lempar.c parser template. Adjust the YY_SHIFT_USE_DFLT constant in the Lemon-generated parser tables so as to guarantee that it is always out of range of the yy_lookahead[] table. FossilOrigin-Name: 83622f3f50030e4d6abafb99d99742928aaf157c --- manifest | 15 +++++++-------- manifest.uuid | 2 +- tool/lemon.c | 13 +++++++------ tool/lempar.c | 20 ++++++++++++-------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 316b95fb86..a0534bfabe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\spcache1TruncateUnsafe()\srun\sfaster\sfor\sthe\scase\swhere\siLimit\sis\nvery\sclose\sto\siMaxKey. -D 2016-08-10T11:50:12.345 +C Improved\scomments\son\sthe\slempar.c\sparser\stemplate.\s\sAdjust\sthe\nYY_SHIFT_USE_DFLT\sconstant\sin\sthe\sLemon-generated\sparser\stables\sso\sas\nto\sguarantee\sthat\sit\sis\salways\sout\sof\srange\sof\sthe\syy_lookahead[]\stable. +D 2016-08-10T13:30:43.279 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1437,8 +1437,8 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 09a96bed19955697a5e20c49ad863ec2005815a2 -F tool/lempar.c 321ebbf1c85ab5435434042590eca0616da24b3d +F tool/lemon.c e3aa9ba3469804d7cae13b5e041aab192b7b381a +F tool/lempar.c 147e42a5cd83ce38275fde0d07a5df3330cb9b3b F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1510,8 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ba6663beefcc8060e6f3be6ab37c13fdbb08b7de -Q +9ab53605d562a926c5620cba9dc96a3b812a432f -R 045183d4dc58e68027bf139105903731 +P b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 +R f8409033fe00bbe724670b3d36a1f97d U drh -Z 7fb6739dae3ac730e38720df5d5c1de9 +Z c9080bc44cd5d5b39b4e8d736cb94a4a diff --git a/manifest.uuid b/manifest.uuid index 5bb9a78a83..d2f3f5ca4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 \ No newline at end of file +83622f3f50030e4d6abafb99d99742928aaf157c \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 5f124601db..df758a5da6 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4231,20 +4231,21 @@ void ReportTable( fprintf(out, "};\n"); lineno++; /* Output the yy_shift_ofst[] table */ - fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", mnTknOfst-1); lineno++; n = lemp->nxstate; while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--; - fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++; - fprintf(out, "#define YY_SHIFT_MIN (%d)\n", mnTknOfst); lineno++; - fprintf(out, "#define YY_SHIFT_MAX (%d)\n", mxTknOfst); lineno++; + fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", lemp->nactiontab); lineno++; + fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++; + fprintf(out, "#define YY_SHIFT_MIN (%d)\n", mnTknOfst); lineno++; + fprintf(out, "#define YY_SHIFT_MAX (%d)\n", mxTknOfst); lineno++; fprintf(out, "static const %s yy_shift_ofst[] = {\n", - minimum_size_type(mnTknOfst-1, mxTknOfst, &sz)); lineno++; + minimum_size_type(mnTknOfst, lemp->nterminal+lemp->nactiontab, &sz)); + lineno++; lemp->tablesize += n*sz; for(i=j=0; isorted[i]; ofst = stp->iTknOfst; - if( ofst==NO_OFFSET ) ofst = mnTknOfst - 1; + if( ofst==NO_OFFSET ) ofst = lemp->nactiontab; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", ofst); if( j==9 || i==n-1 ){ diff --git a/tool/lempar.c b/tool/lempar.c index 74906ae17f..61d19451e9 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -116,7 +116,7 @@ ** ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE ** and YY_MAX_REDUCE - +** ** N == YY_ERROR_ACTION A syntax error has occurred. ** ** N == YY_ACCEPT_ACTION The parser accepts its input. @@ -125,16 +125,20 @@ ** slots in the yy_action[] table. ** ** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as +** Given state S and lookahead X, the action is computed as either: ** -** yy_action[ yy_shift_ofst[S] + X ] +** (A) N = yy_action[ yy_shift_ofst[S] + X ] +** (B) N = yy_default[S] ** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. +** The (A) formula is preferred. The B formula is used instead if: +** (1) The yy_shift_ofst[S]+X value is out of range, or +** (2) yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or +** (3) yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT. +** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that +** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X. +** Hence only tests (1) and (2) need to be evaluated.) ** -** The formula above is for computing the action when the lookahead is +** The formulas above are for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the yy_reduce_ofst[] array is used in place of ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of From 765fecf0103292e1dec8117bf4dff134cbbc58fc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 13:34:16 +0000 Subject: [PATCH 294/302] Increment the version number to 3.15. FossilOrigin-Name: 8c2701e70ab2553d7a586ff5fe7afa02d8c63199 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index f982feb41b..f02113fe87 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.14.0 +3.15.0 diff --git a/configure b/configure index fbcf7309b1..75c7a3720d 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.14.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.15.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.14.0' -PACKAGE_STRING='sqlite 3.14.0' +PACKAGE_VERSION='3.15.0' +PACKAGE_STRING='sqlite 3.15.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1463,7 +1463,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.14.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.15.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1528,7 +1528,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.14.0:";; + short | recursive ) echo "Configuration of sqlite 3.15.0:";; esac cat <<\_ACEOF @@ -1652,7 +1652,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.14.0 +sqlite configure 3.15.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2071,7 +2071,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.14.0, which was +It was created by sqlite $as_me 3.15.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12151,7 +12151,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.14.0, which was +This file was extended by sqlite $as_me 3.15.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12217,7 +12217,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.14.0 +sqlite config.status 3.15.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index a0534bfabe..3a6e935e56 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Improved\scomments\son\sthe\slempar.c\sparser\stemplate.\s\sAdjust\sthe\nYY_SHIFT_USE_DFLT\sconstant\sin\sthe\sLemon-generated\sparser\stables\sso\sas\nto\sguarantee\sthat\sit\sis\salways\sout\sof\srange\sof\sthe\syy_lookahead[]\stable. -D 2016-08-10T13:30:43.279 +C Increment\sthe\sversion\snumber\sto\s3.15. +D 2016-08-10T13:34:16.502 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 -F VERSION cb29eb11e493dd85b3eeec4053c03949bf98478e +F VERSION 25e2e333adeff5965520bc8db999c658898c972d F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -30,7 +30,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 35ce04a15ca046262bf9baaa2ced9337708cc653 x +F configure 3f44893bc0e51c30653e02b0fd4dc2ab585e446a x F configure.ac b5d3df43161374f8dffd2e5f4b88fbb51685b975 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html e2118945e5f07ed146b45c9cd2b2dd6eabb8ebf2 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b07a26df06a2ffb946ff8a1cc7f43eaf701a94b5 -R f8409033fe00bbe724670b3d36a1f97d +P 83622f3f50030e4d6abafb99d99742928aaf157c +R d9d741532efbea2110f3ccf4d8076cf7 U drh -Z c9080bc44cd5d5b39b4e8d736cb94a4a +Z 14b0337226a0ad8779ef18ae936fbfbf diff --git a/manifest.uuid b/manifest.uuid index d2f3f5ca4a..14b26b5a65 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83622f3f50030e4d6abafb99d99742928aaf157c \ No newline at end of file +8c2701e70ab2553d7a586ff5fe7afa02d8c63199 \ No newline at end of file From 167fbbe195c67fbc2b26bd75fc7c167820ff11c4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 14:40:00 +0000 Subject: [PATCH 295/302] Rearrange the code inside sqlite3RunParser() routine so that sqlite3Parser() is only called from a single place. This allows sqlite3Parser() to be in-lined, which results in a 0.25% overall performance gain. FossilOrigin-Name: 25d1d02b3ea126ade22b2a72649ae55509aa1777 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tokenize.c | 35 +++++++++++++++++++---------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 3a6e935e56..65d4efd170 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increment\sthe\sversion\snumber\sto\s3.15. -D 2016-08-10T13:34:16.502 +C Rearrange\sthe\scode\sinside\ssqlite3RunParser()\sroutine\sso\sthat\ssqlite3Parser()\nis\sonly\scalled\sfrom\sa\ssingle\splace.\s\sThis\sallows\ssqlite3Parser()\sto\sbe\nin-lined,\swhich\sresults\sin\sa\s0.25%\soverall\sperformance\sgain. +D 2016-08-10T14:40:00.773 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -443,7 +443,7 @@ F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 F src/test_windirent.h b12055cab6227f7be10f5c19296f67c60cc5e2a5 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 3b29883b0ce4a6c6f643965b66b5ca6613178e59 +F src/tokenize.c 78c8085bc7af1922aa687f0f4bbd716821330de5 F src/treeview.c c56d6ddbed564efda746236b35bcbb8238daac4b F src/trigger.c e14840ee0c3e549e758ec9bf3e4146e166002280 F src/update.c 4f05ea8cddfa367d045e03589756c02199e8f9bd @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 83622f3f50030e4d6abafb99d99742928aaf157c -R d9d741532efbea2110f3ccf4d8076cf7 +P 8c2701e70ab2553d7a586ff5fe7afa02d8c63199 +R d55f09ced5a54b7cb7985c5709f82b8d U drh -Z 14b0337226a0ad8779ef18ae936fbfbf +Z f780132273cb4e2f41bbf55d6f67764f diff --git a/manifest.uuid b/manifest.uuid index 14b26b5a65..806e1635fa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c2701e70ab2553d7a586ff5fe7afa02d8c63199 \ No newline at end of file +25d1d02b3ea126ade22b2a72649ae55509aa1777 \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 62e770b79c..9230da2a0f 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -502,14 +502,26 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ assert( pParse->nVar==0 ); assert( pParse->nzVar==0 ); assert( pParse->azVar==0 ); - while( zSql[i]!=0 ){ + while( 1 ){ assert( i>=0 ); - pParse->sLastToken.z = &zSql[i]; - pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType); - i += pParse->sLastToken.n; - if( i>mxSqlLen ){ - pParse->rc = SQLITE_TOOBIG; - break; + if( zSql[i]!=0 ){ + pParse->sLastToken.z = &zSql[i]; + pParse->sLastToken.n = sqlite3GetToken((u8*)&zSql[i],&tokenType); + i += pParse->sLastToken.n; + if( i>mxSqlLen ){ + pParse->rc = SQLITE_TOOBIG; + break; + } + }else{ + /* Upon reaching the end of input, call the parser two more times + ** with tokens TK_SEMI and 0, in that order. */ + if( lastTokenParsed==TK_SEMI ){ + tokenType = 0; + }else if( lastTokenParsed==0 ){ + break; + }else{ + tokenType = TK_SEMI; + } } if( tokenType>=TK_SPACE ){ assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL ); @@ -530,15 +542,6 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ } assert( nErr==0 ); pParse->zTail = &zSql[i]; - if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){ - assert( zSql[i]==0 ); - if( lastTokenParsed!=TK_SEMI ){ - sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse); - } - if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){ - sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); - } - } #ifdef YYTRACKMAXSTACKDEPTH sqlite3_mutex_enter(sqlite3MallocMutex()); sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK, From f5dbe7f8d8486f79f0ee1be6ff16176d14156ac4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 15:02:49 +0000 Subject: [PATCH 296/302] Tweaks to pcache1TruncateUnsafe() to make it slightly smaller and faster and easier to test. FossilOrigin-Name: 059f4e2efefb7b9deaf539110c19bceaeb10c6ce --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pcache1.c | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 65d4efd170..40aa0f764a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rearrange\sthe\scode\sinside\ssqlite3RunParser()\sroutine\sso\sthat\ssqlite3Parser()\nis\sonly\scalled\sfrom\sa\ssingle\splace.\s\sThis\sallows\ssqlite3Parser()\sto\sbe\nin-lined,\swhich\sresults\sin\sa\s0.25%\soverall\sperformance\sgain. -D 2016-08-10T14:40:00.773 +C Tweaks\sto\spcache1TruncateUnsafe()\sto\smake\sit\sslightly\ssmaller\sand\sfaster\sand\neasier\sto\stest. +D 2016-08-10T15:02:49.189 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -376,7 +376,7 @@ F src/pager.h 966d2769e76ae347c8a32c4165faf6e6cb64546d F src/parse.y 99b676e6fc2f4e331ab93e76b3987cffdbd28efa F src/pcache.c 5583c8ade4b05075a60ba953ef471d1c1a9c05df F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 -F src/pcache1.c dc8a6052e5136d6b5e6afe51f37485145646f5ab +F src/pcache1.c 4bb7a6a5300c67d0b033d25adb509c120c03e812 F src/pragma.c c8b499756658cb8b82cfdbb5845c22cf11f297aa F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 22df6171aec1d86904ed2ad30c2348a5748aa04e @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8c2701e70ab2553d7a586ff5fe7afa02d8c63199 -R d55f09ced5a54b7cb7985c5709f82b8d +P 25d1d02b3ea126ade22b2a72649ae55509aa1777 +R 828a3811914080064b74ae479ed3b60e U drh -Z f780132273cb4e2f41bbf55d6f67764f +Z 4a1a54abd34521e8d97a121a8de840a3 diff --git a/manifest.uuid b/manifest.uuid index 806e1635fa..3afecdeb57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25d1d02b3ea126ade22b2a72649ae55509aa1777 \ No newline at end of file +059f4e2efefb7b9deaf539110c19bceaeb10c6ce \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 1af1ef5bb7..1b1971a399 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -637,19 +637,19 @@ static void pcache1TruncateUnsafe( assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); assert( pCache->iMaxKey >= iLimit ); assert( pCache->nHash > 0 ); - if( pCache->iMaxKey - iLimit < pCache->nHash/2 ){ + if( pCache->iMaxKey - iLimit < pCache->nHash ){ /* If we are just shaving the last few pages off the end of the ** cache, then there is no point in scanning the entire hash table. ** Only scan those hash slots that might contain pages that need to ** be removed. */ - iStop = iLimit % pCache->nHash; - h = pCache->iMaxKey % pCache->nHash; + h = iLimit % pCache->nHash; + iStop = pCache->iMaxKey % pCache->nHash; TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */ }else{ /* This is the general case where many pages are being removed. ** It is necessary to scan the entire hash table */ - iStop = 0; - h = pCache->nHash - 1; + h = pCache->nHash/2; + iStop = h - 1; } for(;;){ PgHdr1 **pp; @@ -668,7 +668,7 @@ static void pcache1TruncateUnsafe( } } if( h==iStop ) break; - h = h ? h-1 : pCache->nHash - 1; + h = (h+1) % pCache->nHash; } assert( nPage<0 || pCache->nPage==(unsigned)nPage ); } From 922802c44e912e9d854408afa9f7e48f8ff1208a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 18:56:32 +0000 Subject: [PATCH 297/302] Performance enhancement in the expression walker. FossilOrigin-Name: ebccbd96094ac64de39dbd0d220d3a7afd8cd40e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/walker.c | 18 ++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 40aa0f764a..5d7ed0ac68 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tweaks\sto\spcache1TruncateUnsafe()\sto\smake\sit\sslightly\ssmaller\sand\sfaster\sand\neasier\sto\stest. -D 2016-08-10T15:02:49.189 +C Performance\senhancement\sin\sthe\sexpression\swalker. +D 2016-08-10T18:56:32.070 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -463,7 +463,7 @@ F src/vtab.c 6b3cfaff7e4397739d6b48511e777ca58c6d06d4 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 -F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 +F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 25d1d02b3ea126ade22b2a72649ae55509aa1777 -R 828a3811914080064b74ae479ed3b60e +P 059f4e2efefb7b9deaf539110c19bceaeb10c6ce +R e10ecf5680d55c2be7b6807b82221bef U drh -Z 4a1a54abd34521e8d97a121a8de840a3 +Z 07228f4a19a0e884d96dc70fff71df0f diff --git a/manifest.uuid b/manifest.uuid index 3afecdeb57..821d79b57b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -059f4e2efefb7b9deaf539110c19bceaeb10c6ce \ No newline at end of file +ebccbd96094ac64de39dbd0d220d3a7afd8cd40e \ No newline at end of file diff --git a/src/walker.c b/src/walker.c index 1e0ad32871..82aae67a61 100644 --- a/src/walker.c +++ b/src/walker.c @@ -41,17 +41,15 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); testcase( ExprHasProperty(pExpr, EP_Reduced) ); rc = pWalker->xExprCallback(pWalker, pExpr); - if( rc==WRC_Continue - && !ExprHasProperty(pExpr,EP_TokenOnly) ){ - if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; - if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; - if( ExprHasProperty(pExpr, EP_xIsSelect) ){ - if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; - }else{ - if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; - } + if( rc || ExprHasProperty(pExpr,EP_TokenOnly) ) return rc & WRC_Abort; + if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; + if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; + if( ExprHasProperty(pExpr, EP_xIsSelect) ){ + if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; + }else{ + if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; } - return rc & WRC_Abort; + return WRC_Continue; } int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue; From e104dd3cc301c0fe79e59502b13a953f6369c6dc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 19:43:29 +0000 Subject: [PATCH 298/302] List of MATCH operator names in isMatchOfColumn() should be constant. FossilOrigin-Name: 7319d676aaf95ba7391379f4cdf193b6aa898893 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5d7ed0ac68..d87a893d49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\senhancement\sin\sthe\sexpression\swalker. -D 2016-08-10T18:56:32.070 +C List\sof\sMATCH\soperator\snames\sin\sisMatchOfColumn()\sshould\sbe\sconstant. +D 2016-08-10T19:43:29.424 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -467,7 +467,7 @@ F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 -F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563 +F src/whereexpr.c 600e6c619d69f5455dd99c69fec8c42ac44e5c9d F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 059f4e2efefb7b9deaf539110c19bceaeb10c6ce -R e10ecf5680d55c2be7b6807b82221bef +P ebccbd96094ac64de39dbd0d220d3a7afd8cd40e +R fac33bc7c9b64529fad9a6567bc0fbba U drh -Z 07228f4a19a0e884d96dc70fff71df0f +Z d9cf90e53680d487c9bbc0ab8247d4aa diff --git a/manifest.uuid b/manifest.uuid index 821d79b57b..1286c1b8bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebccbd96094ac64de39dbd0d220d3a7afd8cd40e \ No newline at end of file +7319d676aaf95ba7391379f4cdf193b6aa898893 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 1cb6be8458..2461d1ddf8 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -290,7 +290,7 @@ static int isMatchOfColumn( Expr *pExpr, /* Test this expression */ unsigned char *peOp2 /* OUT: 0 for MATCH, or else an op2 value */ ){ - struct Op2 { + static const struct Op2 { const char *zOp; unsigned char eOp2; } aOp[] = { From 93ca3933d17bca3cd5dbad1731d722c6d0108bf0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Aug 2016 20:02:21 +0000 Subject: [PATCH 299/302] Optimization to sqlite3WhereExprUsage(). FossilOrigin-Name: 95493058fcf40306727a281f21c5a2a0011b7d02 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/whereexpr.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d87a893d49..842f885dfd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C List\sof\sMATCH\soperator\snames\sin\sisMatchOfColumn()\sshould\sbe\sconstant. -D 2016-08-10T19:43:29.424 +C Optimization\sto\ssqlite3WhereExprUsage(). +D 2016-08-10T20:02:21.519 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -467,7 +467,7 @@ F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3 F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0 F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41 -F src/whereexpr.c 600e6c619d69f5455dd99c69fec8c42ac44e5c9d +F src/whereexpr.c 98ce9f3b8d92b6f741b9f3498f9619695739256e F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ebccbd96094ac64de39dbd0d220d3a7afd8cd40e -R fac33bc7c9b64529fad9a6567bc0fbba +P 7319d676aaf95ba7391379f4cdf193b6aa898893 +R 35b146f4e31088e5d413861ddde93f74 U drh -Z d9cf90e53680d487c9bbc0ab8247d4aa +Z 2c745f38c120984510a4f6c92123cc21 diff --git a/manifest.uuid b/manifest.uuid index 1286c1b8bf..99c25a4923 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7319d676aaf95ba7391379f4cdf193b6aa898893 \ No newline at end of file +95493058fcf40306727a281f21c5a2a0011b7d02 \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 2461d1ddf8..2768428e2d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -1275,13 +1275,14 @@ void sqlite3WhereClauseClear(WhereClause *pWC){ ** tree. */ Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){ - Bitmask mask = 0; + Bitmask mask; if( p==0 ) return 0; if( p->op==TK_COLUMN ){ mask = sqlite3WhereGetMask(pMaskSet, p->iTable); return mask; } - mask = sqlite3WhereExprUsage(pMaskSet, p->pRight); + assert( !ExprHasProperty(p, EP_TokenOnly) ); + mask = p->pRight ? sqlite3WhereExprUsage(pMaskSet, p->pRight) : 0; if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft); if( ExprHasProperty(p, EP_xIsSelect) ){ mask |= exprSelectUsage(pMaskSet, p->x.pSelect); From c73bd0a5ccba807c7f18673063326f9929702473 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Aug 2016 01:24:56 +0000 Subject: [PATCH 300/302] Fix a harmless compiler warning in FTS5. FossilOrigin-Name: 2ea0c8b46eefd4874f021f8dfd344be751f2034f --- ext/fts5/fts5_index.c | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 52fdc634a5..65b92a2b99 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -3200,6 +3200,7 @@ static void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){ ** against no columns at all). */ static void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){ + UNUSED_PARAM(pSeg); pIter->base.nData = 0; } diff --git a/manifest b/manifest index 842f885dfd..4c405c8749 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Optimization\sto\ssqlite3WhereExprUsage(). -D 2016-08-10T20:02:21.519 +C Fix\sa\sharmless\scompiler\swarning\sin\sFTS5. +D 2016-08-11T01:24:56.314 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -104,7 +104,7 @@ F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 F ext/fts5/fts5_expr.c df0004b5bffcbe34c329f2992669c6352443f415 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 -F ext/fts5/fts5_index.c e25ac419fc66f412e6044595b20b4bf8f7cea284 +F ext/fts5/fts5_index.c 05386732609221d066d204b22c4a5275a0225ed4 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7319d676aaf95ba7391379f4cdf193b6aa898893 -R 35b146f4e31088e5d413861ddde93f74 +P 95493058fcf40306727a281f21c5a2a0011b7d02 +R 62963055338ff8dad6eebc29c29c9140 U drh -Z 2c745f38c120984510a4f6c92123cc21 +Z e11e1549fddd90a07d1f00ccb39e8b50 diff --git a/manifest.uuid b/manifest.uuid index 99c25a4923..88d3f117ad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95493058fcf40306727a281f21c5a2a0011b7d02 \ No newline at end of file +2ea0c8b46eefd4874f021f8dfd344be751f2034f \ No newline at end of file From 6ff4627d5ddbaa2fc96945f2a1e042313de1097a Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 Aug 2016 09:55:55 +0000 Subject: [PATCH 301/302] Fix a 1 byte buffer overwrite in the "sqldiff --rbu" command. FossilOrigin-Name: ab83d7077da80ddbcf399d0797d79e964dc64f0e --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/sqldiff.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4c405c8749..7c618d61d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\sFTS5. -D 2016-08-11T01:24:56.314 +C Fix\sa\s1\sbyte\sbuffer\soverwrite\sin\sthe\s"sqldiff\s--rbu"\scommand. +D 2016-08-11T09:55:55.485 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1477,7 +1477,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 4478f0d30230de6adde90bdb0bfe60f68c5ab782 +F tool/sqldiff.c c965d49bf2677db06103854b47e105484b5b1b84 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 95493058fcf40306727a281f21c5a2a0011b7d02 -R 62963055338ff8dad6eebc29c29c9140 -U drh -Z e11e1549fddd90a07d1f00ccb39e8b50 +P 2ea0c8b46eefd4874f021f8dfd344be751f2034f +R 26e854b22e510a9651c111418b0d5f03 +U dan +Z 78ea492cf13c3fac64589b27f22aa44b diff --git a/manifest.uuid b/manifest.uuid index 88d3f117ad..22f2d26d97 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ea0c8b46eefd4874f021f8dfd344be751f2034f \ No newline at end of file +ab83d7077da80ddbcf399d0797d79e964dc64f0e \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index e92e8aab25..b1363bb341 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -1302,7 +1302,7 @@ static void rbudiff_one_table(const char *zTab, FILE *out){ char *zOtaControl; int nOtaControl = sqlite3_column_bytes(pStmt, nCol); - zOtaControl = (char*)sqlite3_malloc(nOtaControl); + zOtaControl = (char*)sqlite3_malloc(nOtaControl+1); memcpy(zOtaControl, sqlite3_column_text(pStmt, nCol), nOtaControl+1); for(i=0; i Date: Thu, 11 Aug 2016 18:05:47 +0000 Subject: [PATCH 302/302] Add the "modeof=" URI parameter to os_unix.c - used to specify a file to copy permissions from when a new database is created. Also allow passing NULL as the second parameter to sqlite3rbu_vacuum(). FossilOrigin-Name: ed406d31ff54ee3de8db91690a966e5c561f8f94 --- ext/rbu/rbuprogress.test | 2 ++ ext/rbu/rbuvacuum2.test | 42 ++++++++++++++++++++++++++++++++++++++++ ext/rbu/sqlite3rbu.c | 32 +++++++++++++++++++++++------- ext/rbu/sqlite3rbu.h | 16 ++++++++++----- ext/rbu/test_rbu.c | 6 +++--- manifest | 22 ++++++++++----------- manifest.uuid | 2 +- src/os_unix.c | 39 +++++++++++++++++++++++++++++-------- 8 files changed, 126 insertions(+), 35 deletions(-) diff --git a/ext/rbu/rbuprogress.test b/ext/rbu/rbuprogress.test index 6afbffe8ed..af202829c1 100644 --- a/ext/rbu/rbuprogress.test +++ b/ext/rbu/rbuprogress.test @@ -361,6 +361,8 @@ foreach {bReopen} { 0 1 } { } } { + if {$tn=="vtab"} { ifcapable !fts5 break } + foreach {tn2 rbusql r1 r2} { 1 { CREATE TABLE data0_t1(a, b, c, rbu_rowid, rbu_control); diff --git a/ext/rbu/rbuvacuum2.test b/ext/rbu/rbuvacuum2.test index 6397751836..bd38660320 100644 --- a/ext/rbu/rbuvacuum2.test +++ b/ext/rbu/rbuvacuum2.test @@ -156,7 +156,49 @@ foreach step {0 1} { trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END} } } +} + +#------------------------------------------------------------------------- +# Test that passing a NULL value as the second argument to +# sqlite3rbu_vacuum() causes it to: +# +# * Use -vacuum as the state db, and +# * Set the state db permissions to the same as those on the db file. +# +db close +if {$::tcl_platform(platform)=="unix"} { + forcedelete test.db + sqlite3 db test.db + do_execsql_test 5.0 { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); + INSERT INTO t1 VALUES(5, 6); + INSERT INTO t1 VALUES(7, 8); + } + db close + + foreach {tn perm} { + 1 00755 + 2 00666 + 3 00644 + 4 00444 + } { + forcedelete test.db-vacuum + + do_test 5.$tn.1 { + file attributes test.db -permissions $perm + sqlite3rbu_vacuum rbu test.db + rbu step + } {SQLITE_OK} + + do_test 5.$tn.2 { file exists test.db-vacuum } 1 + do_test 5.$tn.3 { file attributes test.db-vacuum -permissions} $perm + rbu close + } } + finish_test + diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 73c6647a2c..746469a8af 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -2334,15 +2334,18 @@ static RbuState *rbuLoadState(sqlite3rbu *p){ ** error occurs, leave an error code and message in the RBU handle. */ static void rbuOpenDatabase(sqlite3rbu *p){ - assert( p->rc==SQLITE_OK ); - assert( p->dbMain==0 && p->dbRbu==0 ); - assert( rbuIsVacuum(p) || p->zTarget!=0 ); + assert( p->rc || (p->dbMain==0 && p->dbRbu==0) ); + assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 ); /* Open the RBU database */ p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1); if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){ sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p); + if( p->zState==0 ){ + const char *zFile = sqlite3_db_filename(p->dbRbu, "main"); + p->zState = rbuMPrintf(p, "file://%s-vacuum?modeof=%s", zFile, zFile); + } } /* If using separate RBU and state databases, attach the state database to @@ -3477,8 +3480,7 @@ static sqlite3rbu *openRbuHandle( sqlite3rbu *p; size_t nTarget = zTarget ? strlen(zTarget) : 0; size_t nRbu = strlen(zRbu); - size_t nState = zState ? strlen(zState) : 0; - size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1+ nState+1; + size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1; p = (sqlite3rbu*)sqlite3_malloc64(nByte); if( p ){ @@ -3500,8 +3502,7 @@ static sqlite3rbu *openRbuHandle( memcpy(p->zRbu, zRbu, nRbu+1); pCsr += nRbu+1; if( zState ){ - p->zState = pCsr; - memcpy(p->zState, zState, nState+1); + p->zState = rbuMPrintf(p, "%s", zState); } rbuOpenDatabase(p); } @@ -3611,6 +3612,20 @@ static sqlite3rbu *openRbuHandle( return p; } +/* +** Allocate and return an RBU handle with all fields zeroed except for the +** error code, which is set to SQLITE_MISUSE. +*/ +static sqlite3rbu *rbuMisuseError(void){ + sqlite3rbu *pRet; + pRet = sqlite3_malloc64(sizeof(sqlite3rbu)); + if( pRet ){ + memset(pRet, 0, sizeof(sqlite3rbu)); + pRet->rc = SQLITE_MISUSE; + } + return pRet; +} + /* ** Open and return a new RBU handle. */ @@ -3619,6 +3634,7 @@ sqlite3rbu *sqlite3rbu_open( const char *zRbu, const char *zState ){ + if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); } /* TODO: Check that zTarget and zRbu are non-NULL */ return openRbuHandle(zTarget, zRbu, zState); } @@ -3630,6 +3646,7 @@ sqlite3rbu *sqlite3rbu_vacuum( const char *zTarget, const char *zState ){ + if( zTarget==0 ){ return rbuMisuseError(); } /* TODO: Check that both arguments are non-NULL */ return openRbuHandle(0, zTarget, zState); } @@ -3707,6 +3724,7 @@ int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){ rbuEditErrmsg(p); rc = p->rc; *pzErrmsg = p->zErrmsg; + sqlite3_free(p->zState); sqlite3_free(p); }else{ rc = SQLITE_NOMEM; diff --git a/ext/rbu/sqlite3rbu.h b/ext/rbu/sqlite3rbu.h index 9ce39f543c..3f5f29a8e6 100644 --- a/ext/rbu/sqlite3rbu.h +++ b/ext/rbu/sqlite3rbu.h @@ -319,16 +319,22 @@ sqlite3rbu *sqlite3rbu_open( ** An RBU vacuum is similar to SQLite's built-in VACUUM command, except ** that it can be suspended and resumed like an RBU update. ** -** The second argument to this function, which may not be NULL, identifies -** a database in which to store the state of the RBU vacuum operation if -** it is suspended. The first time sqlite3rbu_vacuum() is called, to start -** an RBU vacuum operation, the state database should either not exist or -** be empty (contain no tables). If an RBU vacuum is suspended by calling +** The second argument to this function identifies a database in which +** to store the state of the RBU vacuum operation if it is suspended. The +** first time sqlite3rbu_vacuum() is called, to start an RBU vacuum +** operation, the state database should either not exist or be empty +** (contain no tables). If an RBU vacuum is suspended by calling ** sqlite3rbu_close() on the RBU handle before sqlite3rbu_step() has ** returned SQLITE_DONE, the vacuum state is stored in the state database. ** The vacuum can be resumed by calling this function to open a new RBU ** handle specifying the same target and state databases. ** +** If the second argument passed to this function is NULL, then the +** name of the state database is "-vacuum", where +** is the name of the target database file. In this case, on UNIX, if the +** state database is not already present in the file-system, it is created +** with the same permissions as the target db is made. +** ** This function does not delete the state database after an RBU vacuum ** is completed, even if it created it. However, if the call to ** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents diff --git a/ext/rbu/test_rbu.c b/ext/rbu/test_rbu.c index bc4c800331..b1a2252741 100644 --- a/ext/rbu/test_rbu.c +++ b/ext/rbu/test_rbu.c @@ -240,13 +240,13 @@ static int SQLITE_TCLAPI test_sqlite3rbu_vacuum( const char *zTarget; const char *zStateDb = 0; - if( objc!=4 ){ - Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB STATE-DB"); + if( objc!=3 && objc!=4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB ?STATE-DB?"); return TCL_ERROR; } zCmd = Tcl_GetString(objv[1]); zTarget = Tcl_GetString(objv[2]); - zStateDb = Tcl_GetString(objv[3]); + if( objc==4 ) zStateDb = Tcl_GetString(objv[3]); pRbu = sqlite3rbu_vacuum(zTarget, zStateDb); Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0); diff --git a/manifest b/manifest index 7c618d61d7..3d5a0dd058 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\s1\sbyte\sbuffer\soverwrite\sin\sthe\s"sqldiff\s--rbu"\scommand. -D 2016-08-11T09:55:55.485 +C Add\sthe\s"modeof="\sURI\sparameter\sto\sos_unix.c\s-\sused\sto\sspecify\sa\sfile\sto\scopy\spermissions\sfrom\swhen\sa\snew\sdatabase\sis\screated.\sAlso\sallow\spassing\sNULL\sas\sthe\ssecond\sparameter\sto\ssqlite3rbu_vacuum(). +D 2016-08-11T18:05:47.763 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -250,13 +250,13 @@ F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda -F ext/rbu/rbuprogress.test 2023a7df2c523e3df1cb532eff811cda385a789a +F ext/rbu/rbuprogress.test e3e25fb7622641b8f2df7c6b7a7eb6fddfc46a4b F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0 -F ext/rbu/rbuvacuum2.test 45009e127c3fb385e5c0fd5a8a63fb922a79d0ab -F ext/rbu/sqlite3rbu.c 948677ee0ec57da51148e6c5f64ac68afcf36ab2 -F ext/rbu/sqlite3rbu.h db8858120c9be14b60c9225f9da28221f5f6b945 -F ext/rbu/test_rbu.c 1a6bbc6982e32485a48df111d0bb1934d537eabd +F ext/rbu/rbuvacuum2.test 2569205b74ff40fbf3bda2fce33a58eb40eebdcc +F ext/rbu/sqlite3rbu.c e074c38798b90591f7f0cf0032d62f152ce5a95e +F ext/rbu/sqlite3rbu.h 1d91c5b7d066645bd1ff8e4b85c2b9b5dd29fb05 +F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c d26a815b0df1c412a6881dae8d7fd3c9c08cce68 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e @@ -368,7 +368,7 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c a9443cdab41d7f3cdf0df3a5aab62fd6e1c9b234 +F src/os_unix.c be9ca0f901a2b6c1bc93dc338f4863675180c189 F src/os_win.c 520f23475f1de530c435d30b67b7b15fe90874b0 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 40928c450320da78bb4bd3ae82818f4239e19b7e @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2ea0c8b46eefd4874f021f8dfd344be751f2034f -R 26e854b22e510a9651c111418b0d5f03 +P ab83d7077da80ddbcf399d0797d79e964dc64f0e +R 753cf0ce0fc5b95ce832a2f13995ee3e U dan -Z 78ea492cf13c3fac64589b27f22aa44b +Z 87571942a0f33f54e925f9d7f08d0ded diff --git a/manifest.uuid b/manifest.uuid index 22f2d26d97..32f13a7c5d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ab83d7077da80ddbcf399d0797d79e964dc64f0e \ No newline at end of file +ed406d31ff54ee3de8db91690a966e5c561f8f94 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index f5b01e9958..08d4cb5d11 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5529,6 +5529,27 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){ return pUnused; } +/* +** Find the mode, uid and gid of file zFile. +*/ +static int getFileMode( + const char *zFile, /* File name */ + mode_t *pMode, /* OUT: Permissions of zFile */ + uid_t *pUid, /* OUT: uid of zFile. */ + gid_t *pGid /* OUT: gid of zFile. */ +){ + struct stat sStat; /* Output of stat() on database file */ + int rc = SQLITE_OK; + if( 0==osStat(zFile, &sStat) ){ + *pMode = sStat.st_mode & 0777; + *pUid = sStat.st_uid; + *pGid = sStat.st_gid; + }else{ + rc = SQLITE_IOERR_FSTAT; + } + return rc; +} + /* ** This function is called by unixOpen() to determine the unix permissions ** to create new files with. If no error occurs, then SQLITE_OK is returned @@ -5564,7 +5585,6 @@ static int findCreateFileMode( if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ char zDb[MAX_PATHNAME+1]; /* Database file path */ int nDb; /* Number of valid bytes in zDb */ - struct stat sStat; /* Output of stat() on database file */ /* zPath is a path to a WAL or journal file. The following block derives ** the path to the associated database file from zPath. This block handles @@ -5595,15 +5615,18 @@ static int findCreateFileMode( memcpy(zDb, zPath, nDb); zDb[nDb] = '\0'; - if( 0==osStat(zDb, &sStat) ){ - *pMode = sStat.st_mode & 0777; - *pUid = sStat.st_uid; - *pGid = sStat.st_gid; - }else{ - rc = SQLITE_IOERR_FSTAT; - } + rc = getFileMode(zDb, pMode, pUid, pGid); }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ *pMode = 0600; + }else if( flags & SQLITE_OPEN_URI ){ + /* If this is a main database file and the file was opened using a URI + ** filename, check for the "modeof" parameter. If present, interpret + ** its value as a filename and try to copy the mode, uid and gid from + ** that file. */ + const char *z = sqlite3_uri_parameter(zPath, "modeof"); + if( z ){ + rc = getFileMode(z, pMode, pUid, pGid); + } } return rc; }