diff options
author | unknown <monty@mysql.com> | 2005-06-03 13:35:58 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-06-03 13:35:58 +0300 |
commit | 0298ebb579d85fd4ccb4d9a74e7692942843d156 (patch) | |
tree | 6fa324831e8ce5b270a10192b3226322f43d2073 | |
parent | 74f3014cf7d916de83fbaab8e872dca610b5e7b7 (diff) | |
parent | 9979feb35c1a90ac61c09e2a170e59ba40efcaa6 (diff) | |
download | mariadb-git-0298ebb579d85fd4ccb4d9a74e7692942843d156.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1
-rw-r--r-- | BUILD/Makefile.am | 1 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 3 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 7 | ||||
-rw-r--r-- | sql/field.cc | 15 |
4 files changed, 19 insertions, 7 deletions
diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am index 9f3c55c20d5..4e27ffd5e7f 100644 --- a/BUILD/Makefile.am +++ b/BUILD/Makefile.am @@ -19,6 +19,7 @@ EXTRA_DIST = FINISH.sh \ SETUP.sh \ + check-cpu \ compile-alpha \ compile-alpha-ccc \ compile-alpha-cxx \ diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index ffdb7cb0f3d..b7aa7c68b67 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -888,3 +888,6 @@ NULL 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; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 02024adb34e..bac6e60c302 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -724,3 +724,10 @@ select ifnull(a,'') from t1; 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; diff --git a/sql/field.cc b/sql/field.cc index 60287d4003b..21c3fe12bb2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4981,31 +4981,32 @@ int Field_str::store(double nr) 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()); } |