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

CAST silently accepts compact date ending in T without warning 1292

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 12.3, 13.1, 12.3.3
    • 12.3, 13.1
    • Data types
    • MariaDB 12.3.3 on Linux x86_64

    Description

      MariaDB 12.3.3 silently accepts the incomplete compact date string '20010101T' in permissive mode. CAST(... AS DATE) returns 2001-01-01 without warning 1292, although the equivalent delimited form '2001-01-01T' produces that warning.

      Reproduction

      Save the following four files and run each in a fresh client session. Separate sessions are necessary because earlier diagnostics can otherwise remain visible after later table-free statements.

      compact.sql:

      SET sql_mode='';
      SELECT CAST('20010101T' AS DATE) AS parsed_value;
      SHOW WARNINGS;

      delimited.sql:

      SET sql_mode='';
      SELECT CAST('2001-01-01T' AS DATE) AS parsed_value;
      SHOW WARNINGS;

      valid.sql:

      SET sql_mode='';
      SELECT CAST('20010101T010203' AS DATETIME) AS parsed_value;
      SHOW WARNINGS;

      date_only.sql:

      SET sql_mode='';
      SELECT CAST('20010101' AS DATE) AS parsed_value;
      SHOW WARNINGS;

      Run the files with:

      mariadb < compact.sql
      mariadb < delimited.sql
      mariadb < valid.sql
      mariadb < date_only.sql

      Decisive observation

      The incomplete compact form returns a date and no warnings:

      parsed_value
      2001-01-01

      The incomplete delimited form returns the same date but reports the expected diagnostic:

      parsed_value
      2001-01-01
      Level    Code  Message
      Warning  1292  Truncated incorrect date value: '2001-01-01T'

      The two valid controls produce no warnings:

      '20010101T010203' -> 2001-01-01 01:02:03
      '20010101'        -> 2001-01-01

      Semantic mismatch

      The trailing T denotes a date-time separator, but '20010101T' contains no time component after it. In permissive mode, both incomplete forms should report warning 1292; preserving the parsed date is not itself the defect. The valid compact datetime and compact date-only forms should continue to produce no warnings.

      This occurs when an incomplete compact date ends with the date-time separator T but contains no following time component.

      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.