MDEV-38791: Disallow duplicate weekday formats in TO_DATE#4810
MDEV-38791: Disallow duplicate weekday formats in TO_DATE#4810alexDiaconuAlex wants to merge 1 commit intoMariaDB:12.3from
Conversation
ac82c2b to
f99b235
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
Please make the commit message compliant with CODING_STANDARDS.md
97f7f8e to
0976451
Compare
gkodinov
left a comment
There was a problem hiding this comment.
LGTM after fixing one small detail below. Please stay tuned for the final review.
47d2310 to
9b6f252
Compare
raghunandanbhat
left a comment
There was a problem hiding this comment.
@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.
9b6f252 to
c7a16c0
Compare
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>
c7a16c0 to
dcecaf8
Compare
Problem
When using
TO_DATEwithsql_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()(insidesql/item_timefunc.cc).Now, inputs like
SELECT TO_DATE('Monday Mon', 'DAY DY') FROM DUAL;correctly fail early and returnERROR 3047 (HY000): Invalid argument error: date format not recognized at DY in function to_date.Reported-by: Elena Stepanova elenastepanova@github