/ Check-in [e6c59d23]
Login

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

Overview
Comment:Remove a pointless OP_Once operation in ORDER BY clauses with LIMIT.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | orderby-planning
Files: files | file ages | folders
SHA1: e6c59d23316c83b318b1a94d9b28a5d321737fa5
User & Date: drh 2014-03-24 02:20:53
Context
2014-03-24
09:34
Remove an unnecessary temporary register allocation. check-in: 5d506743 user: dan tags: orderby-planning
02:20
Remove a pointless OP_Once operation in ORDER BY clauses with LIMIT. check-in: e6c59d23 user: drh tags: orderby-planning
01:43
Further enhancements to generated VDBE code for ORDER BY. check-in: e7188fad user: drh tags: orderby-planning
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

  1140   1140     struct ExprList_item *aOutEx = p->pEList->a;
  1141   1141   #endif
  1142   1142   
  1143   1143     if( pSort->labelBkOut ){
  1144   1144       sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
  1145   1145       sqlite3VdbeAddOp2(v, OP_Goto, 0, addrBreak);
  1146   1146       sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
  1147         -    addrOnce = sqlite3CodeOnce(pParse); VdbeCoverage(v);
  1148   1147     }
  1149   1148     iTab = pSort->iECursor;
  1150   1149     regRow = sqlite3GetTempReg(pParse);
  1151   1150     if( eDest==SRT_Output || eDest==SRT_Coroutine ){
  1152   1151       regRowid = 0;
  1153   1152       regRow = pDest->iSdst;
  1154   1153       nSortData = nColumn;
................................................................................
  1157   1156       regRow = sqlite3GetTempReg(pParse);
  1158   1157       nSortData = 1;
  1159   1158     }
  1160   1159     nKey = pOrderBy->nExpr - pSort->nOBSat;
  1161   1160     if( pSort->sortFlags & SORTFLAG_UseSorter ){
  1162   1161       int regSortOut = ++pParse->nMem;
  1163   1162       iSortTab = pParse->nTab++;
         1163  +    if( pSort->labelBkOut ){
         1164  +      addrOnce = sqlite3CodeOnce(pParse); VdbeCoverage(v);
         1165  +    }
  1164   1166       sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nSortData);
  1165   1167       if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
  1166   1168       addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
  1167   1169       VdbeCoverage(v);
  1168   1170       codeOffset(v, p->iOffset, addrContinue);
  1169   1171       sqlite3VdbeAddOp2(v, OP_SorterData, iTab, regSortOut);
  1170   1172       p5 = OPFLAG_CLEARCACHE;
  1171   1173     }else{
  1172         -    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
  1173   1174       addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);
  1174   1175       codeOffset(v, p->iOffset, addrContinue);
  1175         -    sqlite3VdbeAddOp3(v, OP_Column, iTab, nKey+1, regRow);
  1176   1176       iSortTab = iTab;
  1177   1177       p5 = 0;
  1178   1178     }
  1179   1179     for(i=0; i<nSortData; i++){
  1180   1180       sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+1+i, regRow+i);
  1181   1181       if( i==0 ) sqlite3VdbeChangeP5(v, p5);
  1182   1182       VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));