Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5690

No warning when comparing a DATETIME column to a negative TIME value

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0.8
    • Fix Version/s: 10.0
    • Component/s: None
    • 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.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: