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

GREATEST(date, time) returns a wrong data type

    Details

    • Sprint:
      10.1.8-4

      Description

      GREATEST and COALESCE return different data types
      for a combination of TIME and DATE parameters:

      mysql> SELECT GREATEST(CURRENT_TIME, CURRENT_DATE), COALESCE(CURRENT_TIME, CURRENT_DATE);
      +--------------------------------------+--------------------------------------+
      | GREATEST(CURRENT_TIME, CURRENT_DATE) | COALESCE(CURRENT_TIME, CURRENT_DATE) |
      +--------------------------------------+--------------------------------------+
      | 838:59:59                            | 0000-00-00 16:24:54                  |
      +--------------------------------------+--------------------------------------+
      1 row in set, 1 warning (0.00 sec)
      
      mysql> show warnings;
      +---------+------+----------------------------------------------+
      | Level   | Code | Message                                      |
      +---------+------+----------------------------------------------+
      | Warning | 1292 | Truncated incorrect time value: '1944:00:00' |
      +---------+------+----------------------------------------------+
      1 row in set (0.00 sec)
      

      GREATEST returns TIME, which looks wrong.

      COALESCE return DATETIME, which looks more correct.
      (DATETIME is a minumal common type for DATE and TIME).

      GREATEST should be fixed to return DATETIME as well.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bar Alexander Barkov added a comment -

            MySQL-5.7.8 is not affected.

            Show
            bar Alexander Barkov added a comment - MySQL-5.7.8 is not affected.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Agile