[MDEV-12840] view with ifnull around window function error Created: 2017-05-19  Updated: 2019-03-28  Resolved: 2019-03-28

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2.5
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: David Thompson (Inactive) Assignee: Vicențiu Ciorbaru
Resolution: Cannot Reproduce Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-12851 Window functions with is null functio... Closed

 Description   

A view that has an ifnull around a window function results in error 1356 on querying. A view without the ifnull works and the select with ifnull works.

Test case:

create table t1(dt datetime);
insert into t1 values ('2017-05-17'), ('2017-05-18');
create view v1 as select dt, lead(dt) over (order by dt) from t1;
create view v2 as select dt, ifnull(lead(dt) over (order by dt), '9999-12-31 12:00:00') from t1;
 
select * from v1;
+---------------------+-----------------------------+
| dt                  | lead(dt) over (order by dt) |
+---------------------+-----------------------------+
| 2017-05-17 00:00:00 | 2017-05-18 00:00:00         |
| 2017-05-18 00:00:00 | NULL                        |
+---------------------+-----------------------------+
2 rows in set (0.00 sec)
 
select * from v2;
ERROR 1356 (HY000): View 'genesis.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
 
select dt, ifnull(lead(dt) over (order by dt), '9999-12-31 12:00:00') from t1;
+---------------------+------------------------------------------------------------+
| dt                  | ifnull(lead(dt) over (order by dt), '9999-12-31 12:00:00') |
+---------------------+------------------------------------------------------------+
| 2017-05-17 00:00:00 | 2017-05-18 00:00:00                                        |
| 2017-05-18 00:00:00 | 9999-12-31 12:00:00                                        |
+---------------------+------------------------------------------------------------+
2 rows in set (0.00 sec)



 Comments   
Comment by Alice Sherepa [ 2019-03-28 ]

Currently not reproducible

Generated at Thu Feb 08 08:00:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.