expression: add implicit eval int and real for function dayname#21806
Merged
ti-srebot merged 4 commits intopingcap:masterfrom Dec 17, 2020
Merged
expression: add implicit eval int and real for function dayname#21806ti-srebot merged 4 commits intopingcap:masterfrom
ti-srebot merged 4 commits intopingcap:masterfrom
Conversation
Closed
Contributor
|
/run-all-tests |
Contributor
|
/run-all-tests |
Contributor
Author
|
/run-all-tests |
ichn-hu
approved these changes
Dec 17, 2020
ti-srebot
approved these changes
Dec 17, 2020
Contributor
|
/merge |
Contributor
|
/run-all-tests |
Contributor
|
@zanmato1984 merge failed. |
Contributor
Author
|
/run-all-tests |
Contributor
|
/merge |
Contributor
|
/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>
Contributor
|
cherry pick to release-4.0 in PR #21850 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
hasSpecialCastsanymore. Instead, markdayname()asCanImplicitEvalInt/Real, and do "implicit"evalInt/Realin the actualcastfunctions.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/Realpath makescastfunctions 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