[MDEV-5712] Inconsistent warnings when inserting a DATETIME-alike data into a TIME column Created: 2014-02-21  Updated: 2022-11-01  Resolved: 2022-11-01

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 5.1.67, 5.2.14, 5.3.12, 5.5.36, 10.0.10
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.03 sec)
 
mysql> CREATE TABLE t1 (from_str TIME, from_int TIME,from_dec TIME, from_double TIME);
Query OK, 0 rows affected (0.15 sec)
 
mysql> INSERT INTO t1 VALUES ('2001-01-01 10:20:30',20010101102030,20010101102030.0,20010101102030e0);
Query OK, 1 row affected, 4 warnings (0.01 sec)
 
mysql> SHOW WARNINGS;
+---------+------+--------------------------------------------------+
| Level   | Code | Message                                          |
+---------+------+--------------------------------------------------+
| Note    | 1265 | Data truncated for column 'from_str' at row 1    |
| Warning | 1265 | Data truncated for column 'from_int' at row 1    |
| Warning | 1265 | Data truncated for column 'from_dec' at row 1    |
| Warning | 1265 | Data truncated for column 'from_double' at row 1 |
+---------+------+--------------------------------------------------+
4 rows in set (0.00 sec)
 
mysql> SELECT * FROM t1;
+----------+----------+----------+-------------+
| from_str | from_int | from_dec | from_double |
+----------+----------+----------+-------------+
| 10:20:30 | 10:20:30 | 10:20:30 | 10:20:30    |
+----------+----------+----------+-------------+
1 row in set (0.00 sec)

Notice, string gives a note while the numeric types give warnings.

A note seems to be the most appropriate in all cases.



 Comments   
Comment by Sergei Golubchik [ 2014-02-21 ]

what versions are affected?

Comment by Elena Stepanova [ 2014-04-11 ]

All MariaDB versions are affected, although in a different way.
5.3, 5.5, 10.0 produce the result from the description.

5.1 and 5.2 (and MySQL 5.5) produce the following:

+---------+------+------------------------------------------------------+
| Level   | Code | Message                                              |
+---------+------+------------------------------------------------------+
| Warning | 1264 | Out of range value for column 'from_int' at row 1    |
| Warning | 1264 | Out of range value for column 'from_dec' at row 1    |
| Warning | 1264 | Out of range value for column 'from_double' at row 1 |
+---------+------+------------------------------------------------------+
 
MariaDB [test]> SELECT * FROM t1;
+----------+-----------+-----------+-------------+
| from_str | from_int  | from_dec  | from_double |
+----------+-----------+-----------+-------------+
| 10:20:30 | 838:59:59 | 838:59:59 | 838:59:59   |
+----------+-----------+-----------+-------------+

MySQL 5.6 returns 'Note' and '10:20:30' for all columns.

Comment by Sergei Golubchik [ 2022-11-01 ]

fixed before 10.3.37

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