https://dev.mysql.com/worklog/task/?id=8693
根据WL#8693,MySQL 8.0后续版本将不再支持GROUP BY ASC DESC语法.
测试表和数据
create table t (id int primary key,name varchar(20));
insert into t values(1,'test'),(2,'test2');
MySQL 5.7.30
mysql> select id,count(*) from t group by id desc;
+----+----------+
| id | count(*) |
+----+----------+
| 2 | 1 |
| 1 | 1 |
+----+----------+
mysql> show warnings;
+---------+------+----------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------------------------+
| Warning | 1287 | 'GROUP BY with ASC/DESC' is deprecated and will be removed in a
future release. Please use GROUP BY ... ORDER BY ... ASC/DESC instead |
+---------+------+----------------------------------------------------------------------+
1 row in set (0.00 sec)
MySQL 8.0.22
mysql> select id,count(*) from t group by id desc;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL
server version for the right syntax to use near 'desc' at line 1
该WL还会影响升级操作
在MySQL 5.7创建测试表和存储过程
create database test;
use test;
create table t (id int primary key,name varchar(20));
insert into t values(1,'test'),(2,'test2');
delimiter $
create procedure test_group()
begin
select id,count(*) from t group by id desc;
end $
delimiter ;
关闭实例后,使用MySQL 8.0.22程序进行升级
/data/mysql8_debug/bin/mysqld_safe --defaults-file=./my.cnf --upgrade=FORCE &
升级失败
[ERROR] [MY-013235] [Server] Error in parsing Routine 'test'.'test_group'
during upgrade. You have an error in your SQL syntax; check the manual that
corresponds to your MySQL
server version for the right syntax to use near 'desc; end' at line 3
[ERROR] [MY-010022] [Server] Failed to Populate DD tables.
[ERROR] [MY-010119] [Server] Aborting
[System] [MY-010910] [Server] /data/mysql8_debug/bin/mysqld:
Shutdown complete (mysqld 8.0.22-debug) Source distribution.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。