/ Check-in [129217ee]
Login

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

Overview
Comment:Tweaks to the generated VDBE code to make it a little easier to follow.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 129217ee91782ec77ff82661753ae5bee8ca99d0
User & Date: drh 2014-02-08 13:12:19
Context
2014-02-08
13:24
Fix a harmless compiler warning in VS2013. check-in: 83116ee3 user: drh tags: trunk
13:12
Tweaks to the generated VDBE code to make it a little easier to follow. check-in: 129217ee user: drh tags: trunk
04:24
Enable constant expression factoring even if no tables are read and no transaction is started. check-in: a45b8771 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  4533   4533         i = -1;
  4534   4534       }else if( pTabList->nSrc==1
  4535   4535              && OptimizationEnabled(db, SQLITE_SubqCoroutine)
  4536   4536       ){
  4537   4537         /* Implement a co-routine that will return a single row of the result
  4538   4538         ** set on each invocation.
  4539   4539         */
  4540         -      int addrTop;
         4540  +      int addrTop = sqlite3VdbeCurrentAddr(v)+1;
  4541   4541         pItem->regReturn = ++pParse->nMem;
  4542         -      sqlite3VdbeAddOp0(v, OP_Goto);
  4543         -      addrTop = sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor);
         4542  +      sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);
         4543  +      VdbeComment((v, "%s", pItem->pTab->zName));
         4544  +      sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor);
  4544   4545         sqlite3VdbeChangeP5(v, 1);
  4545         -      VdbeComment((v, "coroutine %s", pItem->pTab->zName));
  4546   4546         pItem->addrFillSub = addrTop;
  4547   4547         sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
  4548   4548         explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
  4549   4549         sqlite3Select(pParse, pSub, &dest);
  4550   4550         pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;
  4551   4551         pItem->viaCoroutine = 1;
  4552   4552         sqlite3VdbeChangeP2(v, addrTop, dest.iSdst);
................................................................................
  4563   4563         int topAddr;
  4564   4564         int onceAddr = 0;
  4565   4565         int retAddr;
  4566   4566         assert( pItem->addrFillSub==0 );
  4567   4567         pItem->regReturn = ++pParse->nMem;
  4568   4568         topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);
  4569   4569         pItem->addrFillSub = topAddr+1;
  4570         -      VdbeNoopComment((v, "materialize %s", pItem->pTab->zName));
  4571   4570         if( pItem->isCorrelated==0 ){
  4572   4571           /* If the subquery is not correlated and if we are not inside of
  4573   4572           ** a trigger, then we only need to compute the value of the subquery
  4574   4573           ** once. */
  4575   4574           onceAddr = sqlite3CodeOnce(pParse);
         4575  +        VdbeComment((v, "materialize \"%s\"", pItem->pTab->zName));
         4576  +      }else{
         4577  +        VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName));
  4576   4578         }
  4577   4579         sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
  4578   4580         explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
  4579   4581         sqlite3Select(pParse, pSub, &dest);
  4580   4582         pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;
  4581   4583         if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);
  4582   4584         retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);

Changes to src/where.c.

  2783   2783     }
  2784   2784   
  2785   2785     /* Special case of a FROM clause subquery implemented as a co-routine */
  2786   2786     if( pTabItem->viaCoroutine ){
  2787   2787       int regYield = pTabItem->regReturn;
  2788   2788       sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
  2789   2789       pLevel->p2 =  sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);
  2790         -    VdbeComment((v, "next row of co-routine %s", pTabItem->pTab->zName));
         2790  +    VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName));
  2791   2791       pLevel->op = OP_Goto;
  2792   2792     }else
  2793   2793   
  2794   2794   #ifndef SQLITE_OMIT_VIRTUALTABLE
  2795   2795     if(  (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
  2796   2796       /* Case 1:  The table is a virtual-table.  Use the VFilter and VNext
  2797   2797       **          to access the data.