From 9b269ea11b49c186a12f1a877c1d7cfa26b8b5c1 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 26 Apr 2012 07:17:34 +0530 Subject: [PATCH] MWL#182: Explain running statements - Correct thd->killed checks in join cache and filesort modules. --- sql/filesort.cc | 20 +++++++++++--------- sql/sql_join_cache.cc | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index 772698c6e1a..3b551796ae1 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -493,7 +493,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, my_off_t record; TABLE *sort_form; THD *thd= current_thd; - volatile killed_state *killed= &thd->killed; + //volatile killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set; uchar *next_sort_key= sort_keys_buf; @@ -588,7 +588,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, break; } - if (*killed) + if (thd->check_killed()) { DBUG_PRINT("info",("Sort killed by user")); if (!indexfile && !quick_select) @@ -1229,18 +1229,20 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, void *first_cmp_arg; element_count dupl_count= 0; uchar *src; - killed_state not_killable; + /* killed_state not_killable; */ uchar *unique_buff= param->unique_buff; - volatile killed_state *killed= ¤t_thd->killed; + /* volatile killed_state *killed= ¤t_thd->killed; */ + const bool killable= !param->not_killable; + THD* const thd=current_thd; DBUG_ENTER("merge_buffers"); - status_var_increment(current_thd->status_var.filesort_merge_passes); - current_thd->query_plan_fsort_passes++; - if (param->not_killable) + status_var_increment(thd->status_var.filesort_merge_passes); + thd->query_plan_fsort_passes++; + /*if (param->not_killable) { killed= ¬_killable; not_killable= NOT_KILLED; - } + }*/ error=0; rec_length= param->rec_length; @@ -1317,7 +1319,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, while (queue.elements > 1) { - if (*killed) + if (killable && thd->check_killed()) { error= 1; goto err; /* purecov: inspected */ } diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index d49be2e446c..6492fb6cd61 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2235,7 +2235,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) while (!(error= join_tab_scan->next())) { - if (join->thd->killed) + if (join->thd->check_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); @@ -2505,7 +2505,7 @@ enum_nested_loop_state JOIN_CACHE::join_null_complements(bool skip_last) for ( ; cnt; cnt--) { - if (join->thd->killed) + if (join->thd->check_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); @@ -3355,7 +3355,7 @@ int JOIN_TAB_SCAN::next() update_virtual_fields(thd, table); while (!err && select && (skip_rc= select->skip_record(thd)) <= 0) { - if (thd->killed || skip_rc < 0) + if (thd->check_killed() || skip_rc < 0) return 1; /* Move to the next record if the last retrieved record does not