diff options
author | Sergei Golubchik <serg@mariadb.org> | 2020-12-11 19:35:38 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-12-11 19:35:38 +0100 |
commit | 4fa44c584cf14c72fdbb15b88d406fd4e9e42c18 (patch) | |
tree | 0854fd83abc8fce7132ac775afef758f3a246080 | |
parent | 79fd338e6ca6df8d4c8cf3f326fc6ae0a256bdd2 (diff) | |
download | mariadb-git-4fa44c584cf14c72fdbb15b88d406fd4e9e42c18.tar.gz |
MDEV-24331 mysqldump fails with "Got error: 1356" if the database contains a view with a subquery
detect derived tables differently. TABLE_LIST::is_derived()
only works after mysql_derived_init()
-rw-r--r-- | mysql-test/r/lock_view.result | 34 | ||||
-rw-r--r-- | mysql-test/t/lock_view.test | 17 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 |
3 files changed, 52 insertions, 1 deletions
diff --git a/mysql-test/r/lock_view.result b/mysql-test/r/lock_view.result index 4d375bace42..364c2cddf60 100644 --- a/mysql-test/r/lock_view.result +++ b/mysql-test/r/lock_view.result @@ -229,3 +229,37 @@ drop user definer@localhost; drop database mysqltest1; drop database mysqltest2; drop database mysqltest3; +# +# MDEV-24331 mysqldump fails with "Got error: 1356" if the database contains a view with a subquery +# +create user u1@localhost; +grant all privileges on test.* to u1@localhost; +connect con1,localhost,u1; +use test; +create table t1 (id int not null); +create view v1 as select * from (select * from t1) dt; +lock table v1 read; +disconnect con1; +connection default; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `v1` ( + `id` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; +/*!50001 DROP TABLE IF EXISTS `v1`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = latin1 */; +/*!50001 SET character_set_results = latin1 */; +/*!50001 SET collation_connection = latin1_swedish_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`u1`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v1` AS select `dt`.`id` AS `id` from (select `test`.`t1`.`id` AS `id` from `test`.`t1`) `dt` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; +drop view v1; +drop table t1; +drop user u1@localhost; diff --git a/mysql-test/t/lock_view.test b/mysql-test/t/lock_view.test index 4b1adac5be1..abb8d317946 100644 --- a/mysql-test/t/lock_view.test +++ b/mysql-test/t/lock_view.test @@ -75,3 +75,20 @@ drop user definer@localhost; drop database mysqltest1; drop database mysqltest2; drop database mysqltest3; + +--echo # +--echo # MDEV-24331 mysqldump fails with "Got error: 1356" if the database contains a view with a subquery +--echo # +create user u1@localhost; +grant all privileges on test.* to u1@localhost; +connect con1,localhost,u1; +use test; +create table t1 (id int not null); +create view v1 as select * from (select * from t1) dt; +lock table v1 read; +disconnect con1; +connection default; +exec $MYSQL_DUMP test v1 -uu1 --compact; +drop view v1; +drop table t1; +drop user u1@localhost; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6e1d36b79a4..54937116383 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6639,7 +6639,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, bool check_single_table_access(THD *thd, ulong privilege, TABLE_LIST *tables, bool no_errors) { - if (tables->is_derived()) + if (tables->derived) return 0; Switch_to_definer_security_ctx backup_sctx(thd, tables); |