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)
char llbuff[22],llbuff2[22];
DBUG_ENTER("sort_get_next_record");
if (killed_ptr(param->thd))
if (*killed_ptr(param->thd))
DBUG_RETURN(1);
switch (share->data_file_type) {
......
......@@ -1644,9 +1644,9 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info,
DBUG_RETURN(1);
} /* 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 */
......
......@@ -693,7 +693,7 @@ int mi_open_keyfile(MYISAM_SHARE *share);
void mi_setup_functions(register MYISAM_SHARE *share);
/* 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_warning _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,
uchar *strpos;
BUFFPEK *buffpek,**refpek;
QUEUE queue;
void *thd= info->sort_info->param->thd;
int *killed= killed_ptr(info->sort_info->param->thd);
DBUG_ENTER("merge_buffers");
......@@ -876,7 +876,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
{
for (;;)
{
if (killed_ptr(thd))
if (*killed)
{
error=1; goto err;
}
......
......@@ -89,9 +89,9 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
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,...)
......
......@@ -154,7 +154,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
thd->proc_info=0;
if (thd->killed)
{
my_error(thd->killed, MYF(0));
thd->send_kill_message();
if (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,
0 : LOG_EVENT_THREAD_SPECIFIC_F, using_trans),
data_buf(0), query(query_arg),
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)
{
time_t end_time;
......
......@@ -154,7 +154,7 @@ static int rr_sequential(READ_RECORD *info)
{
if (info->thd->killed)
{
my_error(info->thd->killed,MYF(0));
info->thd->send_kill_message();
return 1;
}
if (tmp != HA_ERR_RECORD_DELETED)
......
......@@ -559,7 +559,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
if (thd->killed)
{
pthread_mutex_unlock(cond_lock);
DBUG_RETURN(thd->killed);
DBUG_RETURN(thd->killed_errno());
}
}
}
......@@ -1861,7 +1861,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
pthread_mutex_unlock(&data_lock);
DBUG_PRINT("exit",("killed: %d abort: %d slave_running: %d \
improper_arguments: %d timed_out: %d",
(int) thd->killed,
thd->killed_errno(),
(int) (init_abort_pos_wait != abort_pos_wait),
(int) mi->slave_running,
(int) (error == -2),
......
......@@ -527,6 +527,14 @@ class THD :public ilink
enum killed_state { NOT_KILLED=0, KILL_CONNECTION=ER_SERVER_SHUTDOWN, KILL_QUERY=ER_QUERY_INTERRUPTED };
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 tmp_table_used;
......
......@@ -212,7 +212,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
if (error >= 0 || thd->net.report_error)
send_error(thd,thd->killed);
send_error(thd,thd->killed_errno());
else
{
send_ok(thd,deleted);
......
......@@ -379,7 +379,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
{
if (thd->killed)
{
my_error(thd->killed,MYF(0));
thd->send_kill_message();
DBUG_RETURN(1);
}
it.rewind();
......@@ -453,7 +453,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
{
if (thd->killed)
{
my_error(thd->killed,MYF(0));
thd->send_kill_message();
DBUG_RETURN(1);
}
while ((sql_field=(Item_field*) it++))
......
......@@ -1658,7 +1658,7 @@ mysql_execute_command(THD *thd)
cursor)))
{
if (res < 0 || thd->net.report_error)
send_error(thd,thd->killed);
send_error(thd,thd->killed_errno());
DBUG_RETURN(res);
}
}
......@@ -3141,7 +3141,7 @@ mysql_execute_command(THD *thd)
// We end up here if res == 0 and send_ok() has been done,
// or res != 0 and no send_error() has yet been done.
if (res < 0)
send_error(thd,thd->killed);
send_error(thd,thd->killed_errno());
DBUG_RETURN(res);
error:
......
......@@ -674,7 +674,7 @@ static bool send_prepare_results(PREP_STMT *stmt)
DBUG_RETURN(0);
abort:
send_error(thd,thd->killed);
send_error(thd,thd->killed_errno());
DBUG_RETURN(1);
}
......
......@@ -1725,7 +1725,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
sizeof(POSITION)*join->const_tables);
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)
}
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 */
}
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)
{
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 */
}
join->examined_rows++;
......@@ -5097,7 +5097,7 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skipp_last)
{
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 */
}
SQL_SELECT *select=join_tab->select;
......@@ -5745,7 +5745,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
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 */
}
if (!end_of_records)
......@@ -5813,7 +5813,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_RETURN(0);
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 */
}
......@@ -5883,7 +5883,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_RETURN(0);
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 */
}
......@@ -5930,7 +5930,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
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 */
}
if (!join->first_record || end_of_records ||
......@@ -6652,7 +6652,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
{
if (thd->killed)
{
my_error(thd->killed,MYF(0));
thd->send_kill_message();
error=0;
goto err;
}
......@@ -6764,7 +6764,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
{
if (thd->killed)
{
my_error(thd->killed,MYF(0));
thd->send_kill_message();
error=0;
goto err;
}
......
......@@ -2381,7 +2381,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
{
if (thd->killed)
{
my_error(thd->killed,MYF(0));
thd->send_kill_message();
error= 1;
break;
}
......
......@@ -357,7 +357,7 @@ int mysql_update(THD *thd,
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
if (error >= 0)
send_error(thd,thd->killed); /* purecov: inspected */
send_error(thd,thd->killed_errno()); /* purecov: inspected */
else
{
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