SQLite

Check-in [8bb1104c6f]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8bb1104c6f02c88eb09ed345890be71dee099485
User & Date: drh 2010-01-21 01:53:08.000
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: a82e6b4585 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: 8bb1104c6f user: drh tags: trunk)
2010-01-20
14:25
Fix a problem with handling OOM errors in fts3. (check-in: f9c54e95ec user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/vdbemem.c.
464
465
466
467
468
469
470




471
472
473

474
475
476
477
478

479
480
481
482





483
484

485

486
487
488
489
490
491
492
464
465
466
467
468
469
470
471
472
473
474
475
476

477

478
479
480

481




482
483
484
485
486
487

488
489
490
491
492
493
494
495
496
497







+
+
+
+


-
+
-



-
+
-
-
-
-
+
+
+
+
+

-
+

+







  MemSetTypeFlag(pMem, MEM_Real);
  return SQLITE_OK;
}

/*
** Convert pMem so that it has types MEM_Real or MEM_Int or both.
** Invalidate any prior representations.
**
** Every effort is made to force the conversion, even if the input
** is a string that does not look completely like a number.  Convert
** as much of the string as we can and ignore the rest.
*/
int sqlite3VdbeMemNumerify(Mem *pMem){
  double r1, r2;
  int rc;
  i64 i;
  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 );
  assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  r1 = sqlite3VdbeRealValue(pMem);
  rc = sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8);
  i = doubleToInt64(r1);
  r2 = (double)i;
  if( r1==r2 ){
    sqlite3VdbeMemIntegerify(pMem);
  if( rc ) return rc;
  rc = sqlite3VdbeMemNulTerminate(pMem);
  if( rc ) return rc;
  if( sqlite3Atoi64(pMem->z, &pMem->u.i) ){
    MemSetTypeFlag(pMem, MEM_Int);
  }else{
    pMem->r = r1;
    pMem->r = sqlite3VdbeRealValue(pMem);
    MemSetTypeFlag(pMem, MEM_Real);
    sqlite3VdbeIntegerAffinity(pMem);
  }
  return SQLITE_OK;
}

/*
** Delete any previous value and set the value stored in *pMem to NULL.
*/