]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
New enhancements to .wheretrace. The 0x20000 flag shows the WHERE clause
authordrh <drh@noemail.net>
Sat, 28 Dec 2019 14:07:22 +0000 (14:07 +0000)
committerdrh <drh@noemail.net>
Sat, 28 Dec 2019 14:07:22 +0000 (14:07 +0000)
before and after coding each loop.  The 0x800 flag shows status at the start
and at the end of each loop.  An extra "C" tag is shown on coded terms.

FossilOrigin-Name: 59cc46e5a6d8dbb030f27716ad5446ecccf81cf0cfff95338b9133777f2059e7

manifest
manifest.uuid
src/where.c
src/wherecode.c

index 1a2bd71a576ac644baacedad78876850a5c6140e..f39579c83490f57b0223d9484c1da387c6f9f250 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Expose\ssome\sof\sthe\sWhere\sdata\sstructure\sdebug\sprinting\sroutines\sto\sthe\nentire\sWHERE-clause\sprocessing\smodule.
-D 2019-12-28T13:39:47.110
+C New\senhancements\sto\s.wheretrace.\s\sThe\s0x20000\sflag\sshows\sthe\sWHERE\sclause\nbefore\sand\safter\scoding\seach\sloop.\s\sThe\s0x800\sflag\sshows\sstatus\sat\sthe\sstart\nand\sat\sthe\send\sof\seach\sloop.\s\sAn\sextra\s"C"\stag\sis\sshown\son\scoded\sterms.
+D 2019-12-28T14:07:22.649
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -614,9 +614,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c 15a2845769f51ba132f9cf0b2c7a6887a91fc8437892dbcce9fcdc68b66d60a1
 F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
 F src/walker.c a137468bf36c92e64d2275caa80c83902e3a0fc59273591b96c6416d3253d05d
-F src/where.c d1d79673b64278bbdefe790c70cb01ee607f79c48163febdf8dee86f6a7e715e
+F src/where.c 97f19d664256aaf86e4aac1323992c6fda5deb44ed35320539fdb3faa31307b1
 F src/whereInt.h de1b77e416ad5a7cc60a71fc1317484f8d83ca1e52b805dc8c978785a92eeded
-F src/wherecode.c d42d3e0fe93786621b84dec8065e1dc6b324d7c5934df52f141555843b6aef4e
+F src/wherecode.c d074abccfbd4ef2becc34aea640d326ff76709c5867c2b049c719a4ce5b74c06
 F src/whereexpr.c 4b34be1434183e7bb8a05d4bf42bd53ea53021b0b060936fbd12062b4ff6b396
 F src/window.c 87795bb8293179cb8a92529264d49bd66b5bcad5e91cfc17dd8d3e66a2a77f88
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
@@ -1853,7 +1853,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 52ea0672d7494346c636cd7b05ca42161eb3b07d9378fa9959be9a11de87dbbb
-R 36aa1965ca07c18187e2cc17b34e3feb
+P 85e76887761b5d7e290fb2bac7f9121648f79d67fdd92f624d81632f28620518
+R 1054236a3bfbc2d93687a4e1f244d884
 U drh
-Z 9b3b04de4e9f091e2c9e4bbb9028222c
+Z 90307d93afa9b9f29e276d59812ee8ca
index e9516becb7208b4e442e324f18a77abc2c7a09d3..b66df9977f228bc22e4d9e4931da796dac040a71 100644 (file)
@@ -1 +1 @@
-85e76887761b5d7e290fb2bac7f9121648f79d67fdd92f624d81632f28620518
\ No newline at end of file
+59cc46e5a6d8dbb030f27716ad5446ecccf81cf0cfff95338b9133777f2059e7
\ No newline at end of file
index 87d8a5d09ce4a1bdd645e22125376db56bdbe4d3..ebd33ba86fbbb8c2e02f8fb7b5dae85bf46ce311 100644 (file)
@@ -1735,12 +1735,13 @@ void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){
   if( pTerm==0 ){
     sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
   }else{
-    char zType[4];
+    char zType[8];
     char zLeft[50];
-    memcpy(zType, "...", 4);
+    memcpy(zType, "....", 5);
     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->wtFlags & TERM_CODED  ) zType[3] = 'C';
     if( pTerm->eOperator & WO_SINGLE ){
       sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
                        pTerm->leftCursor, pTerm->u.leftColumn);
@@ -1751,12 +1752,13 @@ void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){
       sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
     }
     sqlite3DebugPrintf(
-       "TERM-%-3d %p %s %-12s prob=%-3d op=%03x wtFlags=%04x",
-       iTerm, pTerm, zType, zLeft, pTerm->truthProb,
-       pTerm->eOperator, pTerm->wtFlags);
+       "TERM-%-3d %p %s %-12s op=%03x wtFlags=%04x",
+       iTerm, pTerm, zType, zLeft, pTerm->eOperator, pTerm->wtFlags);
+    /* The 0x10000 .wheretrace flag causes extra information to be
+    ** shown about each Term */
     if( sqlite3WhereTrace & 0x10000 ){
-      sqlite3DebugPrintf(" prereq=%llx,%llx",
-        (u64)pTerm->prereqAll, (u64)pTerm->prereqRight);
+      sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx",
+        pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight);
     }
     if( pTerm->iField ){
       sqlite3DebugPrintf(" iField=%d", pTerm->iField);
index a24dea82eeda3f3ce9a737c0854527980690fe4a..8495de3781f866496d518113eeff66039670cc65 100644 (file)
@@ -1284,6 +1284,17 @@ Bitmask sqlite3WhereCodeOneLoopStart(
   pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
   bRev = (pWInfo->revMask>>iLevel)&1;
   VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
+#if WHERETRACE_ENABLED /* 0x20800 */
+  if( sqlite3WhereTrace & 0x800 ){
+    sqlite3DebugPrintf("Coding level %d:  notReady=%llx\n",
+       iLevel, (u64)notReady);
+    sqlite3WhereLoopPrint(pLoop, pWC);
+  }
+  if( sqlite3WhereTrace & 0x20000 ){
+    sqlite3DebugPrintf("Complete WHERE clause before coding:\n");
+    sqlite3WhereClausePrint(pWC);
+  }
+#endif
 
   /* Create labels for the "break" and "continue" instructions
   ** for the current loop.  Jump to addrBrk to break out of a loop.
@@ -2339,6 +2350,10 @@ Bitmask sqlite3WhereCodeOneLoopStart(
         VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
                          pWC->nTerm-j, pTerm, iLoop));
       }
+      if( sqlite3WhereTrace & 0x800 ){
+        sqlite3DebugPrintf("Coding auxiliary constraint:\n");
+        sqlite3WhereTermPrint(pTerm, pWC->nTerm-j);
+      }
 #endif
       sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
       if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
@@ -2365,6 +2380,12 @@ Bitmask sqlite3WhereCodeOneLoopStart(
     if( pLevel->iLeftJoin ) continue;
     pE = pTerm->pExpr;
     assert( !ExprHasProperty(pE, EP_FromJoin) );
+#ifdef WHERETRACE_ENABLED /* 0x800 */
+    if( sqlite3WhereTrace & 0x800 ){
+      sqlite3DebugPrintf("Coding transitive constraint:\n");
+      sqlite3WhereTermPrint(pTerm, pWC->nTerm-j);
+    }
+#endif
     assert( (pTerm->prereqRight & pLevel->notReady)!=0 );
     pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,
                     WO_EQ|WO_IN|WO_IS, 0);
@@ -2406,5 +2427,15 @@ Bitmask sqlite3WhereCodeOneLoopStart(
     }
   }
 
+#if WHERETRACE_ENABLED /* 0x20800 */
+  if( sqlite3WhereTrace & 0x20000 ){
+    sqlite3DebugPrintf("Complete WHERE clause after coding level %d:\n",iLevel);
+    sqlite3WhereClausePrint(pWC);
+  }
+  if( sqlite3WhereTrace & 0x800 ){
+    sqlite3DebugPrintf("End Coding level %d:  notReady=%llx\n",
+       iLevel, (u64)pLevel->notReady);
+  }
+#endif
   return pLevel->notReady;
 }