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

Reported-by: Elena Stepanova <elenastepanova@github>

Signed-off-by: Alexandru Diaconu <alexandrudiaconu93@gmail.com>
@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

}
else if (tmp1 == 'Y')
{
if (for_to_date && formats_used(&used, FMT_DAY))
Copy link
Member

Choose a reason for hiding this comment

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

You sure you just need to check for FMT_DAY? IMHO more is needed.

{
if (ptr + 2 == end || my_toupper(system_charset_info, *(ptr+2)) != 'Y')
goto error;
if (for_to_date && formats_used(&used, FMT_DAY))
Copy link
Member

Choose a reason for hiding this comment

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

ditto here

@@ -0,0 +1,4 @@
SET sql_mode='ORACLE';

SELECT TO_DATE('Monday Mon', 'DAY DY');
Copy link
Member

Choose a reason for hiding this comment

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

Please add all of the queries mentioned into the JIRa. Also please extend the test suite will all the additional combos you can think of. E.g. IYYY etc.

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.

2 participants