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) #11660

Merged
merged 4 commits into from
Aug 9, 2019

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Aug 7, 2019

cherry-pick #11654 to release-3.0


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

@sre-bot
Copy link
Contributor Author

sre-bot 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

@XuHuaiyu XuHuaiyu removed their request for review August 7, 2019 08:54
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 status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. labels Aug 7, 2019
@wshwsh12
Copy link
Contributor

wshwsh12 commented Aug 7, 2019

/run-unit-test

@sre-bot
Copy link
Contributor Author

sre-bot commented Aug 7, 2019

/run-all-tests

@sre-bot
Copy link
Contributor Author

sre-bot commented Aug 7, 2019

@sre-bot merge failed.

@zz-jason
Copy link
Member

zz-jason commented Aug 7, 2019

/run-auto-merge

@sre-bot
Copy link
Contributor Author

sre-bot commented Aug 7, 2019

/run-all-tests

@sre-bot
Copy link
Contributor Author

sre-bot commented Aug 7, 2019

@sre-bot merge failed.

@wshwsh12
Copy link
Contributor

wshwsh12 commented Aug 8, 2019

/run-unit-test

@wshwsh12
Copy link
Contributor

wshwsh12 commented Aug 9, 2019

/run-auto-merge

@sre-bot
Copy link
Contributor Author

sre-bot commented Aug 9, 2019

/run-all-tests

@sre-bot sre-bot merged commit eb6f46a into pingcap:release-3.0 Aug 9, 2019
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/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants