-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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) #21850
expression: add implicit eval int and real for function dayname (#21806) #21850
Conversation
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
/run-all-tests |
@zanmato1984 you're already a collaborator in bot's repo. |
expression/expression.go
Outdated
@@ -331,20 +331,36 @@ func VecEvalBool(ctx sessionctx.Context, exprList CNFExprs, input *chunk.Chunk, | |||
isZero := allocZeroSlice(n) | |||
defer deallocateZeroSlice(isZero) | |||
for _, expr := range exprList { | |||
<<<<<<< HEAD |
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.
Please resolve conflicts @zanmato1984
Could you please help to resolve conflicts? @ichn-hu @lzmhhh123 |
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-unit-test |
2 similar comments
/run-unit-test |
/run-unit-test |
cherry-pick #21806 to release-4.0
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