MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:February 10 2009 2:52pm
Subject:bzr commit into mysql-6.0-bugteam branch (Alexey.Kopytov:2984)
Bug#21205
View as plain text  
#At file:///Users/kaa/src/bzr/bug21205/my60-bug21205/ based on revid:alfranio.correia@stripped

 2984 Alexey Kopytov	2009-02-10 [merge]
      Manual merge of the patch for bug #21205 to 6.0.
modified:
  client/sql_string.cc
  mysql-test/r/type_float.result
  mysql-test/t/type_float.test

=== modified file 'client/sql_string.cc'
--- a/client/sql_string.cc	2008-05-22 18:40:15 +0000
+++ b/client/sql_string.cc	2009-02-10 14:51:18 +0000
@@ -120,82 +120,19 @@ bool String::set(ulonglong num, CHARSET_
 
 bool String::set(double num,uint decimals, CHARSET_INFO *cs)
 {
-  char buff[331];
+  char buff[FLOATING_POINT_BUFFER];
   uint dummy_errors;
-
+  size_t len;
+  
   str_charset=cs;
   if (decimals >= NOT_FIXED_DEC)
   {
-    uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
+    len= my_gcvt(num, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
     return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
   }
-#ifdef HAVE_FCONVERT
-  int decpt,sign;
-  char *pos,*to;
-
-  (void) fconvert(num,(int) decimals,&decpt,&sign,buff+1);
-  if (!my_isdigit(&my_charset_latin1, buff[1]))
-  {						// Nan or Inf
-    pos=buff+1;
-    if (sign)
-    {
-      buff[0]='-';
-      pos=buff;
-    }
-    uint dummy_errors;
-    return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs, &dummy_errors);
-  }
-  if (alloc((uint32) ((uint32) decpt+3+decimals)))
-    return TRUE;
-  to=Ptr;
-  if (sign)
-    *to++='-';
-
-  pos=buff+1;
-  if (decpt < 0)
-  {					/* value is < 0 */
-    *to++='0';
-    if (!decimals)
-      goto end;
-    *to++='.';
-    if ((uint32) -decpt > decimals)
-      decpt= - (int) decimals;
-    decimals=(uint32) ((int) decimals+decpt);
-    while (decpt++ < 0)
-      *to++='0';
-  }
-  else if (decpt == 0)
-  {
-    *to++= '0';
-    if (!decimals)
-      goto end;
-    *to++='.';
-  }
-  else
-  {
-    while (decpt-- > 0)
-      *to++= *pos++;
-    if (!decimals)
-      goto end;
-    *to++='.';
-  }
-  while (decimals--)
-    *to++= *pos++;
-
-end:
-  *to=0;
-  str_length=(uint32) (to-Ptr);
-  return FALSE;
-#else
-#ifdef HAVE_SNPRINTF
-  buff[sizeof(buff)-1]=0;			// Safety
-  snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
-#else
-  sprintf(buff,"%.*f",(int) decimals,num);
-#endif
-  return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs,
+  len= my_fcvt(num, decimals, buff, NULL);
+  return copy(buff, (uint32) len, &my_charset_latin1, cs,
               &dummy_errors);
-#endif
 }
 
 

=== modified file 'mysql-test/r/type_float.result'
--- a/mysql-test/r/type_float.result	2008-12-10 16:24:28 +0000
+++ b/mysql-test/r/type_float.result	2009-02-10 14:51:18 +0000
@@ -425,4 +425,9 @@ u
 9223372036854790144
 18400000000000000000
 drop table t1;
+CREATE TABLE t1 (f1 DOUBLE);
+INSERT INTO t1 VALUES(-1.79769313486231e+308);
+SELECT f1 FROM t1;
+f1
+-1.79769313486231e308
 End of 5.0 tests

=== modified file 'mysql-test/t/type_float.test'
--- a/mysql-test/t/type_float.test	2008-12-10 16:24:28 +0000
+++ b/mysql-test/t/type_float.test	2009-02-10 14:51:18 +0000
@@ -297,4 +297,12 @@ update t1 set u = d;
 select u from t1;
 drop table t1;
 
+#
+# Bug #21205: Different number of digits for float/doble/real in --ps-protocol
+#
+
+CREATE TABLE t1 (f1 DOUBLE);
+INSERT INTO t1 VALUES(-1.79769313486231e+308);
+SELECT f1 FROM t1;
+
 --echo End of 5.0 tests

Thread
bzr commit into mysql-6.0-bugteam branch (Alexey.Kopytov:2984)Bug#21205Alexey Kopytov10 Feb