summaryrefslogtreecommitdiff
path: root/sql/init.cc
diff options
context:
space:
mode:
authorunknown <kaa@polly.local>2007-05-28 12:44:59 +0400
committerunknown <kaa@polly.local>2007-05-28 12:44:59 +0400
commite3af3c2127132e327ea8dd21d942ef2e09d7f4d6 (patch)
treece229fe64aa84c932114a35a906ee691371bd962 /sql/init.cc
parentdc9b20a60301040cfc3801703f4799c5e60477a3 (diff)
downloadmariadb-git-e3af3c2127132e327ea8dd21d942ef2e09d7f4d6.tar.gz
Fix for bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits"
When storing a large number to a FLOAT or DOUBLE field with fixed length, it could be incorrectly truncated if the field's length was greater than 31. This patch also does some code cleanups to be able to reuse code which is common between Field_float::store() and Field_double::store(). include/m_string.h: Added declarations for log_10 and log_01 from strtod.c mysql-test/r/type_float.result: Added the testcase for bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits" mysql-test/t/type_float.test: Added the testcase for bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits" sql/field.cc: Moved common code from Field_float::store() and Field_double:store() to Field_real::truncate() Fixed the algorithm to not truncate large input numbers if the field length is greater than 31. Fixed rounding to not depend on FLT_MAX/DBL_MAX constants. sql/field.h: Moved not_fixed member from Field_double to Field_real to allow code reuse between Field_float::store() and Field_double::store() Added truncate() method to Field_real which is used by both Field_float and Field_double sql/init.cc: log_10[] and log_01[] are now defined as statical arrays in strtod.c, no need to pre-computed them. sql/item_cmpfunc.cc: log_01[] now starts from 1e0, not from 1e-1 for consistency. sql/mysql_priv.h: Moved log_10[] and log_01[] from mysqld.cc to libmystrings. sql/mysqld.cc: Moved log_10[] and log_01[] from mysqld.cc to libmystrings. strings/strtod.c: Define and use log_10[] and log_01[] as static arrays of constants instead of values pre-computed at startup.
Diffstat (limited to 'sql/init.cc')
-rw-r--r--sql/init.cc13
1 files changed, 0 insertions, 13 deletions
diff --git a/sql/init.cc b/sql/init.cc
index ad55a2a8b24..b3b68926683 100644
--- a/sql/init.cc
+++ b/sql/init.cc
@@ -21,8 +21,6 @@
void unireg_init(ulong options)
{
- uint i;
- double nr;
DBUG_ENTER("unireg_init");
MYSYS_PROGRAM_DONT_USE_CURSES();
@@ -39,16 +37,5 @@ void unireg_init(ulong options)
VOID(strmov(reg_ext,".frm"));
specialflag=SPECIAL_SAME_DB_NAME | options; /* Set options from argv */
- /* Make a tab of powers of 10 */
- for (i=0,nr=1.0; i < array_elements(log_10) ; i++)
- { /* It's used by filesort... */
- log_10[i]= nr ; nr*= 10.0;
- }
- /* Make a tab of powers of 0.1 */
- for (i= 0, nr= 0.1; i < array_elements(log_01); i++)
- {
- log_01[i]= nr;
- nr*= 0.1;
- }
DBUG_VOID_RETURN;
}