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

expression: fix the issue that incorrect result for a predicate that uses the CHAR() function #16014

Merged
merged 14 commits into from
Apr 17, 2020

Conversation

Reminiscent
Copy link
Contributor

@Reminiscent Reminiscent commented Apr 2, 2020

What problem does this PR solve?

Issue Number: close #15986

What is changed and how it works?

When we use the string type to determine the bool value, the string type is converted to a float type instead of an int type.

Check List

Tests

  • Unit test
  • Integration test

@Reminiscent Reminiscent requested a review from a team as a code owner April 2, 2020 09:08
@ghost ghost removed their request for review April 2, 2020 09:08
Comment on lines -432 to -435
iVal, err = HandleOverflowOnSelection(sc, iVal, err)
if err != nil {
return err
}
Copy link
Contributor Author

@Reminiscent Reminiscent Apr 2, 2020

Choose a reason for hiding this comment

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

The function types.StrToFloat does not generate an overflow error, so the function HandleOverflowOnSelection and the test TestVecToBool are both unneeded.

@codecov
Copy link

codecov bot commented Apr 2, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@2b03cf2). Click here to learn what that means.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #16014   +/-   ##
===========================================
  Coverage          ?   80.3714%           
===========================================
  Files             ?        506           
  Lines             ?     136317           
  Branches          ?          0           
===========================================
  Hits              ?     109560           
  Misses            ?      18215           
  Partials          ?       8542           

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

From #15986,

Interestingly, the first query results in the following warning:

mysql> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '.9<' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

Please add some test cases to ensure there's no this type of warnings anymore.

@Reminiscent
Copy link
Contributor Author

From #15986,

Interestingly, the first query results in the following warning:

mysql> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '.9<' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

Please add some test cases to ensure there's no this type of warnings anymore.

The warning seems can not be eliminated. Because in the implementation of TIDB, when the string type cannot be completely converted to the float type, it will prompt this warning. @SunRunAway PTAL

@Reminiscent Reminiscent self-assigned this Apr 7, 2020
Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM

@Reminiscent
Copy link
Contributor Author

@qw4990 @XuHuaiyu PTAL

Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

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

LGTM

@qw4990 qw4990 added status/LGT2 Indicates that a PR has LGTM 2. status/can-merge Indicates a PR has been approved by a committer. labels Apr 14, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 14, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Apr 14, 2020

@Reminiscent merge failed.

@zz-jason
Copy link
Member

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

@Reminiscent merge failed.

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

sre-bot commented Apr 17, 2020

cherry pick to release-2.1 in PR #16556

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

sre-bot commented Apr 17, 2020

cherry pick to release-3.0 in PR #16557

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

sre-bot commented Apr 17, 2020

cherry pick to release-3.1 in PR #16558

@sre-bot
Copy link
Contributor

sre-bot commented Apr 17, 2020

cherry pick to release-4.0 in PR #16559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect result for a predicate that uses the CHAR() function
7 participants