[MDEV-22984] Throw an error when arguments to window functions are window functions Created: 2020-06-23  Updated: 2020-06-30  Resolved: 2020-06-30

Status: Closed
Project: MariaDB Server
Component/s: Optimizer, Optimizer - Window functions
Affects Version/s: 10.2
Fix Version/s: 10.2.33, 10.3.24, 10.4.14, 10.5.5

Type: Bug Priority: Major
Reporter: Varun Gupta (Inactive) Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 0
Labels: None


 Description   

CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES (1,1), (2,2), (3,3);

MariaDB [test]> SELECT NTILE(MAX(a) OVER (PARTITION BY a)) OVER (PARTITION BY a ORDER BY b) FROM t1;
ERROR 4074 (HY000): Window functions can not be used as arguments to group functions.

MariaDB [test]> SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1 GROUP BY a;

This query just crashes.
We should ensure that for FIRST_VALUE window function, we don't allow a window function in its arguments.



 Comments   
Comment by Varun Gupta (Inactive) [ 2020-06-23 ]

Patch
https://github.com/mariadb/server/commit/db8f07beebb193dcf092f31b980cfdd374323658

Comment by Sergei Petrunia [ 2020-06-30 ]

Ok to push.

Generated at Thu Feb 08 09:18:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.