[MDEV-5690] No warning when comparing a DATETIME column to a negative TIME value Created: 2014-02-17  Updated: 2022-11-01  Resolved: 2022-11-01

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.0.8
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

If I compare a DATETIME column to a negative TIME value,
it does not print any warnings:

mysql> drop table if exists t1; create table t1 (f1 datetime, key (f1));  insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49'); select * from t1 where f1 > time('-00:00:01'); 
Query OK, 0 rows affected (0.05 sec)
 
Query OK, 0 rows affected (0.18 sec)
 
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
+---------------------+
| f1                  |
+---------------------+
| 2000-09-12 00:00:00 |
| 2007-04-25 05:08:49 |
+---------------------+
2 rows in set (0.00 sec)

At the same time it does print warnings for negative number:

mysql> select * from t1 where f1 > -1;
+---------------------+
| f1                  |
+---------------------+
| 2000-09-12 00:00:00 |
| 2007-04-25 05:08:49 |
+---------------------+
2 rows in set, 1 warning (0.00 sec)
 
mysql> show warnings;
+---------+------+--------------------------------+
| Level   | Code | Message                        |
+---------+------+--------------------------------+
| Warning | 1292 | Incorrect datetime value: '-1' |
+---------+------+--------------------------------+
1 row in set (0.00 sec)

Comparison to TIME should be fixed to print the warning.


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