Bug #113783 | only_full_group_by option does not take effect | ||
---|---|---|---|
Submitted: | 28 Jan 12:50 | Modified: | 30 Jan 9:52 |
Reporter: | peng gao | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[28 Jan 12:50]
peng gao
[29 Jan 11:31]
MySQL Verification Team
Hi Mr. gao, Thank you for your bug report. We have managed to repeat your test case: select IFNULL(aa.balance,0) balance, IFNULL(sum(bb.amount),0) amount from aa1 aa left join bb on aa.id=bb.from_pool_id where aa.id=3 and bb.is_deleted=0 and aa.is_deleted=0 and bb.status =1; ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.aa.balance'; this is incompatible with sql_mode=only_full_group_by We should inform you that this kind of aggregated queries are not compliant with SQL Standard. However, since MySQL is still supporting this syntax we are verifying this report, but with a lower priority. Verified as reported.
[29 Jan 11:34]
MySQL Verification Team
Hi Mr. gao, We have discussed your report with a Dvelopment team in charge and we agreed that this, actually, is not a bug. Reason for that is simple ....... The reason is that when we have a primary key, and the predicate aa.id=3, then we have only one row in the table, and thus only one aa.balance value, which is of course unique. Thus, it is correct to allow the implicitly grouped query. It does not violate only_full_group_by. But without the primary key, we may have multiple rows, and subsequently multiple, non-distinct values for aa.balance which violates only_full_group_by. Not a bug, after all. Thanks for your report, any way .......
[30 Jan 9:43]
peng gao
Thank you,But I don't quite understand what the return value means, +---------+--------+ | balance | amount | +---------+--------+ | 0.00 | 0.00 | +---------+--------+ there are no values that meet the criteria here, mysql> select * -> from aa -> left join bb -> on aa.id=bb.from_pool_id -> where aa.id=3 -> and bb.is_deleted=0 -> and aa.is_deleted=0 -> and bb.status =1; Empty set (0.00 sec)
[30 Jan 9:52]
peng gao
I understand, thank you.
[30 Jan 10:58]
MySQL Verification Team
We are glad that you understood ......