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

STR_TO_DATE returns NULL only when en_US locale is omitted under utf8mb4_bin

    XMLWordPrintable

Details

    Description

      MariaDB 12.3.3-MariaDB-ubu2404 returns NULL when STR_TO_DATE parses a lowercase English month under utf8mb4_bin using the session's en_US locale. Supplying the same locale explicitly returns 2026-03-01.

      Reproducer

      Run these statements in one MariaDB session:

      SET NAMES utf8mb4;
      SET lc_time_names='en_US';
      SELECT 'bin_lower', STR_TO_DATE(_utf8mb4'1 march 2026' COLLATE utf8mb4_bin,'%d %M %Y'), STR_TO_DATE(_utf8mb4'1 march 2026' COLLATE utf8mb4_bin,'%d %M %Y','en_US');
      SHOW WARNINGS;
      SELECT 'ci_lower', STR_TO_DATE(_utf8mb4'1 march 2026' COLLATE utf8mb4_general_ci,'%d %M %Y'), STR_TO_DATE(_utf8mb4'1 march 2026' COLLATE utf8mb4_general_ci,'%d %M %Y','en_US');
      SELECT 'bin_title', STR_TO_DATE(_utf8mb4'1 March 2026' COLLATE utf8mb4_bin,'%d %M %Y'), STR_TO_DATE(_utf8mb4'1 March 2026' COLLATE utf8mb4_bin,'%d %M %Y','en_US');

      Decisive observation

      The first value after each label uses the session locale implicitly; the second passes en_US explicitly.

      bin_lower  NULL        2026-03-01
      Warning    1411        Incorrect datetime value: '1 march 2026' for function str_to_date
      ci_lower   2026-03-01  2026-03-01
      bin_title  2026-03-01  2026-03-01

      The failure is limited to the combination of the lowercase month, binary collation, and omitted locale argument in this case. The case-insensitive-collation control and title-case control both produce the same date with omitted and explicit locales.

      Semantic mismatch

      With lc_time_names='en_US', omitting the optional locale and explicitly passing en_US select the same locale. Both calls receive identical text and format and should therefore parse the date as 2026-03-01. Instead, only the omitted-locale call returns NULL and raises warning 1411.

      This occurs when STR_TO_DATE parses a lowercase localized month under a binary collation while relying on lc_time_names instead of an explicit locale argument.

      Attachments

        Issue Links

          Activity

            People

              alice Alice Sherepa
              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.