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

STR_TO_DATE is inconsistent regarding precision

    Details

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

      Description

      This SQL script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (date VARCHAR(32), format VARCHAR(30));
      INSERT INTO t1 VALUES ('2003-01-02 10:11:12','%Y-%m-%d %H:%i:%S');
      SELECT str_to_date(date, format) AS a, coalesce(str_to_date(date, format)) AS b FROM t1;
      

      returns the following results:

      +---------------------+----------------------------+
      | a                   | b                          |
      +---------------------+----------------------------+
      | 2003-01-02 10:11:12 | 2003-01-02 10:11:12.000000 |
      +---------------------+----------------------------+
      

      Notice, "a" returns 0 fractional digits, while "b" returns 6 fractional digits.

      The data type for the both expressions is DATETIME(6).
      "a" should return 6 digits, like "b" does.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

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

                Dates

                • Created:
                  Updated: