You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mysql> create table t(a int, b int); Query OK, 0 rows affected (0.00 sec)
mysql> insert into t values(1,2);
Query OK, 1 row affected (0.00 sec)
mysql> insert into t values(4,5);
Query OK, 1 row affected (0.00 sec)
mysql> select (select sum(a) over ()) from t ;
+-------------------------+
| (select sum(a) over ()) |
+-------------------------+
| 1 |
| NULL |
+-------------------------+
2 rows in set (0.00 sec)
mysql> select sum(a) over () from t ;
+----------------+
| sum(a) over () |
+----------------+
| 5 |
| 5 |
+----------------+
2 rows in set (0.00 sec)
2. What did you expect to see?
mysql> select (select sum(a) over ()) from t ;
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 '()) from t' at line 1
mysql> select sum(a) over () from t ;
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 '() from t' at line 1
3. What did you see instead?
The results don't make any sense.
4. What version of TiDB are you using? (tidb-server -V or run select tidb_version(); on TiDB)
Reproducible on master branch:
commit 38298c2e3e8ae6438b2b9caa696586087ea58a4d (HEAD -> master, origin/master, origin/HEAD)
Author: Zhuomin(Charming) Liu <[email protected]>
Date: Fri May 22 17:40:10 2020 +0800
The text was updated successfully, but these errors were encountered:
zhangysh1995
changed the title
[P0]-[4.0 Bug Hunting]-[Window Function]-over function is weird
P1-[4.0 Bug Hunting]-[Window Function]-over function is weird
May 22, 2020
Window functions are a MySQL 8.0 feature. Both these queries actually work in MySQL 8, but the result of the first query is different, which I believe is a bug:
droptable if exists t;
createtablet(a int, b int);
insert into t values(1,2),(4,5);
select (selectsum(a) over ()) from t ;
selectsum(a) over () from t ;
..
mysql [localhost:8020] {msandbox} (test) >select (selectsum(a) over ()) from t ;
+-------------------------+
| (selectsum(a) over ()) |
+-------------------------+
| 1 |
| 4 |
+-------------------------+2 rows inset (0.00 sec)
mysql [localhost:8020] {msandbox} (test) >selectsum(a) over () from t ;
+----------------+
| sum(a) over () |
+----------------+
| 5 |
| 5 |
+----------------+2 rows inset (0.00 sec)
Bug Report
1. What did you do?
2. What did you expect to see?
3. What did you see instead?
The results don't make any sense.
4. What version of TiDB are you using? (
tidb-server -V
or runselect tidb_version();
on TiDB)Reproducible on master branch:
The text was updated successfully, but these errors were encountered: