Bug #42791 EQ condition with invalid date gives double warnings
Description:
A comparison with an invalid data in a table, where there are rows, will issue 2 warnings. This is only true for eq comparisons, not for greater than or anything else.
How to repeat:
mysql> select @@sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> create table tab1(c1 date);
Query OK, 0 rows affected (0.00 sec)
mysql> select * from tab1 where c1 = '0000-00-00';
Empty set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------+
| Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 |
+---------+------+-------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select * from tab1 where c1 < '0000-00-00';
Empty set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------+
| Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 |
+---------+------+-------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> insert into tab1 values('2009-01-01');
Query OK, 1 row affected (0.00 sec)
mysql> select * from tab1 where c1 = '0000-00-00';
Empty set, 2 warnings (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------+
| Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 |
| Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 |
+---------+------+-------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> select * from tab1 where c1 < '0000-00-00';
Empty set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------+
| Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 |
+---------+------+-------------------------------------------------------------+
1 row in set (0.00 sec)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: A comparison with an invalid data in a table, where there are rows, will issue 2 warnings. This is only true for eq comparisons, not for greater than or anything else. How to repeat: mysql> select @@sql_mode; +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | @@sql_mode | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> create table tab1(c1 date); Query OK, 0 rows affected (0.00 sec) mysql> select * from tab1 where c1 = '0000-00-00'; Empty set, 1 warning (0.00 sec) mysql> show warnings; +---------+------+-------------------------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------------------------+ | Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 | +---------+------+-------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select * from tab1 where c1 < '0000-00-00'; Empty set, 1 warning (0.00 sec) mysql> show warnings; +---------+------+-------------------------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------------------------+ | Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 | +---------+------+-------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> insert into tab1 values('2009-01-01'); Query OK, 1 row affected (0.00 sec) mysql> select * from tab1 where c1 = '0000-00-00'; Empty set, 2 warnings (0.00 sec) mysql> show warnings; +---------+------+-------------------------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------------------------+ | Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 | | Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 | +---------+------+-------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> select * from tab1 where c1 < '0000-00-00'; Empty set, 1 warning (0.00 sec) mysql> show warnings; +---------+------+-------------------------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------------------------+ | Warning | 1292 | Incorrect date value: '0000-00-00' for column 'c1' at row 1 | +---------+------+-------------------------------------------------------------+ 1 row in set (0.00 sec)