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

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            Assignee Alexander Barkov [ bar ]
            bar Alexander Barkov made changes -
            Summary MAKETIME does not preserve microseconds Some temporal functions do not preserve microseconds
            bar Alexander Barkov made changes -
            Description The function MAKETIME() in MariaDB does not preserve fractional digits:

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

            It works as expected in MySQL-5.6:

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

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

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

            It works as expected in MySQL-5.6:

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

            More examples:
            {code:sql}
            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)
            {code}
            The expected column type is time(0).
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.5 [ 13201 ]
            Fix Version/s 5.5.33 [ 13300 ]
            bar Alexander Barkov made changes -
            Description The function MAKETIME() in MariaDB does not preserve fractional digits:

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

            It works as expected in MySQL-5.6:

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

            More examples:
            {code:sql}
            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)
            {code}
            The expected column type is time(0).
            The function MAKETIME() in MariaDB does not preserve fractional digits:

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

            It works as expected in MySQL-5.6:

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

            {code}
            MariaDB [test]> SELECT MAKETIME(0, 0, 59.9);
            +----------------------+
            | MAKETIME(0, 0, 59.9) |
            +----------------------+
            | NULL |
            +----------------------+
            {code}
            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:
            {code:sql}
            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)
            {code}
            The expected column type is time(0).
            bar Alexander Barkov made changes -
            Description The function MAKETIME() in MariaDB does not preserve fractional digits:

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

            It works as expected in MySQL-5.6:

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

            {code}
            MariaDB [test]> SELECT MAKETIME(0, 0, 59.9);
            +----------------------+
            | MAKETIME(0, 0, 59.9) |
            +----------------------+
            | NULL |
            +----------------------+
            {code}
            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:
            {code:sql}
            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)
            {code}
            The expected column type is time(0).
            The function MAKETIME() in MariaDB does not preserve fractional digits:

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

            It works as expected in MySQL-5.6:

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

            A possibly related problem:
            {code}
            MariaDB [test]> SELECT MAKETIME(0, 0, 59.9);
            +----------------------+
            | MAKETIME(0, 0, 59.9) |
            +----------------------+
            | NULL |
            +----------------------+
            {code}
            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:
            {code:sql}
            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)
            {code}
            The expected column type is time(0).

            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
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Priority Major [ 3 ] Minor [ 4 ]

            Fixed in 5.5.31, 5.3.12

            bar Alexander Barkov added a comment - Fixed in 5.5.31, 5.3.12
            bar Alexander Barkov made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            bar Alexander Barkov made changes -
            serg Sergei Golubchik made changes -
            Workflow defaullt [ 27768 ] MariaDB v2 [ 44612 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Workflow MariaDB v2 [ 44612 ] MariaDB v3 [ 61757 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 61757 ] MariaDB v4 [ 146818 ]

            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.