Commit 0428d086 authored by hf@deer.mysql.r18.ru's avatar hf@deer.mysql.r18.ru

SCRUM

two KILL versions
code trimming with headquarter's suggestions 
parent dcdc24b5
...@@ -2585,7 +2585,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) ...@@ -2585,7 +2585,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
char llbuff[22],llbuff2[22]; char llbuff[22],llbuff2[22];
DBUG_ENTER("sort_get_next_record"); DBUG_ENTER("sort_get_next_record");
if (killed_ptr(param->thd)) if (*killed_ptr(param->thd))
DBUG_RETURN(1); DBUG_RETURN(1);
switch (share->data_file_type) { switch (share->data_file_type) {
......
...@@ -1644,9 +1644,9 @@ err: ...@@ -1644,9 +1644,9 @@ err:
DBUG_RETURN(1); DBUG_RETURN(1);
} /* sort_record_index */ } /* sort_record_index */
bool killed_ptr(void *thd) int *killed_ptr(void *thd)
{ {
return (bool)thd; /* always NULL */ return (int *)thd; /* always NULL */
} }
/* print warnings and errors */ /* print warnings and errors */
......
...@@ -693,7 +693,7 @@ int mi_open_keyfile(MYISAM_SHARE *share); ...@@ -693,7 +693,7 @@ int mi_open_keyfile(MYISAM_SHARE *share);
void mi_setup_functions(register MYISAM_SHARE *share); void mi_setup_functions(register MYISAM_SHARE *share);
/* Functions needed by mi_check */ /* Functions needed by mi_check */
bool killed_ptr(void *thd); int *killed_ptr(void *thd);
void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...));
void mi_check_print_warning _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_warning _VARARGS((MI_CHECK *param, const char *fmt,...));
void mi_check_print_info _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_info _VARARGS((MI_CHECK *param, const char *fmt,...));
......
...@@ -844,7 +844,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, ...@@ -844,7 +844,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
uchar *strpos; uchar *strpos;
BUFFPEK *buffpek,**refpek; BUFFPEK *buffpek,**refpek;
QUEUE queue; QUEUE queue;
void *thd= info->sort_info->param->thd; int *killed= killed_ptr(info->sort_info->param->thd);
DBUG_ENTER("merge_buffers"); DBUG_ENTER("merge_buffers");
...@@ -876,7 +876,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, ...@@ -876,7 +876,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
{ {
for (;;) for (;;)
{ {
if (killed_ptr(thd)) if (*killed)
{ {
error=1; goto err; error=1; goto err;
} }
......
...@@ -89,9 +89,9 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -89,9 +89,9 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
extern "C" { extern "C" {
bool killed_ptr(void *thd) int *killed_ptr(void *thd)
{ {
return ((THD *)thd)->killed; return (int*)&((THD *)thd)->killed;
} }
void mi_check_print_error(MI_CHECK *param, const char *fmt,...) void mi_check_print_error(MI_CHECK *param, const char *fmt,...)
......
...@@ -154,7 +154,7 @@ retry: ...@@ -154,7 +154,7 @@ retry:
thd->proc_info=0; thd->proc_info=0;
if (thd->killed) if (thd->killed)
{ {
my_error(thd->killed, MYF(0)); thd->send_kill_message();
if (sql_lock) if (sql_lock)
{ {
mysql_unlock_tables(thd,sql_lock); mysql_unlock_tables(thd,sql_lock);
......
...@@ -779,7 +779,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ...@@ -779,7 +779,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
0 : LOG_EVENT_THREAD_SPECIFIC_F, using_trans), 0 : LOG_EVENT_THREAD_SPECIFIC_F, using_trans),
data_buf(0), query(query_arg), data_buf(0), query(query_arg),
db(thd_arg->db), q_len((uint32) query_length), db(thd_arg->db), q_len((uint32) query_length),
error_code((int)thd_arg->killed ? (int)thd_arg->killed : thd_arg->net.last_errno), error_code(thd_arg->killed != THD::NOT_KILLED ? thd->killed_errno() : thd_arg->net.last_errno),
thread_id(thd_arg->thread_id) thread_id(thd_arg->thread_id)
{ {
time_t end_time; time_t end_time;
......
...@@ -154,7 +154,7 @@ static int rr_sequential(READ_RECORD *info) ...@@ -154,7 +154,7 @@ static int rr_sequential(READ_RECORD *info)
{ {
if (info->thd->killed) if (info->thd->killed)
{ {
my_error(info->thd->killed,MYF(0)); info->thd->send_kill_message();
return 1; return 1;
} }
if (tmp != HA_ERR_RECORD_DELETED) if (tmp != HA_ERR_RECORD_DELETED)
......
...@@ -559,7 +559,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, ...@@ -559,7 +559,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
if (thd->killed) if (thd->killed)
{ {
pthread_mutex_unlock(cond_lock); pthread_mutex_unlock(cond_lock);
DBUG_RETURN(thd->killed); DBUG_RETURN(thd->killed_errno());
} }
} }
} }
...@@ -1861,7 +1861,7 @@ err: ...@@ -1861,7 +1861,7 @@ err:
pthread_mutex_unlock(&data_lock); pthread_mutex_unlock(&data_lock);
DBUG_PRINT("exit",("killed: %d abort: %d slave_running: %d \ DBUG_PRINT("exit",("killed: %d abort: %d slave_running: %d \
improper_arguments: %d timed_out: %d", improper_arguments: %d timed_out: %d",
(int) thd->killed, thd->killed_errno(),
(int) (init_abort_pos_wait != abort_pos_wait), (int) (init_abort_pos_wait != abort_pos_wait),
(int) mi->slave_running, (int) mi->slave_running,
(int) (error == -2), (int) (error == -2),
......
...@@ -527,6 +527,14 @@ public: ...@@ -527,6 +527,14 @@ public:
enum killed_state { NOT_KILLED=0, KILL_CONNECTION=ER_SERVER_SHUTDOWN, KILL_QUERY=ER_QUERY_INTERRUPTED }; enum killed_state { NOT_KILLED=0, KILL_CONNECTION=ER_SERVER_SHUTDOWN, KILL_QUERY=ER_QUERY_INTERRUPTED };
killed_state volatile killed; killed_state volatile killed;
inline int killed_errno() const
{
return killed;
}
inline void send_kill_message() const
{
my_error(killed_errno(), MYF(0));
}
bool prepare_command; bool prepare_command;
bool tmp_table_used; bool tmp_table_used;
......
...@@ -212,7 +212,7 @@ cleanup: ...@@ -212,7 +212,7 @@ cleanup:
delete select; delete select;
free_underlaid_joins(thd, &thd->lex.select_lex); free_underlaid_joins(thd, &thd->lex.select_lex);
if (error >= 0 || thd->net.report_error) if (error >= 0 || thd->net.report_error)
send_error(thd,thd->killed); send_error(thd,thd->killed_errno());
else else
{ {
send_ok(thd,deleted); send_ok(thd,deleted);
......
...@@ -379,7 +379,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields, ...@@ -379,7 +379,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(thd->killed,MYF(0)); thd->send_kill_message();
DBUG_RETURN(1); DBUG_RETURN(1);
} }
it.rewind(); it.rewind();
...@@ -453,7 +453,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, ...@@ -453,7 +453,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(thd->killed,MYF(0)); thd->send_kill_message();
DBUG_RETURN(1); DBUG_RETURN(1);
} }
while ((sql_field=(Item_field*) it++)) while ((sql_field=(Item_field*) it++))
......
...@@ -1658,7 +1658,7 @@ mysql_execute_command(THD *thd) ...@@ -1658,7 +1658,7 @@ mysql_execute_command(THD *thd)
cursor))) cursor)))
{ {
if (res < 0 || thd->net.report_error) if (res < 0 || thd->net.report_error)
send_error(thd,thd->killed); send_error(thd,thd->killed_errno());
DBUG_RETURN(res); DBUG_RETURN(res);
} }
} }
...@@ -3141,7 +3141,7 @@ mysql_execute_command(THD *thd) ...@@ -3141,7 +3141,7 @@ mysql_execute_command(THD *thd)
// We end up here if res == 0 and send_ok() has been done, // We end up here if res == 0 and send_ok() has been done,
// or res != 0 and no send_error() has yet been done. // or res != 0 and no send_error() has yet been done.
if (res < 0) if (res < 0)
send_error(thd,thd->killed); send_error(thd,thd->killed_errno());
DBUG_RETURN(res); DBUG_RETURN(res);
error: error:
......
...@@ -674,7 +674,7 @@ static bool send_prepare_results(PREP_STMT *stmt) ...@@ -674,7 +674,7 @@ static bool send_prepare_results(PREP_STMT *stmt)
DBUG_RETURN(0); DBUG_RETURN(0);
abort: abort:
send_error(thd,thd->killed); send_error(thd,thd->killed_errno());
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
...@@ -1725,7 +1725,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, ...@@ -1725,7 +1725,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
sizeof(POSITION)*join->const_tables); sizeof(POSITION)*join->const_tables);
join->best_read=1.0; join->best_read=1.0;
} }
DBUG_RETURN(join->thd->killed || get_best_combination(join)); DBUG_RETURN(join->thd->killed_errno() || get_best_combination(join));
} }
...@@ -4978,7 +4978,7 @@ sub_select_cache(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) ...@@ -4978,7 +4978,7 @@ sub_select_cache(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
} }
if (join->thd->killed) // If aborted by user if (join->thd->killed) // If aborted by user
{ {
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
return -2; /* purecov: inspected */ return -2; /* purecov: inspected */
} }
if (join_tab->use_quick != 2 || test_if_quick_select(join_tab) <= 0) if (join_tab->use_quick != 2 || test_if_quick_select(join_tab) <= 0)
...@@ -5017,7 +5017,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) ...@@ -5017,7 +5017,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
{ {
if (join->thd->killed) // Aborted by user if (join->thd->killed) // Aborted by user
{ {
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
return -2; /* purecov: inspected */ return -2; /* purecov: inspected */
} }
join->examined_rows++; join->examined_rows++;
...@@ -5097,7 +5097,7 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skipp_last) ...@@ -5097,7 +5097,7 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skipp_last)
{ {
if (join->thd->killed) if (join->thd->killed)
{ {
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
return -2; // Aborted by user /* purecov: inspected */ return -2; // Aborted by user /* purecov: inspected */
} }
SQL_SELECT *select=join_tab->select; SQL_SELECT *select=join_tab->select;
...@@ -5745,7 +5745,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -5745,7 +5745,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (join->thd->killed) // Aborted by user if (join->thd->killed) // Aborted by user
{ {
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
if (!end_of_records) if (!end_of_records)
...@@ -5813,7 +5813,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -5813,7 +5813,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_RETURN(0); DBUG_RETURN(0);
if (join->thd->killed) // Aborted by user if (join->thd->killed) // Aborted by user
{ {
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
...@@ -5883,7 +5883,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -5883,7 +5883,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_RETURN(0); DBUG_RETURN(0);
if (join->thd->killed) // Aborted by user if (join->thd->killed) // Aborted by user
{ {
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
...@@ -5930,7 +5930,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -5930,7 +5930,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (join->thd->killed) if (join->thd->killed)
{ // Aborted by user { // Aborted by user
my_error(join->thd->killed,MYF(0)); /* purecov: inspected */ join->thd->send_kill_message();
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
if (!join->first_record || end_of_records || if (!join->first_record || end_of_records ||
...@@ -6652,7 +6652,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, ...@@ -6652,7 +6652,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(thd->killed,MYF(0)); thd->send_kill_message();
error=0; error=0;
goto err; goto err;
} }
...@@ -6764,7 +6764,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, ...@@ -6764,7 +6764,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(thd->killed,MYF(0)); thd->send_kill_message();
error=0; error=0;
goto err; goto err;
} }
......
...@@ -2381,7 +2381,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, ...@@ -2381,7 +2381,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(thd->killed,MYF(0)); thd->send_kill_message();
error= 1; error= 1;
break; break;
} }
......
...@@ -357,7 +357,7 @@ int mysql_update(THD *thd, ...@@ -357,7 +357,7 @@ int mysql_update(THD *thd,
delete select; delete select;
free_underlaid_joins(thd, &thd->lex.select_lex); free_underlaid_joins(thd, &thd->lex.select_lex);
if (error >= 0) if (error >= 0)
send_error(thd,thd->killed); /* purecov: inspected */ send_error(thd,thd->killed_errno()); /* purecov: inspected */
else else
{ {
char buff[80]; char buff[80];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment