Skip to content
/ server Public

MDEV-38791: Disallow duplicate weekday formats in TO_DATE#4810

Open
alexDiaconuAlex wants to merge 1 commit intoMariaDB:12.3from
alexDiaconuAlex:MDEV-38791-fix-12.3
Open

MDEV-38791: Disallow duplicate weekday formats in TO_DATE#4810
alexDiaconuAlex wants to merge 1 commit intoMariaDB:12.3from
alexDiaconuAlex:MDEV-38791-fix-12.3

Conversation

@alexDiaconuAlex
Copy link

@alexDiaconuAlex alexDiaconuAlex commented Mar 15, 2026

Problem

When using TO_DATE with sql_mode='ORACLE', providing duplicate weekday format specifiers (such as 'DAY DY') did not throw an error during the format string parsing phase.

Solution

Added duplicate format checks for weekday specifiers in parse_format_string() (inside sql/item_timefunc.cc).

Now, inputs like SELECT TO_DATE('Monday Mon', 'DAY DY') FROM DUAL; correctly fail early and return ERROR 3047 (HY000): Invalid argument error: date format not recognized at DY in function to_date.

Reported-by: Elena Stepanova elenastepanova@github

@alexDiaconuAlex alexDiaconuAlex force-pushed the MDEV-38791-fix-12.3 branch 2 times, most recently from ac82c2b to f99b235 Compare March 15, 2026 19:02
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 16, 2026
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

Please make the commit message compliant with CODING_STANDARDS.md

@alexDiaconuAlex alexDiaconuAlex force-pushed the MDEV-38791-fix-12.3 branch 3 times, most recently from 97f7f8e to 0976451 Compare March 19, 2026 13:20
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after fixing one small detail below. Please stay tuned for the final review.

@alexDiaconuAlex alexDiaconuAlex force-pushed the MDEV-38791-fix-12.3 branch 2 times, most recently from 47d2310 to 9b6f252 Compare March 20, 2026 21:39
Copy link
Contributor

@raghunandanbhat raghunandanbhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexDiaconuAlex thanks for the contribution.

code looks good; please fix the tests.

I suggest updating the commit message to accurately reflect the scope of this fix. The current message states that the patch 'introduces' family-based conflict checks and lists YYYY YYYY and AM PM as examples of specifiers that were incorrectly allowed. However, the MDEV description shows that YYYY YYYY, DD DD, and MONTH MONTH were already being caught correctly by MariaDB.

Since the code change is specifically adding formats_used() checks for FMT_DAY, the commit message should clarify that this patch completes the existing validation framework by addressing the Day-name family, rather than implying the checks were missing for all logical time buckets.

The Oracle-mode TO_DATE() function incorrectly parsed strings containing
conflicting format specifiers within the Day-name family (e.g., 'DAY DY')
without throwing an ER_STD_INVALID_ARGUMENT error.

This patch completes the existing validation framework for family-based
conflict checks in item_timefunc.cc during format string parsing.
Specifically, it adds formats_used() checks for FMT_DAY, ensuring that
specifiers within the Day-name family strictly block each other. This
aligns the Day-name handling with the already existing checks for the
Year, Month, Hour, and Meridian families.

Compatible specifiers, such as YYYY and DDD (Year and Day of Year),
remain unaffected and parse successfully. A comprehensive MTR test
suite has been added to func_to_date.test to cover standard and
edge-case conflicts.

Reported-by: Elena Stepanova <elenastepanova@github>

Signed-off-by: Alexandru Diaconu <alexandrudiaconu93@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants