summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.mysql.com>2007-10-15 09:22:11 +0200
committerunknown <msvensson@pilot.mysql.com>2007-10-15 09:22:11 +0200
commit13afffd03b80ab73d813158f3d0a1ebf63a5ef31 (patch)
tree3de11e8fde7659d77c1b9e980c52e129ebb2a925
parent4eb5506257326deb4e7244f74bfd9cdb522dfbd2 (diff)
parent2fbebfec1df2c72bfd33516b9da20181124b22f5 (diff)
downloadmariadb-git-13afffd03b80ab73d813158f3d0a1ebf63a5ef31.tar.gz
Merge pilot.mysql.com:/data/msvensson/mysql/bug11589/my50-test_latest
into pilot.mysql.com:/data/msvensson/mysql/mysql-5.0-maint libmysql/libmysql.c: Auto merged mysql-test/r/type_float.result: Manual merge mysql-test/t/type_float.test: Manual merge
-rw-r--r--libmysql/libmysql.c10
-rw-r--r--mysql-test/r/type_float.result16
-rw-r--r--mysql-test/t/type_float.test16
3 files changed, 41 insertions, 1 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 2e10060f1d3..2a92d115ee2 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3876,7 +3876,15 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
sprintf(buff, "%.*f", (int) field->decimals, value);
end= strend(buff);
}
- fetch_string_with_conversion(param, buff, (uint) (end - buff));
+ uint length= (uint) (end-buff);
+ if (field->flags & ZEROFILL_FLAG && length < field->length &&
+ field->length < MAX_DOUBLE_STRING_REP_LENGTH-1)
+ {
+ bmove_upp((char*) buff+field->length,buff+length, length);
+ bfill((char*) buff, field->length - length,'0');
+ length= field->length;
+ }
+ fetch_string_with_conversion(param, buff, length);
break;
}
}
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index 53844d2cfe2..f1075604ca9 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -344,6 +344,22 @@ create table t1 (s1 float(0,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
create table t1 (s1 float(1,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
+CREATE TABLE t1 (
+f1 real zerofill,
+f2 double zerofill,
+f3 float zerofill);
+INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1);
+PREPARE stmt1 FROM 'select f1, f2, f3 FROM t1';
+select f1, f2, f3 FROM t1;
+f1 f2 f3
+0000000000000003.14152 0000000000000003.14152 000003.14152
+select f1, f2, f3 FROM t1;
+f1 f2 f3
+0000000000000003.14152 0000000000000003.14152 000003.14152
+EXECUTE stmt1;
+f1 f2 f3
+0000000000000003.14152 0000000000000003.14152 000003.14152
+DROP TABLE t1;
create table t1 (f1 double(200, 0));
insert into t1 values (1e199), (-1e199);
insert into t1 values (1e200), (-1e200);
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index a55200c8853..ed3abb12140 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -224,6 +224,22 @@ create table t1 (s1 float(0,2));
create table t1 (s1 float(1,2));
#
+# MySQL Bugs: #11589: mysqltest --ps-protocol, strange output, float/double/real with zerofill
+#
+
+CREATE TABLE t1 (
+ f1 real zerofill,
+ f2 double zerofill,
+ f3 float zerofill);
+INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1);
+
+let $my_stmt= select f1, f2, f3 FROM t1;
+eval PREPARE stmt1 FROM '$my_stmt';
+select f1, f2, f3 FROM t1;
+eval $my_stmt;
+EXECUTE stmt1;
+
+DROP TABLE t1;
# Bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits"
#