Skip to content

count distinct with multiple column return wrong result under new collation #27091

Closed
@windtalker

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t2(id int, v1 char(10) collate utf8mb4_general_ci, v2 char(10) collate utf8mb4_bin);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t2 values(1,'a','A'),(2,'A','A'),(3,'a ','A'),(4,'A ','A');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select count(distinct v1,v2) from t2;
+-----------------------+
| count(distinct v1,v2) |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.01 sec)

mysql>
mysql>
mysql>
mysql>
mysql> select count(distinct v1,v2) from t2;
+-----------------------+
| count(distinct v1,v2) |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

mysql> select * from t2;
+------+------+------+
| id   | v1   | v2   |
+------+------+------+
|    1 | a    | A    |
|    2 | A    | A    |
|    3 | a    | A    |
|    4 | A    | A    |
+------+------+------+
4 rows in set (0.00 sec)

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

mysql> select count(distinct v1,v2) from t2;
+-----------------------+
| count(distinct v1,v2) |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select count(distinct v1,v2) from t2;
+-----------------------+
| count(distinct v1,v2) |
+-----------------------+
|                     2 |
+-----------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

master@a7fdc2a056636119202c16feefb91f25702a8f4f

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions