-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: refactor constant folding for IF&IFNULL #9094
expression: refactor constant folding for IF&IFNULL #9094
Conversation
Signed-off-by: Jian Zhang <zjsariel@gmail.com>
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #9094 +/- ##
==========================================
+ Coverage 67.15% 67.16% +0.01%
==========================================
Files 372 372
Lines 77839 77836 -3
==========================================
+ Hits 52270 52282 +12
+ Misses 20896 20890 -6
+ Partials 4673 4664 -9
Continue to review full report at Codecov.
|
Can we check the returned from |
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.
Don't directly call Constant.EvalInt(), which results in error if the constant is a string.
It seems that it's not correct to call ToInt64
in Constant.EvalInt when a Datum is of type KindString since it goes against the original intent of this function.
If that datum is typed ENUM/BIT/SET, we have to call |
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
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.
will there be unit test in this pr?
/run-all-tests |
if c.GetType().Hybrid() || c.Value.Kind() == types.KindBinaryLiteral || c.Value.Kind() == types.KindString {}
func (ft *FieldType) Hybrid() bool {
return ft.Tp == mysql.TypeEnum || ft.Tp == mysql.TypeBit || ft.Tp == mysql.TypeSet
}
|
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
Signed-off-by: Jian Zhang zjsariel@gmail.com
What problem does this PR solve?
ifnull
should not logData Truncated
warning messagesifnull
should not returnData Truncated
warnings to the client.What is changed and how it works?
Don't directly call
Constant.EvalInt()
, which results in error if the constant is a string. I changed it to callConstant.Eval()
to get aDatum
, use thatDatum
to check whether the first parameter is aNULL
value.If the first parameter for
IFNULL
is a constant and it's not aNULL
value, we can directly return that constant parameter. In the old implementation, we returned the originalIFNULL
expression.Check List
Tests
TODO: add it laterDoneRelated changes