From 822071ca5b6d109e5497f1c15efa44fe47d277c5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Apr 2019 13:02:51 +0200 Subject: [PATCH] MDEV-18241 Downgrade from 10.4 to 10.3 crashes privilege tables can never be views or temporary tables, don't even try to open them, if they are. --- mysql-test/r/grant4.result | 11 +++++++++++ mysql-test/t/grant4.test | 15 +++++++++++++++ sql/sql_acl.cc | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/mysql-test/r/grant4.result b/mysql-test/r/grant4.result index d0b6627cd0b..9b6d4c42c59 100644 --- a/mysql-test/r/grant4.result +++ b/mysql-test/r/grant4.result @@ -121,3 +121,14 @@ View Create View character_set_client collation_connection v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t_select_priv`.`a` AS `a`,`t_select_priv`.`b` AS `b` from `t_select_priv` latin1 latin1_swedish_ci drop database mysqltest_db1; drop user mysqltest_u1@localhost; +call mtr.add_suppression("Table 'mysql.user' doesn't exist"); +rename table mysql.user to mysql.user1; +create view mysql.user as select * from mysql.user1; +flush privileges; +ERROR 42S02: Table 'mysql.user' doesn't exist +drop view mysql.user; +create temporary table mysql.user select * from mysql.user1 limit 0; +flush privileges; +ERROR 42S02: Table 'mysql.user' doesn't exist +drop temporary table mysql.user; +rename table mysql.user1 to mysql.user; diff --git a/mysql-test/t/grant4.test b/mysql-test/t/grant4.test index f3e551cd623..2762182b978 100644 --- a/mysql-test/t/grant4.test +++ b/mysql-test/t/grant4.test @@ -144,3 +144,18 @@ connection default; disconnect con1; drop database mysqltest_db1; drop user mysqltest_u1@localhost; + +# +# MDEV-18241 Downgrade from 10.4 to 10.3 crashes +# +call mtr.add_suppression("Table 'mysql.user' doesn't exist"); +rename table mysql.user to mysql.user1; +create view mysql.user as select * from mysql.user1; +--error ER_NO_SUCH_TABLE +flush privileges; +drop view mysql.user; +create temporary table mysql.user select * from mysql.user1 limit 0; +--error ER_NO_SUCH_TABLE +flush privileges; +drop temporary table mysql.user; +rename table mysql.user1 to mysql.user; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 19ecd870307..5d7f82ff5dd 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1155,8 +1155,12 @@ static void fix_table_list(TABLE_LIST *tl, uint n) TABLE_LIST *end; for (end= tl + n - 1; tl < end; tl++) { + tl->i_s_requested_object= OPEN_TABLE_ONLY; + tl->open_type= OT_BASE_ONLY; tl->next_local= tl->next_global= tl + 1; } + tl->i_s_requested_object= OPEN_TABLE_ONLY; + tl->open_type= OT_BASE_ONLY; }