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

expression: handle invalid argument for addtime and subtime function #21600

Merged
merged 6 commits into from
Dec 10, 2020

Conversation

wjhuang2016
Copy link
Member

Signed-off-by: wjhuang2016 huangwenjun1997@gmail.com

What problem does this PR solve?

Issue Number: close #12342

Problem Summary:
Didn't handle the error for the second argument.

What is changed and how it works?

If the second argument is invalid, use NULL instead of returning an error.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

Release note

  • handle invalid argument for addtime and subtime function

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 requested a review from a team as a code owner December 9, 2020 07:59
@wjhuang2016 wjhuang2016 requested review from XuHuaiyu and removed request for a team December 9, 2020 07:59
arg0, err := types.ParseTime(sc, d, mysql.TypeDatetime, types.MaxFsp)
if err != nil {
return "", err
sc.AppendWarning(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we check the sql_mode to decide whether to return an error or a warning?

e.g. sc.HandleTruncate

Copy link
Member Author

Choose a reason for hiding this comment

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

Even in the strict mode, MySQL returns a warning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment for it?

ichn-hu
ichn-hu previously approved these changes Dec 9, 2020
Copy link
Contributor

@ichn-hu ichn-hu left a comment

Choose a reason for hiding this comment

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

LGTM

expression/builtin_time.go Outdated Show resolved Hide resolved
expression/builtin_time.go Outdated Show resolved Hide resolved
@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 9, 2020
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
XuHuaiyu
XuHuaiyu previously approved these changes Dec 9, 2020
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 9, 2020
ti-srebot
ti-srebot previously approved these changes Dec 9, 2020
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Dec 9, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 9, 2020
@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 21587

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@wjhuang2016 merge failed.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Dec 9, 2020

/merge

@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 21324

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@wjhuang2016 merge failed.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Dec 9, 2020

/run-check_dev_2
/run-integration-copr-test

@wjhuang2016
Copy link
Member Author

/run-integration-copr-test

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016
Copy link
Member Author

/run-integration-copr-test

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@XuHuaiyu
Copy link
Contributor

LGTM

@XuHuaiyu
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit c138941 into pingcap:master Dec 10, 2020
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Dec 10, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #21635

ti-srebot added a commit that referenced this pull request Jan 25, 2021
@wjhuang2016 wjhuang2016 deleted the fix_addtime_subtime branch November 17, 2022 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

different result addtime with two string arguments.
4 participants