Skip to content
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

util: build right range when where stmt only have string column. #16645

Merged
merged 7 commits into from
Apr 21, 2020

Conversation

wshwsh12
Copy link
Contributor

@wshwsh12 wshwsh12 commented Apr 20, 2020

What problem does this PR solve?

Issue Number: close #16505 , close #16190

Problem Summary: TableIndexScan's result is different from TableFullScan and Selection.

What is changed and how it works?

What's Changed: If the where stmt only have String column, it shouldn't be one of accessCondition to build access range. Because we should convert the string to float to check it is ture/false.

How it Works: However, revert #16135 that only cover some cases. The pr can cover all situations.

Related changes

  • Need to cherry-pick to the release branch 2.1,3.0,3.1,4.0

Check List

Tests

  • Unit test
  • Integration test

Release note

Fix the wrong result when where stmt only have string column.

@wshwsh12 wshwsh12 requested review from a team as code owners April 20, 2020 15:39
@ghost ghost requested review from XuHuaiyu and eurekaka and removed request for XuHuaiyu and a team April 20, 2020 15:39
@wshwsh12 wshwsh12 requested a review from winoros April 20, 2020 15:40
@wshwsh12
Copy link
Contributor Author

/run-all-tests

@wshwsh12
Copy link
Contributor Author

/run-integration-copr-test

@codecov
Copy link

codecov bot commented Apr 20, 2020

Codecov Report

Merging #16645 into master will decrease coverage by 0.0279%.
The diff coverage is 77.7777%.

@@               Coverage Diff                @@
##             master     #16645        +/-   ##
================================================
- Coverage   80.4000%   80.3720%   -0.0280%     
================================================
  Files           506        506                
  Lines        137082     136861       -221     
================================================
- Hits         110214     109998       -216     
+ Misses        18268      18264         -4     
+ Partials       8600       8599         -1     

@wshwsh12
Copy link
Contributor Author

@winoros @eurekaka PTAL

util/ranger/checker.go Outdated Show resolved Hide resolved
@@ -32,6 +32,11 @@ func (c *conditionChecker) check(condition expression.Expression) bool {
case *expression.ScalarFunction:
return c.checkScalarFunction(x)
case *expression.Column:
if s, ok := condition.(*expression.Column); ok {
if s.RetType.EvalType() == types.ETString {
return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we cannot use index for this kind of filter? would it cause performance regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Maybe it cause performance regression, but It is a correctness question. In Mysql, the range is empty also. If we use index, it can only filter null and ''.

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wshwsh12 wshwsh12 requested a review from eurekaka April 21, 2020 05:25
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eurekaka eurekaka added the status/can-merge Indicates a PR has been approved by a committer. label Apr 21, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 21, 2020

/run-all-tests

@sre-bot sre-bot merged commit 0d5a831 into pingcap:master Apr 21, 2020
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 21, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 21, 2020

cherry pick to release-2.1 in PR #16657

@sre-bot
Copy link
Contributor

sre-bot commented Apr 21, 2020

cherry pick to release-3.0 in PR #16658

@sre-bot
Copy link
Contributor

sre-bot commented Apr 21, 2020

cherry pick to release-3.1 in PR #16659

@sre-bot
Copy link
Contributor

sre-bot commented Apr 21, 2020

cherry pick to release-4.0 in PR #16660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression component/util sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error 1690: DOUBLE value is out of range Failed Integration Push Down Test
4 participants