Skip to content

only_full_group_by check is not compatible with MySQL  #26576

@hawkingrei

Description

@hawkingrei

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table

CREATE TABLE `defer_regress_profile` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `profile1` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
  );

CREATE TABLE `defer_regress_request` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `profile_id` int(11) DEFAULT NULL,
  `location_id` int(11) NOT NULL,
  `request1` varchar(255) NOT NULL,
  `request2` varchar(255) NOT NULL,
  `request3` varchar(255) NOT NULL,
  `request4` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
  );

CREATE TABLE `defer_regress_request_items` (  
  `id` int(11) NOT NULL AUTO_INCREMENT,
    `request_id` int(11) NOT NULL,
    `item_id` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `defer_regress_request_items_request_id_item_id_124dc438_uniq` (`request_id`,`item_id`)
    );

CREATE TABLE `defer_regress_location` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `location1` varchar(255) NOT NULL,
  PRIMARY KEY (`id`) 
  );

run problem sql:

SELECT `defer_regress_request`.`id`,
       `defer_regress_request`.`profile_id`,
       `defer_regress_request`.`location_id`,
       COUNT(`defer_regress_request_items`.`item_id`) AS `items__count`,
       `defer_regress_profile`.`id`,
       `defer_regress_profile`.`profile1`,
       `defer_regress_location`.`id`,
       `defer_regress_location`.`location1`
FROM `defer_regress_request`
LEFT OUTER JOIN `defer_regress_request_items` ON (`defer_regress_request`.`id` = `defer_regress_request_items`.`request_id`)
LEFT OUTER JOIN `defer_regress_profile` ON (`defer_regress_request`.`profile_id` = `defer_regress_profile`.`id`)
INNER JOIN `defer_regress_location` ON (`defer_regress_request`.`location_id` = `defer_regress_location`.`id`)
GROUP BY `defer_regress_request`.`id`
ORDER BY NULL;

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

not error message in the mysql 8.0.25

3. What did you see instead (Required)

Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test_django_tests.defer_regress_location.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

4. What is your TiDB version? (Required)

Release Version: v5.2.0-alpha-392-g71638ee46
Edition: Community
Git Commit Hash: 71638ee
Git Branch: master
UTC Build Time: 2021-07-26 10:23:54
GoVersion: go1.16.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions