Bug #43451 Wrong varchar to decimal conversion
Submitted: 6 Mar 2009 10:28 Modified: 6 Mar 2009 11:35
Reporter: Øystein Grøvlen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.0, 5.1, 6.0 bzr OS:Linux
Assigned to: CPU Architecture:Any
Tags: regression

[6 Mar 2009 10:28] Øystein Grøvlen
Description:
The following behavior seems wrong:

mysql> create table t (s varchar(10), i integer, f real, d decimal(5,2));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values ('1F1', '1F1', '1F1', '1F1');
Query OK, 1 row affected, 3 warnings (0.00 sec)

mysql> insert into t values ('1EF1', '1EF1', '1EF1', '1EF1');
Query OK, 1 row affected, 3 warnings (0.00 sec)

mysql> insert into t values ('1E1', '1E1', '1E1', '1E1');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t;
+------+------+------+-------+
| s    | i    | f    | d     |
+------+------+------+-------+
| 1F1  |    1 |    1 |  1.00 | 
| 1EF1 |    1 |    1 |  0.00 | 
| 1E1  |   10 |   10 | 10.00 | 
+------+------+------+-------+
3 rows in set (0.00 sec)

I would expect '1EF1' to give 1.00 in the decimal column.

How to repeat:
See above.
[6 Mar 2009 11:35] Sveta Smirnova
Thank you for the report.

Verified as described. In version 4.1 1.0 was in the decimal column.