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

TO_DATE: DATETIME(6) instead of DATETIME(0) when format is read from a table

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Not a Bug
    • N/A
    • N/A
    • Server
    • None
    • Not for Release Notes

    Description

      The review notes said that TO_DATE should return DATETIME(0) (and there is also FF extension to get fractional seconds). However, if the format is read from a table instead of a constant, the function returns DATETIME(6) even without FF:

      CREATE TABLE t (fmt VARCHAR(64));
      INSERT INTO t VALUES ('YYYY-MM-DD');
      SELECT TO_DATE('2026-01-01', fmt) FROM t;
      SELECT TO_DATE('2026-01-01', 'YYYY-MM-DD') FROM t;
      

      bb-12.3-MDEV-19683-to_date 7cbf7a8c641379d4318067607b71704956e87e5e

      SELECT TO_DATE('2026-01-01', fmt) FROM t;
      TO_DATE('2026-01-01', fmt)
      2026-01-01 00:00:00.000000
      SELECT TO_DATE('2026-01-01', 'YYYY-MM-DD') FROM t;
      TO_DATE('2026-01-01', 'YYYY-MM-DD')
      2026-01-01 00:00:00
      

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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