Uploaded image for project: 'Percona Server for MySQL'
  1. Percona Server for MySQL
  2. PS-7236

Correct grouping by GROUP BY processing with timezone

Details

    • Bug
    • Status: Done
    • Medium
    • Resolution: Fixed
    • 8.0.20-11
    • 8.0.22-13
    • None

    Description

      Hello.

      We are faced with an error due to which groups would not work correctly when specifying a timezone on Percona Server 8.0.20.

      Prev releases works fine.

      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)
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            larrabee Vladimir
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Smart Checklist