MariaDB Development
  1. MariaDB Development
  2. MDEV-4724

Some temporal functions do not preserve microseconds

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.4, 5.5.31, 5.3.12
    • Fix Version/s: 10.0.5, 5.5.33
    • Labels:
      None
    • Global Rank:
      3256

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

        Issue Links

          Activity

          Hide
          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

          Show
          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
          Hide
          Alexander Barkov added a comment -

          Fixed in 5.5.31, 5.3.12

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: