[MDEV-20229] CTE defined with table value constructor cannot be used in views. Created: 2019-08-01  Updated: 2019-09-21  Resolved: 2019-09-21

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.3
Fix Version/s: 10.3.19, 10.4.9, 10.5.0

Type: Bug Priority: Major
Reporter: Igor Babaev Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None


 Description   

The following query demonstrates the problem:

create view v1 as with t(a) as (values (2), (1)) select a from t;

MariaDB [test]> select * from v1;
ERROR 1356 (HY000): View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them



 Comments   
Comment by Igor Babaev [ 2019-08-01 ]

The following shows the cause of the problem:

MariaDB [test]> show create view v1;
+------+----------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View                                                                                                                      | character_set_client | collation_connection |
+------+----------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| v1   | CREATE ALGORITHM=UNDEFINED DEFINER=`` SQL SECURITY DEFINER VIEW `v1` AS with t as (values (2),(1))select `t`.`a` AS `a` from `t` | utf8                 | utf8_general_ci      |
+------+----------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+

So the internal representation of the view lacks the list of the column names.
It happens because With_element::print does not print this list.

Comment by Igor Babaev [ 2019-09-21 ]

A fix for this bug was pushed into 10.3

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