Bug #68192 Limitation on DOUBLE or REAL length is ignored with INSERT .. SELECT
Submitted: 27 Jan 2013 20:52 Modified: 28 Jan 2013 15:39
Reporter: Elena Stepanova Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.1, 5.5, 5.6.9 OS:Any
Assigned to: CPU Architecture:Any
Triage: Needs Triage: D2 (Serious)

[27 Jan 2013 20:52] Elena Stepanova
Description:
Sorry if it's a duplicate. I have a feeling that it was filed before, but I couldn't find it. 

CREATE TABLE t1 (d1 DOUBLE(5,2), d2 DOUBLE(10,2)) ENGINE=InnoDB;

INSERT INTO t1 VALUES (10000000.55, 10000000.55);
Warnings:
Warning	1264	Out of range value for column 'd1' at row 1

# As expected, d1 is truncated:

SELECT * FROM t1;
d1	d2
999.99	10000000.55

INSERT INTO t1 SELECT d2, d2 FROM t1;

# Now d1 is not truncated, and no warnings:

SELECT * FROM t1;
d1	d2
999.99	10000000.55
10000000.55	10000000.55

How to repeat:
CREATE TABLE t1 (d1 DOUBLE(5,2), d2 DOUBLE(10,2)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (10000000.55, 10000000.55);
INSERT INTO t1 SELECT d2, d2 FROM t1;
SELECT * FROM t1;
[28 Jan 2013 14:14] Valeriy Kravchuk
This is really easy to verify:

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot -proot -P3312 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE TABLE t1 (d1 DOUBLE(5,2), d2 DOUBLE(10,2)) ENGINE=InnoDB;
Query OK, 0 rows affected (0.11 sec)

mysql> set session sql_mode='';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 VALUES (10000000.55, 10000000.55);
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> show warnings\G
*************************** 1. row ***************************
  Level: Warning
   Code: 1264
Message: Out of range value for column 'd1' at row 1
1 row in set (0.00 sec)

mysql> INSERT INTO t1 SELECT d2, d2 FROM t1;
Query OK, 1 row affected (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM t1;
+-------------+-------------+
| d1          | d2          |
+-------------+-------------+
|      999.99 | 10000000.55 |
| 10000000.55 | 10000000.55 |
+-------------+-------------+
2 rows in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.5.29    |
+-----------+
1 row in set (0.00 sec)

I was not able to find the duplicate you mentioned based on quick search. Maybe others will be more lucky with search.
[28 Jan 2013 15:39] Miguel Solorzano
Thank you for the bug report.