two KILL commands implementation (version 2)
This commit is contained in:
hf@genie.(none) 2003-03-31 13:39:46 +05:00
parent d00b3ba511
commit f8f0b70380
51 changed files with 93 additions and 74 deletions

View File

@ -282,4 +282,5 @@
#define ER_SP_BADSELECT 1263 #define ER_SP_BADSELECT 1263
#define ER_SP_BADRETURN 1264 #define ER_SP_BADRETURN 1264
#define ER_SP_BADQUERY 1265 #define ER_SP_BADQUERY 1265
#define ER_ERROR_MESSAGES 266 #define ER_QUERY_INTERRUPTED 1266
#define ER_ERROR_MESSAGES 267

View File

@ -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)) if (killed_ptr(param->thd))
DBUG_RETURN(1); DBUG_RETURN(1);
switch (share->data_file_type) { switch (share->data_file_type) {

View File

@ -1644,9 +1644,9 @@ err:
DBUG_RETURN(1); DBUG_RETURN(1);
} /* sort_record_index */ } /* sort_record_index */
volatile bool *killed_ptr(MI_CHECK *param) bool killed_ptr(void *thd)
{ {
return (bool *)(& param->thd); /* always NULL */ return (bool)thd; /* always NULL */
} }
/* print warnings and errors */ /* print warnings and errors */

View File

@ -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 */
volatile bool *killed_ptr(MI_CHECK *param); bool 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,...));

View File

@ -844,7 +844,8 @@ 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;
volatile bool *killed= killed_ptr(info->sort_info->param); void *thd= info->sort_info->param->thd;
DBUG_ENTER("merge_buffers"); DBUG_ENTER("merge_buffers");
count=error=0; count=error=0;
@ -875,7 +876,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
{ {
for (;;) for (;;)
{ {
if (*killed) if (killed_ptr(thd))
{ {
error=1; goto err; error=1; goto err;
} }

View File

@ -277,7 +277,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
byte *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH]; byte *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH];
my_off_t record; my_off_t record;
TABLE *sort_form; TABLE *sort_form;
volatile bool *killed= &current_thd->killed; volatile THD::killed_state *killed= &current_thd->killed;
handler *file; handler *file;
DBUG_ENTER("find_all_keys"); DBUG_ENTER("find_all_keys");
DBUG_PRINT("info",("using: %s",(select?select->quick?"ranges":"where":"every row"))); DBUG_PRINT("info",("using: %s",(select?select->quick?"ranges":"where":"every row")));
@ -690,15 +690,15 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
BUFFPEK *buffpek,**refpek; BUFFPEK *buffpek,**refpek;
QUEUE queue; QUEUE queue;
qsort2_cmp cmp; qsort2_cmp cmp;
volatile bool *killed= &current_thd->killed; volatile THD::killed_state *killed= &current_thd->killed;
bool not_killable; THD::killed_state not_killable;
DBUG_ENTER("merge_buffers"); DBUG_ENTER("merge_buffers");
statistic_increment(filesort_merge_passes, &LOCK_status); statistic_increment(filesort_merge_passes, &LOCK_status);
if (param->not_killable) if (param->not_killable)
{ {
killed= &not_killable; killed= &not_killable;
not_killable=0; not_killable=THD::NOT_KILLED;
} }
error=0; error=0;

View File

@ -2103,7 +2103,7 @@ static void print_msg(THD *thd, const char *table_name, const char *op_name,
protocol->store(msg_type); protocol->store(msg_type);
protocol->store(msgbuf); protocol->store(msgbuf);
if (protocol->write()) if (protocol->write())
thd->killed=1; thd->killed=THD::KILL_CONNECTION;
} }
#endif #endif

View File

@ -89,9 +89,9 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
extern "C" { extern "C" {
volatile bool *killed_ptr(MI_CHECK *param) bool killed_ptr(void *thd)
{ {
return &(((THD *)(param->thd))->killed); return ((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,...)

View File

@ -154,7 +154,7 @@ retry:
thd->proc_info=0; thd->proc_info=0;
if (thd->killed) if (thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); my_error(thd->killed, MYF(0));
if (sql_lock) if (sql_lock)
{ {
mysql_unlock_tables(thd,sql_lock); mysql_unlock_tables(thd,sql_lock);

View File

@ -770,7 +770,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(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno), error_code((int)thd_arg->killed ? (int)thd_arg->killed : 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;

View File

@ -632,7 +632,7 @@ static void close_connections(void)
{ {
DBUG_PRINT("quit",("Informing thread %ld that it's time to die", DBUG_PRINT("quit",("Informing thread %ld that it's time to die",
tmp->thread_id)); tmp->thread_id));
tmp->killed=1; tmp->killed= THD::KILL_CONNECTION;
if (tmp->mysys_var) if (tmp->mysys_var)
{ {
tmp->mysys_var->abort=1; tmp->mysys_var->abort=1;
@ -1393,7 +1393,7 @@ extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
THD *thd=current_thd; THD *thd=current_thd;
DBUG_ENTER("abort_thread"); DBUG_ENTER("abort_thread");
if (thd) if (thd)
thd->killed=1; thd->killed= THD::KILL_CONNECTION;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#endif #endif
@ -2802,7 +2802,7 @@ static void create_new_thread(THD *thd)
("Can't create thread to handle request (error %d)", ("Can't create thread to handle request (error %d)",
error)); error));
thread_count--; thread_count--;
thd->killed=1; // Safety thd->killed= THD::KILL_CONNECTION; // Safety
(void) pthread_mutex_unlock(&LOCK_thread_count); (void) pthread_mutex_unlock(&LOCK_thread_count);
net_printf(thd,ER_CANT_CREATE_THREAD,error); net_printf(thd,ER_CANT_CREATE_THREAD,error);
(void) pthread_mutex_lock(&LOCK_thread_count); (void) pthread_mutex_lock(&LOCK_thread_count);

View File

@ -154,7 +154,7 @@ static int rr_sequential(READ_RECORD *info)
{ {
if (info->thd->killed) if (info->thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); my_error(info->thd->killed,MYF(0));
return 1; return 1;
} }
if (tmp != HA_ERR_RECORD_DELETED) if (tmp != HA_ERR_RECORD_DELETED)

View File

@ -276,3 +276,4 @@ v/*
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -270,3 +270,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -278,3 +278,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -272,3 +272,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -277,3 +277,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -269,3 +269,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -269,3 +269,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -269,3 +269,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -269,3 +269,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -271,3 +271,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -271,3 +271,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -270,3 +270,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -263,3 +263,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -275,3 +275,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -268,3 +268,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -267,3 +267,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -272,3 +272,4 @@
"SELECT in a stored procedure must have INTO" "SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a FUNCTION" "RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION" "Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
"Query execution was interrupted"

View File

@ -543,7 +543,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(ER_SERVER_SHUTDOWN); DBUG_RETURN(thd->killed);
} }
} }
} }

View File

@ -2390,7 +2390,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
/* Kill delayed insert threads */ /* Kill delayed insert threads */
if (in_use->system_thread && ! in_use->killed) if (in_use->system_thread && ! in_use->killed)
{ {
in_use->killed=1; in_use->killed= THD::KILL_CONNECTION;
pthread_mutex_lock(&in_use->mysys_var->mutex); pthread_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond) if (in_use->mysys_var->current_cond)
{ {

View File

@ -2929,7 +2929,7 @@ void Query_cache::wreck(uint line, const char *message)
DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line)); DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line));
DBUG_PRINT("warning", ("==================================")); DBUG_PRINT("warning", ("=================================="));
if (thd) if (thd)
thd->killed = 1; thd->killed= THD::KILL_CONNECTION;
cache_dump(); cache_dump();
/* check_integrity(0); */ /* Can't call it here because of locks */ /* check_integrity(0); */ /* Can't call it here because of locks */
bins_dump(); bins_dump();

View File

@ -85,8 +85,9 @@ THD::THD():user_time(0), is_fatal_error(0),
{ {
host=user=priv_user=db=query=ip=0; host=user=priv_user=db=query=ip=0;
host_or_ip= "connecting host"; host_or_ip= "connecting host";
locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password= locked=count_cuted_fields=some_tables_deleted=no_errors=password=
query_start_used=prepare_command=0; query_start_used=prepare_command=0;
killed= NOT_KILLED;
db_length=query_length=col_access=0; db_length=query_length=col_access=0;
query_error= tmp_table_used= 0; query_error= tmp_table_used= 0;
next_insert_id=last_insert_id=0; next_insert_id=last_insert_id=0;
@ -176,7 +177,7 @@ THD::THD():user_time(0), is_fatal_error(0),
if (open_cached_file(&transaction.trans_log, if (open_cached_file(&transaction.trans_log,
mysql_tmpdir, LOG_PREFIX, binlog_cache_size, mysql_tmpdir, LOG_PREFIX, binlog_cache_size,
MYF(MY_WME))) MYF(MY_WME)))
killed=1; killed= KILL_CONNECTION;
transaction.trans_log.end_of_file= max_binlog_cache_size; transaction.trans_log.end_of_file= max_binlog_cache_size;
} }
#endif #endif
@ -318,13 +319,13 @@ THD::~THD()
} }
void THD::awake(bool prepare_to_die) void THD::awake(THD::killed_state state_to_set)
{ {
THD_CHECK_SENTRY(this); THD_CHECK_SENTRY(this);
safe_mutex_assert_owner(&LOCK_delete); safe_mutex_assert_owner(&LOCK_delete);
if (prepare_to_die) killed= state_to_set;
killed = 1; if (state_to_set != THD::KILL_QUERY)
thr_alarm_kill(real_id); thr_alarm_kill(real_id);
#ifdef SIGNAL_WITH_VIO_CLOSE #ifdef SIGNAL_WITH_VIO_CLOSE
close_active_vio(); close_active_vio();
@ -442,7 +443,7 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length)
{ {
my_error(EE_OUTOFMEMORY, MYF(ME_BELL), my_error(EE_OUTOFMEMORY, MYF(ME_BELL),
ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1); ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1);
killed= 1; killed= KILL_CONNECTION;
return 0; return 0;
} }

View File

@ -548,8 +548,10 @@ public:
bool query_start_used,last_insert_id_used,insert_id_used,rand_used; bool query_start_used,last_insert_id_used,insert_id_used,rand_used;
bool system_thread,in_lock_tables,global_read_lock; bool system_thread,in_lock_tables,global_read_lock;
bool query_error, bootstrap, cleanup_done; bool query_error, bootstrap, cleanup_done;
bool volatile killed;
bool volatile only_kill_query; enum killed_state { NOT_KILLED=0, KILL_CONNECTION=ER_SERVER_SHUTDOWN, KILL_QUERY=ER_QUERY_INTERRUPTED };
killed_state volatile killed;
bool prepare_command; bool prepare_command;
bool tmp_table_used; bool tmp_table_used;
sp_rcontext *spcont; // SP runtime context sp_rcontext *spcont; // SP runtime context
@ -592,7 +594,7 @@ public:
} }
void close_active_vio(); void close_active_vio();
#endif #endif
void awake(bool prepare_to_die); void awake(THD::killed_state state_to_set);
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
const char* msg) const char* msg)
{ {

View File

@ -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 ? ER_SERVER_SHUTDOWN: 0); send_error(thd,thd->killed);
else else
{ {
send_ok(thd,deleted); send_ok(thd,deleted);

View File

@ -935,7 +935,7 @@ void kill_delayed_threads(void)
{ {
/* Ensure that the thread doesn't kill itself while we are looking at it */ /* Ensure that the thread doesn't kill itself while we are looking at it */
pthread_mutex_lock(&tmp->mutex); pthread_mutex_lock(&tmp->mutex);
tmp->thd.killed=1; tmp->thd.killed= THD::KILL_CONNECTION;
if (tmp->thd.mysys_var) if (tmp->thd.mysys_var)
{ {
pthread_mutex_lock(&tmp->thd.mysys_var->mutex); pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
@ -974,7 +974,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
thd->thread_id=thread_id++; thd->thread_id=thread_id++;
thd->end_time(); thd->end_time();
threads.append(thd); threads.append(thd);
thd->killed=abort_loop; thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
pthread_mutex_lock(&di->mutex); pthread_mutex_lock(&di->mutex);
@ -1027,7 +1027,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
for (;;) for (;;)
{ {
if (thd->killed) if (thd->killed == THD::KILL_CONNECTION)
{ {
uint lock_count; uint lock_count;
/* /*
@ -1075,7 +1075,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
break; break;
if (error == ETIME || error == ETIMEDOUT) if (error == ETIME || error == ETIMEDOUT)
{ {
thd->killed=1; thd->killed= THD::KILL_CONNECTION;
break; break;
} }
} }
@ -1094,7 +1094,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
/* request for new delayed insert */ /* request for new delayed insert */
if (!(thd->lock=mysql_lock_tables(thd,&di->table,1))) if (!(thd->lock=mysql_lock_tables(thd,&di->table,1)))
{ {
di->dead=thd->killed=1; // Fatal error di->dead=thd->killed= THD::KILL_CONNECTION; // Fatal error
} }
pthread_cond_broadcast(&di->cond_client); pthread_cond_broadcast(&di->cond_client);
} }
@ -1102,7 +1102,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
{ {
if (di->handle_inserts()) if (di->handle_inserts())
{ {
di->dead=thd->killed=1; // Some fatal error di->dead=thd->killed=THD::KILL_CONNECTION; // Some fatal error
} }
} }
di->status=0; di->status=0;
@ -1129,7 +1129,7 @@ end:
close_thread_tables(thd); // Free the table close_thread_tables(thd); // Free the table
di->table=0; di->table=0;
di->dead=thd->killed=1; // If error di->dead=thd->killed= THD::KILL_CONNECTION; // If error
pthread_cond_broadcast(&di->cond_client); // Safety pthread_cond_broadcast(&di->cond_client); // Safety
pthread_mutex_unlock(&di->mutex); pthread_mutex_unlock(&di->mutex);
@ -1198,7 +1198,7 @@ bool delayed_insert::handle_inserts(void)
max_rows=delayed_insert_limit; max_rows=delayed_insert_limit;
if (thd.killed || table->version != refresh_version) if (thd.killed || table->version != refresh_version)
{ {
thd.killed=1; thd.killed= THD::KILL_CONNECTION;
max_rows= ~0; // Do as much as possible max_rows= ~0; // Do as much as possible
} }

View File

@ -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(ER_SERVER_SHUTDOWN,MYF(0)); my_error(thd->killed,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
it.rewind(); it.rewind();
@ -453,7 +453,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); my_error(thd->killed,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
while ((sql_field=(Item_field*) it++)) while ((sql_field=(Item_field*) it++))

View File

@ -848,7 +848,7 @@ pthread_handler_decl(handle_one_connection,arg)
init_sql_alloc(&thd->mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); init_sql_alloc(&thd->mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
init_sql_alloc(&thd->transaction.mem_root, init_sql_alloc(&thd->transaction.mem_root,
TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC); TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC);
while (!net->error && net->vio != 0 && !(thd->killed && !thd->only_kill_query)) while (!net->error && net->vio != 0 && !(thd->killed == THD::KILL_CONNECTION))
{ {
if (do_command(thd)) if (do_command(thd))
break; break;
@ -1054,11 +1054,8 @@ bool do_command(THD *thd)
} }
else else
{ {
if (thd->only_kill_query) if (thd->killed == THD::KILL_QUERY)
{ thd->killed= THD::NOT_KILLED;
thd->killed= FALSE;
thd->only_kill_query= FALSE;
}
packet=(char*) net->read_pos; packet=(char*) net->read_pos;
command = (enum enum_server_command) (uchar) packet[0]; command = (enum enum_server_command) (uchar) packet[0];
@ -1666,7 +1663,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 ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed);
DBUG_RETURN(res); DBUG_RETURN(res);
} }
} }
@ -3126,7 +3123,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 ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed);
DBUG_RETURN(res); DBUG_RETURN(res);
error: error:
@ -4221,13 +4218,7 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query)
if ((thd->master_access & SUPER_ACL) || if ((thd->master_access & SUPER_ACL) ||
!strcmp(thd->user,tmp->user)) !strcmp(thd->user,tmp->user))
{ {
if (only_kill_query) tmp->awake(only_kill_query ? THD::KILL_QUERY : THD::KILL_CONNECTION);
{
tmp->killed= 1;
tmp->only_kill_query= 1;
}
else
tmp->awake(1 /*prepare to die*/);
error=0; error=0;
} }
else else

View File

@ -675,7 +675,7 @@ static bool send_prepare_results(PREP_STMT *stmt)
DBUG_RETURN(0); DBUG_RETURN(0);
abort: abort:
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed);
DBUG_RETURN(1); DBUG_RETURN(1);
} }

View File

@ -826,7 +826,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
it will be slow because it will iterate through the list it will be slow because it will iterate through the list
again. We just to do kill the thread ourselves. again. We just to do kill the thread ourselves.
*/ */
tmp->awake(1/*prepare to die*/); tmp->awake(THD::KILL_QUERY);
pthread_mutex_unlock(&tmp->LOCK_delete); pthread_mutex_unlock(&tmp->LOCK_delete);
} }
} }

View File

@ -20,7 +20,7 @@ extern I_List<i_string> binlog_do_db, binlog_ignore_db;
extern int max_binlog_dump_events; extern int max_binlog_dump_events;
extern my_bool opt_sporadic_binlog_dump_fail; extern my_bool opt_sporadic_binlog_dump_fail;
#define KICK_SLAVE(thd) { pthread_mutex_lock(&(thd)->LOCK_delete); (thd)->awake(0 /* do not prepare to die*/); pthread_mutex_unlock(&(thd)->LOCK_delete); } #define KICK_SLAVE(thd) { pthread_mutex_lock(&(thd)->LOCK_delete); (thd)->awake(THD::NOT_KILLED); pthread_mutex_unlock(&(thd)->LOCK_delete); }
File open_binlog(IO_CACHE *log, const char *log_file_name, File open_binlog(IO_CACHE *log, const char *log_file_name,
const char **errmsg); const char **errmsg);

View File

@ -4943,7 +4943,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(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
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)
@ -4982,7 +4982,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(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
return -2; /* purecov: inspected */ return -2; /* purecov: inspected */
} }
join->examined_rows++; join->examined_rows++;
@ -5062,7 +5062,7 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skipp_last)
{ {
if (join->thd->killed) if (join->thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
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;
@ -5710,7 +5710,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(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
if (!end_of_records) if (!end_of_records)
@ -5778,7 +5778,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(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
@ -5848,7 +5848,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(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
@ -5895,7 +5895,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(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */ my_error(join->thd->killed,MYF(0)); /* purecov: inspected */
DBUG_RETURN(-2); /* purecov: inspected */ DBUG_RETURN(-2); /* purecov: inspected */
} }
if (!join->first_record || end_of_records || if (!join->first_record || end_of_records ||
@ -6617,7 +6617,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); my_error(thd->killed,MYF(0));
error=0; error=0;
goto err; goto err;
} }
@ -6729,7 +6729,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); my_error(thd->killed,MYF(0));
error=0; error=0;
goto err; goto err;
} }

View File

@ -1335,7 +1335,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
thd_info->command=(int) tmp->command; thd_info->command=(int) tmp->command;
if ((mysys_var= tmp->mysys_var)) if ((mysys_var= tmp->mysys_var))
pthread_mutex_lock(&mysys_var->mutex); pthread_mutex_lock(&mysys_var->mutex);
thd_info->proc_info= (char*) (tmp->killed ? "Killed" : 0); thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
thd_info->state_info= (char*) (tmp->locked ? "Locked" : thd_info->state_info= (char*) (tmp->locked ? "Locked" :
tmp->net.reading_or_writing ? tmp->net.reading_or_writing ?

View File

@ -2379,7 +2379,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
{ {
if (thd->killed) if (thd->killed)
{ {
my_error(ER_SERVER_SHUTDOWN,MYF(0)); my_error(thd->killed,MYF(0));
error= 1; error= 1;
break; break;
} }

View File

@ -355,7 +355,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 ? ER_SERVER_SHUTDOWN : 0); /* purecov: inspected */ send_error(thd,thd->killed); /* purecov: inspected */
else else
{ {
char buff[80]; char buff[80];