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 a bug when comparing bit with string #11654

Merged
merged 2 commits into from
Aug 7, 2019

Conversation

wshwsh12
Copy link
Contributor

@wshwsh12 wshwsh12 commented Aug 7, 2019

What problem does this PR solve?

Issue: #11647
When a bit column compare with a constant string, it gets a wrong result.
Befor the pr:

mysql> create table xx (b bit(1));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into xx values (b'1');
Query OK, 1 row affected (0.00 sec)

mysql> select count(*) from xx where b='1';
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

This pr:

mysql> create table xx (b bit(1));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into xx values (b'1');
Query OK, 1 row affected (0.00 sec)

mysql> select count(*) from xx where b='1';
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

What is changed and how it works?

The reason is that we select a wrong target field type in function RefineComparedConstant.
Before this pr, the target field is TypeBit, and convert '1' to 49.
In fact, the target field shoule be an int type in this situation, and convert '1' to 1.
In this pr, I change the target field to TypeLonglong.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Code changes

  • Has exported function/method change

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

@codecov
Copy link

codecov bot commented Aug 7, 2019

Codecov Report

Merging #11654 into master will decrease coverage by 0.3285%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11654        +/-   ##
================================================
- Coverage   81.6152%   81.2867%   -0.3286%     
================================================
  Files           426        426                
  Lines         93594      91983      -1611     
================================================
- Hits          76387      74770      -1617     
- Misses        11801      11844        +43     
+ Partials       5406       5369        -37

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Aug 7, 2019

/run-all-tests

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

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added the status/can-merge Indicates a PR has been approved by a committer. label Aug 7, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 7, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Aug 7, 2019

cherry pick to release-2.1 in PR #11659

@sre-bot
Copy link
Contributor

sre-bot commented Aug 7, 2019

cherry pick to release-3.0 in PR #11660

@wshwsh12 wshwsh12 deleted the fix_cmp_bit_with_string branch August 20, 2019 08:42
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. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants