summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-08-19 23:11:16 +0200
committerunknown <serg@serg.mylan>2004-08-19 23:11:16 +0200
commitd1c5ca31f615592f62280ef2d005fa1201541027 (patch)
treea3aeaec255a5d5a0e7ff06fdc3ec4a68115fa9ea
parent03a20c23b320bb28a13aa6dc69c9445ff414a144 (diff)
parent432a0f36838f0c68d5db3087bf3331ff9df1460b (diff)
downloadmariadb-git-d1c5ca31f615592f62280ef2d005fa1201541027.tar.gz
Merge bk-internal:/home/bk/mysql-4.0/
into serg.mylan:/usr/home/serg/Abk/mysql-4.0
-rw-r--r--mysql-test/r/type_float.result3
-rw-r--r--mysql-test/t/type_float.test7
-rw-r--r--sql/field.cc6
3 files changed, 14 insertions, 2 deletions
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index 61b90c8cf2e..f4c5df353a3 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -114,6 +114,9 @@ select min(a) from t1;
min(a)
-0.010
drop table t1;
+create table t1 (c20 char);
+insert into t1 (c20) values (5000.0);
+drop table t1;
create table t1 (f float(54));
Incorrect column specifier for column 'f'
drop table if exists t1;
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index bd6448616dc..084d4b815e5 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -54,6 +54,13 @@ select a from t1 order by a;
select min(a) from t1;
drop table t1;
+#
+# float in a char(1) field
+#
+create table t1 (c20 char);
+insert into t1 (c20) values (5000.0);
+drop table t1;
+
# Errors
--error 1063
diff --git a/sql/field.cc b/sql/field.cc
index 1b5c688fe7a..71ec7545efc 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -3733,15 +3733,17 @@ static void store_double_in_string_field(Field_str *field, uint32 field_length,
use_scientific_notation= (field->ceiling < nr);
}
length= (uint)sprintf(buff, "%-.*g",
- use_scientific_notation ? max(0,field_length-5) : field_length,
+ use_scientific_notation ? max(0,(int)field_length-5) : field_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,
+ like inserting 500.0 in char(1)
*/
- DBUG_ASSERT(length <= field_length+1);
+ DBUG_ASSERT(field_length < 5 || length <= field_length+1);
field->store(buff, min(length, field_length));
}