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

Incorrect range for CHAR column #10397

Closed
zz-jason opened this issue May 9, 2019 · 1 comment · Fixed by #10124
Closed

Incorrect range for CHAR column #10397

zz-jason opened this issue May 9, 2019 · 1 comment · Fixed by #10124
Assignees
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@zz-jason
Copy link
Member

zz-jason commented May 9, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?

drop table if exists t;
create table t(a char(2) primary key, b char(2));
insert into t values("a ", "b ");
set @@sql_mode="PAD_CHAR_TO_FULL_LENGTH";
select * from t tmp where a = "a";

2. What did you expect to see?

the correct result should be empty:

MySQL(root@localhost:test) > select * from t tmp where a = "a";
Empty set (0.00 sec)

mysql version:

MySQL(root@localhost:test) > select version();
+-----------+
| version() |
+-----------+
| 8.0.11    |
+-----------+
1 row in set (0.00 sec)

3. What did you see instead?

In TiDB the result is:

TiDB(root@127.0.0.1:test) > select * from t tmp where a = "a";
+---+------+
| a | b    |
+---+------+
| a | b    |
+---+------+
1 row in set (0.00 sec)

the range is:

TiDB(root@127.0.0.1:test) > desc select * from t tmp where a = "a";
+-------------------+-------+------+---------------------------------------------------------------------+
| id                | count | task | operator info                                                       |
+-------------------+-------+------+---------------------------------------------------------------------+
| IndexLookUp_7     | 10.00 | root |                                                                     |
| ├─IndexScan_5     | 10.00 | cop  | table:tmp, index:a, range:["a","a"], keep order:false, stats:pseudo |
| └─TableScan_6     | 10.00 | cop  | table:t, keep order:false, stats:pseudo                             |
+-------------------+-------+------+---------------------------------------------------------------------+
3 rows in set (0.00 sec)

actually the range should be: ["a ","a "]

4. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

TiDB(root@127.0.0.1:test) > select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v3.0.0-beta.1-231-g78ecec45e
Git Commit Hash: 78ecec45e8c02d6a8747b1e95ee25373c93d3edd
Git Branch: master
UTC Build Time: 2019-05-09 01:11:02
GoVersion: go version go1.12.4 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
1 row in set (0.00 sec)
@zz-jason zz-jason added sig/planner SIG: Planner type/bug The issue is confirmed as a bug. labels May 9, 2019
@zz-jason zz-jason changed the title Incorrect range in for CHAR PK Incorrect range for CHAR PK May 9, 2019
@zz-jason zz-jason changed the title Incorrect range for CHAR PK Incorrect range for CHAR column May 9, 2019
@zz-jason
Copy link
Member Author

zz-jason commented May 9, 2019

Relates to #10124, which is point get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants