List:Commits« Previous MessageNext Message »
From:msvensson Date:February 21 2006 1:56pm
Subject:bk commit into 5.0 tree (msvensson:1.2020) BUG#11589
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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.2020 06/02/21 14:55:54 msvensson@neptunus.(none) +3 -0
  Bug#11589 mysqltest, --ps-protocol, strange output, float/double/real with zerofill
   - Add zerofill in client if real/float/double is bound to string and fetched using binary protocol.

  mysql-test/t/type_float.test
    1.28 06/02/21 14:55:50 msvensson@neptunus.(none) +18 -0
    Add test for zerofill and prepared statments

  mysql-test/r/type_float.result
    1.43 06/02/21 14:55:50 msvensson@neptunus.(none) +16 -0
    Update test for zerofill

  libmysql/libmysql.c
    1.231 06/02/21 14:55:50 msvensson@neptunus.(none) +9 -1
    Add zerofill before value if column is created with zerofill 

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/bug11589/my50-bug11589

--- 1.230/libmysql/libmysql.c	2005-08-04 13:25:02 +02:00
+++ 1.231/libmysql/libmysql.c	2006-02-21 14:55:50 +01:00
@@ -3850,7 +3850,15 @@
       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;
   }
   }

--- 1.42/mysql-test/r/type_float.result	2005-10-11 13:38:16 +02:00
+++ 1.43/mysql-test/r/type_float.result	2006-02-21 14:55:50 +01:00
@@ -244,3 +244,19 @@
 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;

--- 1.27/mysql-test/t/type_float.test	2005-10-11 11:43:51 +02:00
+++ 1.28/mysql-test/t/type_float.test	2006-02-21 14:55:50 +01:00
@@ -169,3 +169,21 @@
 create table t1 (s1 float(0,2));
 --error 1427
 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;
Thread
bk commit into 5.0 tree (msvensson:1.2020) BUG#11589msvensson21 Feb