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

Wrong result caused by misuse of batch-point-get #19191

Closed
zyguan opened this issue Aug 13, 2020 · 3 comments · Fixed by #19456
Closed

Wrong result caused by misuse of batch-point-get #19191

zyguan opened this issue Aug 13, 2020 · 3 comments · Fixed by #19456
Assignees
Labels
severity/critical type/bug The issue is confirmed as a bug.

Comments

@zyguan
Copy link
Contributor

zyguan commented Aug 13, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t (c_int int, c_str varchar(40), primary key(c_int, c_str));
insert into t values (3, 'friendly bose');
select * from t where c_int in (3);
select * from t where c_int in (3) or c_str in ('gifted yalow') and c_int in (1, 2);

2. What did you expect to see? (Required)

Both selection should return:

+-------+---------------+
| c_int | c_str         |
+-------+---------------+
|     3 | friendly bose |
+-------+---------------+

3. What did you see instead (Required)

mysql> select * from t where c_int in (3);
+-------+---------------+
| c_int | c_str         |
+-------+---------------+
|     3 | friendly bose |
+-------+---------------+
1 row in set (0.05 sec)

mysql> select * from t where c_int in (3) or c_str in ('gifted yalow') and c_int in (1, 2);
Empty set (0.05 sec)

mysql> explain select * from t where c_int in (3) or c_str in ('gifted yalow') and c_int in (1, 2);
+-------------------+---------+------+--------------------------------------+------------------------------+
| id                | estRows | task | access object                        | operator info                |
+-------------------+---------+------+--------------------------------------+------------------------------+
| Batch_Point_Get_5 | 3.00    | root | table:t, index:PRIMARY(c_int, c_str) | keep order:false, desc:false |
+-------------------+---------+------+--------------------------------------+------------------------------+
1 row in set (0.05 sec)

4. What is your TiDB version? (Required)

master @ 84e07a2
release-4.0 @ 1483de3

@zyguan zyguan added the type/bug The issue is confirmed as a bug. label Aug 13, 2020
@zyguan
Copy link
Contributor Author

zyguan commented Aug 13, 2020

/label severity/critical

@zyguan
Copy link
Contributor Author

zyguan commented Aug 13, 2020

/assign @zz-jason

@ghost
Copy link

ghost commented Aug 14, 2020

Verified I can reproduce against master. Just to expand the testcase to prove this is not an operator precedence issue:

drop table if exists t;
create table t (c_int int, c_str varchar(40), primary key(c_int, c_str));
insert into t values (3, 'friendly bose');
select * from t where c_int in (3);
select * from t where c_int in (3) or c_str in ('gifted yalow') and c_int in (1, 2); -- incorrect
select * from t where c_int in (3) or (c_str in ('gifted yalow') and c_int in (1, 2)); -- incorrect
select * from t where c_int in (3) or (false); -- correct

..

mysql> select * from t where c_int in (3) or c_str in ('gifted yalow') and c_int in (1, 2); -- incorrect
Empty set (0.00 sec)

mysql> select * from t where c_int in (3) or (c_str in ('gifted yalow') and c_int in (1, 2)); -- incorrect
Empty set (0.00 sec)

mysql> select * from t where c_int in (3) or (false); -- correct
+-------+---------------+
| c_int | c_str         |
+-------+---------------+
|     3 | friendly bose |
+-------+---------------+
1 row in set (0.00 sec)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-947-g84e07a2a5
Edition: Community
Git Commit Hash: 84e07a2a593b6dd9a85712f1910883e5f7281b07
Git Branch: master
UTC Build Time: 2020-08-12 08:42:23
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

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

Successfully merging a pull request may close this issue.

5 participants