Bug #103296 Aggregate function group by primary key/non-primary key has differnet result
Submitted: 13 Apr 2021 5:35 Modified: 13 Apr 2021 6:00
Reporter: Shenghui Wu Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.22, 5.7.33, 8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[13 Apr 2021 5:35] Shenghui Wu
Description:
Aggregate function group by primary key/non-primary key has differnet result

How to repeat:
create table t1(a int primary key, b set('Alice','Bob') DEFAULT NULL);
insert into t1 value(1,'Bob');
select max(b) + 0 from t1 group by a;
+------------+
| max(b) + 0 |
+------------+
|          0 |
+------------+

create table t2(a int, b set('Alice','Bob') DEFAULT NULL);
insert into t2 value(1,'Bob');
select max(b) + 0 from t2 group by a;
+------------+
| max(b) + 0 |
+------------+
|          2 |
+------------+
[13 Apr 2021 6:00] MySQL Verification Team
Hello Shenghui Wu,

Thank you for the report and test case.

regards,
Umesh