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

TO_DATE accepts conflicting AD and BC era elements instead of rejecting the format

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 12.3, 13.1, 12.3.3
    • 12.3, 13.1
    • Data types, Temporal Types
    • None
    • Linux x86_64; MariaDB 12.3.3 binary distribution

    Description

      In Oracle mode, TO_DATE accepts formats containing both AD and BC even though both elements populate the same era field. The conflicting formats return a date instead of reporting an invalid-format error. This was observed with literal formats in either order and with row-dependent formats on MariaDB 12.3.3.

      Reproducer

      Run the following statements in order:

      SET sql_mode='ORACLE';
      SET lc_time_names='en_US';
      SELECT TO_DATE('2024-01-02 AD AD', 'YYYY-MM-DD AD BC') AS value;
       
      SET sql_mode='ORACLE';
      SET lc_time_names='en_US';
      SELECT TO_DATE('2024-01-02 AD AD', 'YYYY-MM-DD BC AD') AS value;
       
      SET sql_mode='ORACLE';
      SET lc_time_names='en_US';
      SELECT TO_DATE('2024-01-02 AD AD', f) AS value
      FROM (
        SELECT 'YYYY-MM-DD AD BC' AS f
        UNION ALL
        SELECT 'YYYY-MM-DD BC AD'
      ) AS formats;

      Decisive observation

      All three statements complete successfully. The two literal cases each return:

      value
      2024-01-02 00:00:00

      The row-dependent case returns:

      value
      2024-01-02 00:00:00.000000
      2024-01-02 00:00:00.000000

      There is no error output.

      Semantic mismatch

      AD and BC both describe the era of the same date value, so they are conflicting elements when combined in one input format. MariaDB already rejects repeated same-spelling era elements such as AD AD and BC BC with error 3047, "date format not recognized". Mixed AD BC and BC AD combinations should be rejected by the same family-level validation rather than being accepted because their spellings differ.

      A single era element remains valid and returns 2024-01-02 00:00:00 for the demonstrated AD input. BC date representability is not involved here because the input uses AD indicators.

      This occurs when TO_DATE parses an input format containing both AD and BC era elements, including when the format is supplied per row.

      Attachments

        Issue Links

          Activity

            People

              raghunandan.bhat Raghunandan Bhat
              noob liu
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.