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

CEILING() and FLOOR() convert temporal input to numbers, unlike ROUND() and TRUNCATE()

    XMLWordPrintable

Details

    Description

      Under terms of MDEV-20397 we modified functions ROUND() and TRUNCATE() to handle the TIME, DATETIME, TIMESTAMP data types correctly:

      SELECT ROUND(time'00:00:01.9'), TRUNCATE(TIMESTAMP'2001-01-01 00:00:01.9',0);
      

      +-------------------------+----------------------------------------------+
      | ROUND(time'00:00:01.9') | TRUNCATE(TIMESTAMP'2001-01-01 00:00:01.9',0) |
      +-------------------------+----------------------------------------------+
      | 00:00:02                | 2001-01-01 00:00:01                          |
      +-------------------------+----------------------------------------------+
      

      But the functions CEILING() and FLOOR() still convert temporal data types to numbers:

      SELECT CEILING(time'00:00:01.9'), FLOOR(TIMESTAMP'2001-01-01 00:00:01.9');
      

      +---------------------------+-----------------------------------------+
      | CEILING(time'00:00:01.9') | FLOOR(TIMESTAMP'2001-01-01 00:00:01.9') |
      +---------------------------+-----------------------------------------+
      |                         2 |                          20010101000001 |
      +---------------------------+-----------------------------------------+
      

      CEILING() and FLOOR() should be fixed to return TIME (for TIME input) and DATETIME (for DATETIME and TIMESTAMP input), like ROUND() and TRUNCATE() do.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.