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

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

Closed
windtalker opened this issue Aug 11, 2021 · 1 comment · Fixed by #27111
Closed

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

windtalker opened this issue Aug 11, 2021 · 1 comment · Fixed by #27111
Assignees
Labels

Comments

@windtalker
Copy link
Contributor

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

@windtalker windtalker added the type/bug The issue is confirmed as a bug. label Aug 11, 2021
@windtalker windtalker changed the title count distinct with multiple column return wrong result count distinct with multiple column return wrong result under new collation Aug 12, 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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants