/ Check-in [bac2820e]
Login

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

Overview
Comment:Experimental simplification of memory flags/type handling.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | noMemType
Files: files | file ages | folders
SHA1: bac2820e13a79d91d0f8938c643134a9d6900327
User & Date: mistachkin 2014-03-05 01:29:18
Context
2014-03-05
11:48
Remove the redundant memType field from struct Mem. check-in: 9e852857 user: dan tags: trunk
01:29
Experimental simplification of memory flags/type handling. Closed-Leaf check-in: bac2820e user: mistachkin tags: noMemType
2014-03-04
21:19
Avoid indexing off the front end of an array when creating a view with two or more blank column names in the SELECT statement that defines the view. check-in: 554501f1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test5.c.

    72     72     }
    73     73   
    74     74     if( Tcl_GetIntFromObj(interp, objv[1], &repeat_count) ) return TCL_ERROR;
    75     75     if( Tcl_GetIntFromObj(interp, objv[2], &do_calls) ) return TCL_ERROR;
    76     76   
    77     77     val.flags = MEM_Str|MEM_Term|MEM_Static;
    78     78     val.z = "hello world";
    79         -  val.memType = MEM_Str;
    80     79     val.enc = SQLITE_UTF8;
    81     80   
    82     81     for(i=0; i<repeat_count; i++){
    83     82       if( do_calls ){
    84     83         sqlite3_value_text(&val);
    85     84       }
    86     85     }

Changes to src/test_func.c.

   495    495       Mem mem;
   496    496   
   497    497       memset(&mem, 0, sizeof(mem));
   498    498       mem.db = db;
   499    499       mem.enc = ENC(db);
   500    500       pHdr += sqlite3GetVarint(pHdr, &iSerialType);
   501    501       pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
   502         -    sqlite3VdbeMemStoreType(&mem);
   503    502   
   504    503       if( iCurrent==iIdx ){
   505    504         sqlite3_result_value(context, &mem);
   506    505       }
   507    506   
   508    507       sqlite3DbFree(db, mem.zMalloc);
   509    508     }
................................................................................
   545    544   
   546    545       memset(&mem, 0, sizeof(mem));
   547    546       mem.db = db;
   548    547       mem.enc = ENC(db);
   549    548       pHdr += sqlite3GetVarint(pHdr, &iSerialType);
   550    549       pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
   551    550   
   552         -    sqlite3VdbeMemStoreType(&mem);
   553    551       switch( sqlite3_value_type(&mem) ){
   554    552         case SQLITE_TEXT:
   555    553           pVal = Tcl_NewStringObj((const char*)sqlite3_value_text(&mem), -1);
   556    554           break;
   557    555   
   558    556         case SQLITE_BLOB: {
   559    557           char hexdigit[] = {

Changes to src/vdbe.c.

   289    289   ** loss of information and return the revised type of the argument.
   290    290   */
   291    291   int sqlite3_value_numeric_type(sqlite3_value *pVal){
   292    292     int eType = sqlite3_value_type(pVal);
   293    293     if( eType==SQLITE_TEXT ){
   294    294       Mem *pMem = (Mem*)pVal;
   295    295       applyNumericAffinity(pMem);
   296         -    sqlite3VdbeMemStoreType(pMem);
   297    296       eType = sqlite3_value_type(pVal);
   298    297     }
   299    298     return eType;
   300    299   }
   301    300   
   302    301   /*
   303    302   ** Exported version of applyAffinity(). This one works on sqlite3_value*, 
................................................................................
  1239   1238     pMem = p->pResultSet = &aMem[pOp->p1];
  1240   1239     for(i=0; i<pOp->p2; i++){
  1241   1240       assert( memIsValid(&pMem[i]) );
  1242   1241       Deephemeralize(&pMem[i]);
  1243   1242       assert( (pMem[i].flags & MEM_Ephem)==0
  1244   1243               || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
  1245   1244       sqlite3VdbeMemNulTerminate(&pMem[i]);
  1246         -    sqlite3VdbeMemStoreType(&pMem[i]);
  1247   1245       REGISTER_TRACE(pOp->p1+i, &pMem[i]);
  1248   1246     }
  1249   1247     if( db->mallocFailed ) goto no_mem;
  1250   1248   
  1251   1249     /* Return SQLITE_ROW
  1252   1250     */
  1253   1251     p->pc = pc + 1;
................................................................................
  1485   1483     assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem-p->nCursor)+1) );
  1486   1484     assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );
  1487   1485     pArg = &aMem[pOp->p2];
  1488   1486     for(i=0; i<n; i++, pArg++){
  1489   1487       assert( memIsValid(pArg) );
  1490   1488       apVal[i] = pArg;
  1491   1489       Deephemeralize(pArg);
  1492         -    sqlite3VdbeMemStoreType(pArg);
  1493   1490       REGISTER_TRACE(pOp->p2+i, pArg);
  1494   1491     }
  1495   1492   
  1496   1493     assert( pOp->p4type==P4_FUNCDEF );
  1497   1494     ctx.pFunc = pOp->p4.pFunc;
  1498   1495     ctx.iOp = pc;
  1499   1496     ctx.pVdbe = p;
................................................................................
  5490   5487     pRec = &aMem[pOp->p2];
  5491   5488     apVal = p->apArg;
  5492   5489     assert( apVal || n==0 );
  5493   5490     for(i=0; i<n; i++, pRec++){
  5494   5491       assert( memIsValid(pRec) );
  5495   5492       apVal[i] = pRec;
  5496   5493       memAboutToChange(p, pRec);
  5497         -    sqlite3VdbeMemStoreType(pRec);
  5498   5494     }
  5499   5495     ctx.pFunc = pOp->p4.pFunc;
  5500   5496     assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) );
  5501   5497     ctx.pMem = pMem = &aMem[pOp->p3];
  5502   5498     pMem->n++;
  5503   5499     ctx.s.flags = MEM_Null;
  5504   5500     ctx.s.z = 0;
................................................................................
  5924   5920   
  5925   5921     /* Invoke the xFilter method */
  5926   5922     {
  5927   5923       res = 0;
  5928   5924       apArg = p->apArg;
  5929   5925       for(i = 0; i<nArg; i++){
  5930   5926         apArg[i] = &pArgc[i+1];
  5931         -      sqlite3VdbeMemStoreType(apArg[i]);
  5932   5927       }
  5933   5928   
  5934   5929       p->inVtabMethod = 1;
  5935   5930       rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
  5936   5931       p->inVtabMethod = 0;
  5937   5932       sqlite3VtabImportErrmsg(p, pVtab);
  5938   5933       if( rc==SQLITE_OK ){
................................................................................
  6131   6126     if( ALWAYS(pModule->xUpdate) ){
  6132   6127       u8 vtabOnConflict = db->vtabOnConflict;
  6133   6128       apArg = p->apArg;
  6134   6129       pX = &aMem[pOp->p3];
  6135   6130       for(i=0; i<nArg; i++){
  6136   6131         assert( memIsValid(pX) );
  6137   6132         memAboutToChange(p, pX);
  6138         -      sqlite3VdbeMemStoreType(pX);
  6139   6133         apArg[i] = pX;
  6140   6134         pX++;
  6141   6135       }
  6142   6136       db->vtabOnConflict = pOp->p5;
  6143   6137       rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
  6144   6138       db->vtabOnConflict = vtabOnConflict;
  6145   6139       sqlite3VtabImportErrmsg(p, pVtab);

Changes to src/vdbeInt.h.

   164    164       int nZero;          /* Used when bit MEM_Zero is set in flags */
   165    165       FuncDef *pDef;      /* Used only when flags==MEM_Agg */
   166    166       RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */
   167    167       VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */
   168    168     } u;
   169    169     int n;              /* Number of characters in string value, excluding '\0' */
   170    170     u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
   171         -  u8  memType;        /* Lower 5 bits of flags */
   172    171     u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
   173    172   #ifdef SQLITE_DEBUG
   174    173     Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */
   175    174     void *pFiller;      /* So that sizeof(Mem) is a multiple of 8 */
   176    175   #endif
   177    176     void (*xDel)(void *);  /* If not null, call this function to delete Mem.z */
   178    177     char *zMalloc;      /* Dynamic buffer allocated by sqlite3_malloc() */
................................................................................
   191    190   ** flags may coexist with the MEM_Str flag.
   192    191   */
   193    192   #define MEM_Null      0x0001   /* Value is NULL */
   194    193   #define MEM_Str       0x0002   /* Value is a string */
   195    194   #define MEM_Int       0x0004   /* Value is an integer */
   196    195   #define MEM_Real      0x0008   /* Value is a real number */
   197    196   #define MEM_Blob      0x0010   /* Value is a BLOB */
          197  +#define MEM_AffMask   0x001f   /* Mask of affinity bits */
   198    198   #define MEM_RowSet    0x0020   /* Value is a RowSet object */
   199    199   #define MEM_Frame     0x0040   /* Value is a VdbeFrame object */
   200    200   #define MEM_Undefined 0x0080   /* Value is undefined */
   201    201   #define MEM_Cleared   0x0100   /* NULL set by OP_Null, not from data */
   202    202   #define MEM_TypeMask  0x01ff   /* Mask of type bits */
   203    203   
   204    204   
................................................................................
   430    430     if( VdbeMemDynamic(X) ) sqlite3VdbeMemReleaseExternal(X);
   431    431   int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
   432    432   const char *sqlite3OpcodeName(int);
   433    433   int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
   434    434   int sqlite3VdbeCloseStatement(Vdbe *, int);
   435    435   void sqlite3VdbeFrameDelete(VdbeFrame*);
   436    436   int sqlite3VdbeFrameRestore(VdbeFrame *);
   437         -#define sqlite3VdbeMemStoreType(X)  (X)->memType = (u8)((X)->flags&0x1f)
   438         -/* void sqlite3VdbeMemStoreType(Mem *pMem); */
   439    437   int sqlite3VdbeTransferError(Vdbe *p);
   440    438   
   441    439   int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
   442    440   void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
   443    441   int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
   444    442   int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *);
   445    443   int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *);

Changes to src/vdbeapi.c.

   202    202        SQLITE_FLOAT,    /* 0x1a */
   203    203        SQLITE_NULL,     /* 0x1b */
   204    204        SQLITE_INTEGER,  /* 0x1c */
   205    205        SQLITE_NULL,     /* 0x1d */
   206    206        SQLITE_INTEGER,  /* 0x1e */
   207    207        SQLITE_NULL,     /* 0x1f */
   208    208     };
   209         -  return aType[pVal->memType&0x1f];
          209  +  return aType[pVal->flags&MEM_AffMask];
   210    210   }
   211    211   
   212    212   /**************************** sqlite3_result_  *******************************
   213    213   ** The following routines are used by user-defined functions to specify
   214    214   ** the function result.
   215    215   **
   216    216   ** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the
................................................................................
   754    754       ** these assert()s from failing, when building with SQLITE_DEBUG defined
   755    755       ** using gcc, we force nullMem to be 8-byte aligned using the magical
   756    756       ** __attribute__((aligned(8))) macro.  */
   757    757       static const Mem nullMem 
   758    758   #if defined(SQLITE_DEBUG) && defined(__GNUC__)
   759    759         __attribute__((aligned(8))) 
   760    760   #endif
   761         -      = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0,
          761  +      = {0, "", (double)0, {0}, 0, MEM_Null, 0,
   762    762   #ifdef SQLITE_DEBUG
   763    763            0, 0,  /* pScopyFrom, pFiller */
   764    764   #endif
   765    765            0, 0 };
   766    766   
   767    767       if( pVm && ALWAYS(pVm->db) ){
   768    768         sqlite3_mutex_enter(pVm->db->mutex);

Changes to src/vdbeaux.c.

  1359   1359         for(j=0; i>=apSub[j]->nOp; j++){
  1360   1360           i -= apSub[j]->nOp;
  1361   1361         }
  1362   1362         pOp = &apSub[j]->aOp[i];
  1363   1363       }
  1364   1364       if( p->explain==1 ){
  1365   1365         pMem->flags = MEM_Int;
  1366         -      pMem->memType = MEM_Int;
  1367   1366         pMem->u.i = i;                                /* Program counter */
  1368   1367         pMem++;
  1369   1368     
  1370   1369         pMem->flags = MEM_Static|MEM_Str|MEM_Term;
  1371   1370         pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
  1372   1371         assert( pMem->z!=0 );
  1373   1372         pMem->n = sqlite3Strlen30(pMem->z);
  1374         -      pMem->memType = MEM_Str;
  1375   1373         pMem->enc = SQLITE_UTF8;
  1376   1374         pMem++;
  1377   1375   
  1378   1376         /* When an OP_Program opcode is encounter (the only opcode that has
  1379   1377         ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
  1380   1378         ** kept in p->aMem[9].z to hold the new program - assuming this subprogram
  1381   1379         ** has not already been seen.
................................................................................
  1393   1391             pSub->n = nSub*sizeof(SubProgram*);
  1394   1392           }
  1395   1393         }
  1396   1394       }
  1397   1395   
  1398   1396       pMem->flags = MEM_Int;
  1399   1397       pMem->u.i = pOp->p1;                          /* P1 */
  1400         -    pMem->memType = MEM_Int;
  1401   1398       pMem++;
  1402   1399   
  1403   1400       pMem->flags = MEM_Int;
  1404   1401       pMem->u.i = pOp->p2;                          /* P2 */
  1405         -    pMem->memType = MEM_Int;
  1406   1402       pMem++;
  1407   1403   
  1408   1404       pMem->flags = MEM_Int;
  1409   1405       pMem->u.i = pOp->p3;                          /* P3 */
  1410         -    pMem->memType = MEM_Int;
  1411   1406       pMem++;
  1412   1407   
  1413   1408       if( sqlite3VdbeMemGrow(pMem, 32, 0) ){            /* P4 */
  1414   1409         assert( p->db->mallocFailed );
  1415   1410         return SQLITE_ERROR;
  1416   1411       }
  1417   1412       pMem->flags = MEM_Str|MEM_Term;
................................................................................
  1419   1414       if( zP4!=pMem->z ){
  1420   1415         sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
  1421   1416       }else{
  1422   1417         assert( pMem->z!=0 );
  1423   1418         pMem->n = sqlite3Strlen30(pMem->z);
  1424   1419         pMem->enc = SQLITE_UTF8;
  1425   1420       }
  1426         -    pMem->memType = MEM_Str;
  1427   1421       pMem++;
  1428   1422   
  1429   1423       if( p->explain==1 ){
  1430   1424         if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
  1431   1425           assert( p->db->mallocFailed );
  1432   1426           return SQLITE_ERROR;
  1433   1427         }
  1434   1428         pMem->flags = MEM_Str|MEM_Term;
  1435   1429         pMem->n = 2;
  1436   1430         sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5);   /* P5 */
  1437         -      pMem->memType = MEM_Str;
  1438   1431         pMem->enc = SQLITE_UTF8;
  1439   1432         pMem++;
  1440   1433     
  1441   1434   #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
  1442   1435         if( sqlite3VdbeMemGrow(pMem, 500, 0) ){
  1443   1436           assert( p->db->mallocFailed );
  1444   1437           return SQLITE_ERROR;
  1445   1438         }
  1446   1439         pMem->flags = MEM_Str|MEM_Term;
  1447   1440         pMem->n = displayComment(pOp, zP4, pMem->z, 500);
  1448         -      pMem->memType = MEM_Str;
  1449   1441         pMem->enc = SQLITE_UTF8;
  1450   1442   #else
  1451   1443         pMem->flags = MEM_Null;                       /* Comment */
  1452         -      pMem->memType = MEM_Null;
  1453   1444   #endif
  1454   1445       }
  1455   1446   
  1456   1447       p->nResColumn = 8 - 4*(p->explain-1);
  1457   1448       p->pResultSet = &p->aMem[1];
  1458   1449       p->rc = SQLITE_OK;
  1459   1450       rc = SQLITE_ROW;
................................................................................
  3933   3924     if( v ){
  3934   3925       Mem *pMem = &v->aVar[iVar-1];
  3935   3926       if( 0==(pMem->flags & MEM_Null) ){
  3936   3927         sqlite3_value *pRet = sqlite3ValueNew(v->db);
  3937   3928         if( pRet ){
  3938   3929           sqlite3VdbeMemCopy((Mem *)pRet, pMem);
  3939   3930           sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
  3940         -        sqlite3VdbeMemStoreType((Mem *)pRet);
  3941   3931         }
  3942   3932         return pRet;
  3943   3933       }
  3944   3934     }
  3945   3935     return 0;
  3946   3936   }
  3947   3937   

Changes to src/vdbemem.c.

   317    317       sqlite3VdbeMemSetNull(p);
   318    318     }
   319    319   }
   320    320   
   321    321   /*
   322    322   ** Release any memory held by the Mem. This may leave the Mem in an
   323    323   ** inconsistent state, for example with (Mem.z==0) and
   324         -** (Mem.memType==MEM_Str).
          324  +** (Mem.flags==MEM_Str).
   325    325   */
   326    326   void sqlite3VdbeMemRelease(Mem *p){
   327    327     assert( sqlite3VdbeCheckMemInvariants(p) );
   328    328     VdbeMemRelease(p);
   329    329     if( p->zMalloc ){
   330    330       sqlite3DbFree(p->db, p->zMalloc);
   331    331       p->zMalloc = 0;
................................................................................
   509    509       pFrame->pParent = pFrame->v->pDelFrame;
   510    510       pFrame->v->pDelFrame = pFrame;
   511    511     }
   512    512     if( pMem->flags & MEM_RowSet ){
   513    513       sqlite3RowSetClear(pMem->u.pRowSet);
   514    514     }
   515    515     MemSetTypeFlag(pMem, MEM_Null);
   516         -  pMem->memType = MEM_Null;
   517    516   }
   518    517   void sqlite3ValueSetNull(sqlite3_value *p){
   519    518     sqlite3VdbeMemSetNull((Mem*)p); 
   520    519   }
   521    520   
   522    521   /*
   523    522   ** Delete any previous value and set the value to be a BLOB of length
   524    523   ** n containing all zeros.
   525    524   */
   526    525   void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
   527    526     sqlite3VdbeMemRelease(pMem);
   528    527     pMem->flags = MEM_Blob|MEM_Zero;
   529         -  pMem->memType = MEM_Blob;
   530    528     pMem->n = 0;
   531    529     if( n<0 ) n = 0;
   532    530     pMem->u.nZero = n;
   533    531     pMem->enc = SQLITE_UTF8;
   534    532   
   535    533   #ifdef SQLITE_OMIT_INCRBLOB
   536    534     sqlite3VdbeMemGrow(pMem, n, 0);
................................................................................
   545    543   ** Delete any previous value and set the value stored in *pMem to val,
   546    544   ** manifest type INTEGER.
   547    545   */
   548    546   void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
   549    547     sqlite3VdbeMemRelease(pMem);
   550    548     pMem->u.i = val;
   551    549     pMem->flags = MEM_Int;
   552         -  pMem->memType = MEM_Int;
   553    550   }
   554    551   
   555    552   #ifndef SQLITE_OMIT_FLOATING_POINT
   556    553   /*
   557    554   ** Delete any previous value and set the value stored in *pMem to val,
   558    555   ** manifest type REAL.
   559    556   */
................................................................................
   560    557   void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
   561    558     if( sqlite3IsNaN(val) ){
   562    559       sqlite3VdbeMemSetNull(pMem);
   563    560     }else{
   564    561       sqlite3VdbeMemRelease(pMem);
   565    562       pMem->r = val;
   566    563       pMem->flags = MEM_Real;
   567         -    pMem->memType = MEM_Real;
   568    564     }
   569    565   }
   570    566   #endif
   571    567   
   572    568   /*
   573    569   ** Delete any previous value and set the value of pMem to be an
   574    570   ** empty boolean index.
................................................................................
   769    765       pMem->xDel = xDel;
   770    766       flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);
   771    767     }
   772    768   
   773    769     pMem->n = nByte;
   774    770     pMem->flags = flags;
   775    771     pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
   776         -  pMem->memType = flags&0x1f;
   777    772   
   778    773   #ifndef SQLITE_OMIT_UTF16
   779    774     if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
   780    775       return SQLITE_NOMEM;
   781    776     }
   782    777   #endif
   783    778   
................................................................................
   835    830       }else{
   836    831         rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);
   837    832       }
   838    833       if( rc==SQLITE_OK ){
   839    834         pMem->z[amt] = 0;
   840    835         pMem->z[amt+1] = 0;
   841    836         pMem->flags = MEM_Blob|MEM_Term;
   842         -      pMem->memType = MEM_Blob;
   843    837         pMem->n = (int)amt;
   844    838       }else{
   845    839         sqlite3VdbeMemRelease(pMem);
   846    840       }
   847    841     }
   848    842   
   849    843     return rc;
................................................................................
   898    892   /*
   899    893   ** Create a new sqlite3_value object.
   900    894   */
   901    895   sqlite3_value *sqlite3ValueNew(sqlite3 *db){
   902    896     Mem *p = sqlite3DbMallocZero(db, sizeof(*p));
   903    897     if( p ){
   904    898       p->flags = MEM_Null;
   905         -    p->memType = MEM_Null;
   906    899       p->db = db;
   907    900     }
   908    901     return p;
   909    902   }
   910    903   
   911    904   /*
   912    905   ** Context object passed by sqlite3Stat4ProbeSetValue() through to 
................................................................................
   947    940           pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);
   948    941           if( pRec->pKeyInfo ){
   949    942             assert( pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField==nCol );
   950    943             assert( pRec->pKeyInfo->enc==ENC(db) );
   951    944             pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));
   952    945             for(i=0; i<nCol; i++){
   953    946               pRec->aMem[i].flags = MEM_Null;
   954         -            pRec->aMem[i].memType = MEM_Null;
   955    947               pRec->aMem[i].db = db;
   956    948             }
   957    949           }else{
   958    950             sqlite3DbFree(db, pRec);
   959    951             pRec = 0;
   960    952           }
   961    953         }
................................................................................
  1020   1012       if( pVal==0 ) goto no_mem;
  1021   1013       if( ExprHasProperty(pExpr, EP_IntValue) ){
  1022   1014         sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
  1023   1015       }else{
  1024   1016         zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
  1025   1017         if( zVal==0 ) goto no_mem;
  1026   1018         sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
  1027         -      if( op==TK_FLOAT ) pVal->memType = MEM_Real;
  1028   1019       }
  1029   1020       if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){
  1030   1021         sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
  1031   1022       }else{
  1032   1023         sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
  1033   1024       }
  1034   1025       if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;
................................................................................
  1066   1057       nVal = sqlite3Strlen30(zVal)-1;
  1067   1058       assert( zVal[nVal]=='\'' );
  1068   1059       sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
  1069   1060                            0, SQLITE_DYNAMIC);
  1070   1061     }
  1071   1062   #endif
  1072   1063   
  1073         -  if( pVal ){
  1074         -    sqlite3VdbeMemStoreType(pVal);
  1075         -  }
  1076   1064     *ppVal = pVal;
  1077   1065     return rc;
  1078   1066   
  1079   1067   no_mem:
  1080   1068     db->mallocFailed = 1;
  1081   1069     sqlite3DbFree(db, zVal);
  1082   1070     assert( *ppVal==0 );
................................................................................
  1232   1220         pVal = valueNew(db, &alloc);
  1233   1221         if( pVal ){
  1234   1222           rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
  1235   1223           if( rc==SQLITE_OK ){
  1236   1224             sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
  1237   1225           }
  1238   1226           pVal->db = pParse->db;
  1239         -        sqlite3VdbeMemStoreType((Mem*)pVal);
  1240   1227         }
  1241   1228       }
  1242   1229     }else{
  1243   1230       rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc);
  1244   1231     }
  1245   1232     *pbOk = (pVal!=0);
  1246   1233