/ Check-in [fd598e475d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In the ".wheretrace 0x100" debugging mode, show the structure of the main parameters to sqlite3WhereBegin() calls.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fd598e475d353363e19adc27a671170f11ae9f6d8cad58cb2303fb2ad8ac6bec
User & Date: drh 2019-08-03 16:17:46
Context
2019-08-03
16:37
Fix a problem with queries of the form "SELECT min(<expr>) ... WHERE <expr>=?" where there is an index on <expr>. Fix for [71e183ca]. check-in: d465c3eef4 user: dan tags: trunk
16:17
In the ".wheretrace 0x100" debugging mode, show the structure of the main parameters to sqlite3WhereBegin() calls. check-in: fd598e475d user: drh tags: trunk
01:40
Add the SQLITE_TESTCTRL_PRNG_SEED which can control the PRNG seed either directly or through the schema cookie of a supplied database connection. check-in: 2660e9292a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

  2900   2900   #define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */
  2901   2901   #define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */
  2902   2902   #define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */
  2903   2903   #define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */
  2904   2904   #define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */
  2905   2905   #define SF_IncludeHidden  0x20000  /* Include hidden columns in output */
  2906   2906   #define SF_ComplexResult  0x40000  /* Result contains subquery or function */
         2907  +#define SF_WhereBegin     0x80000  /* Really a WhereBegin() call.  Debug Only */
  2907   2908   
  2908   2909   /*
  2909   2910   ** The results of a SELECT can be distributed in several ways, as defined
  2910   2911   ** by one of the following macros.  The "SRT" prefix means "SELECT Result
  2911   2912   ** Type".
  2912   2913   **
  2913   2914   **     SRT_Union       Store results as a key in a temporary index

Changes to src/treeview.c.

   172    172     pView = sqlite3TreeViewPush(pView, moreToFollow);
   173    173     if( p->pWith ){
   174    174       sqlite3TreeViewWith(pView, p->pWith, 1);
   175    175       cnt = 1;
   176    176       sqlite3TreeViewPush(pView, 1);
   177    177     }
   178    178     do{
   179         -    sqlite3TreeViewLine(pView,
   180         -      "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
   181         -      ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
   182         -      ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
   183         -      p->selId, p, p->selFlags,
   184         -      (int)p->nSelectRow
   185         -    );
          179  +    if( p->selFlags & SF_WhereBegin ){
          180  +      sqlite3TreeViewLine(pView, "sqlite3WhereBegin()");
          181  +    }else{
          182  +      sqlite3TreeViewLine(pView,
          183  +        "SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d",
          184  +        ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
          185  +        ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
          186  +        p->selId, p, p->selFlags,
          187  +        (int)p->nSelectRow
          188  +      );
          189  +    }
   186    190       if( cnt++ ) sqlite3TreeViewPop(pView);
   187    191       if( p->pPrior ){
   188    192         n = 1000;
   189    193       }else{
   190    194         n = 0;
   191    195         if( p->pSrc && p->pSrc->nSrc ) n++;
   192    196         if( p->pWhere ) n++;
................................................................................
   195    199         if( p->pOrderBy ) n++;
   196    200         if( p->pLimit ) n++;
   197    201   #ifndef SQLITE_OMIT_WINDOWFUNC
   198    202         if( p->pWin ) n++;
   199    203         if( p->pWinDefn ) n++;
   200    204   #endif
   201    205       }
   202         -    sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set");
          206  +    if( p->pEList ){
          207  +      sqlite3TreeViewExprList(pView, p->pEList, n>0, "result-set");
          208  +    }
          209  +    n--;
   203    210   #ifndef SQLITE_OMIT_WINDOWFUNC
   204    211       if( p->pWin ){
   205    212         Window *pX;
   206    213         pView = sqlite3TreeViewPush(pView, (n--)>0);
   207    214         sqlite3TreeViewLine(pView, "window-functions");
   208    215         for(pX=p->pWin; pX; pX=pX->pNextWin){
   209    216           sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0);

Changes to src/where.c.

  4765   4765   #if defined(WHERETRACE_ENABLED)
  4766   4766     if( sqlite3WhereTrace & 0xffff ){
  4767   4767       sqlite3DebugPrintf("*** Optimizer Start *** (wctrlFlags: 0x%x",wctrlFlags);
  4768   4768       if( wctrlFlags & WHERE_USE_LIMIT ){
  4769   4769         sqlite3DebugPrintf(", limit: %d", iAuxArg);
  4770   4770       }
  4771   4771       sqlite3DebugPrintf(")\n");
         4772  +    if( sqlite3WhereTrace & 0x100 ){
         4773  +      Select sSelect;
         4774  +      memset(&sSelect, 0, sizeof(sSelect));
         4775  +      sSelect.selFlags = SF_WhereBegin;
         4776  +      sSelect.pSrc = pTabList;
         4777  +      sSelect.pWhere = pWhere;
         4778  +      sSelect.pOrderBy = pOrderBy;
         4779  +      sSelect.pEList = pResultSet;
         4780  +      sqlite3TreeViewSelect(0, &sSelect, 0);
         4781  +    }
  4772   4782     }
  4773   4783     if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
  4774   4784       sqlite3WhereClausePrint(sWLB.pWC);
  4775   4785     }
  4776   4786   #endif
  4777   4787   
  4778   4788     if( nTabList!=1 || whereShortCut(&sWLB)==0 ){