]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Redesign the string to numeric value caster so that it is more likely to
authordrh <drh@noemail.net>
Thu, 21 Jan 2010 01:53:07 +0000 (01:53 +0000)
committerdrh <drh@noemail.net>
Thu, 21 Jan 2010 01:53:07 +0000 (01:53 +0000)
work on unusual floating point hardware.

FossilOrigin-Name: 8bb1104c6f02c88eb09ed345890be71dee099485

manifest
manifest.uuid
src/vdbemem.c

index 8193364431d8cdbaeb1cb5f4d85dd9e995b9405c..c3cd3e5faf968315832d6b6a154703f1c154e8b8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,8 @@
-C Fix\sa\sproblem\swith\shandling\sOOM\serrors\sin\sfts3.
-D 2010-01-20T14:25:37
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+C Redesign\sthe\sstring\sto\snumeric\svalue\scaster\sso\sthat\sit\sis\smore\slikely\sto\nwork\son\sunusual\sfloating\spoint\shardware.
+D 2010-01-21T01:53:08
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -215,7 +218,7 @@ F src/vdbeInt.h e276691b6835da5c0008cc5beaaecedcd7bdba8e
 F src/vdbeapi.c c2c75b052151f5bb67917480c4f05a70cc9f9236
 F src/vdbeaux.c 8f30e619a8077ee516fa1494fa603550fa951726
 F src/vdbeblob.c 84f924700a7a889152aeebef77ca5f4e3875ffb4
-F src/vdbemem.c 1ce5005ee4a1ee25ef677abdcaef1259261cc252
+F src/vdbemem.c aeba77b59f3553d3cc5b72c18a8267c6fba546b9
 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
 F src/vtab.c 7c7713d66cda699f16bf1cc601d8d4f5070ab935
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
@@ -785,7 +788,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 571594bfbe89d9949bdb8b07712e96d0a3467c6e
-R 16b92d007b95d3ba89603d98fb6dcd32
-U dan
-Z 55b4214ad5f217518f3632810d0b3f17
+P f9c54e95ecf1c36c4750bb151e91d81c1d1bd596
+R 3e61b23567b174ad8e61bfe06454c1ae
+U drh
+Z b36821be2163198094fa5c8204d312e5
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQFLV7OHoxKgR168RlERAmaWAKCKiOPK/gaKglHagKY28OJSuIbFigCgjEq9
+dFT+JRCF+URG2mLXFWfa/os=
+=csLp
+-----END PGP SIGNATURE-----
index f9c2f0e1084d47e728491261ae2ecb11bb1c5c69..342c7cf5459fd025cd820441219072c5d439c2ba 100644 (file)
@@ -1 +1 @@
-f9c54e95ecf1c36c4750bb151e91d81c1d1bd596
\ No newline at end of file
+8bb1104c6f02c88eb09ed345890be71dee099485
\ No newline at end of file
index eb6b1698188c8ce562aa7f7ebea65fa68bce8754..2b3ea5643dde6a428eed25314d7cbfb4f6638325 100644 (file)
@@ -468,21 +468,26 @@ int sqlite3VdbeMemRealify(Mem *pMem){
 /*
 ** 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;
-  i64 i;
+  int rc;
   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);
-  i = doubleToInt64(r1);
-  r2 = (double)i;
-  if( r1==r2 ){
-    sqlite3VdbeMemIntegerify(pMem);
+  rc = sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8);
+  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;
 }