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

Some temporal functions do not preserve microseconds

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.0.4, 5.5.31, 5.3.12
    • 10.0.5, 5.5.33
    • None
    • None

    Description

      The function MAKETIME() in MariaDB does not preserve fractional digits:

      MariaDB [test]> SELECT MAKETIME(10,10,10.231);
      +------------------------+
      | MAKETIME(10,10,10.231) |
      +------------------------+
      | 10:10:10               |
      +------------------------+
      1 row in set (0.00 sec)

      It works as expected in MySQL-5.6:

      MySQL [test]> SELECT MAKETIME(10,10,10.231);
      +------------------------+
      | MAKETIME(10,10,10.231) |
      +------------------------+
      | 10:10:10.231           |
      +------------------------+
      1 row in set (0.00 sec)

      A possibly related problem:

      MariaDB [test]> SELECT MAKETIME(0, 0, 59.9);
      +----------------------+
      | MAKETIME(0, 0, 59.9) |
      +----------------------+
      | NULL                 |
      +----------------------+

      The above result is wrong.
      It seems 59.9 is rounded to 60, which makes a wrong time '00:00:60', hence NULL.
      The expected result is '00:00:59.9'.

      More examples:

      MariaDB [test]> drop table if exists t1; create table t1 as select time('10:00:00'); show create table t1;
      Query OK, 0 rows affected (0.00 sec)
      Query OK, 1 row affected (0.10 sec)
      Records: 1  Duplicates: 0  Warnings: 0
      +-------+------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                         |
      +-------+------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `time('10:00:00')` time(6) DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
      +-------+------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)

      The expected column type is time(0).

      Attachments

        Issue Links

          Activity

            for maketime it was kind of intentional. it used to take three integers, and it still does. feel free to change it, if you'd like.

            the second issue is a duplicate of MDEV-3922

            serg Sergei Golubchik added a comment - for maketime it was kind of intentional. it used to take three integers, and it still does. feel free to change it, if you'd like. the second issue is a duplicate of MDEV-3922

            Fixed in 5.5.31, 5.3.12

            bar Alexander Barkov added a comment - Fixed in 5.5.31, 5.3.12

            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.