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

2nd execution name resolution problem with pushdown into unions

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

            Johnston Rex Johnston created issue -
            Johnston Rex Johnston made changes -
            Field Original Value New Value
            Johnston Rex Johnston made changes -
            Assignee Rex Johnston [ JIRAUSER52533 ]
            Johnston Rex Johnston made changes -
            Description {code:sql}
            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;
            {code}

            first execution give the correct answer

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

            2nd execution does not

            {noformat}
            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
            {noformat}

            I have solved this problem in the linked MDEV, but it will be worth backporting the fix to earlier versions.
            {code:sql}
            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;
            {code}

            first execution gives the correct answer

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

            2nd execution does not

            {noformat}
            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
            {noformat}

            I have solved this problem in the linked MDEV, but it will be worth backporting the fix to earlier versions.
            Johnston Rex Johnston made changes -
            Affects Version/s 11.5.1 [ 29634 ]
            Affects Version/s 11.4.2 [ 29633 ]
            Affects Version/s 11.2.4 [ 29631 ]
            Affects Version/s 11.1.5 [ 29629 ]
            Affects Version/s 10.11.8 [ 29630 ]
            Affects Version/s 10.6.18 [ 29627 ]
            Affects Version/s 11.6.0 [ 29839 ]
            Johnston Rex Johnston made changes -
            Fix Version/s 10.11.9 [ 29834 ]
            Fix Version/s 11.1.6 [ 29835 ]
            Fix Version/s 11.2.5 [ 29836 ]
            Fix Version/s 11.4.3 [ 29837 ]
            Fix Version/s 11.5.2 [ 29838 ]
            Fix Version/s 10.7 [ 24805 ]
            Johnston Rex Johnston made changes -
            Description {code:sql}
            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;
            {code}

            first execution gives the correct answer

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

            2nd execution does not

            {noformat}
            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
            {noformat}

            I have solved this problem in the linked MDEV, but it will be worth backporting the fix to earlier versions.
            {code:sql}
            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;
            {code}

            first execution gives the correct answer

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

            2nd execution does not

            {noformat}
            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
            {noformat}

            I have solved this problem in the linked MDEV, but it will be worth backporting the fix to earlier versions.
            Johnston Rex Johnston made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            Johnston Rex Johnston made changes -
            Assignee Rex Johnston [ JIRAUSER52533 ] Igor Babaev [ igor ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.4 [ 29301 ]
            Fix Version/s 11.5 [ 29506 ]
            Fix Version/s 10.11.9 [ 29834 ]
            Fix Version/s 11.1.6 [ 29835 ]
            Fix Version/s 11.2.5 [ 29836 ]
            Fix Version/s 11.4.3 [ 29837 ]
            Fix Version/s 11.5.2 [ 29838 ]
            Johnston Rex Johnston made changes -
            Assignee Igor Babaev [ igor ] Rex Johnston [ JIRAUSER52533 ]
            Johnston Rex Johnston made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            Johnston Rex Johnston made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            igor Igor Babaev (Inactive) made changes -
            Status In Progress [ 3 ] Needs Feedback [ 10501 ]
            Johnston Rex Johnston made changes -
            Fix Version/s N/A [ 14700 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.4 [ 29301 ]
            Fix Version/s 11.5 [ 29506 ]
            Resolution Incomplete [ 4 ]
            Status Needs Feedback [ 10501 ] Closed [ 6 ]
            Johnston Rex Johnston made changes -
            Resolution Incomplete [ 4 ]
            Status Closed [ 6 ] Stalled [ 10000 ]
            Johnston Rex Johnston made changes -
            Assignee Rex Johnston [ JIRAUSER52533 ] Igor Babaev [ igor ]
            Status Stalled [ 10000 ] In Review [ 10002 ]
            igor Igor Babaev (Inactive) made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            igor Igor Babaev (Inactive) made changes -
            Assignee Igor Babaev [ igor ] Rex Johnston [ JIRAUSER52533 ]
            Johnston Rex Johnston made changes -
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.4 [ 29301 ]
            Fix Version/s 11.5 [ 29506 ]
            Fix Version/s 11.6 [ 29515 ]
            Fix Version/s N/A [ 14700 ]
            Johnston Rex Johnston made changes -
            Fix Version/s 10.5.26 [ 29832 ]
            Fix Version/s 10.6.19 [ 29833 ]
            Fix Version/s 10.11.9 [ 29834 ]
            Fix Version/s 11.1.6 [ 29835 ]
            Fix Version/s 11.2.5 [ 29836 ]
            Fix Version/s 11.4.3 [ 29837 ]
            Fix Version/s 11.5.2 [ 29838 ]
            Fix Version/s 11.6.1 [ 29847 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.4 [ 29301 ]
            Fix Version/s 11.5 [ 29506 ]
            Fix Version/s 11.6 [ 29515 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]

            People

              Johnston Rex Johnston
              Johnston Rex Johnston
              Votes:
              1 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.