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
planner: fix wrong row compare logic in expression_rewriter #8241
Conversation
planner/core/expression_rewriter.go
Outdated
@@ -220,6 +220,24 @@ func (er *expressionRewriter) constructBinaryOpFunction(l expression.Expression, | |||
if err != nil { | |||
return nil, errors.Trace(err) | |||
} | |||
if evalexpr, ok := expr1.(*expression.Constant); ok { | |||
_, isNull, err1 := evalexpr.EvalInt(er.ctx, chunk.Row{}) | |||
if err1 != nil { |
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.
if err1 != nil || isNil {
return expr1, err1
}
We do not need the errors.Trace now.
@@ -220,6 +220,24 @@ func (er *expressionRewriter) constructBinaryOpFunction(l expression.Expression, | |||
if err != nil { | |||
return nil, errors.Trace(err) | |||
} | |||
if evalexpr, ok := expr1.(*expression.Constant); ok { | |||
_, isNull, err1 := evalexpr.EvalInt(er.ctx, chunk.Row{}) |
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.
(er.ctx, nil) is enough.
@XuHuaiyu addressed |
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 |
PTAL @zz-jason |
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
What problem does this PR solve?
When execute this SQL:
SELECT (1,2,3) < (1,NULL, 3)
.TiDB:
MySQL:
Correct compare logic is comparing prefix of row until there is different digit between them.
If they has same prefix before
NULL
digit, it will returnNULL
.What is changed and how it works?
adding check code before entering next recursion.
Check List
Tests
Side effects
Related changes