Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20229

CTE defined with table value constructor cannot be used in views.

Details

    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
      

      Attachments

        Activity

          igor Igor Babaev added a comment -

          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.

          igor Igor Babaev added a comment - 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.
          igor Igor Babaev added a comment -

          A fix for this bug was pushed into 10.3

          igor Igor Babaev added a comment - A fix for this bug was pushed into 10.3

          People

            igor Igor Babaev
            igor Igor Babaev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.