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

CREATE VIEW in a stored procedure accepts an XMLTYPE method call on an SP variable and creates a broken view

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • N/A
    • 13.3
    • Data types, Views
    • None

    Description

      A plain SP variable in a view definition is rejected at CREATE PROCEDURE with ER_VIEW_SELECT_VARIABLE; a method call on one is accepted. The view is stored without the variable and can't be used afterwards.

      --delimiter $$
      --error ER_VIEW_SELECT_VARIABLE
      CREATE PROCEDURE p0()
      BEGIN
        DECLARE x XMLTYPE DEFAULT '<root>9</root>';
        CREATE VIEW v0 AS SELECT x AS c;
      END$$
      --echo # BUG if no ER_VIEW_SELECT_VARIABLE, as for p0
      CREATE PROCEDURE p1()
      BEGIN
        DECLARE x XMLTYPE DEFAULT '<root>9</root>';
        CREATE VIEW v1 AS SELECT x.getRootElement() AS c;
      END$$
      --delimiter ;
      CALL p1();
      SHOW CREATE VIEW v1;
      --error ER_VIEW_INVALID
      SELECT * FROM v1;
      DROP VIEW v1;
      DROP PROCEDURE p1;

      SHOW CREATE VIEW v1;
      v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `getRootElement`() AS `c`	latin1	latin1_swedish_ci
      Warnings:
      Warning	1356	View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
      SELECT * FROM v1;
      ERROR 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

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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