Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-11341 STR_TO_DATE does not return NULL for invalid dates #3829

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gengtianuiowa
Copy link

Description

STR_TO_DATE function in MariaDB does date to string conversion for invalid dates strings, e.g.: 1949-02-30, and 1949-06-31, but null is return by other invalid dates such as 1949-01-32 because the checking function returns null for any date whose day is larger than 31, which is too naive and needs to be changed.

This commit changed the rule of check_date in extract_date_time function, which is executed after extracting date and time and check if
the result is valid. Now the conversion will consider the number of days in a month, including skip years.

How can this PR be tested?

Execute the main suite in mysql-test-run.

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch

Backward compatibility

This is a new feature introducing stricter date check before a conversion is generated and affect backwards compatibility.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

@CLAassistant
Copy link

CLAassistant commented Feb 11, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@svoj svoj added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Feb 12, 2025
STR_TO_DATE function in MariaDB does date to string conversion for invalid
dates strings, e.g.: 1949-02-30, and 1949-06-31, but null is return by
other invalid dates such as 1949-01-32 because the checking function
returns null for any date whose day is larger than 31, which is too naive
and needs to be changed.

This commit changed the rule of check_date in extract_date_time function,
which is executed after extracting date and time and check if the result
is valid. Now the conversion will consider the number of days in a month,
including skip years.

All new code of the whole pull request, including one or several files that
are either new files or modified ones, are contributed under the BSD-new
license. I am contributing on behalf of my employer Amazon Web Services, Inc.
@ottok
Copy link
Contributor

ottok commented Feb 18, 2025

The test job that is failing here is not labelled 'Required' so we will ignore it for now.

@svoj svoj requested a review from abarkov February 26, 2025 18:09
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.

5 participants