summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-08-08 21:24:00 +0400
committerSergey Petrunya <psergey@askmonty.org>2012-08-08 21:24:00 +0400
commit0e5193435ae01ae9323448aa32570a50b23c8658 (patch)
treed7e47f04b1b9c88a7da346b86781e6f2f01b0b3e /sql/sql_parse.cc
parentb71f7d97db491a7dc09f3b27336da214dd64b8f2 (diff)
downloadmariadb-git-0e5193435ae01ae9323448aa32570a50b23c8658.tar.gz
MWL#182: Explain running statements: Address feedback:
- Use LEX::value_list instead of LEX::show_explain_for_thread - Factor out common code into find_thread_by_id(ulong id)
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc42
1 files changed, 29 insertions, 13 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 73dbe328761..16f195c44cd 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2165,7 +2165,7 @@ mysql_execute_command(THD *thd)
goto error;
}
- Item **it= &(lex->show_explain_for_thread);
+ Item **it= lex->value_list.head_ref();
if ((!(*it)->fixed && (*it)->fix_fields(lex->thd, it)) ||
(*it)->check_cols(1))
{
@@ -6586,23 +6586,17 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List<String> *using_fields,
/**
- kill on thread.
+ Find a thread by id and return it, locking it LOCK_thd_data
- @param thd Thread class
- @param id Thread id
- @param only_kill_query Should it kill the query or the connection
+ @param id Identifier of the thread we're looking for
- @note
- This is written such that we have a short lock on LOCK_thread_count
+ @return NULL - not found
+ pointer - thread found, and its LOCK_thd_data is locked.
*/
-uint kill_one_thread(THD *thd, ulong id, killed_state kill_signal)
+THD *find_thread_by_id(ulong id)
{
THD *tmp;
- uint error=ER_NO_SUCH_THREAD;
- DBUG_ENTER("kill_one_thread");
- DBUG_PRINT("enter", ("id: %lu signal: %u", id, (uint) kill_signal));
-
mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
I_List_iterator<THD> it(threads);
while ((tmp=it++))
@@ -6616,7 +6610,29 @@ uint kill_one_thread(THD *thd, ulong id, killed_state kill_signal)
}
}
mysql_mutex_unlock(&LOCK_thread_count);
- if (tmp)
+ return tmp;
+}
+
+
+/**
+ kill on thread.
+
+ @param thd Thread class
+ @param id Thread id
+ @param only_kill_query Should it kill the query or the connection
+
+ @note
+ This is written such that we have a short lock on LOCK_thread_count
+*/
+
+uint kill_one_thread(THD *thd, ulong id, killed_state kill_signal)
+{
+ THD *tmp;
+ uint error=ER_NO_SUCH_THREAD;
+ DBUG_ENTER("kill_one_thread");
+ DBUG_PRINT("enter", ("id: %lu signal: %u", id, (uint) kill_signal));
+
+ if ((tmp= find_thread_by_id(id)))
{
/*
If we're SUPER, we can KILL anything, including system-threads.