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

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

@wshwsh12 wshwsh12 force-pushed the wshwsh12:fix_cmp_bit_with_string branch from e553339 to 34d59bd Aug 7, 2019

@wshwsh12 wshwsh12 requested review from qw4990, XuHuaiyu and zz-jason Aug 7, 2019

@codecov

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2019

/run-all-tests

@qw4990
Copy link
Contributor

left a comment

LGTM

@zz-jason
Copy link
Member

left a comment

LGTM

@sre-bot

This comment has been minimized.

Copy link

commented Aug 7, 2019

/run-all-tests

@sre-bot sre-bot merged commit 8fac5e2 into pingcap:master Aug 7, 2019

14 checks passed

ci/circleci Your tests passed on CircleCI!
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@sre-bot

This comment has been minimized.

Copy link

commented Aug 7, 2019

cherry pick to release-2.1 in PR #11659

@sre-bot

This comment has been minimized.

Copy link

commented Aug 7, 2019

cherry pick to release-3.0 in PR #11660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.