[freetds] patch: corrects the reading of large integer values when represented as double
Jose Luu
jluu at applia.fr
Wed May 19 01:52:35 EDT 2004
Hi,
An integer column datatype can be sent (and may be stored in the
database) as a double precision float.
In my case, 16 digit integers were transmitted this way and I was losing
the last digit (became always 0).
This is somehow a borderline case since only 90% of the 16 digit
integers can be represented using a double float. However, it would make
the library more robust to allow for such cases.
Also note that the Sybase openclient library is converting to 16 places.
In the patch below I have allowed for float8 conversion to 16 places.
This has been tested with freetds 0.62.1 by should work on the more
recent versions as the file convert.c has not changed.
--- src/tds/convert.c.orig Wed Jan 7 17:01:50 2004
+++ src/tds/convert.c Tue May 18 14:22:08 2004
@@ -1477,7 +1477,7 @@
memcpy(&the_value, src, 8);
switch (desttype) {
case CASE_ALL_CHAR:
- sprintf(tmp_str, "%.15g", the_value);
+ sprintf(tmp_str, "%.16g", the_value);
return string_to_result(tmp_str, cr);
break;
@@ -1535,7 +1535,7 @@
break;
case SYBNUMERIC:
case SYBDECIMAL:
- sprintf(tmp_str, "%.15g", the_value);
+ sprintf(tmp_str, "%.16g", the_value);
return stringz_to_numeric(tmp_str, cr);
break;
/* not allowed */
More information about the FreeTDS
mailing list