List:Internals« Previous MessageNext Message »
From:bar Date:June 3 2005 4:37am
Subject:bk commit into 4.1 tree (bar:1.2308) BUG#10714
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2308 05/06/03 09:37:53 bar@stripped +3 -0
  ctype_utf8.result, ctype_utf8.test:
    adding test
  field.cc:
    bug#10714 Inserting double value into utf8 column crashes server:
    sprintf was executed with too big length, which caused
    crash on some Windows platforms.

  mysql-test/r/ctype_utf8.result
    1.53 05/06/03 09:36:45 bar@stripped +3 -0
    adding test

  mysql-test/t/ctype_utf8.test
    1.53 05/06/03 09:36:38 bar@stripped +7 -0
    adding test

  sql/field.cc
    1.218 05/06/03 09:35:09 bar@stripped +8 -7
    bug#10714 Inserting double value into utf8 column crashes server
    sprintf was executed with too long length, which cau
    crashe on Windows.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-4.1

--- 1.217/sql/field.cc	2005-06-02 05:23:48 +05:00
+++ 1.218/sql/field.cc	2005-06-03 09:35:09 +05:00
@@ -4981,31 +4981,32 @@
   char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
   uint length;
   bool use_scientific_notation= TRUE;
+  uint char_length= field_length / charset()->mbmaxlen;
   /*
     Check fabs(nr) against longest value that can be stored in field,
     which depends on whether the value is < 1 or not, and negative or not
   */
   double anr= fabs(nr);
   int neg= (nr < 0.0) ? 1 : 0;
-  if (field_length > 4 && field_length < 32 &&
-      (anr < 1.0 ? anr > 1/(log_10[max(0,field_length-neg-2)]) /* -2 for "0." */
-                 : anr < log_10[field_length-neg]-1))
+  if (char_length > 4 && char_length < 32 &&
+      (anr < 1.0 ? anr > 1/(log_10[max(0,char_length-neg-2)]) /* -2 for "0." */
+                 : anr < log_10[char_length-neg]-1))
     use_scientific_notation= FALSE;
 
   length= (uint) my_sprintf(buff, (buff, "%-.*g",
                                    (use_scientific_notation ?
-                                    max(0, (int)field_length-neg-5) :
-                                    field_length),
+                                    max(0, (int)char_length-neg-5) :
+                                    char_length),
                                    nr));
   /*
     +1 below is because "precision" in %g above means the
     max. number of significant digits, not the output width.
     Thus the width can be larger than number of significant digits by 1
     (for decimal point)
-    the test for field_length < 5 is for extreme cases,
+    the test for char_length < 5 is for extreme cases,
     like inserting 500.0 in char(1)
   */
-  DBUG_ASSERT(field_length < 5 || length <= field_length+1);
+  DBUG_ASSERT(char_length < 5 || length <= char_length+1);
   return store((const char *) buff, length, charset());
 }
 

--- 1.52/mysql-test/r/ctype_utf8.result	2005-05-09 20:54:58 +05:00
+++ 1.53/mysql-test/r/ctype_utf8.result	2005-06-03 09:36:45 +05:00
@@ -888,3 +888,6 @@
 select ifnull(NULL, _utf8'string');
 ifnull(NULL, _utf8'string')
 string
+create table t1 (a varchar(255)) default character set utf8;
+insert into t1 values (1.0);
+drop table t1;

--- 1.52/mysql-test/t/ctype_utf8.test	2005-05-09 20:54:58 +05:00
+++ 1.53/mysql-test/t/ctype_utf8.test	2005-06-03 09:36:38 +05:00
@@ -724,3 +724,10 @@
 drop table t1;
 select repeat(_utf8'+',3) as h union select NULL;
 select ifnull(NULL, _utf8'string');
+
+#
+# Bug#10714: Inserting double value into utf8 column crashes server
+#
+create table t1 (a varchar(255)) default character set utf8;
+insert into t1 values (1.0);
+drop table t1;
Thread
bk commit into 4.1 tree (bar:1.2308) BUG#10714bar3 Jun