diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-07-02 00:05:27 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-07-02 16:44:00 +0200 |
commit | 164a64baa3beb84e7a2c431cd136e22c9e3dbf81 (patch) | |
tree | 006fe3eb7ec8eba3819e988dbe667347d49f6957 /sql/sql_reload.cc | |
parent | b5f50e2de8dd8f43f0975a3a913d808a54e87c8d (diff) | |
download | mariadb-git-164a64baa3beb84e7a2c431cd136e22c9e3dbf81.tar.gz |
MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
privilege checks for tables flushed via views
Diffstat (limited to 'sql/sql_reload.cc')
-rw-r--r-- | sql/sql_reload.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 0fa2fa10df8..64544e42d30 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -24,6 +24,7 @@ #include "sql_connect.h" // reset_mqh #include "thread_cache.h" #include "sql_base.h" // close_cached_tables +#include "sql_parse.h" // check_single_table_access #include "sql_db.h" // my_dbopt_cleanup #include "hostname.h" // hostname_cache_refresh #include "sql_repl.h" // reset_master, reset_slave @@ -586,28 +587,27 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) &lock_tables_prelocking_strategy)) goto error_reset_bits; - if (thd->lex->type & REFRESH_FOR_EXPORT) + if (thd->lex->type & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK)) { - // Check if all storage engines support FOR EXPORT. for (TABLE_LIST *table_list= all_tables; table_list; table_list= table_list->next_global) { - if (!(table_list->is_view() || - table_list->table->file->ha_table_flags() & HA_CAN_EXPORT)) + if (table_list->belong_to_view && + check_single_table_access(thd, PRIV_LOCK_TABLES, table_list, FALSE)) + { + table_list->hide_view_error(thd); + goto error_reset_bits; + } + if (table_list->is_view()) + continue; + if (thd->lex->type & REFRESH_FOR_EXPORT && + !(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT)) { my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(), table_list->db.str, table_list->table_name.str); goto error_reset_bits; } - } - } - - if (thd->lex->type & REFRESH_READ_LOCK) - { - for (auto table_list= all_tables; table_list; - table_list= table_list->next_global) - { - if (!table_list->is_view() && + if (thd->lex->type & REFRESH_READ_LOCK && table_list->table->file->extra(HA_EXTRA_FLUSH)) goto error_reset_bits; } |