[MDEV-8490] INT,DOUBLE,DECIMAL produce different warnings on comparison Created: 2015-07-17  Updated: 2019-11-18

Status: Open
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

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

Epic Link: Data type cleanups

 Description   

Update:

  • In versions 5.5 and 10.0 it works as described below
  • In versions 10.1, 10.2, 10.3, 10.4 there are no warnings produced for all data types. Looks wrong. One warning is expected.

This script with INT data type:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (0),(10),(20),(30);
SELECT * FROM t1 WHERE a='x';
SHOW WARNINGS;

returns no warnings.

So does the same script with DOUBLE:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DOUBLE, KEY(a));
INSERT INTO t1 VALUES (0),(10),(20),(30);
SELECT * FROM t1 WHERE a='x'; SHOW WARNINGS;

The script with DECIMAL works differently:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL, KEY(a));
INSERT INTO t1 VALUES (0),(10),(20),(30);
SELECT * FROM t1 WHERE a='x';
SHOW WARNINGS;

It returns a number of warnings, some of them are obviously redundant:

+---------+------+------------------------------------------------------+
| Level   | Code | Message                                              |
+---------+------+------------------------------------------------------+
| Warning | 1366 | Incorrect decimal value: 'x' for column 'a' at row 1 |
| Warning | 1366 | Incorrect decimal value: 'x' for column 'a' at row 1 |
| Warning | 1366 | Incorrect decimal value: 'x' for column 'a' at row 1 |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'x'                |
+---------+------+------------------------------------------------------+
4 rows in set (0.00 sec)

With an empty string INT and DOUBLE produce no warnings:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (0),(10),(20),(30);
SELECT * FROM t1 WHERE a='';
SHOW WARNINGS;

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DOUBLE, KEY(a));
INSERT INTO t1 VALUES (0),(10),(20),(30);
SELECT * FROM t1 WHERE a='';
SHOW WARNINGS;

while DECIMAL:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL, KEY(a));
INSERT INTO t1 VALUES (0),(10),(20),(30);
SELECT * FROM t1 WHERE a='';
SHOW WARNINGS;

produces a number of similar warnings:

+---------+------+-----------------------------------------------------+
| Level   | Code | Message                                             |
+---------+------+-----------------------------------------------------+
| Warning | 1366 | Incorrect decimal value: '' for column 'a' at row 1 |
| Warning | 1366 | Incorrect decimal value: '' for column 'a' at row 1 |
| Warning | 1366 | Incorrect decimal value: '' for column 'a' at row 1 |
+---------+------+-----------------------------------------------------+



 Comments   
Comment by Daniel Black [ 2016-05-13 ]

So it seems the correct response is a single 1366 warning in all cases?

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