[MDEV-24331] mysqldump fails with "Got error: 1356" if the database contains a view with a subquery Created: 2020-12-02  Updated: 2020-12-12  Resolved: 2020-12-12

Status: Closed
Project: MariaDB Server
Component/s: Locking, Views
Affects Version/s: 10.2.35, 10.3.26, 10.4.16, 10.5.7
Fix Version/s: 10.2.37, 10.3.28, 10.4.18, 10.5.9

Type: Bug Priority: Blocker
Reporter: Nikita Rybalov Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: mysqldump, regression, subquery, view, views
Environment:

Debian 9.0, CentOS 7.9, CentOS 8.2



 Description   

Impact

Database users cannot use data export if the database contains views with subqueries. This causes difficulties in backing up data and causes an application compatibility issue with newer versions of MariaDB.

Steps to reproduce

  1. Create database and user, grant all privileges:

    mysql -uroot
    

    CREATE DATABASE test;
    CREATE USER 'test'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost';
    

  2. Create test data:

    mysql -utest -ppassword
    

    USE test;
    CREATE TABLE `test_table` (`id` INT NOT NULL);
    CREATE VIEW `test_view` AS SELECT * FROM (SELECT * FROM `test_table`) tt;
    

  3. Try to dump the database:

    mysqldump test -utest -ppassword
    

Actual result

The dump fails with an error:

mysqldump: Got error: 1356: "View 'test.test_view' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" when using LOCK TABLES

Expected result

The dump procedure is completed successfully.

Additional information

The issue is reproduced on versions: 10.5.8, 10.4.17. But I have not tested earlier versions (10.5.* and 10.4.*).

The issue does not occur on earlier versions of MariaDB (10.3.27 works correct).



 Comments   
Comment by Sergei Golubchik [ 2020-12-03 ]

possibly caused by https://github.com/MariaDB/server/commit/0c3723e1d50

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