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

Query result is not compatible with MySQL while using in clause for enum type #26434

Closed
PragmaTwice opened this issue Jul 21, 2021 · 4 comments
Closed

Comments

@PragmaTwice
Copy link
Contributor

Bug Report

(Maybe a MySQL issue)

1. Minimal reproduce step (Required)

create table a(b datetime, c enum('David'), d double);
replace a set b = '2030-05-19', c = 'David', d = 0;
SELECT d FROM a WHERE c IN(SELECT d WHERE b);

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

in MySQL:

+------+
| d    |
+------+
|    0 |
+------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

Empty set (0.01 sec)

4. What is your TiDB version? (Required)

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()

                                                                            |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.2.0-alpha-316-g014005ab6
Edition: Community
Git Commit Hash: 014005ab68b5c9a28795d13c1ca685cf46a3be7e
Git Branch: master
UTC Build Time: 2021-07-17 09:44:18
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@PragmaTwice PragmaTwice added the type/bug The issue is confirmed as a bug. label Jul 21, 2021
@dveeden
Copy link
Contributor

dveeden commented Jul 21, 2021

SELECT c IN(SELECT d WHERE b) FROM a also shows the difference.

@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Jul 29, 2021

Behavior of MySQL is inconsistent. IMO, it's a MySQL's bug(bug report)

drop table if exists t1;
create table t1(col_datetime datetime, col_enum enum('ABC'), col_double double);
insert into t1 values('2030-05-19', 'ABC', 0);                                                                                                                                                                                                                                
select 1 from t1 where col_enum IN (select col_double where col_datetime);
select 1 from t1 where col_enum IN (select col_double);

mysql> select 1 from t1 where col_enum IN (select col_double where col_datetime);
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql> select 1 from t1 where col_enum IN (select col_double);
Empty set (0.00 sec)

TiDB's result is reasonable. I will make this issue as compatiblility issue after bug report is verified.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Aug 9, 2021

Verified in MySQL:

Actually, this is a bug, but with a very low priority.

@XuHuaiyu XuHuaiyu closed this as completed Aug 9, 2021
@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants