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

TIME_ROUND_FRACTIONAL is not respected on TIME->BIGINT conversion

    XMLWordPrintable

Details

    Description

      MySQL rounds fractional seconds on implicit TIME->BIGINT conversion and on explicit CAST:

      SET sql_mode=''; -- MySQL rounds by default
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a BIGINT);
      INSERT INTO t1 VALUES (TIME'-00:00:01.6');
      SELECT a, CAST(TIME'-00:00:01.6' AS SIGNED) FROM t1;
      

      +------+-----------------------------------+
      | a    | CAST(TIME'-00:00:01.6' AS SIGNED) |
      +------+-----------------------------------+
      |   -2 |                                -2 |
      +------+-----------------------------------+
      

      MariaDB truncates:

      SET sql_mode='TIME_ROUND_FRACTIONAL';
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a BIGINT);
      INSERT INTO t1 VALUES (TIME'-00:00:01.6');
      SELECT a, CAST(TIME'-00:00:01.6' AS SIGNED) FROM t1;
      

      +------+-----------------------------------+
      | a    | CAST(TIME'-00:00:01.6' AS SIGNED) |
      +------+-----------------------------------+
      |   -1 |                                -1 |
      +------+-----------------------------------+
      

      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:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.