From: drh Date: Mon, 28 Oct 2013 19:03:21 +0000 (+0000) Subject: Bug fix and enhancements to the improved wheretrace logic that shows the X-Git-Tag: version-3.8.2~153 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c1ba2e7a529dabe1d7670f9e8c9e03315fe769c3;p=thirdparty%2Fsqlite.git Bug fix and enhancements to the improved wheretrace logic that shows the constraint expressions. FossilOrigin-Name: 10f125f5da55eca15e68c74d62ab7d37bbbbfb5f --- diff --git a/manifest b/manifest index ca4f6895d2..cafa1e586a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 +C Bug\sfix\sand\senhancements\sto\sthe\simproved\swheretrace\slogic\sthat\sshows\sthe\nconstraint\sexpressions. +D 2013-10-28T19:03:21.821 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 8eaf13f3047d80841f6f1a38f4dfaf4409528a4b +F src/where.c 65ff0a3241feaebda8c2996f1d56e13e13bfad11 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 21eccb919441bd111ba414dde3f00862822e2c99 -R 5260b5cc40060f48c72b8d61c27b1dc0 +P 710a18ac7916cb688955505d7d461b461f563155 +R 89498d16fc02d0b55681c504013a5543 U drh -Z d9787b9cfeec57eaa314263c770f7600 +Z a3f286e08ab862275ce77a1e64b61897 diff --git a/manifest.uuid b/manifest.uuid index d7cffd19dd..c55ac6df95 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -710a18ac7916cb688955505d7d461b461f563155 \ No newline at end of file +10f125f5da55eca15e68c74d62ab7d37bbbbfb5f \ No newline at end of file diff --git a/src/where.c b/src/where.c index 7a12e8dc76..3d3989cedc 100644 --- a/src/where.c +++ b/src/where.c @@ -3893,7 +3893,8 @@ static Bitmask codeOneLoopStart( /* ** Print a WhereLoop object for debugging purposes */ -static void whereLoopPrint(WhereLoop *p, WhereInfo *pWInfo){ +static void whereLoopPrint(WhereLoop *p, WhereClause *pWC){ + WhereInfo *pWInfo = pWC->pWInfo; int nb = 1+(pWInfo->pTabList->nSrc+7)/8; struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab; Table *pTab = pItem->pTab; @@ -3902,9 +3903,8 @@ static void whereLoopPrint(WhereLoop *p, WhereInfo *pWInfo){ sqlite3DebugPrintf(" %12s", pItem->zAlias ? pItem->zAlias : pTab->zName); if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){ - if( p->u.btree.pIndex ){ - const char *zName = p->u.btree.pIndex->zName; - if( zName==0 ) zName = "ipk"; + const char *zName; + if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){ if( strncmp(zName, "sqlite_autoindex_", 17)==0 ){ int i = sqlite3Strlen30(zName) - 1; while( zName[i]!='_' ) i--; @@ -3936,14 +3936,18 @@ static void whereLoopPrint(WhereLoop *p, WhereInfo *pWInfo){ Vdbe *v = pWInfo->pParse->pVdbe; sqlite3ExplainBegin(v); for(i=0; inLTerm; i++){ - sqlite3ExplainPrintf(v, " (%d) ", i+1); + WhereTerm *pTerm = p->aLTerm[i]; + sqlite3ExplainPrintf(v, " (%d) #%d ", i+1, (int)(pTerm-pWC->a)); + if( (pTerm->wtFlags & (TERM_ORINFO|TERM_ANDINFO))==0 ){ + sqlite3ExplainPrintf(v, "lhs=%-2d ", pTerm->u.leftColumn); + } sqlite3ExplainPush(v); - sqlite3ExplainExpr(v, p->aLTerm[i]->pExpr); + sqlite3ExplainExpr(v, pTerm->pExpr); sqlite3ExplainPop(v); sqlite3ExplainNL(v); } - sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v)); sqlite3ExplainFinish(v); + sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v)); } #endif } @@ -4088,7 +4092,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ #if WHERETRACE_ENABLED /* 0x8 */ if( sqlite3WhereTrace & 0x8 ){ sqlite3DebugPrintf(x?" or-%d: ":" or-X: ", n); - whereLoopPrint(pTemplate, pWInfo); + whereLoopPrint(pTemplate, pBuilder->pWC); } #endif return SQLITE_OK; @@ -4162,10 +4166,10 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ if( sqlite3WhereTrace & 0x8 ){ if( p!=0 ){ sqlite3DebugPrintf("ins-del: "); - whereLoopPrint(p, pWInfo); + whereLoopPrint(p, pBuilder->pWC); } sqlite3DebugPrintf("ins-new: "); - whereLoopPrint(pTemplate, pWInfo); + whereLoopPrint(pTemplate, pBuilder->pWC); } #endif if( p==0 ){ @@ -4189,7 +4193,7 @@ whereLoopInsert_noop: #if WHERETRACE_ENABLED /* 0x8 */ if( sqlite3WhereTrace & 0x8 ){ sqlite3DebugPrintf("ins-noop: "); - whereLoopPrint(pTemplate, pWInfo); + whereLoopPrint(pTemplate, pBuilder->pWC); } #endif return SQLITE_OK; @@ -5848,7 +5852,7 @@ WhereInfo *sqlite3WhereBegin( "ABCDEFGHIJKLMNOPQRSTUVWYXZ"; for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){ p->cId = zLabel[i%sizeof(zLabel)]; - whereLoopPrint(p, pWInfo); + whereLoopPrint(p, sWLB.pWC); } } #endif @@ -5889,7 +5893,7 @@ WhereInfo *sqlite3WhereBegin( } sqlite3DebugPrintf("\n"); for(ii=0; iinLevel; ii++){ - whereLoopPrint(pWInfo->a[ii].pWLoop, pWInfo); + whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC); } } #endif