-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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: add implicit eval int and real for function dayname #21806
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zanmato1984
added
type/bug-fix
This PR fixes a bug.
component/expression
needs-cherry-pick-4.0
labels
Dec 15, 2020
Closed
lzmhhh123
reviewed
Dec 15, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-all-tests |
/run-all-tests |
XuHuaiyu
requested review from
ichn-hu
and removed request for
qw4990 and
XuHuaiyu
December 16, 2020 09:01
ichn-hu
approved these changes
Dec 17, 2020
ti-srebot
approved these changes
Dec 17, 2020
/merge |
ti-srebot
added
the
status/can-merge
Indicates a PR has been approved by a committer.
label
Dec 17, 2020
/run-all-tests |
@zanmato1984 merge failed. |
/run-all-tests |
/merge |
/run-all-tests |
ti-srebot
pushed a commit
to ti-srebot/tidb
that referenced
this pull request
Dec 17, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #21850 |
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/bug-fix
This PR fixes a bug.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: close #19992
Problem Summary:
It's a bit long story.
MySQL has a weird behavior about function
dayname()
(IMO this apparently is a MySQL defect):It evaluates as integer directly despite the function signature is actually string. Quoted of comments in MySQL source code:
PR #9975 fixed this issue by removing the implicit cast from
dayname()
string to int/real, however introduced a more obvious bug:As shown above, unconditionally removing implicit cast gave the wrong result for non-arithmetic expressions involving function
dayname()
.What is changed and how it works?
What's Changed:
Don't use
hasSpecialCasts
anymore. Instead, markdayname()
asCanImplicitEvalInt/Real
, and do "implicit"evalInt/Real
in the actualcast
functions.Besides, since filter operator has its own path to evaluate expressions into boolean, modify it too to do "implicit"
evalInt/Real
.How it Works:
Adding implicit
evalInt/Real
path makescast
functions directly evaluatedayname()
as int/real, which further involve into whatever evaluation in the upper level of the expression tree.Related changes
pingcap/docs
/pingcap/docs-cn
: noneCheck List
Tests
Side effects
Release note
dayname