/ Check-in [a9a30726]
Login

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

Overview
Comment:New VDBE comments and coverage macros.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a9a307265b0626b3e9df69534c8eacf18413ea31784c9d931eadcff515d3dd84
User & Date: drh 2018-07-10 05:11:03
Context
2018-07-10
06:32
Enhance the TreeView mechanism so that it shows the window function data structures as part of the abstract syntax tree. check-in: a2c0e1be user: drh tags: trunk
05:11
New VDBE comments and coverage macros. check-in: a9a30726 user: drh tags: trunk
2018-07-09
22:49
Fixes for various harmless compiler warnings. check-in: 5023b1b8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  5936   5936         int iBreak = sqlite3VdbeMakeLabel(v);
  5937   5937         int regGosub = ++pParse->nMem;
  5938   5938   
  5939   5939         sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
  5940   5940   
  5941   5941         sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
  5942   5942         sqlite3VdbeResolveLabel(v, addrGosub);
         5943  +      VdbeNoopComment((v, "SELECT inner-loop subroutine"));
  5943   5944         selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);
  5944   5945         sqlite3VdbeResolveLabel(v, iCont);
  5945   5946         sqlite3VdbeAddOp1(v, OP_Return, regGosub);
         5947  +      VdbeComment((v, "end inner-loop subroutine"));
  5946   5948         sqlite3VdbeResolveLabel(v, iBreak);
  5947   5949       }else
  5948   5950   #endif /* SQLITE_OMIT_WINDOWFUNC */
  5949   5951       {
  5950   5952         /* Use the standard inner loop. */
  5951   5953         selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,
  5952   5954             sqlite3WhereContinueLabel(pWInfo),

Changes to src/window.c.

  1030   1030     };
  1031   1031     static int aOp[] = { OP_Ge, OP_Ge, OP_Gt };
  1032   1032     Vdbe *v = sqlite3GetVdbe(pParse);
  1033   1033     int regZero = sqlite3GetTempReg(pParse);
  1034   1034     assert( eCond==0 || eCond==1 || eCond==2 );
  1035   1035     sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);
  1036   1036     sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
  1037         -  VdbeCoverage(v);
         1037  +  VdbeCoverageIf(v, eCond==0);
         1038  +  VdbeCoverageIf(v, eCond==1);
         1039  +  VdbeCoverageIf(v, eCond==2);
  1038   1040     sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);
  1039         -  VdbeCoverage(v);
         1041  +  VdbeCoverageIf(v, eCond==0);
         1042  +  VdbeCoverageIf(v, eCond==1);
         1043  +  VdbeCoverageIf(v, eCond==2);
  1040   1044     sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
  1041   1045     sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
  1042   1046     sqlite3ReleaseTempReg(pParse, regZero);
  1043   1047   }
  1044   1048   
  1045   1049   /*
  1046   1050   ** Return the number of arguments passed to the window-function associated
................................................................................
  1246   1250   
  1247   1251       addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
  1248   1252       sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
  1249   1253       sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
  1250   1254       VdbeCoverage(v);
  1251   1255       sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
  1252   1256       sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
         1257  +    VdbeComment((v, "call flush_partition"));
  1253   1258     }
  1254   1259   
  1255   1260     /* Buffer the current row in the ephemeral table. */
  1256   1261     sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
  1257   1262     sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
  1258   1263   
  1259   1264     /* End of the input loop */
  1260   1265     sqlite3WhereEnd(pWInfo);
  1261   1266   
  1262   1267     /* Invoke "flush_partition" to deal with the final (or only) partition */
  1263   1268     sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
         1269  +  VdbeComment((v, "call flush_partition"));
  1264   1270   }
  1265   1271   
  1266   1272   /*
  1267   1273   ** Invoke the sub-routine at regGosub (generated by code in select.c) to
  1268   1274   ** return the current row of Window.iEphCsr. If all window functions are
  1269   1275   ** aggregate window functions that use the standard API, a single
  1270   1276   ** OP_Gosub instruction is all that this routine generates. Extra VM code
................................................................................
  1584   1590   
  1585   1591     addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
  1586   1592   
  1587   1593     /* Start of "flush_partition" */
  1588   1594     sqlite3VdbeResolveLabel(v, lblFlushPart);
  1589   1595     sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
  1590   1596     VdbeCoverage(v);
         1597  +  VdbeComment((v, "Flush_partition subroutine"));
  1591   1598     sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
  1592   1599     sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);
  1593   1600   
  1594   1601     /* If either regStart or regEnd are not non-negative integers, throw 
  1595   1602     ** an exception.  */
  1596   1603     if( pMWin->pStart ){
  1597   1604       sqlite3ExprCode(pParse, pMWin->pStart, regStart);
................................................................................
  1705   1712     }
  1706   1713     sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
  1707   1714   
  1708   1715     /* flush_partition_done: */
  1709   1716     sqlite3VdbeResolveLabel(v, lblFlushDone);
  1710   1717     sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
  1711   1718     sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
         1719  +  VdbeComment((v, "end flush_partition subroutine"));
  1712   1720   
  1713   1721     /* Jump to here to skip over flush_partition */
  1714   1722     sqlite3VdbeJumpHere(v, addrGoto);
  1715   1723   }
  1716   1724   
  1717   1725   /*
  1718   1726   ** This function does the work of sqlite3WindowCodeStep() for cases that