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

2nd execution name resolution problem with pushdown into unions

    XMLWordPrintable

Details

    Description

      create table t1 (c1 int, c2 int, c3 int);
      insert into t1 values (1,2,3),(4,5,6);
      create table t2 like t1;
      insert into t2 values (7,8,9),(10,11,12);
      create view v1 (f1, f2, f3) as select * from (
        select c1, c2, sum(c3) as s from t1 group by c1, c2 having s > 2
        union
        select c1, c2, sum(c3) as u from t2 group by c1, c2 having u > 3 ) d2;
      prepare stmt from 'select * from v1 where f2 > 0';
      execute stmt;
      execute stmt;
      

      first execution gives the correct answer

      +------+------+------+
      | f1   | f2   | f3   |
      +------+------+------+
      |    1 |    2 |    3 |
      |    4 |    5 |    6 |
      |    7 |    8 |    9 |
      |   10 |   11 |   12 |
      +------+------+------+
      

      2nd execution does not

      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
      

      I have solved this problem in the linked MDEV, but it will be worth backporting the fix to earlier versions.

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              Johnston Rex Johnston
              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.