[MDEV-4102] Limitation on DOUBLE or REAL length is ignored with INSERT .. SELECT Created: 2013-01-27  Updated: 2016-03-14  Resolved: 2016-03-14

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0.0, 5.5.28a, 5.3.11, 5.2.13, 5.1.66
Fix Version/s: 10.2.0

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: upstream

Issue Links:
Relates
relates to MDEV-9709 Unexpected modification of value and ... Closed

 Description   

The problem is also reproducible on MySQL 5.1-5.6 and filed as http://bugs.mysql.com/bug.php?id=68192

A DOUBLE (or REAL) column definition has a limitation on the total number of digits. It's honored when values are inserted explicitly, but not on INSERT .. SELECT:

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

Reproducible on 5.1-10.0.

Test case:

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;



 Comments   
Comment by Alexander Barkov [ 2016-03-14 ]

The bug is repeatable with other ENGINE types, e.g. MyISAM.

Generated at Thu Feb 08 06:53:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.