/ Check-in [f2f52554]
Login

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

Overview
Comment:Improved EQP output for recursive CTEs and multi-value VALUES clauses.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rework-EQP
Files: files | file ages | folders
SHA3-256: f2f525548c65f89f55cbe91da8a21512dedc6f7b68b58b7906d653e800a2963a
User & Date: drh 2018-05-02 16:13:48
Context
2018-05-02
18:00
Fix test cases so that they work with the new EXPLAIN QUERY PLAN output format. Only some of the cases have been fixed. This is an incremental check-in. check-in: 5f0e803e user: drh tags: rework-EQP
16:13
Improved EQP output for recursive CTEs and multi-value VALUES clauses. check-in: f2f52554 user: drh tags: rework-EQP
14:24
Fix a dangling-else problem that was causing recursive CTEs to malfunction. Begin fixing test cases to work with the new EQP output. check-in: 82ca44b8 user: drh tags: rework-EQP
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  2286   2286     }
  2287   2287   
  2288   2288     /* Detach the ORDER BY clause from the compound SELECT */
  2289   2289     p->pOrderBy = 0;
  2290   2290   
  2291   2291     /* Store the results of the setup-query in Queue. */
  2292   2292     pSetup->pNext = 0;
         2293  +  ExplainQueryPlan((pParse, 1, "SETUP"));
         2294  +  ExplainQueryPlanSetId(pParse, pSetup);
  2293   2295     rc = sqlite3Select(pParse, pSetup, &destQueue);
  2294   2296     pSetup->pNext = p;
  2295   2297     if( rc ) goto end_of_recursive_query;
  2296   2298   
  2297   2299     /* Find the next row in the Queue and output that row */
  2298   2300     addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak); VdbeCoverage(v);
  2299   2301   
................................................................................
  2320   2322     /* Execute the recursive SELECT taking the single row in Current as
  2321   2323     ** the value for the recursive-table. Store the results in the Queue.
  2322   2324     */
  2323   2325     if( p->selFlags & SF_Aggregate ){
  2324   2326       sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
  2325   2327     }else{
  2326   2328       p->pPrior = 0;
         2329  +    ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
         2330  +    ExplainQueryPlanSetId(pParse, p);
  2327   2331       sqlite3Select(pParse, p, &destQueue);
  2328   2332       assert( p->pPrior==0 );
  2329   2333       p->pPrior = pSetup;
  2330   2334     }
  2331   2335   
  2332   2336     /* Keep running the loop until the Queue is empty */
  2333   2337     sqlite3VdbeGoto(v, addrTop);
................................................................................
  2379   2383       assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
  2380   2384       assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );
  2381   2385       if( p->pPrior==0 ) break;
  2382   2386       assert( p->pPrior->pNext==p );
  2383   2387       p = p->pPrior;
  2384   2388       nRow++;
  2385   2389     }while(1);
         2390  +  ExplainQueryPlan((pParse, 0, "SCAN %d CONSTANT ROWS", nRow));
  2386   2391     while( p ){
  2387   2392       pPrior = p->pPrior;
  2388   2393       p->pPrior = 0;
  2389   2394       rc = sqlite3Select(pParse, p, pDest);
  2390   2395       p->pPrior = pPrior;
  2391   2396       if( rc || pRightmost->pLimit ) break;
  2392   2397       p->nSelectRow = nRow;

Changes to src/where.c.

  4588   4588     /* Special case: No FROM clause
  4589   4589     */
  4590   4590     if( nTabList==0 ){
  4591   4591       if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
  4592   4592       if( wctrlFlags & WHERE_WANT_DISTINCT ){
  4593   4593         pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
  4594   4594       }
         4595  +    ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
  4595   4596     }else{
  4596   4597       /* Assign a bit from the bitmask to every term in the FROM clause.
  4597   4598       **
  4598   4599       ** The N-th term of the FROM clause is assigned a bitmask of 1<<N.
  4599   4600       **
  4600   4601       ** The rule of the previous sentence ensures thta if X is the bitmask for
  4601   4602       ** a table T, then X-1 is the bitmask for all other tables to the left of T.