• unknown's avatar
    WL #2934 "Make/find library for doing float/double to string conversions · 04116597
    unknown authored
    and vice versa"
    Initial import of the dtoa.c code and custom wrappers around it to allow
    its usage from the server code.
    
    Conversion of FLOAT/DOUBLE values to DECIMAL ones or strings and vice
    versa has been significantly reworked. As the new algoritms are more
    precise than the older ones, results of such conversions may not always
    match those obtained from older server versions. This in turn may break
    compatibility for some applications.
    
    This patch also fixes the following bugs:
    - bug #12860 "Difference in zero padding of exponent between Unix and
    Windows"
    - bug #21497 "DOUBLE truncated to unusable value"
    - bug #26788 "mysqld (debug) aborts when inserting specific numbers into
    char fields"
    - bug #24541 "Data truncated..." on decimal type columns without any
    good reason"
    
    
    BitKeeper/deleted/.del-strtod.c:
      Rename: strings/strtod.c -> BitKeeper/deleted/.del-strtod.c
    client/Makefile.am:
      Added dtoa.c
    client/sql_string.cc:
      Replaced sprintf() with a new wrapper around dtoa()
    include/m_string.h:
      Added declarations for the new double to/from string conversion 
      functions.
    libmysql/Makefile.shared:
      Removed strtod.c, added dtoa.c
    libmysql/libmysql.c:
      Replaced sprintf() with my_gcvt(). We must use the same conversion
      method in both server and client lib.
    mysql-test/r/archive_gis.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/cast.result:
      Fixed tests to take the formatting changes into account.
    mysql-test/r/func_group.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/func_math.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/func_str.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/gis.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/innodb_gis.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/insert.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/mysqldump.result:
      No need for result substitution since we do not rely on system behavior
      anymore.
    mysql-test/r/ndb_gis.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/parser.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/ps_2myisam.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/ps_3innodb.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/ps_4heap.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/ps_5merge.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/ps_7ndb.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/select.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/r/sp.result:
      Fixed tests to take additional precision from dtoa() into account.
      Decimal 2.7182818284590452354 is now converted to the double value of
      2.718281828459045, not 2.718281828459. Thus we get additional precision
      from the subsequent calculations.
    mysql-test/r/strict.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/type_decimal.result:
      Added a test case for bug #24541.
    mysql-test/r/type_float.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
      Added test cases for bugs #12860, #21497 and #26788.
    mysql-test/r/type_newdecimal.result:
      Fixed tests to take additional precision from dtoa() and formatting
      changes into account.
    mysql-test/r/variables.result:
      Fixed tests to take the formatting changes into account.
    mysql-test/r/view.result:
      Fixed tests to take additional precision from dtoa() into account.
    mysql-test/t/cast.test:
      No need to replace the results for Windows anymore.
    mysql-test/t/insert.test:
      Added test cases from bug #26788.
    mysql-test/t/mysqldump.test:
      Fixed tests to take additional precision from dtoa() into account.
      No need for results substitution because we do not rely on system
      behavior anymore.
    mysql-test/t/type_decimal.test:
      Added a test case for bug #24541.
    mysql-test/t/type_float.test:
      Added test cases for bugs #12860, #21497 and #26788.
    mysql-test/t/type_newdecimal.test:
      Removed replace_result which is pointless with our own floating point
      conversion library.
      Added a reference for WL#3977.
    sql/field.cc:
      Replaced the field.cc's own constant for the maximum double->string 
      conversion buffer with the one defined in m_string.h
      Replaced double->string conversion code with the new wrappers around
      dtoa().
      Fixed a bug in Field_real::truncate() which led to incorrect results
      when +-Infinity was passed as an input number.
      Fixed Field_blob::store(double) to use NOT_FIXED_DEC instead of 2 as
      precision, so that my_gcvt() is now used for conversion.
    sql/field.h:
      Moved NOT_FIXED_DEC to m_string.h because we now use this constant in
      floating point <-> string conversion routines.
    sql/item.cc:
      If a result of a numeric functions is stored in a string field, follow
      the same rules as in Field_str::store(double), i.e. take the field width
      into account.
    sql/log_event.cc:
      Replaced sprintf() with my_gcvt().
    sql/mysql_priv.h:
      Moved log_10[] from strtod.c to mysqld.c, because we don't need it in
      libmystrings anymore.
    sql/mysqld.cc:
      Moved log_10[] from strtod.c to mysqld.c, because we don't need it in
      libmystrings anymore.
    sql/sql_show.cc:
      Replaced sprintf() with my_fcvt().
    sql/sql_string.cc:
      Replace the double->string conversion code with the new wrappers around
      dtoa().
    sql/unireg.h:
      Moved FLOATING_POINT_BUFFER from unireg.h to m_string.h so it can be
      used in libmystrings.
    strings/Makefile.am:
      Removed strtod.c, added dtoa.c
    strings/decimal.c:
      Replaced sprintf() with my_gcvt().
      Changed double2decimal() to print the digits to a string buffer, then
      use my_strtod().
    strings/dtoa.c:
      Initial import of the dtoa code and custom wrappers around it to allow
      its usage from the server code.
    04116597
m_string.h 8.64 KB