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

XMLTYPE SP variable named like a table alias hides table-qualified columns: wrong result or "FUNCTION t1.a does not exist"

    XMLWordPrintable

Details

    Description

      Since XMLTYPE got methods (has_methods() returns true), a two-part identifier t1.col whose first part names an XMLTYPE SP variable is always treated as a method call on the variable. A variable of another type with the same name lets t1.col resolve to the column.

      Regression from MDEV-36261 (5370405937a): at its parent 6f18dc2d117 the same test returns 2 and 1.

      CREATE TABLE t1 (a INT, getrootelement INT);
      INSERT INTO t1 VALUES (1, 2);
      --delimiter $$
      CREATE PROCEDURE p1()
      BEGIN
        DECLARE t1 XMLTYPE DEFAULT '<r/>';
        SELECT t1.getrootelement FROM t1;
      END$$
      --delimiter ;
      --echo # BUG if not 2
      CALL p1();
      --delimiter $$
      --echo # BUG if error: t1.a is a column, as with an INT variable
      CREATE PROCEDURE p2()
      BEGIN
        DECLARE t1 XMLTYPE DEFAULT '<r/>';
        SELECT t1.a FROM t1;
      END$$
      --delimiter ;
      CALL p2();
      DROP PROCEDURE p1;
      DROP PROCEDURE p2;
      DROP TABLE t1;

      CALL p1();
      t1.getrootelement
      r
      CREATE PROCEDURE p2() ...
      ERROR 42000: FUNCTION t1.a does not exist

      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.