mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge 10.10 into 10.11
This commit is contained in:
@@ -947,7 +947,7 @@ find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files, LEX_CSTRING *db,
|
||||
|
||||
if (!(dirp = my_dir(path, MY_THREAD_SPECIFIC | (db ? 0 : MY_WANT_STAT))))
|
||||
{
|
||||
if (my_errno == ENOENT)
|
||||
if (my_errno == ENOENT && db)
|
||||
my_error(ER_BAD_DB_ERROR, MYF(0), db->str);
|
||||
else
|
||||
my_error(ER_CANT_READ_DIR, MYF(0), path, my_errno);
|
||||
@@ -2985,7 +2985,7 @@ void Show_explain_request::call_in_target_thread()
|
||||
target_thd->set_n_backup_active_arena((Query_arena*)request_thd,
|
||||
&backup_arena);
|
||||
|
||||
query_str.copy(target_thd->query(),
|
||||
query_str.copy(target_thd->query(),
|
||||
target_thd->query_length(),
|
||||
target_thd->query_charset());
|
||||
|
||||
@@ -3136,6 +3136,8 @@ int fill_show_explain_or_analyze(THD *thd, TABLE_LIST *table, COND *cond,
|
||||
if ((tmp= find_thread_by_id(thread_id)))
|
||||
{
|
||||
Security_context *tmp_sctx= tmp->security_ctx;
|
||||
MEM_ROOT explain_mem_root, *save_mem_root;
|
||||
|
||||
/*
|
||||
If calling_user==NULL, calling thread has SUPER or PROCESS
|
||||
privilege, and so can do SHOW EXPLAIN/SHOW ANALYZE on any user.
|
||||
@@ -3161,7 +3163,8 @@ int fill_show_explain_or_analyze(THD *thd, TABLE_LIST *table, COND *cond,
|
||||
bool bres;
|
||||
/*
|
||||
Ok we've found the thread of interest and it won't go away because
|
||||
we're holding its LOCK_thd_kill. Post it a SHOW EXPLAIN/SHOW ANALYZE request.
|
||||
we're holding its LOCK_thd_kill. Post it a SHOW EXPLAIN/SHOW ANALYZE
|
||||
request.
|
||||
*/
|
||||
bool timed_out;
|
||||
int timeout_sec= 30;
|
||||
@@ -3169,7 +3172,9 @@ int fill_show_explain_or_analyze(THD *thd, TABLE_LIST *table, COND *cond,
|
||||
explain_req.is_json_format= json_format;
|
||||
select_result_explain_buffer *explain_buf;
|
||||
|
||||
explain_buf= new select_result_explain_buffer(thd, table->table);
|
||||
if (!(explain_buf= new (thd->mem_root)
|
||||
select_result_explain_buffer(thd, table->table)))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
explain_req.is_analyze= is_analyze;
|
||||
explain_req.explain_buf= explain_buf;
|
||||
@@ -3177,8 +3182,19 @@ int fill_show_explain_or_analyze(THD *thd, TABLE_LIST *table, COND *cond,
|
||||
explain_req.request_thd= thd;
|
||||
explain_req.failed_to_produce= FALSE;
|
||||
|
||||
/*
|
||||
Do not use default memroot as this is only to be used by the
|
||||
target thread (It's marked as thread MY_THREAD_SPECIFIC).
|
||||
*/
|
||||
init_sql_alloc(key_memory_thd_main_mem_root,
|
||||
&explain_mem_root, 0, 8000, MYF(0));
|
||||
save_mem_root= thd->mem_root;
|
||||
thd->mem_root= &explain_mem_root;
|
||||
|
||||
/* Ok, we have a lock on target->LOCK_thd_kill, can call: */
|
||||
bres= tmp->apc_target.make_apc_call(thd, &explain_req, timeout_sec, &timed_out);
|
||||
bres= tmp->apc_target.make_apc_call(thd, &explain_req, timeout_sec,
|
||||
&timed_out);
|
||||
thd->mem_root= save_mem_root;
|
||||
|
||||
if (bres || explain_req.failed_to_produce)
|
||||
{
|
||||
@@ -3223,6 +3239,7 @@ int fill_show_explain_or_analyze(THD *thd, TABLE_LIST *table, COND *cond,
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_YES, warning_text);
|
||||
}
|
||||
free_root(&explain_mem_root, MYF(0));
|
||||
DBUG_RETURN(bres);
|
||||
}
|
||||
my_error(ER_NO_SUCH_THREAD, MYF(0), (ulong) thread_id);
|
||||
|
Reference in New Issue
Block a user