[MDEV-24314] Unexpected error message when selecting from view that uses mergeable derived table Created: 2020-12-01  Updated: 2020-12-08  Resolved: 2020-12-04

Status: Closed
Project: MariaDB Server
Component/s: Views
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.2.37, 10.3.28, 10.4.18, 10.5.9

Type: Bug Priority: Critical
Reporter: Igor Babaev Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-22781 CREATE VIEW containing WITH clause Si... Closed

 Description   

The following test case demonstrates the problem:

drop database test;
create database test;
create table test.t1 (a int);
insert into test.t1 values (3),(7),(1);
create view test.v2 as select * from (select * from test.t1) as t;
select test.v2.a from test.v2;

MariaDB [(none)]> select test.v2.a from test.v2;
ERROR 1356 (HY000): View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them                                                                                                                 



 Comments   
Comment by Igor Babaev [ 2020-12-01 ]

Sanja:
Most probably the bug exists starting from:

commit 7166069537a4e18d4c0848655fcbc0c8ee568fd4
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date:   Thu Feb 25 14:55:04 2016 +0100
 
    MDEV-3944: Allow derived tables in VIEWS

I made a checkout for this commit. Yet the tree after this commit was not in a good shape as I got:

MariaDB [(none)]> create view test.v2 as select * from (select * from test.t1) as t;
ERROR 1142 (42000): ANY command denied to user ''@'' for table '*'

I marked this bug as "Critical" because MDEV-22781 is marked as 'Critical'.
MDEV-22781 is crashing, but I checked it against my fix for MDEV-22886 and there I had the same error message as for MDEV-24314.

Comment by Oleksandr Byelkin [ 2020-12-02 ]

   if (all_tables)
      res= check_table_access(thd,
                              privileges_requested,
                              all_tables, FALSE, UINT_MAX, FALSE);
    else

correctly assign privileges and detect that all required given

Comment by Oleksandr Byelkin [ 2020-12-04 ]

OK to push

Comment by Igor Babaev [ 2020-12-04 ]

A fix for this bug was pushed into 10.2

Generated at Thu Feb 08 09:29:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.