TiDBv5.1.0开窗函数ROW_NUMBER报错

Bug 反馈
清晰准确地描述您发现的问题,提供任何可能复现问题的步骤有助于研发同学及时处理问题
【 Bug 的影响】
系统无法使用

【可能的问题复现步骤】

CREATE TABLE tmp_2021071201 ( c_sort int );

INSERT INTO tmp_2021071201(c_sort) VALUES(1),(2),(3),(4),(5);

SELECT ROW_NUMBER() OVER (ORDER BY c_sort) c_sort FROM tmp_2021071201;

【看到的非预期行为】
报错提示:

Error occurred during SQL query execution

原因:
SQL 错误 [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 98 near “(ORDER BY c_sort) c_sort FROM tmp_2021071201”

【期望看到的行为】
查询返回正常结果

【相关组件及具体版本】
TiDB版本: 5.7.25-TiDB-v5.1.0

【其他背景信息或者截图】
如集群拓扑,系统和内核版本,应用 app 信息等;如果问题跟 SQL 有关,请提供 SQL 语句和相关表的 Schema 信息;如果节点日志存在关键报错,请提供相关节点的日志内容或文件;如果一些业务敏感信息不便提供,请留下联系方式,我们与您私下沟通。

tidb 日志有没有打印报错堆栈,我在本地用 v5.1.0 和 v5.0.0 版本都没有复现

稍等,我查一下。我这边本机部署单机测试也不报错,但tiup部署的测试服务器报错,就很奇怪。

什么都没有

[2021/07/12 10:29:36.992 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=39.99325ms]
[2021/07/12 10:36:30.821 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=36.162216ms]
[2021/07/12 10:37:10.824 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=39.105542ms]
[2021/07/12 10:43:10.560 +08:00] [WARN] [2pc.go:1446] [“schemaLeaseChecker is not set for this transaction”] [sessionID=35] [startTS=426261293397704712] [commitTS=426261293437026305]
[2021/07/12 10:43:10.934 +08:00] [WARN] [session.go:1320] [“parse SQL failed”] [conn=35] [error=“line 1 column 98 near “(ORDER BY c_sort) c_sort FROM tmp_2021071201” “] [SQL=”/* ApplicationName=DBeaver Enterprise 7.3.0 - SQLEditor <Script.sql> / SELECT ROW_NUMBER() OVER (ORDER BY c_sort) c_sort FROM tmp_2021071201"]
[2021/07/12 10:43:36.369 +08:00] [WARN] [session.go:1320] [“parse SQL failed”] [conn=37] [error="line 1 column 98 near “(ORDER BY c_sort) c_sort FROM tmp_2021071201” “] [SQL=”/
ApplicationName=DBeaver Enterprise 7.3.0 - SQLEditor <Script.sql> / SELECT ROW_NUMBER() OVER (ORDER BY c_sort) c_sort FROM tmp_2021071201"]
[2021/07/12 10:43:36.970 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=32.624586ms]
[2021/07/12 10:43:36.987 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=48.873128ms]
[2021/07/12 10:43:48.976 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=38.967341ms]
[2021/07/12 10:44:15.382 +08:00] [WARN] [session.go:1320] [“parse SQL failed”] [conn=37] [error="line 1 column 98 near “(ORDER BY c_sort) c_sort FROM tmp_2021071201” “] [SQL=”/
ApplicationName=DBeaver Enterprise 7.3.0 - SQLEditor <Script.sql> */ SELECT ROW_NUMBER() OVER (ORDER BY c_sort) c_sort FROM tmp_2021071201”]
[2021/07/12 10:44:43.980 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=33.10919ms]
[2021/07/12 10:44:59.969 +08:00] [WARN] [pd.go:131] [“get timestamp too slow”] [“cost time”=31.879878ms]

刚收集到一个信息,报错的测试服务器是从3.0升级到的5.1不知道和这个有没有关系。