/ Check-in [657c9fb5]
Login

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

Overview
Comment:When constructing records and index keys, use static string space rather than mallocing (when possible) for a small speed improvement. (CVS 817)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:657c9fb5133aef93e4edd433912e6942ad9674ec
User & Date: drh 2003-01-07 13:43:46
Context
2003-01-07
13:55
In the VDBE, allocate space to hold column names when the VDBE first starts. The ColumnCount opcode now just writes the null terminator into this space. (CVS 818) check-in: 46d8f5e3 user: drh tags: trunk
13:43
When constructing records and index keys, use static string space rather than mallocing (when possible) for a small speed improvement. (CVS 817) check-in: 657c9fb5 user: drh tags: trunk
02:47
More optimizations. (CVS 816) check-in: a362981b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    32     32   **
    33     33   ** Various scripts scan this source file in order to generate HTML
    34     34   ** documentation, headers files, or other derived files.  The formatting
    35     35   ** of the code in this file is, therefore, important.  See other comments
    36     36   ** in this file for details.  If in doubt, do not deviate from existing
    37     37   ** commenting and indentation practices when changing or adding code.
    38     38   **
    39         -** $Id: vdbe.c,v 1.192 2003/01/07 02:47:48 drh Exp $
           39  +** $Id: vdbe.c,v 1.193 2003/01/07 13:43:46 drh Exp $
    40     40   */
    41     41   #include "sqliteInt.h"
    42     42   #include <ctype.h>
    43     43   
    44     44   /*
    45     45   ** The makefile scans this source file and creates the following
    46     46   ** array of string constants which are the names of all VDBE opcodes.
................................................................................
   772    772       pElem = sqliteHashFirst(&p->hash);
   773    773     }
   774    774     return pElem ? sqliteHashData(pElem) : 0;
   775    775   }
   776    776   
   777    777   /*
   778    778   ** Convert the given stack entity into a string if it isn't one
   779         -** already.  Return non-zero if we run out of memory.
   780         -**
   781         -** NULLs are converted into an empty string.
          779  +** already.
   782    780   */
   783         -#define Stringify(P,I) ((aStack[I].flags & STK_Str)==0 ? hardStringify(P,I) : 0)
          781  +#define Stringify(P,I) if((aStack[I].flags & STK_Str)==0){hardStringify(P,I);}
   784    782   static int hardStringify(Vdbe *p, int i){
   785    783     Stack *pStack = &p->aStack[i];
   786         -  char **pzStack = &p->zStack[i];
   787    784     int fg = pStack->flags;
   788    785     if( fg & STK_Real ){
   789    786       sprintf(pStack->z,"%.15g",pStack->r);
   790    787     }else if( fg & STK_Int ){
   791    788       sprintf(pStack->z,"%d",pStack->i);
   792    789     }else{
   793    790       pStack->z[0] = 0;
   794    791     }
   795         -  *pzStack = pStack->z;
   796         -  pStack->n = strlen(*pzStack)+1;
          792  +  p->zStack[i] = pStack->z;
          793  +  pStack->n = strlen(pStack->z)+1;
   797    794     pStack->flags = STK_Str;
   798    795     return 0;
   799    796   }
          797  +
          798  +/*
          799  +** Convert the given stack entity into a string that has been obtained
          800  +** from sqliteMalloc().  This is different from Stringify() above in that
          801  +** Stringify() will use the NBFS bytes of static string space if the string
          802  +** will fit but this routine always mallocs for space.
          803  +** Return non-zero if we run out of memory.
          804  +*/
          805  +#define Dynamicify(P,I) ((aStack[I].flags & STK_Dyn)==0 ? hardDynamicify(P,I):0)
          806  +static int hardDynamicify(Vdbe *p, int i){
          807  +  Stack *pStack = &p->aStack[i];
          808  +  int fg = pStack->flags;
          809  +  char *z;
          810  +  if( (fg & STK_Str)==0 ){
          811  +    hardStringify(p, i);
          812  +  }
          813  +  assert( (fg & STK_Dyn)==0 );
          814  +  z = sqliteMallocRaw( pStack->n );
          815  +  if( z==0 ) return 1;
          816  +  memcpy(z, p->zStack[i], pStack->n);
          817  +  p->zStack[i] = z;
          818  +  pStack->flags |= STK_Dyn;
          819  +  return 0;
          820  +}
   800    821   
   801    822   /*
   802    823   ** An ephemeral string value (signified by the STK_Ephem flag) contains
   803    824   ** a pointer to a dynamically allocated string where some other entity
   804    825   ** is responsible for deallocating that string.  Because the stack entry
   805    826   ** does not control the string, it might be deleted without the stack
   806    827   ** entry knowing it.
................................................................................
  1736   1757     int i = p->tos - pOp->p1 + 1;
  1737   1758     int j;
  1738   1759     VERIFY( if( i<0 ) goto not_enough_stack; )
  1739   1760     for(j=i; j<=p->tos; j++){
  1740   1761       if( aStack[j].flags & STK_Null ){
  1741   1762         zStack[j] = 0;
  1742   1763       }else{
  1743         -      if( Stringify(p, j) ) goto no_mem;
         1764  +      Stringify(p, j);
  1744   1765       }
  1745   1766     }
  1746   1767     zStack[p->tos+1] = 0;
  1747   1768     if( xCallback!=0 ){
  1748   1769       if( sqliteSafetyOff(db) ) goto abort_due_to_misuse; 
  1749   1770       if( xCallback(pArg, pOp->p1, &zStack[i], p->azColName)!=0 ){
  1750   1771         rc = SQLITE_ABORT;
................................................................................
  1813   1834     VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
  1814   1835     nByte = 1 - nSep;
  1815   1836     for(i=p->tos-nField+1; i<=p->tos; i++){
  1816   1837       if( aStack[i].flags & STK_Null ){
  1817   1838         nByte = -1;
  1818   1839         break;
  1819   1840       }else{
  1820         -      if( Stringify(p, i) ) goto no_mem;
         1841  +      Stringify(p, i);
  1821   1842         nByte += aStack[i].n - 1 + nSep;
  1822   1843       }
  1823   1844     }
  1824   1845     if( nByte<0 ){
  1825   1846       if( pOp->p2==0 ) PopStack(p, nField);
  1826   1847       p->tos++;
  1827   1848       aStack[p->tos].flags = STK_Null;
................................................................................
  1983   2004     n = pOp->p1;
  1984   2005     VERIFY( if( n<0 ) goto bad_instruction; )
  1985   2006     VERIFY( if( p->tos+1<n ) goto not_enough_stack; )
  1986   2007     for(i=p->tos-n+1; i<=p->tos; i++){
  1987   2008       if( aStack[i].flags & STK_Null ){
  1988   2009         zStack[i] = 0;
  1989   2010       }else{
  1990         -      if( Stringify(p, i) ) goto no_mem;
         2011  +      Stringify(p, i);
  1991   2012       }
  1992   2013     }
  1993   2014     ctx.pFunc = (FuncDef*)pOp->p3;
  1994   2015     ctx.s.flags = STK_Null;
  1995   2016     ctx.z = 0;
  1996   2017     ctx.isError = 0;
  1997   2018     ctx.isStep = 0;
................................................................................
  2279   2300       c = aStack[nos].i - aStack[tos].i;
  2280   2301     }else if( (fn & STK_Int)!=0 && (ft & STK_Str)!=0 && toInt(zStack[tos],&v) ){
  2281   2302       Release(p, tos);
  2282   2303       aStack[tos].i = v;
  2283   2304       aStack[tos].flags = STK_Int;
  2284   2305       c = aStack[nos].i - aStack[tos].i;
  2285   2306     }else{
  2286         -    if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
         2307  +    Stringify(p, tos);
         2308  +    Stringify(p, nos);
  2287   2309       c = sqliteCompare(zStack[nos], zStack[tos]);
  2288   2310     }
  2289   2311     switch( pOp->opcode ){
  2290   2312       case OP_Eq:    c = c==0;     break;
  2291   2313       case OP_Ne:    c = c!=0;     break;
  2292   2314       case OP_Lt:    c = c<0;      break;
  2293   2315       case OP_Le:    c = c<=0;     break;
................................................................................
  2429   2451         if( pOp->p1 ) pc = pOp->p2-1;
  2430   2452       }else{
  2431   2453         p->tos++;
  2432   2454         aStack[nos].flags = STK_Null;
  2433   2455       }
  2434   2456       break;
  2435   2457     }else{
  2436         -    if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
         2458  +    Stringify(p, tos);
         2459  +    Stringify(p, nos);
  2437   2460       c = strcmp(zStack[nos], zStack[tos]);
  2438   2461     }
  2439   2462     /* The asserts on each case of the following switch are there to verify
  2440   2463     ** that string comparison opcodes are always exactly 6 greater than the
  2441   2464     ** corresponding numeric comparison opcodes.  The code generator depends
  2442   2465     ** on this fact.
  2443   2466     */
................................................................................
  2690   2713     int nByte;
  2691   2714     int nField;
  2692   2715     int i, j;
  2693   2716     int idxWidth;
  2694   2717     u32 addr;
  2695   2718     int addUnique = 0;   /* True to cause bytes to be added to make the
  2696   2719                          ** generated record distinct */
         2720  +  char zTemp[NBFS];    /* Temp space for small records */
  2697   2721   
  2698   2722     /* Assuming the record contains N fields, the record format looks
  2699   2723     ** like this:
  2700   2724     **
  2701   2725     **   -------------------------------------------------------------------
  2702   2726     **   | idx0 | idx1 | ... | idx(N-1) | idx(N) | data0 | ... | data(N-1) |
  2703   2727     **   -------------------------------------------------------------------
................................................................................
  2716   2740     nField = pOp->p1;
  2717   2741     VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
  2718   2742     nByte = 0;
  2719   2743     for(i=p->tos-nField+1; i<=p->tos; i++){
  2720   2744       if( (aStack[i].flags & STK_Null) ){
  2721   2745         addUnique = pOp->p2;
  2722   2746       }else{
  2723         -      if( Stringify(p, i) ) goto no_mem;
         2747  +      Stringify(p, i);
  2724   2748         nByte += aStack[i].n;
  2725   2749       }
  2726   2750     }
  2727   2751     if( addUnique ) nByte += sizeof(uniqueCnt);
  2728   2752     if( nByte + nField + 1 < 256 ){
  2729   2753       idxWidth = 1;
  2730   2754     }else if( nByte + 2*nField + 2 < 65536 ){
................................................................................
  2733   2757       idxWidth = 3;
  2734   2758     }
  2735   2759     nByte += idxWidth*(nField + 1);
  2736   2760     if( nByte>MAX_BYTES_PER_ROW ){
  2737   2761       rc = SQLITE_TOOBIG;
  2738   2762       goto abort_due_to_error;
  2739   2763     }
  2740         -  zNewRecord = sqliteMallocRaw( nByte );
  2741         -  if( zNewRecord==0 ) goto no_mem;
         2764  +  if( nByte<=NBFS ){
         2765  +    zNewRecord = zTemp;
         2766  +  }else{
         2767  +    zNewRecord = sqliteMallocRaw( nByte );
         2768  +    if( zNewRecord==0 ) goto no_mem;
         2769  +  }
  2742   2770     j = 0;
  2743   2771     addr = idxWidth*(nField+1) + addUnique*sizeof(uniqueCnt);
  2744   2772     for(i=p->tos-nField+1; i<=p->tos; i++){
  2745   2773       zNewRecord[j++] = addr & 0xff;
  2746   2774       if( idxWidth>1 ){
  2747   2775         zNewRecord[j++] = (addr>>8)&0xff;
  2748   2776         if( idxWidth>2 ){
................................................................................
  2770   2798         memcpy(&zNewRecord[j], zStack[i], aStack[i].n);
  2771   2799         j += aStack[i].n;
  2772   2800       }
  2773   2801     }
  2774   2802     PopStack(p, nField);
  2775   2803     p->tos++;
  2776   2804     aStack[p->tos].n = nByte;
  2777         -  aStack[p->tos].flags = STK_Str | STK_Dyn;
  2778         -  zStack[p->tos] = zNewRecord;
         2805  +  if( nByte<=NBFS ){
         2806  +    assert( zNewRecord==zTemp );
         2807  +    memcpy(aStack[p->tos].z, zTemp, nByte);
         2808  +    zStack[p->tos] = aStack[p->tos].z;
         2809  +    aStack[p->tos].flags = STK_Str;
         2810  +  }else{
         2811  +    assert( zNewRecord!=zTemp );
         2812  +    aStack[p->tos].flags = STK_Str | STK_Dyn;
         2813  +    zStack[p->tos] = zNewRecord;
         2814  +  }
  2779   2815     break;
  2780   2816   }
  2781   2817   
  2782   2818   /* Opcode: MakeKey P1 P2 P3
  2783   2819   **
  2784   2820   ** Convert the top P1 entries of the stack into a single entry suitable
  2785   2821   ** for use as the key in an index.  The top P1 records are
................................................................................
  2847   2883   case OP_MakeKey: {
  2848   2884     char *zNewKey;
  2849   2885     int nByte;
  2850   2886     int nField;
  2851   2887     int addRowid;
  2852   2888     int i, j;
  2853   2889     int containsNull = 0;
         2890  +  char zTemp[NBFS];
  2854   2891   
  2855   2892     addRowid = pOp->opcode==OP_MakeIdxKey;
  2856   2893     nField = pOp->p1;
  2857   2894     VERIFY( if( p->tos+1+addRowid<nField ) goto not_enough_stack; )
  2858   2895     nByte = 0;
  2859   2896     for(j=0, i=p->tos-nField+1; i<=p->tos; i++, j++){
  2860   2897       int flags = aStack[i].flags;
................................................................................
  2886   2923       }
  2887   2924     }
  2888   2925     if( nByte+sizeof(u32)>MAX_BYTES_PER_ROW ){
  2889   2926       rc = SQLITE_TOOBIG;
  2890   2927       goto abort_due_to_error;
  2891   2928     }
  2892   2929     if( addRowid ) nByte += sizeof(u32);
  2893         -  zNewKey = sqliteMallocRaw( nByte );
  2894         -  if( zNewKey==0 ) goto no_mem;
         2930  +  if( nByte<=NBFS ){
         2931  +    zNewKey = zTemp;
         2932  +  }else{
         2933  +    zNewKey = sqliteMallocRaw( nByte );
         2934  +    if( zNewKey==0 ) goto no_mem;
         2935  +  }
  2895   2936     j = 0;
  2896   2937     for(i=p->tos-nField+1; i<=p->tos; i++){
  2897   2938       if( aStack[i].flags & STK_Null ){
  2898   2939         zNewKey[j++] = 'a';
  2899   2940         zNewKey[j++] = 0;
  2900   2941       }else{
  2901   2942         if( aStack[i].flags & (STK_Int|STK_Real) ){
................................................................................
  2915   2956       PopStack(p, nField+1);
  2916   2957       if( pOp->p2 && containsNull ) pc = pOp->p2 - 1;
  2917   2958     }else{
  2918   2959       if( pOp->p2==0 ) PopStack(p, nField+addRowid);
  2919   2960     }
  2920   2961     p->tos++;
  2921   2962     aStack[p->tos].n = nByte;
  2922         -  aStack[p->tos].flags = STK_Str|STK_Dyn;
  2923         -  zStack[p->tos] = zNewKey;
         2963  +  if( nByte<=NBFS ){
         2964  +    assert( zNewKey==zTemp );
         2965  +    zStack[p->tos] = aStack[p->tos].z;
         2966  +    memcpy(zStack[p->tos], zTemp, nByte);
         2967  +    aStack[p->tos].flags = STK_Str;
         2968  +  }else{
         2969  +    aStack[p->tos].flags = STK_Str|STK_Dyn;
         2970  +    zStack[p->tos] = zNewKey;
         2971  +  }
  2924   2972     break;
  2925   2973   }
  2926   2974   
  2927   2975   /* Opcode: IncrKey * * *
  2928   2976   **
  2929   2977   ** The top of the stack should contain an index key generated by
  2930   2978   ** The MakeKey opcode.  This routine increases the least significant
................................................................................
  2932   2980   ** will move to the first entry greater than the key rather than to
  2933   2981   ** the key itself.
  2934   2982   */
  2935   2983   case OP_IncrKey: {
  2936   2984     int tos = p->tos;
  2937   2985   
  2938   2986     VERIFY( if( tos<0 ) goto bad_instruction );
  2939         -  if( Stringify(p, tos) ) goto no_mem;
         2987  +  Stringify(p, tos);
  2940   2988     if( aStack[tos].flags & (STK_Static|STK_Ephem) ){
  2941   2989       /* CANT HAPPEN.  The IncrKey opcode is only applied to keys
  2942   2990       ** generated by MakeKey or MakeIdxKey and the results of those
  2943   2991       ** operands are always dynamic strings.
  2944   2992       */
  2945   2993       goto abort_due_to_error;
  2946   2994     }
................................................................................
  3360   3408       int res, oc;
  3361   3409       if( aStack[tos].flags & STK_Int ){
  3362   3410         int iKey = intToKey(aStack[tos].i);
  3363   3411         sqliteBtreeMoveto(pC->pCursor, (char*)&iKey, sizeof(int), &res);
  3364   3412         pC->lastRecno = aStack[tos].i;
  3365   3413         pC->recnoIsValid = res==0;
  3366   3414       }else{
  3367         -      if( Stringify(p, tos) ) goto no_mem;
         3415  +      Stringify(p, tos);
  3368   3416         sqliteBtreeMoveto(pC->pCursor, zStack[tos], aStack[tos].n, &res);
  3369   3417         pC->recnoIsValid = 0;
  3370   3418       }
  3371   3419       pC->nullRow = 0;
  3372   3420       sqlite_search_count++;
  3373   3421       oc = pOp->opcode;
  3374   3422       if( oc==OP_MoveTo && res<0 ){
................................................................................
  3436   3484     int i = pOp->p1;
  3437   3485     int tos = p->tos;
  3438   3486     int alreadyExists = 0;
  3439   3487     Cursor *pC;
  3440   3488     VERIFY( if( tos<0 ) goto not_enough_stack; )
  3441   3489     if( VERIFY( i>=0 && i<p->nCursor && ) (pC = &p->aCsr[i])->pCursor!=0 ){
  3442   3490       int res, rx;
  3443         -    if( Stringify(p, tos) ) goto no_mem;
         3491  +    Stringify(p, tos);
  3444   3492       rx = sqliteBtreeMoveto(pC->pCursor, zStack[tos], aStack[tos].n, &res);
  3445   3493       alreadyExists = rx==SQLITE_OK && res==0;
  3446   3494     }
  3447   3495     if( pOp->opcode==OP_Found ){
  3448   3496       if( alreadyExists ) pc = pOp->p2 - 1;
  3449   3497     }else{
  3450   3498       if( !alreadyExists ) pc = pOp->p2 - 1;
................................................................................
  3492   3540       int res, rc;
  3493   3541       int v;         /* The record number on the P1 entry that matches K */
  3494   3542       char *zKey;    /* The value of K */
  3495   3543       int nKey;      /* Number of bytes in K */
  3496   3544   
  3497   3545       /* Make sure K is a string and make zKey point to K
  3498   3546       */
  3499         -    if( Stringify(p, nos) ) goto no_mem;
         3547  +    Stringify(p, nos);
  3500   3548       zKey = zStack[nos];
  3501   3549       nKey = aStack[nos].n;
  3502   3550       assert( nKey >= 4 );
  3503   3551   
  3504   3552       /* Search for an entry in P1 where all but the last four bytes match K.
  3505   3553       ** If there is no such entry, jump immediately to P2.
  3506   3554       */
................................................................................
  3705   3753     int i = pOp->p1;
  3706   3754     Cursor *pC;
  3707   3755     VERIFY( if( nos<0 ) goto not_enough_stack; )
  3708   3756     if( VERIFY( i>=0 && i<p->nCursor && ) (pC = &p->aCsr[i])->pCursor!=0 ){
  3709   3757       char *zKey;
  3710   3758       int nKey, iKey;
  3711   3759       if( pOp->opcode==OP_PutStrKey ){
  3712         -      if( Stringify(p, nos) ) goto no_mem;
         3760  +      Stringify(p, nos);
  3713   3761         nKey = aStack[nos].n;
  3714   3762         zKey = zStack[nos];
  3715   3763       }else{
  3716   3764         assert( aStack[nos].flags & STK_Int );
  3717   3765         nKey = sizeof(int);
  3718   3766         iKey = intToKey(aStack[nos].i);
  3719   3767         zKey = (char*)&iKey;
................................................................................
  4195   4243     int i= pOp->p1;
  4196   4244     int tos = p->tos;
  4197   4245     BtCursor *pCrsr;
  4198   4246   
  4199   4247     if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){
  4200   4248       int res, rc;
  4201   4249    
  4202         -    if( Stringify(p, tos) ) goto no_mem;
         4250  +    Stringify(p, tos);
  4203   4251       rc = sqliteBtreeKeyCompare(pCrsr, zStack[tos], aStack[tos].n, 4, &res);
  4204   4252       if( rc!=SQLITE_OK ){
  4205   4253         break;
  4206   4254       }
  4207   4255       if( pOp->opcode==OP_IdxLT ){
  4208   4256         res = -res;
  4209   4257       }else if( pOp->opcode==OP_IdxGE ){
................................................................................
  4458   4506   ** made using SortMakeKey and SortMakeRec, respectively.
  4459   4507   */
  4460   4508   case OP_SortPut: {
  4461   4509     int tos = p->tos;
  4462   4510     int nos = tos - 1;
  4463   4511     Sorter *pSorter;
  4464   4512     VERIFY( if( tos<1 ) goto not_enough_stack; )
  4465         -  if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
         4513  +  if( Dynamicify(p, tos) || Dynamicify(p, nos) ) goto no_mem;
  4466   4514     pSorter = sqliteMallocRaw( sizeof(Sorter) );
  4467   4515     if( pSorter==0 ) goto no_mem;
  4468   4516     pSorter->pNext = p->pSort;
  4469   4517     p->pSort = pSorter;
  4470   4518     assert( aStack[tos].flags & STK_Dyn );
  4471   4519     pSorter->nKey = aStack[tos].n;
  4472   4520     pSorter->zKey = zStack[tos];
................................................................................
  4498   4546     int i, j;
  4499   4547   
  4500   4548     nField = pOp->p1;
  4501   4549     VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
  4502   4550     nByte = 0;
  4503   4551     for(i=p->tos-nField+1; i<=p->tos; i++){
  4504   4552       if( (aStack[i].flags & STK_Null)==0 ){
  4505         -      if( Stringify(p, i) ) goto no_mem;
         4553  +      Stringify(p, i);
  4506   4554         nByte += aStack[i].n;
  4507   4555       }
  4508   4556     }
  4509   4557     nByte += sizeof(char*)*(nField+1);
  4510   4558     azArg = sqliteMallocRaw( nByte );
  4511   4559     if( azArg==0 ) goto no_mem;
  4512   4560     z = (char*)&azArg[nField+1];
................................................................................
  4551   4599     nField = strlen(pOp->p3);
  4552   4600     VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
  4553   4601     nByte = 1;
  4554   4602     for(i=p->tos-nField+1; i<=p->tos; i++){
  4555   4603       if( (aStack[i].flags & STK_Null)!=0 ){
  4556   4604         nByte += 2;
  4557   4605       }else{
  4558         -      if( Stringify(p, i) ) goto no_mem;
         4606  +      Stringify(p, i);
  4559   4607         nByte += aStack[i].n+2;
  4560   4608       }
  4561   4609     }
  4562   4610     zNewKey = sqliteMallocRaw( nByte );
  4563   4611     if( zNewKey==0 ) goto no_mem;
  4564   4612     j = 0;
  4565   4613     k = 0;
................................................................................
  4995   5043     VERIFY( if( n<0 ) goto bad_instruction; )
  4996   5044     VERIFY( if( p->tos+1<n ) goto not_enough_stack; )
  4997   5045     VERIFY( if( aStack[p->tos].flags!=STK_Int ) goto bad_instruction; )
  4998   5046     for(i=p->tos-n; i<p->tos; i++){
  4999   5047       if( aStack[i].flags & STK_Null ){
  5000   5048         zStack[i] = 0;
  5001   5049       }else{
  5002         -      if( Stringify(p, i) ) goto no_mem;
         5050  +      Stringify(p, i);
  5003   5051       }
  5004   5052     }
  5005   5053     i = aStack[p->tos].i;
  5006   5054     VERIFY( if( i<0 || i>=p->agg.nMem ) goto bad_instruction; )
  5007   5055     ctx.pFunc = (FuncDef*)pOp->p3;
  5008   5056     pMem = &p->agg.pCurrent->aMem[i];
  5009   5057     ctx.z = pMem->s.z;
................................................................................
  5038   5086   case OP_AggFocus: {
  5039   5087     int tos = p->tos;
  5040   5088     AggElem *pElem;
  5041   5089     char *zKey;
  5042   5090     int nKey;
  5043   5091   
  5044   5092     VERIFY( if( tos<0 ) goto not_enough_stack; )
  5045         -  if( Stringify(p, tos) ) goto no_mem;
         5093  +  Stringify(p, tos);
  5046   5094     zKey = zStack[tos]; 
  5047   5095     nKey = aStack[tos].n;
  5048   5096     pElem = sqliteHashFind(&p->agg.hash, zKey, nKey);
  5049   5097     if( pElem ){
  5050   5098       p->agg.pCurrent = pElem;
  5051   5099       pc = pOp->p2 - 1;
  5052   5100     }else{
................................................................................
  5188   5236       p->nSet = i+1;
  5189   5237     }
  5190   5238     if( pOp->p3 ){
  5191   5239       sqliteHashInsert(&p->aSet[i].hash, pOp->p3, strlen(pOp->p3)+1, p);
  5192   5240     }else{
  5193   5241       int tos = p->tos;
  5194   5242       if( tos<0 ) goto not_enough_stack;
  5195         -    if( Stringify(p, tos) ) goto no_mem;
         5243  +    Stringify(p, tos);
  5196   5244       sqliteHashInsert(&p->aSet[i].hash, zStack[tos], aStack[tos].n, p);
  5197   5245       POPSTACK;
  5198   5246     }
  5199   5247     if( sqlite_malloc_failed ) goto no_mem;
  5200   5248     break;
  5201   5249   }
  5202   5250   
................................................................................
  5206   5254   ** contents of set P1.  If the element popped exists in set P1,
  5207   5255   ** then jump to P2.  Otherwise fall through.
  5208   5256   */
  5209   5257   case OP_SetFound: {
  5210   5258     int i = pOp->p1;
  5211   5259     int tos = p->tos;
  5212   5260     VERIFY( if( tos<0 ) goto not_enough_stack; )
  5213         -  if( Stringify(p, tos) ) goto no_mem;
         5261  +  Stringify(p, tos);
  5214   5262     if( i>=0 && i<p->nSet &&
  5215   5263          sqliteHashFind(&p->aSet[i].hash, zStack[tos], aStack[tos].n)){
  5216   5264       pc = pOp->p2 - 1;
  5217   5265     }
  5218   5266     POPSTACK;
  5219   5267     break;
  5220   5268   }
................................................................................
  5225   5273   ** contents of set P1.  If the element popped does not exists in 
  5226   5274   ** set P1, then jump to P2.  Otherwise fall through.
  5227   5275   */
  5228   5276   case OP_SetNotFound: {
  5229   5277     int i = pOp->p1;
  5230   5278     int tos = p->tos;
  5231   5279     VERIFY( if( tos<0 ) goto not_enough_stack; )
  5232         -  if( Stringify(p, tos) ) goto no_mem;
         5280  +  Stringify(p, tos);
  5233   5281     if( i<0 || i>=p->nSet ||
  5234   5282          sqliteHashFind(&p->aSet[i].hash, zStack[tos], aStack[tos].n)==0 ){
  5235   5283       pc = pOp->p2 - 1;
  5236   5284     }
  5237   5285     POPSTACK;
  5238   5286     break;
  5239   5287   }