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

TO_DATE: Date strings with non-ASCII symbols cause warnings and wrong results

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • N/A
    • 12.3.1
    • Server
    • None
    • Not for Release Notes
    • Q1/2026 Server Maintenance

    Description

      Non-ASCII symbols in e.g. month names with corresponding NLS_DATE_LANGUAGEs don't appear to be working, or at least I can't make them work, and can't find any example in MTR tests.

      bb-12.3-MDEV-19683-to_date f45636ea81a5a02444833e993e47c262ed52f384

      MariaDB [test]> set names utf8mb3;
      Query OK, 0 rows affected (0.001 sec)
       
      MariaDB [test]> SELECT TO_DATE('15 Heinäkuu 2024','DD MONTH YYYY','NLS_DATE_LANGUAGE=FINNISH') AS x FROM DUAL;
      +------+
      | x    |
      +------+
      | NULL |
      +------+
      1 row in set, 1 warning (0.001 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+--------------------------------------------------------------------+
      | Level   | Code | Message                                                            |
      +---------+------+--------------------------------------------------------------------+
      | Warning | 1411 | Incorrect datetime value: '15 Heinäkuu 2024' for function to_date  |
      +---------+------+--------------------------------------------------------------------+
      1 row in set (0.001 sec)
      

      When the month name is used alone (or is the last element), it is parsed, but the warning still occurs:

      MariaDB [test]> SELECT TO_DATE('Heinäkuu','MONTH','NLS_DATE_LANGUAGE=FINNISH') AS x;
      +---------------------+
      | x                   |
      +---------------------+
      | 2026-07-09 00:00:00 |
      +---------------------+
      1 row in set, 1 warning (0.001 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+-------------------------------------------------------+
      | Level   | Code | Message                                               |
      +---------+------+-------------------------------------------------------+
      | Warning | 1292 | Truncated incorrect datetime value: 'Hein\xC3\xA4kuu' |
      +---------+------+-------------------------------------------------------+
      1 row in set (0.001 sec)
      

      Same while reading from a table:

      MariaDB [test]> SELECT a, TO_DATE(a,'MONTH','NLS_DATE_LANGUAGE=FINNISH'), TO_DATE(CONCAT(a,' 2026'),'MONTH YYYY','NLS_DATE_LANGUAGE=FINNISH') FROM t;
      +-----------+------------------------------------------------+---------------------------------------------------------------------+
      | a         | TO_DATE(a,'MONTH','NLS_DATE_LANGUAGE=FINNISH') | TO_DATE(CONCAT(a,' 2026'),'MONTH YYYY','NLS_DATE_LANGUAGE=FINNISH') |
      +-----------+------------------------------------------------+---------------------------------------------------------------------+
      | Heinäkuu  | 2026-07-09 00:00:00                            | NULL                                                                |
      | Syyskuu   | 2026-09-09 00:00:00                            | 2026-09-09 00:00:00                                                 |
      +-----------+------------------------------------------------+---------------------------------------------------------------------+
      2 rows in set, 2 warnings (0.002 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+-----------------------------------------------------------------+
      | Level   | Code | Message                                                         |
      +---------+------+-----------------------------------------------------------------+
      | Warning | 1292 | Truncated incorrect datetime value: 'Hein\xC3\xA4kuu'           |
      | Warning | 1411 | Incorrect datetime value: 'Heinäkuu 2026' for function to_date  |
      +---------+------+-----------------------------------------------------------------+
      

      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.