summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_myisam.cc4
-rw-r--r--sql/lock.cc2
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/records.cc2
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/sql_class.h8
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_load.cc4
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc20
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_update.cc2
13 files changed, 33 insertions, 25 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 69b6e248ac5..10574a15e3a 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -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,...)
diff --git a/sql/lock.cc b/sql/lock.cc
index 9e399a364b2..45ffefed14f 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -154,7 +154,7 @@ retry:
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);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 5132388224f..b533ddb126a 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -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;
diff --git a/sql/records.cc b/sql/records.cc
index 38904fa405f..2efd331b048 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -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)
diff --git a/sql/slave.cc b/sql/slave.cc
index 78b415503f9..e6f7c5eac54 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -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 @@ err:
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),
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 96a3bb7051f..605d86e9684 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -527,6 +527,14 @@ public:
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;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 921854469a5..392b81ba30b 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -212,7 +212,7 @@ cleanup:
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);
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 69585ddbc77..b7f007fa7ba 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -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++))
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 5f99163b33c..6b604644450 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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:
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 1d5e78b5e69..5ed8159793a 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -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);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f6b5372812b..cbf30126272 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 6473fe7f961..27db0ea0827 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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;
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 23783883502..4ad14da242e 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -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];