[MDEV-8897] Integer type columns silently truncate fractional digits Created: 2015-10-05  Updated: 2018-06-13

Status: Open
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 5.5, 10.0, 10.1, 10.3.4, 10.2
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: upstream


 Description   

This script:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10.1)

produces no warnings or notes though truncation happens.

The DECIMAL data type in the same scenario does produce a note:

 DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(10,0));
INSERT INTO t1 VALUES (10.1);
SHOW WARNINGS;

+-------+------+----------------------------------------+
| Level | Code | Message                                |
+-------+------+----------------------------------------+
| Note  | 1265 | Data truncated for column 'a' at row 1 |
+-------+------+----------------------------------------+

CAST from DECIMAL to INT on SELECT also does not produce warnings:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(10,1));
INSERT INTO t1 VALUES (10.1);
SELECT CAST(a AS SIGNED) FROM t1;



 Comments   
Comment by Alexander Barkov [ 2015-10-05 ]

Repeatable in MySQL-5.7

Generated at Thu Feb 08 07:30:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.