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

indexjoin should take collation into consideration #19654

Closed
XuHuaiyu opened this issue Sep 1, 2020 · 1 comment · Fixed by #19699
Closed

indexjoin should take collation into consideration #19654

XuHuaiyu opened this issue Sep 1, 2020 · 1 comment · Fixed by #19699
Labels
severity/critical type/bug The issue is confirmed as a bug.

Comments

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Sep 1, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

-- open collate

drop table t1, t2;

create table t1 (
b enum('A', 'B') collate utf8mb4_general_ci
);
insert into t1 values ('A');

create table t2 (
b enum('b','a') collate utf8mb4_general_ci not null,
unique(b)
);
insert into t2 values ('a');

select /*+ inl_join(t2)*/ * from t1, t2 where t1.b=t2.b;

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

+------+---+
| b    | b |
+------+---+
| A    | a |
+------+---+

3. What did you see instead (Required)

empty set

4. What is your TiDB version? (Required)

master @ 349adf8

@XuHuaiyu XuHuaiyu added the type/bug The issue is confirmed as a bug. label Sep 1, 2020
@XuHuaiyu XuHuaiyu closed this as completed Sep 1, 2020
@XuHuaiyu XuHuaiyu reopened this Sep 1, 2020
@XuHuaiyu XuHuaiyu changed the title join should take collation into consideration indexjoin should take collation into consideration Sep 1, 2020
@wjhuang2016
Copy link
Member

wjhuang2016 commented Sep 1, 2020

I don't think it's a collation bug:

mysql> create table t1 (
    -> b enum('A', 'B') collate utf8mb4_general_ci
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values ('A');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> create table t2 (
    -> b enum('a','b') collate utf8mb4_general_ci not null,
    -> unique(b)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t2 values ('a');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> select /*+ inl_join(t2)*/ * from t1, t2 where t1.b=t2.b;
+------+---+
| b    | b |
+------+---+
| A    | a |
+------+---+
1 row in set (0.00 sec)

And

mysql> drop table t1, t2;
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> create table t1 (
    -> b enum('A', 'B') collate utf8mb4_general_ci
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values ('A');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> create table t2 (
    -> b enum('B','A') collate utf8mb4_general_ci not null,
    -> unique(b)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t2 values ('a');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> select /*+ inl_join(t2)*/ * from t1, t2 where t1.b=t2.b;
Empty 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.

3 participants