if( p->iOffset>=0 ){ sqliteVdbeAddOp(v, OP_MemIncr, p->iOffset, addr+4); sqliteVdbeAddOp(v, OP_Pop, 1, 0); sqliteVdbeAddOp(v, OP_Goto, 0, addr); } if( p->iLimit>=0 ){ sqliteVdbeAddOp(v, OP_MemIncr, p->iLimit, end2); }
codeLimiter(v, p, addr, end2, 1);
static void generateSortTail(  Select *p,       /* The SELECT statement */  Vdbe *v,         /* Generate code into this VDBE */  int nColumn,     /* Number of columns of data */  int eDest,       /* Write the sorted results here */  int iParm        /* Optional parameter associated with eDest */){  int end1 = sqliteVdbeMakeLabel(v);  int end2 = sqliteVdbeMakeLabel(v);  int addr;  if( eDest==SRT_Sorter ) return;  sqliteVdbeAddOp(v, OP_Sort, 0, 0);  addr = sqliteVdbeAddOp(v, OP_SortNext, 0, end1);  if( p->iOffset>=0 ){    sqliteVdbeAddOp(v, OP_MemIncr, p->iOffset, addr+4);    sqliteVdbeAddOp(v, OP_Pop, 1, 0);    sqliteVdbeAddOp(v, OP_Goto, 0, addr);  }  if( p->iLimit>=0 ){    sqliteVdbeAddOp(v, OP_MemIncr, p->iLimit, end2);  }  switch( eDest ){    case SRT_Callback: {      sqliteVdbeAddOp(v, OP_SortCallback, nColumn, 0);      break;    }    case SRT_Table:    case SRT_TempTable: {      sqliteVdbeAddOp(v, OP_NewRecno, iParm, 0);      sqliteVdbeAddOp(v, OP_Pull, 1, 0);      sqliteVdbeAddOp(v, OP_PutIntKey, iParm, 0);      break;    }    case SRT_Set: {      assert( nColumn==1 );      sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3);      sqliteVdbeAddOp(v, OP_Pop, 1, 0);      sqliteVdbeAddOp(v, OP_Goto, 0, sqliteVdbeCurrentAddr(v)+3);      sqliteVdbeAddOp(v, OP_String, 0, 0);      sqliteVdbeAddOp(v, OP_PutStrKey, iParm, 0);      break;    }    case SRT_Mem: {      assert( nColumn==1 );      sqliteVdbeAddOp(v, OP_MemStore, iParm, 1);      sqliteVdbeAddOp(v, OP_Goto, 0, end1);      break;    }    case SRT_Subroutine: {      int i;      for(i=0; i<nColumn; i++){        sqliteVdbeAddOp(v, OP_Column, -1-i, i);      }      sqliteVdbeAddOp(v, OP_Gosub, 0, iParm);      sqliteVdbeAddOp(v, OP_Pop, 1, 0);      break;    }    default: {      /* Do nothing */      break;    }  }  sqliteVdbeAddOp(v, OP_Goto, 0, addr);  sqliteVdbeResolveLabel(v, end2);  sqliteVdbeAddOp(v, OP_Pop, 1, 0);  sqliteVdbeResolveLabel(v, end1);  sqliteVdbeAddOp(v, OP_SortReset, 0, 0);}