[MDEV-5697] Incosistent warnings from CAST(AS DATETIME) for different field types Created: 2014-02-18  Updated: 2017-11-05

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.6
Fix Version/s: 10.2

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


 Description   

This SQL script

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, b REAL, c DECIMAL(20,6), d TIME,e CHAR(30));
INSERT INTO t1 VALUES (-1,-1,-1,'-800:10:10','-800:10:10');
SELECT CAST(a AS DATETIME) AS a, CAST(b AS DATETIME) AS b, CAST(c AS DATETIME) AS c,
CAST(d AS DATETIME) AS d, CAST(e AS datetime) AS e FROM t1;
SHOW WARNINGS;

returns NULL for all columns:

+------+------+------+------+------+
| a    | b    | c    | d    | e    |
+------+------+------+------+------+
| NULL | NULL | NULL | NULL | NULL |
+------+------+------+------+------+
1 row in set, 5 warnings (0.00 sec)

which is OK.

But the warnings returned are different:

+---------+------+--------------------------------------------------------+
| Level   | Code | Message                                                |
+---------+------+--------------------------------------------------------+
| Warning | 1292 | Incorrect datetime value: '-1'                         |
| Warning | 1292 | Incorrect datetime value: '-1' for column 'b' at row 1 |
| Warning | 1292 | Incorrect datetime value: '-1.000000'                  |
| Warning | 1292 | Truncated incorrect datetime value: '-800:10:10'       |
| Warning | 1292 | Incorrect datetime value: '-800:10:10'                 |
+---------+------+--------------------------------------------------------+
5 rows in set (0.00 sec)

Notice three different warning versions.

This should probably be fixed to return the same warning
for all column types.



 Comments   
Comment by Alexander Barkov [ 2014-02-18 ]

There should not be field names (field names should be printed only on INSERT/UPDATE).

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