Bug #101105 Incorrect grouping by GROUP BY with timezone
Submitted: 9 Oct 2020 13:09 Modified: 1 Nov 2020 17:34
Reporter: Eduardo Ubide Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.20, 8.0.21 OS:Linux
Assigned to: CPU Architecture:Any
Tags: regression

[9 Oct 2020 13:09] Eduardo Ubide
Description:
From MySQL 8.0.20 and later version, I can see regression on a select group by sentences would not work correctly when specifying a timezone, the result returns duplicate dates.

Previous releases work fine.

How to repeat:
Prepare environment:

Apply attached SQL file.

Exec query, it's return expected output:

```
mysql> set time_zone = 'UTC';
mysql> select date(from_unixtime(date_received)) as `dt`, count(distinct pid) FROM test2 GROUP by `dt`;
+------------+---------------------+
| dt         | count(distinct pid) |
+------------+---------------------+
| 2020-07-30 |                  10 |
| 2020-07-31 |                  10 |
| 2020-08-01 |                  10 |
| 2020-08-02 |                  10 |
+------------+---------------------+
4 rows in set (0.00 sec)
```

But when we change timezone and exec this query it's return output with duplicate dates:

```
mysql> set time_zone = 'America/Los_Angeles';
mysql> select date(from_unixtime(date_received)) as `dt`, count(distinct pid) FROM test2 GROUP by `dt`;
+------------+---------------------+
| dt         | count(distinct pid) |
+------------+---------------------+
| 2020-07-30 |                   3 |
| 2020-07-29 |                   2 |
| 2020-07-30 |                   2 |
| 2020-07-29 |                   1 |
| 2020-07-30 |                   1 |
| 2020-07-29 |                   1 |
| 2020-07-30 |                   1 |
| 2020-07-29 |                   1 |
| 2020-07-30 |                   1 |
| 2020-07-29 |                   2 |
| 2020-07-30 |                   7 |
| 2020-07-29 |                   3 |
| 2020-07-30 |                   2 |
| 2020-07-29 |                  10 |
| 2020-07-30 |                   1 |
| 2020-07-29 |                   6 |
| 2020-07-30 |                   1 |
| 2020-07-29 |                  10 |
| 2020-07-30 |                  10 |
| 2020-07-31 |                   2 |
| 2020-07-30 |                   1 |
| 2020-07-31 |                   1 |
| 2020-07-30 |                   1 |
| 2020-07-31 |                   2 |
| 2020-07-30 |                   2 |
| 2020-07-31 |                   2 |
| 2020-07-30 |                   2 |
| 2020-07-31 |                   1 |
| 2020-07-30 |                   1 |
| 2020-07-31 |                   2 |
| 2020-07-30 |                   1 |
| 2020-07-31 |                   2 |
| 2020-07-30 |                  10 |
| 2020-07-31 |                  10 |
| 2020-08-01 |                   4 |
| 2020-07-31 |                   2 |
| 2020-08-01 |                   1 |
| 2020-07-31 |                   1 |
| 2020-08-01 |                   5 |
| 2020-07-31 |                   1 |
| 2020-08-01 |                   1 |
| 2020-07-31 |                   2 |
| 2020-08-01 |                   2 |
| 2020-07-31 |                  10 |
| 2020-08-01 |                   1 |
| 2020-07-31 |                  10 |
| 2020-08-01 |                  10 |
+------------+---------------------+
47 rows in set (0.01 sec)
```
[9 Oct 2020 13:10] Eduardo Ubide
To prepare the enviroment

Attachment: prepare.sql (application/octet-stream, text), 111.36 KiB.

[9 Oct 2020 13:23] MySQL Verification Team
Hello Eduardo Ubide,

Thank you for the report and test case.

regards,
Umesh
[1 Nov 2020 17:34] Erlend Dahl
Fixed in 8.0.22 under the heading of

Bug#31168097: SIG 6 ASSERTION `0' IN TIME_ZONE_UTC::GET_NAME AT TZTIME.CC:1182