Improved "wheretrace" capabilities: Show the constraint expression if the
wheretrace flag has the 0x100 bit set and if compiled with SQLITE_ENABLE_TREE_EXPLAIN. FossilOrigin-Name: 710a18ac7916cb688955505d7d461b461f563155
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
C Add\sthe\s".open"\scommand\sto\sthe\scommand-line\sshell.
|
||||
D 2013-10-24T15:20:20.917
|
||||
C Improved\s"wheretrace"\scapabilities:\s\sShow\sthe\sconstraint\sexpression\sif\sthe\nwheretrace\sflag\shas\sthe\s0x100\sbit\sset\sand\sif\scompiled\swith\nSQLITE_ENABLE_TREE_EXPLAIN.
|
||||
D 2013-10-28T14:34:35.937
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -292,7 +292,7 @@ F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d
|
||||
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
|
||||
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
|
||||
F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74
|
||||
F src/where.c dd2d0d69280d6653d8ef8cf3b6b4b848b9058197
|
||||
F src/where.c 8eaf13f3047d80841f6f1a38f4dfaf4409528a4b
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
|
||||
@@ -1126,7 +1126,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||
P f1d8c3b07e61c5a8b39675d0d62876ca15e207f3
|
||||
R 669ddc5b90d3123c7996e141023f003e
|
||||
P 21eccb919441bd111ba414dde3f00862822e2c99
|
||||
R 5260b5cc40060f48c72b8d61c27b1dc0
|
||||
U drh
|
||||
Z eb67a516397c437f69feed70887b8d2e
|
||||
Z d9787b9cfeec57eaa314263c770f7600
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
21eccb919441bd111ba414dde3f00862822e2c99
|
||||
710a18ac7916cb688955505d7d461b461f563155
|
||||
+41
-22
@@ -2550,7 +2550,7 @@ static int whereRangeScanEst(
|
||||
nOut = nNew;
|
||||
}
|
||||
pLoop->nOut = (LogEst)nOut;
|
||||
WHERETRACE(0x100, ("range scan regions: %u..%u est=%d\n",
|
||||
WHERETRACE(0x10, ("range scan regions: %u..%u est=%d\n",
|
||||
(u32)iLower, (u32)iUpper, nOut));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@@ -2636,7 +2636,7 @@ static int whereEqualScanEst(
|
||||
pBuilder->nRecValid = nEq;
|
||||
|
||||
whereKeyStats(pParse, p, pRec, 0, a);
|
||||
WHERETRACE(0x100,("equality scan regions: %d\n", (int)a[1]));
|
||||
WHERETRACE(0x10,("equality scan regions: %d\n", (int)a[1]));
|
||||
*pnRow = a[1];
|
||||
|
||||
return rc;
|
||||
@@ -2684,7 +2684,7 @@ static int whereInScanEst(
|
||||
if( rc==SQLITE_OK ){
|
||||
if( nRowEst > p->aiRowEst[0] ) nRowEst = p->aiRowEst[0];
|
||||
*pnRow = nRowEst;
|
||||
WHERETRACE(0x100,("IN row estimate: est=%g\n", nRowEst));
|
||||
WHERETRACE(0x10,("IN row estimate: est=%g\n", nRowEst));
|
||||
}
|
||||
assert( pBuilder->nRecValid==nRecValid );
|
||||
return rc;
|
||||
@@ -3893,9 +3893,9 @@ static Bitmask codeOneLoopStart(
|
||||
/*
|
||||
** Print a WhereLoop object for debugging purposes
|
||||
*/
|
||||
static void whereLoopPrint(WhereLoop *p, SrcList *pTabList){
|
||||
int nb = 1+(pTabList->nSrc+7)/8;
|
||||
struct SrcList_item *pItem = pTabList->a + p->iTab;
|
||||
static void whereLoopPrint(WhereLoop *p, WhereInfo *pWInfo){
|
||||
int nb = 1+(pWInfo->pTabList->nSrc+7)/8;
|
||||
struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab;
|
||||
Table *pTab = pItem->pTab;
|
||||
sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
|
||||
p->iTab, nb, p->maskSelf, nb, p->prereq);
|
||||
@@ -3927,6 +3927,25 @@ static void whereLoopPrint(WhereLoop *p, SrcList *pTabList){
|
||||
}
|
||||
sqlite3DebugPrintf(" f %04x N %d", p->wsFlags, p->nLTerm);
|
||||
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
|
||||
#ifdef SQLITE_ENABLE_TREE_EXPLAIN
|
||||
/* If the 0x100 bit of wheretracing is set, then show all of the constraint
|
||||
** expressions in the WhereLoop.aLTerm[] array.
|
||||
*/
|
||||
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){ /* WHERETRACE 0x100 */
|
||||
int i;
|
||||
Vdbe *v = pWInfo->pParse->pVdbe;
|
||||
sqlite3ExplainBegin(v);
|
||||
for(i=0; i<p->nLTerm; i++){
|
||||
sqlite3ExplainPrintf(v, " (%d) ", i+1);
|
||||
sqlite3ExplainPush(v);
|
||||
sqlite3ExplainExpr(v, p->aLTerm[i]->pExpr);
|
||||
sqlite3ExplainPop(v);
|
||||
sqlite3ExplainNL(v);
|
||||
}
|
||||
sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v));
|
||||
sqlite3ExplainFinish(v);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4066,10 +4085,10 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
|
||||
#endif
|
||||
whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun,
|
||||
pTemplate->nOut);
|
||||
#if WHERETRACE_ENABLED
|
||||
#if WHERETRACE_ENABLED /* 0x8 */
|
||||
if( sqlite3WhereTrace & 0x8 ){
|
||||
sqlite3DebugPrintf(x?" or-%d: ":" or-X: ", n);
|
||||
whereLoopPrint(pTemplate, pWInfo->pTabList);
|
||||
whereLoopPrint(pTemplate, pWInfo);
|
||||
}
|
||||
#endif
|
||||
return SQLITE_OK;
|
||||
@@ -4139,14 +4158,14 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
|
||||
** with pTemplate[] if p[] exists, or if p==NULL then allocate a new
|
||||
** WhereLoop and insert it.
|
||||
*/
|
||||
#if WHERETRACE_ENABLED
|
||||
#if WHERETRACE_ENABLED /* 0x8 */
|
||||
if( sqlite3WhereTrace & 0x8 ){
|
||||
if( p!=0 ){
|
||||
sqlite3DebugPrintf("ins-del: ");
|
||||
whereLoopPrint(p, pWInfo->pTabList);
|
||||
whereLoopPrint(p, pWInfo);
|
||||
}
|
||||
sqlite3DebugPrintf("ins-new: ");
|
||||
whereLoopPrint(pTemplate, pWInfo->pTabList);
|
||||
whereLoopPrint(pTemplate, pWInfo);
|
||||
}
|
||||
#endif
|
||||
if( p==0 ){
|
||||
@@ -4167,10 +4186,10 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
|
||||
|
||||
/* Jump here if the insert is a no-op */
|
||||
whereLoopInsert_noop:
|
||||
#if WHERETRACE_ENABLED
|
||||
#if WHERETRACE_ENABLED /* 0x8 */
|
||||
if( sqlite3WhereTrace & 0x8 ){
|
||||
sqlite3DebugPrintf("ins-noop: ");
|
||||
whereLoopPrint(pTemplate, pWInfo->pTabList);
|
||||
whereLoopPrint(pTemplate, pWInfo);
|
||||
}
|
||||
#endif
|
||||
return SQLITE_OK;
|
||||
@@ -5328,7 +5347,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
}
|
||||
if( jj>=nTo ){
|
||||
if( nTo>=mxChoice && rCost>=mxCost ){
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* 0x4 */
|
||||
if( sqlite3WhereTrace&0x4 ){
|
||||
sqlite3DebugPrintf("Skip %s cost=%-3d,%3d order=%c\n",
|
||||
wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
|
||||
@@ -5346,7 +5365,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
jj = mxI;
|
||||
}
|
||||
pTo = &aTo[jj];
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* 0x4 */
|
||||
if( sqlite3WhereTrace&0x4 ){
|
||||
sqlite3DebugPrintf("New %s cost=%-3d,%3d order=%c\n",
|
||||
wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
|
||||
@@ -5355,7 +5374,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
#endif
|
||||
}else{
|
||||
if( pTo->rCost<=rCost && pTo->nRow<=nOut ){
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* 0x4 */
|
||||
if( sqlite3WhereTrace&0x4 ){
|
||||
sqlite3DebugPrintf(
|
||||
"Skip %s cost=%-3d,%3d order=%c",
|
||||
@@ -5371,7 +5390,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
}
|
||||
testcase( pTo->rCost==rCost+1 );
|
||||
/* A new and better score for a previously created equivalent path */
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* 0x4 */
|
||||
if( sqlite3WhereTrace&0x4 ){
|
||||
sqlite3DebugPrintf(
|
||||
"Update %s cost=%-3d,%3d order=%c",
|
||||
@@ -5407,7 +5426,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* >=2 */
|
||||
if( sqlite3WhereTrace>=2 ){
|
||||
sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
|
||||
for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
|
||||
@@ -5821,7 +5840,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
if( rc ) goto whereBeginError;
|
||||
|
||||
/* Display all of the WhereLoop objects if wheretrace is enabled */
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* !=0 */
|
||||
if( sqlite3WhereTrace ){
|
||||
WhereLoop *p;
|
||||
int i;
|
||||
@@ -5829,7 +5848,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWYXZ";
|
||||
for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){
|
||||
p->cId = zLabel[i%sizeof(zLabel)];
|
||||
whereLoopPrint(p, pTabList);
|
||||
whereLoopPrint(p, pWInfo);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -5847,7 +5866,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
if( pParse->nErr || NEVER(db->mallocFailed) ){
|
||||
goto whereBeginError;
|
||||
}
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
#ifdef WHERETRACE_ENABLED /* !=0 */
|
||||
if( sqlite3WhereTrace ){
|
||||
int ii;
|
||||
sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
|
||||
@@ -5870,7 +5889,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
}
|
||||
sqlite3DebugPrintf("\n");
|
||||
for(ii=0; ii<pWInfo->nLevel; ii++){
|
||||
whereLoopPrint(pWInfo->a[ii].pWLoop, pTabList);
|
||||
whereLoopPrint(pWInfo->a[ii].pWLoop, pWInfo);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user