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

GREATEST(date, time) returns a wrong data type

    XMLWordPrintable

Details

    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.