diff --git a/sql/sql_class.cc b/sql/sql_class.cc index cc57ba726b4..cbdaca0fac5 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -802,6 +802,7 @@ THD::THD() rli_fake(0), rli_slave(NULL), user_time(0), in_sub_stmt(0), fill_status_recursion_level(0), + fill_variables_recursion_level(0), binlog_unsafe_warning_flags(0), binlog_table_maps(0), table_map_for_update(0), diff --git a/sql/sql_class.h b/sql/sql_class.h index 22b4eabac13..5a5e8b48754 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1603,6 +1603,7 @@ public: decremented each time before it returns from the function. */ uint fill_status_recursion_level; + uint fill_variables_recursion_level; /* container for handler's private per-connection data */ Ha_data ha_data[MAX_HA]; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 51f5d75e49b..4c9811cea2d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6317,7 +6317,11 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) Lock LOCK_plugin_delete to avoid deletion of any plugins while creating SHOW_VAR array and hold it until all variables are stored in the table. */ - mysql_mutex_lock(&LOCK_plugin_delete); + if (thd->fill_variables_recursion_level++ == 0) + { + mysql_mutex_lock(&LOCK_plugin_delete); + } + // Lock LOCK_system_variables_hash to prepare SHOW_VARs array. mysql_rwlock_rdlock(&LOCK_system_variables_hash); DEBUG_SYNC(thd, "acquired_LOCK_system_variables_hash"); @@ -6327,7 +6331,11 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) res= show_status_array(thd, wild, sys_var_array, option_type, NULL, "", tables->table, upper_case_names, cond); - mysql_mutex_unlock(&LOCK_plugin_delete); + if (thd->fill_variables_recursion_level-- == 1) + { + mysql_mutex_unlock(&LOCK_plugin_delete); + } + DBUG_RETURN(res); }