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

Microseconds do not work in INTERVAL definition, a value with a fractional part gets rounded

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a Bug
    • Affects Version/s: 5.5.25
    • Fix Version/s: 5.5.27
    • Component/s: None
    • Labels:
      None

      Description

      I presume it also affects 5.3, but I didn't check.

      create table t1 (d datetime(6));
      insert into t1 values ('2012-12-12 00:00:00');
      update t1 set d = adddate(d, interval 1.5 second);
      select * from t1;
      

      MySQL 5.6 result:

      +----------------------------+
      | d                          |
      +----------------------------+
      | 2012-12-12 00:00:01.500000 |
      +----------------------------+
      

      MariaDB result:

      +----------------------------+
      | d                          |
      +----------------------------+
      | 2012-12-12 00:00:02.000000 |
      +----------------------------+
      

      I think that MySQL result is reasonable for a server which supports fractional seconds, although https://kb.askmonty.org/en/microseconds-in-mariadb/ does not explicitly specify that microseconds support is supposed to work in this case.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            It is intentional.
            To create an interval with microseconds, one should use, for example
            ... + INTERVAL 1.5 SECOND_MICROSECOND
            or any other interval type that supports microseconds, one of MINUTE_MICROSECOND, HOUR_MICROSECOND, DAY_MICROSECOND.

            But for compatibility reasons we will support MySQL-5.6 behavior too, in MariaDB-10.x branch.

            Show
            serg Sergei Golubchik added a comment - It is intentional. To create an interval with microseconds, one should use, for example ... + INTERVAL 1.5 SECOND_MICROSECOND or any other interval type that supports microseconds, one of MINUTE_MICROSECOND, HOUR_MICROSECOND, DAY_MICROSECOND. But for compatibility reasons we will support MySQL-5.6 behavior too, in MariaDB-10.x branch.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: