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

Where conditions are eliminated wrongly caused by HashCode collision #30094

Closed
time-and-fate opened this issue Nov 24, 2021 · 2 comments · Fixed by #30120
Closed

Where conditions are eliminated wrongly caused by HashCode collision #30094

time-and-fate opened this issue Nov 24, 2021 · 2 comments · Fixed by #30120
Assignees
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@time-and-fate
Copy link
Member

time-and-fate commented Nov 24, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a varchar(10));
explain select * from t where cast(a as float) and cast(a as char);
explain select * from t where a = 0xe59388e59388e59388 and a = 0xe598bfe598bfe598bf;

UPDATE: the second SQL can't trigger the bug anymore. Please switch to use the following SQL:

explain select * from t30094 t1 where  concat(t1.a,'1') = _binary 0xe59388e59388e59388 collate binary and concat(t1.a,'1') = _binary 0xe598bfe598bfe598bf collate binary;

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

The selection operator has two conditions.

3. What did you see instead (Required)

> explain select * from t where cast(a as float) and cast(a as char);
+-------------------------+----------+-----------+---------------+--------------------------------+
| id                      | estRows  | task      | access object | operator info                  |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7           | 8000.00  | root      |               | data:Selection_6               |
| └─Selection_6           | 8000.00  | cop[tikv] |               | cast(test2.t.a, float BINARY)  |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+

> explain select * from t where a = 0xe59388e59388e59388 and a = 0xe598bfe598bfe598bf;
+-------------------------+----------+-----------+---------------+---------------------------------------+
| id                      | estRows  | task      | access object | operator info                         |
+-------------------------+----------+-----------+---------------+---------------------------------------+
| TableReader_7           | 10.00    | root      |               | data:Selection_6                      |
| └─Selection_6           | 10.00    | cop[tikv] |               | eq(test2.t.a, "0xe59388e59388e59388") |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo        |
+-------------------------+----------+-----------+---------------+---------------------------------------+

4. What is your TiDB version? (Required)

master

@time-and-fate time-and-fate added the type/bug The issue is confirmed as a bug. label Nov 24, 2021
@time-and-fate
Copy link
Member Author

/assign

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

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
1 participant