/ Check-in [8bb1104c]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Redesign the string to numeric value caster so that it is more likely to work on unusual floating point hardware.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8bb1104c6f02c88eb09ed345890be71dee099485
User & Date: drh 2010-01-21 01:53:08
Context
2010-01-21
23:11
Fix a segfault that can occur when the LHS of a LIKE operator has an undefined collating sequence. Ticket [1258875e07553]. check-in: a82e6b45 user: drh tags: trunk
01:53
Redesign the string to numeric value caster so that it is more likely to work on unusual floating point hardware. check-in: 8bb1104c user: drh tags: trunk
2010-01-20
14:25
Fix a problem with handling OOM errors in fts3. check-in: f9c54e95 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

   464    464     MemSetTypeFlag(pMem, MEM_Real);
   465    465     return SQLITE_OK;
   466    466   }
   467    467   
   468    468   /*
   469    469   ** Convert pMem so that it has types MEM_Real or MEM_Int or both.
   470    470   ** Invalidate any prior representations.
          471  +**
          472  +** Every effort is made to force the conversion, even if the input
          473  +** is a string that does not look completely like a number.  Convert
          474  +** as much of the string as we can and ignore the rest.
   471    475   */
   472    476   int sqlite3VdbeMemNumerify(Mem *pMem){
   473         -  double r1, r2;
   474         -  i64 i;
          477  +  int rc;
   475    478     assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 );
   476    479     assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
   477    480     assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
   478         -  r1 = sqlite3VdbeRealValue(pMem);
   479         -  i = doubleToInt64(r1);
   480         -  r2 = (double)i;
   481         -  if( r1==r2 ){
   482         -    sqlite3VdbeMemIntegerify(pMem);
          481  +  rc = sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8);
          482  +  if( rc ) return rc;
          483  +  rc = sqlite3VdbeMemNulTerminate(pMem);
          484  +  if( rc ) return rc;
          485  +  if( sqlite3Atoi64(pMem->z, &pMem->u.i) ){
          486  +    MemSetTypeFlag(pMem, MEM_Int);
   483    487     }else{
   484         -    pMem->r = r1;
          488  +    pMem->r = sqlite3VdbeRealValue(pMem);
   485    489       MemSetTypeFlag(pMem, MEM_Real);
          490  +    sqlite3VdbeIntegerAffinity(pMem);
   486    491     }
   487    492     return SQLITE_OK;
   488    493   }
   489    494   
   490    495   /*
   491    496   ** Delete any previous value and set the value stored in *pMem to NULL.
   492    497   */