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

Inconsistent between implicit and explicit conversion from DATETIME to TIME

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.3.12, 5.5.35, 10.0.8
    • Fix Version/s: 10.0, 5.5
    • Component/s: None
    • Labels:
      None

      Description

      There is a difference between explicit and implicit
      DATETIME->TIME conversion when using a datetime
      with zero year and month and non-zero day:

      mysql> DROP TABLE IF EXISTS t1;
      Query OK, 0 rows affected (0.08 sec)
      
      mysql> CREATE TABLE t1 (a TIME);
      Query OK, 0 rows affected (0.18 sec)
      
      mysql> INSERT INTO t1 VALUES (TIMESTAMP'0000-00-01 10:20:30');
      Query OK, 1 row affected (0.01 sec)
      
      mysql> SELECT  * FROM t1;
      +----------+
      | a        |
      +----------+
      | 34:20:30 |
      +----------+
      1 row in set (0.00 sec)
      
      mysql> SELECT CAST(TIMESTAMP'0000-00-01 10:20:30' AS TIME);
      +----------------------------------------------+
      | CAST(TIMESTAMP'0000-00-01 10:20:30' AS TIME) |
      +----------------------------------------------+
      | 10:20:30                                     |
      +----------------------------------------------+
      1 row in set (0.01 sec)
      

      Notice, implicit conversion adds days to hours, while
      explicit does not.

      Implicit conversion should not add days to hours.

      The problem also presents in the upstream.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            what versions are affected?

            Show
            serg Sergei Golubchik added a comment - what versions are affected?

              People

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

                Dates

                • Created:
                  Updated: