MySQL Bug#74853 Index: mysql-5.7.5-m15/sql/mdl.h =================================================================== --- mysql-5.7.5-m15.orig/sql/mdl.h +++ mysql-5.7.5-m15/sql/mdl.h @@ -93,7 +93,7 @@ public: /** Has the owner thread been killed? */ - virtual int is_killed() = 0; + virtual bool is_killed() = 0; /** Does the owner still have connection to the client? Index: mysql-5.7.5-m15/sql/sql_class.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_class.cc +++ mysql-5.7.5-m15/sql/sql_class.cc @@ -503,7 +503,7 @@ void thd_set_psi(THD *thd, PSI_thread *p */ void thd_set_killed(THD *thd) { - thd->killed= THD::KILL_CONNECTION; + thd->set_killed_state(THD::KILL_CONNECTION); } /** @@ -1171,7 +1171,7 @@ THD::THD(bool enable_plugins) password= 0; query_start_usec_used= 0; count_cuted_fields= CHECK_FIELD_IGNORE; - killed= NOT_KILLED; + set_killed_state(NOT_KILLED); col_access=0; is_slave_error= thread_specific_used= FALSE; my_hash_clear(&handler_tables_hash); @@ -1677,7 +1677,7 @@ void THD::cleanup_connection(void) mysql_mutex_unlock(&LOCK_status); cleanup(); - killed= NOT_KILLED; + set_killed_state(NOT_KILLED); cleanup_done= 0; init(); stmt_map.reset(); @@ -1729,7 +1729,7 @@ void THD::cleanup(void) DBUG_ENTER("THD::cleanup"); DBUG_ASSERT(cleanup_done == 0); - killed= KILL_CONNECTION; + set_killed_state(KILL_CONNECTION); session_tracker.deinit(); #ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE if (transaction.xid_state.has_state(XA_STATE::XA_PREPARED)) @@ -2006,7 +2006,7 @@ void THD::awake(THD::killed_state state_ { /* nothing */ } else { - killed= state_to_set; + set_killed_state(state_to_set); } if (state_to_set != THD::KILL_QUERY && state_to_set != THD::KILL_TIMEOUT) @@ -2118,7 +2118,7 @@ void THD::disconnect() mysql_mutex_lock(&LOCK_thd_data); - killed= THD::KILL_CONNECTION; + set_killed_state(THD::KILL_CONNECTION); /* Since a active vio might might have not been set yet, in @@ -2488,7 +2488,7 @@ void THD::add_changed_table(const char * { DBUG_ENTER("THD::add_changed_table(key)"); if (get_transaction()->add_changed_table(key, key_length)) - killed= KILL_CONNECTION; + set_killed_state(KILL_CONNECTION); DBUG_VOID_RETURN; } @@ -4202,9 +4202,9 @@ void THD::end_attachable_transaction() @retval 0 the user thread is active @retval 1 the user thread has been killed */ -extern "C" int thd_killed(const MYSQL_THD thd) +extern "C" int thd_killed(MYSQL_THD thd) { - return(thd->killed); + return(thd->is_killed()); } /** @@ -4212,7 +4212,7 @@ extern "C" int thd_killed(const MYSQL_TH @param thd user thread connection handle */ -extern "C" void thd_set_kill_status(const MYSQL_THD thd) +extern "C" void thd_set_kill_status(MYSQL_THD thd) { thd->send_kill_message(); } Index: mysql-5.7.5-m15/sql/sql_class.h =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_class.h +++ mysql-5.7.5-m15/sql/sql_class.h @@ -2559,7 +2559,12 @@ public: KILL_TIMEOUT=ER_QUERY_TIMEOUT, KILLED_NO_VALUE /* means neither of the states */ }; - killed_state volatile killed; + private: + int32 m_killed; + public: + void set_killed_state(killed_state s) { my_atomic_store32(&m_killed, s); } + killed_state get_killed_state() volatile { return (killed_state)my_atomic_load32(&m_killed); } + virtual bool is_killed() { return get_killed_state() != NOT_KILLED; } /* scramble - random string sent to client on handshake */ char scramble[SCRAMBLE_LENGTH+1]; @@ -2830,7 +2835,6 @@ public: DBUG_VOID_RETURN; } - virtual int is_killed() { return killed; } virtual THD* get_thd() { return this; } /** @@ -3080,7 +3084,7 @@ public: */ inline void fatal_error() { - DBUG_ASSERT(get_stmt_da()->is_error() || killed); + DBUG_ASSERT(get_stmt_da()->is_error() || is_killed()); is_fatal_error= 1; DBUG_PRINT("error",("Fatal error set")); } @@ -3189,12 +3193,12 @@ public: state after execution of a non-prepared SQL statement. */ void end_statement(); - inline int killed_errno() const + inline int killed_errno() { - killed_state killed_val; /* to cache the volatile 'killed' */ - return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0; + killed_state killed_val= get_killed_state(); + return (killed_val) != KILL_BAD_DATA ? killed_val : 0; } - inline void send_kill_message() const + inline void send_kill_message() { int err= killed_errno(); if (err && !get_stmt_da()->is_set()) Index: mysql-5.7.5-m15/sql/log.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/log.cc +++ mysql-5.7.5-m15/sql/log.cc @@ -938,7 +938,7 @@ bool Log_to_csv_event_handler::log_gener err: thd->pop_internal_handler(); - if (result && !thd->killed) + if (result && !thd->is_killed()) sql_print_error("Failed to write to mysql.general_log: %s", error_handler.message()); @@ -1116,7 +1116,7 @@ bool Log_to_csv_event_handler::log_slow( err: thd->pop_internal_handler(); - if (result && !thd->killed) + if (result && !thd->is_killed()) sql_print_error("Failed to write to mysql.slow_log: %s", error_handler.message()); Index: mysql-5.7.5-m15/sql/mdl.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/mdl.cc +++ mysql-5.7.5-m15/sql/mdl.cc @@ -3592,7 +3592,7 @@ MDL_context::acquire_lock(MDL_request *m my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); break; case MDL_wait::KILLED: - if ((get_thd())->killed == THD::KILL_TIMEOUT) + if ((get_thd())->get_killed_state() == THD::KILL_TIMEOUT) my_error(ER_QUERY_TIMEOUT, MYF(0)); else my_error(ER_QUERY_INTERRUPTED, MYF(0)); Index: mysql-5.7.5-m15/sql/log_event.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/log_event.cc +++ mysql-5.7.5-m15/sql/log_event.cc @@ -3089,7 +3089,7 @@ Slave_worker *Log_event::get_slave_worke if (ret_worker == NULL) { /* get_least_occupied_worker may return NULL if the thread is killed */ - DBUG_ASSERT(thd->killed); + DBUG_ASSERT(thd->is_killed()); DBUG_RETURN(NULL); } ptr_group->worker_id= ret_worker->id; @@ -5196,7 +5196,7 @@ compare_errors: get_type_str(), thd->get_stmt_da()->message_text()); } clear_all_errors(thd, const_cast(rli)); - thd->killed= THD::NOT_KILLED; + thd->set_killed_state(THD::NOT_KILLED); } /* Other cases: mostly we expected no error and get one. Index: mysql-5.7.5-m15/sql/rpl_binlog_sender.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_binlog_sender.cc +++ mysql-5.7.5-m15/sql/rpl_binlog_sender.cc @@ -166,7 +166,7 @@ void Binlog_sender::run() init(); - while (!has_error() && !m_thd->killed) + while (!has_error() && !m_thd->is_killed()) { /* Faked rotate event is only required in a few cases(see comment of the @@ -276,7 +276,7 @@ my_off_t Binlog_sender::send_binlog(IO_C if (my_b_tell(log_cache) != start_pos) my_b_seek(log_cache, start_pos); - while (!m_thd->killed) + while (!m_thd->is_killed()) { my_off_t end_pos; @@ -287,8 +287,8 @@ my_off_t Binlog_sender::send_binlog(IO_C if (send_events(log_cache, end_pos)) return 1; - m_thd->killed= DBUG_EVALUATE_IF("simulate_kill_dump", THD::KILL_CONNECTION, - m_thd->killed); + DBUG_EXECUTE_IF("simulate_kill_dump", + { m_thd->set_killed_state(THD::KILL_CONNECTION) }; ); DBUG_EXECUTE_IF("wait_after_binlog_EOF", { @@ -334,7 +334,7 @@ inline my_off_t Binlog_sender::get_binlo if (unlikely(wait_new_events(log_pos))) DBUG_RETURN(1); - } while (unlikely(!m_thd->killed)); + } while (unlikely(!m_thd->is_killed())); DBUG_RETURN(1); } @@ -354,7 +354,7 @@ int Binlog_sender::send_events(IO_CACHE uchar* event_ptr; uint32 event_len; - if (unlikely(thd->killed)) + if (unlikely(thd->is_killed())) DBUG_RETURN(1); if (unlikely(read_event(log_cache, m_event_checksum_alg, @@ -508,7 +508,7 @@ inline int Binlog_sender::wait_with_hear #endif if (send_heartbeat_event(log_pos)) return 1; - } while (!m_thd->killed); + } while (!m_thd->is_killed()); return ret ? 1 : 0; } Index: mysql-5.7.5-m15/sql/rpl_gtid_execution.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_gtid_execution.cc +++ mysql-5.7.5-m15/sql/rpl_gtid_execution.cc @@ -78,7 +78,7 @@ int gtid_acquire_ownership_single(THD *t // global_sid_lock and mutex are now released // Check if thread was killed. - if (thd->killed || in_abort_loop()) + if (thd->is_killed() || in_abort_loop()) DBUG_RETURN(1); #ifdef HAVE_REPLICATION // If this thread is a slave SQL thread or slave SQL worker @@ -168,7 +168,7 @@ int gtid_acquire_ownership_multiple(THD // at this point, we don't hold any locks. re-acquire the global // read lock that was held when this function was invoked - if (thd->killed || in_abort_loop()) + if (thd->is_killed() || in_abort_loop()) DBUG_RETURN(1); #ifdef HAVE_REPLICATION // If this thread is a slave SQL thread or slave SQL worker Index: mysql-5.7.5-m15/sql/rpl_gtid_mutex_cond_array.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_gtid_mutex_cond_array.cc +++ mysql-5.7.5-m15/sql/rpl_gtid_mutex_cond_array.cc @@ -91,7 +91,7 @@ error: RETURN_REPORTED_ERROR; } -bool Mutex_cond_array::check_thd_killed(const THD* thd) const +bool Mutex_cond_array::check_thd_killed(THD* thd) const { - return thd->killed; + return thd->is_killed(); } Index: mysql-5.7.5-m15/sql/rpl_gtid_state.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_gtid_state.cc +++ mysql-5.7.5-m15/sql/rpl_gtid_state.cc @@ -275,7 +275,7 @@ int Gtid_state::wait_for_gtid_set(THD* t if (timeout > 0) set_timespec(&abstime, timeout); - while (!thd->killed) + while (!thd->is_killed()) { global_sid_lock->wrlock(); const Gtid_set *executed_gtids= gtid_state->get_executed_gtids(); @@ -324,7 +324,7 @@ int Gtid_state::wait_for_gtid_set(THD* t } // return in case the query is interrupted. - if (thd->killed) + if (thd->is_killed()) { my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(-1); Index: mysql-5.7.5-m15/sql/rpl_rli.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_rli.cc +++ mysql-5.7.5-m15/sql/rpl_rli.cc @@ -741,7 +741,7 @@ int Relay_log_info::wait_for_pos(THD* th } /* The "compare and wait" main loop */ - while (!thd->killed && + while (!thd->is_killed() && init_abort_pos_wait == abort_pos_wait && slave_running) { @@ -796,7 +796,7 @@ int Relay_log_info::wait_for_pos(THD* th pos_reached= ((!cmp_result && group_master_log_pos >= (ulonglong)log_pos) || cmp_result > 0); - if (pos_reached || thd->killed) + if (pos_reached || thd->is_killed()) break; } @@ -854,7 +854,7 @@ improper_arguments: %d timed_out: %d", (int) slave_running, (int) (error == -2), (int) (error == -1))); - if (thd->killed || init_abort_pos_wait != abort_pos_wait || + if (thd->is_killed() || init_abort_pos_wait != abort_pos_wait || !slave_running) { error= -2; @@ -914,7 +914,7 @@ int Relay_log_info::wait_for_gtid_set(TH global_sid_lock->unlock(); /* The "compare and wait" main loop */ - while (!thd->killed && + while (!thd->is_killed() && init_abort_pos_wait == abort_pos_wait && slave_running) { @@ -1000,7 +1000,7 @@ improper_arguments: %d timed_out: %d", (int) slave_running, (int) (error == -2), (int) (error == -1))); - if (thd->killed || init_abort_pos_wait != abort_pos_wait || + if (thd->is_killed() || init_abort_pos_wait != abort_pos_wait || !slave_running) { error= -2; Index: mysql-5.7.5-m15/sql/rpl_rli_pdb.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_rli_pdb.cc +++ mysql-5.7.5-m15/sql/rpl_rli_pdb.cc @@ -970,10 +970,10 @@ Slave_worker *map_db_to_worker(const cha &stage_slave_waiting_worker_to_release_partition, &old_stage); mysql_cond_wait(&slave_worker_hash_cond, &slave_worker_hash_lock); - } while (entry->usage != 0 && !thd->killed); + } while (entry->usage != 0 && !thd->is_killed()); thd->EXIT_COND(&old_stage); - if (thd->killed) + if (thd->is_killed()) { entry= NULL; goto err; @@ -1593,7 +1593,7 @@ bool Slave_worker::worker_sleep(ulong se mysql_mutex_lock(lock); info_thd->ENTER_COND(cond, lock, NULL, NULL); - while (!(ret= info_thd->killed || running_status != RUNNING)) + while (!(ret= info_thd->is_killed() || running_status != RUNNING)) { int error= mysql_cond_timedwait(cond, lock, &abstime); if (error == ETIMEDOUT || error == ETIME) @@ -1958,7 +1958,7 @@ bool append_item_to_jobs(slave_job_item &stage_slave_waiting_worker_to_free_events, &old_stage); mysql_cond_wait(&rli->pending_jobs_cond, &rli->pending_jobs_lock); thd->EXIT_COND(&old_stage); - if (thd->killed) + if (thd->is_killed()) return true; if (rli->wq_size_waits_cnt % 10 == 1) sql_print_information("Multi-threaded slave: Coordinator has waited " @@ -2008,7 +2008,7 @@ bool append_item_to_jobs(slave_job_item mysql_mutex_lock(&worker->jobs_lock); // possible WQ overfill - while (worker->running_status == Slave_worker::RUNNING && !thd->killed && + while (worker->running_status == Slave_worker::RUNNING && !thd->is_killed() && (ret= en_queue(&worker->jobs, job_item)) == -1) { thd->ENTER_COND(&worker->jobs_cond, &worker->jobs_lock, @@ -2158,7 +2158,7 @@ struct slave_job_item* pop_jobs_item(Sla mysql_mutex_lock(&worker->jobs_lock); job_item->data= NULL; - while (!job_item->data && !thd->killed && + while (!job_item->data && !thd->is_killed() && worker->running_status == Slave_worker::RUNNING) { PSI_stage_info old_stage; @@ -2218,7 +2218,7 @@ int slave_worker_exec_job_group(Slave_wo while (1) { - if (unlikely(thd->killed || worker->running_status != Slave_worker::RUNNING)) + if (unlikely(thd->is_killed() || worker->running_status != Slave_worker::RUNNING)) { // de-queueing and decrement counters is in the caller's exit branch error= -1; @@ -2282,7 +2282,7 @@ err: { sql_print_information("Worker %lu is exiting: killed %i, error %i, " "running_status %d", - worker->id, thd->killed, thd->is_error(), + worker->id, thd->is_killed(), thd->is_error(), worker->running_status); worker->slave_worker_ends_group(ev, error); /* last done sets post exec */ } Index: mysql-5.7.5-m15/sql/rpl_slave.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_slave.cc +++ mysql-5.7.5-m15/sql/rpl_slave.cc @@ -1162,11 +1162,11 @@ int start_slave_thread( registered, we could otherwise go waiting though thd->killed is set. */ - if (!thd->killed) + if (!thd->is_killed()) mysql_cond_wait(start_cond, cond_lock); thd->EXIT_COND(& saved_stage); mysql_mutex_lock(cond_lock); // re-acquire it as exit_cond() released - if (thd->killed) + if (thd->is_killed()) { if (start_lock) mysql_mutex_unlock(start_lock); @@ -1318,7 +1318,7 @@ static bool io_slave_killed(THD* thd, Ma DBUG_ASSERT(mi->info_thd == thd); DBUG_ASSERT(mi->slave_running); // tracking buffer overrun - DBUG_RETURN(mi->abort_slave || in_abort_loop() || thd->killed); + DBUG_RETURN(mi->abort_slave || in_abort_loop() || thd->is_killed()); } /** @@ -1349,10 +1349,10 @@ bool sql_slave_killed(THD* thd, Relay_lo DBUG_ASSERT(rli->info_thd == thd); DBUG_ASSERT(rli->slave_running == 1); - if (in_abort_loop() || thd->killed || rli->abort_slave) + if (in_abort_loop() || thd->is_killed() || rli->abort_slave) { is_parallel_warn= (rli->is_parallel_exec() && - (rli->is_mts_in_group() || thd->killed)); + (rli->is_mts_in_group() || thd->is_killed())); /* Slave can execute stop being in one of two MTS or Single-Threaded mode. The modes define different criteria to accept the stop. @@ -4624,23 +4624,23 @@ log space"); } DBUG_EXECUTE_IF("stop_io_after_reading_gtid_log_event", if (event_buf[EVENT_TYPE_OFFSET] == GTID_LOG_EVENT) - thd->killed= THD::KILLED_NO_VALUE; + thd->set_killed_state(THD::KILLED_NO_VALUE); ); DBUG_EXECUTE_IF("stop_io_after_reading_query_log_event", if (event_buf[EVENT_TYPE_OFFSET] == QUERY_EVENT) - thd->killed= THD::KILLED_NO_VALUE; + thd->set_killed_state(THD::KILLED_NO_VALUE); ); DBUG_EXECUTE_IF("stop_io_after_reading_user_var_log_event", if (event_buf[EVENT_TYPE_OFFSET] == USER_VAR_EVENT) - thd->killed= THD::KILLED_NO_VALUE; + thd->set_killed_state(THD::KILLED_NO_VALUE); ); DBUG_EXECUTE_IF("stop_io_after_reading_xid_log_event", if (event_buf[EVENT_TYPE_OFFSET] == XID_EVENT) - thd->killed= THD::KILLED_NO_VALUE; + thd->set_killed_state(THD::KILLED_NO_VALUE); ); DBUG_EXECUTE_IF("stop_io_after_reading_write_rows_log_event", if (event_buf[EVENT_TYPE_OFFSET] == WRITE_ROWS_EVENT) - thd->killed= THD::KILLED_NO_VALUE; + thd->set_killed_state(THD::KILLED_NO_VALUE); ); } } @@ -5579,7 +5579,7 @@ void slave_stop_workers(Relay_log_info * commit-events of last assigned groups. */ if (rli->mts_group_status != Relay_log_info::MTS_KILLED_GROUP && - thd->killed == THD::NOT_KILLED) + thd->get_killed_state() == THD::NOT_KILLED) { DBUG_ASSERT(rli->mts_group_status != Relay_log_info::MTS_IN_GROUP || thd->is_error()); @@ -7623,7 +7623,7 @@ static Log_event* next_event(Relay_log_i set_timespec_nsec(&waittime, period); ret= rli->relay_log.wait_for_update_relay_log(thd, &waittime); } while ((ret == ETIMEDOUT || ret == ETIME) /* todo:remove */ && - signal_cnt == rli->relay_log.signal_cnt && !thd->killed); + signal_cnt == rli->relay_log.signal_cnt && !thd->is_killed()); } else { Index: mysql-5.7.5-m15/storage/myisam/ha_myisam.cc =================================================================== --- mysql-5.7.5-m15.orig/storage/myisam/ha_myisam.cc +++ mysql-5.7.5-m15/storage/myisam/ha_myisam.cc @@ -119,7 +119,7 @@ static void debug_wait_for_kill(const ch THD *thd; thd= current_thd; prev_info= thd_proc_info(thd, info); - while(!thd->killed) + while(!thd->is_killed()) my_sleep(1000); DBUG_PRINT("info", ("Exit debug_wait_for_kill")); thd_proc_info(thd, prev_info); @@ -564,10 +564,9 @@ int check_definition(MI_KEYDEF *t1_keyin extern "C" { -volatile int *killed_ptr(MI_CHECK *param) +int mi_is_killed(MI_CHECK *param) { - /* In theory Unsafe conversion, but should be ok for now */ - return (int*) &(((THD *)(param->thd))->killed); + return ((THD *)(param->thd))->is_killed(); } void mi_check_print_error(MI_CHECK *param, const char *fmt,...) @@ -905,7 +904,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_ HA_STATUS_CONST); } } - else if (!mi_is_crashed(file) && !thd->killed) + else if (!mi_is_crashed(file) && !thd->is_killed()) { mi_mark_crashed(file); file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; @@ -948,7 +947,7 @@ int ha_myisam::analyze(THD *thd, HA_CHEC error=update_state_info(¶m,file,UPDATE_STAT); mysql_mutex_unlock(&share->intern_lock); } - else if (!mi_is_crashed(file) && !thd->killed) + else if (!mi_is_crashed(file) && !thd->is_killed()) mi_mark_crashed(file); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } @@ -1535,7 +1534,7 @@ int ha_myisam::end_bulk_insert() */ if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) && - current_thd->killed) + current_thd->is_killed()) { delete_all_rows(); /* not crashed, despite being killed during repair */ Index: mysql-5.7.5-m15/storage/myisam/mi_check.c =================================================================== --- mysql-5.7.5-m15.orig/storage/myisam/mi_check.c +++ mysql-5.7.5-m15/storage/myisam/mi_check.c @@ -161,7 +161,7 @@ int chk_del(MI_CHECK *param, MI_INFO *in empty=0; for (i= info->state->del ; i > 0L && next_link != HA_OFFSET_ERROR ; i--) { - if (*killed_ptr(param)) + if (mi_is_killed(param)) DBUG_RETURN(1); if (test_flag & T_VERBOSE) printf(" %9s",llstr(next_link,buff)); @@ -256,7 +256,7 @@ static int check_k_link(MI_CHECK *param, records= (ha_rows) (info->state->key_file_length / block_size); while (next_link != HA_OFFSET_ERROR && records > 0) { - if (*killed_ptr(param)) + if (mi_is_killed(param)) DBUG_RETURN(1); if (param->testflag & T_VERBOSE) printf("%16s",llstr(next_link,llbuff)); @@ -765,7 +765,7 @@ static int chk_index(MI_CHECK *param, MI } for ( ;; ) { - if (*killed_ptr(param)) + if (mi_is_killed(param)) goto err; memcpy((char*) info->lastkey,(char*) key,key_length); info->lastkey_length=key_length; @@ -977,7 +977,7 @@ int chk_data_link(MI_CHECK *param, MI_IN memset(key_checksum, 0, info->s->base.keys * sizeof(key_checksum[0])); while (pos < info->state->data_file_length) { - if (*killed_ptr(param)) + if (mi_is_killed(param)) goto err2; switch (info->s->data_file_type) { case STATIC_RECORD: @@ -3218,7 +3218,7 @@ static int sort_get_next_record(MI_SORT_ char llbuff[22],llbuff2[22]; DBUG_ENTER("sort_get_next_record"); - if (*killed_ptr(param)) + if (mi_is_killed(param)) DBUG_RETURN(1); switch (share->data_file_type) { Index: mysql-5.7.5-m15/storage/myisam/myisamchk.c =================================================================== --- mysql-5.7.5-m15.orig/storage/myisam/myisamchk.c +++ mysql-5.7.5-m15/storage/myisam/myisamchk.c @@ -1703,12 +1703,9 @@ err: This is overloaded by other programs that want to be able to abort sorting */ - -static int not_killed= 0; - -volatile int *killed_ptr(MI_CHECK *param __attribute__((unused))) +int mi_is_killed(MI_CHECK *param __attribute__((unused))) { - return ¬_killed; /* always NULL */ + return 0; } /* print warnings and errors */ Index: mysql-5.7.5-m15/storage/myisam/myisamdef.h =================================================================== --- mysql-5.7.5-m15.orig/storage/myisam/myisamdef.h +++ mysql-5.7.5-m15/storage/myisam/myisamdef.h @@ -769,7 +769,7 @@ void _mi_report_crashed(MI_INFO *file, c int mi_check_index_cond(MI_INFO *info, uint keynr, uchar *record); /* Functions needed by mi_check */ -volatile int *killed_ptr(MI_CHECK *param); +int mi_is_killed(MI_CHECK *param); void mi_check_print_error(MI_CHECK *param, const char *fmt,...); void mi_check_print_warning(MI_CHECK *param, const char *fmt,...); void mi_check_print_info(MI_CHECK *param, const char *fmt,...); Index: mysql-5.7.5-m15/storage/myisam/sort.c =================================================================== --- mysql-5.7.5-m15.orig/storage/myisam/sort.c +++ mysql-5.7.5-m15/storage/myisam/sort.c @@ -909,7 +909,6 @@ merge_buffers(MI_SORT_PARAM *info, uint uchar *strpos; BUFFPEK *buffpek,**refpek; QUEUE queue; - volatile int *killed= killed_ptr(info->sort_info->param); DBUG_ENTER("merge_buffers"); count=error=0; @@ -941,7 +940,7 @@ merge_buffers(MI_SORT_PARAM *info, uint { for (;;) { - if (*killed) + if (mi_is_killed(info->sort_info->param)) { error=1; goto err; } Index: mysql-5.7.5-m15/sql/filesort.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/filesort.cc +++ mysql-5.7.5-m15/sql/filesort.cc @@ -755,7 +755,6 @@ static ha_rows find_all_keys(Sort_param my_off_t record; TABLE *sort_form; THD *thd= current_thd; - volatile THD::killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set; bool skip_record; @@ -856,7 +855,7 @@ static ha_rows find_all_keys(Sort_param break; } - if (*killed) + if (thd->is_killed()) { DBUG_PRINT("info",("Sort killed by user")); if (!quick_select) @@ -1806,16 +1805,9 @@ int merge_buffers(Sort_param *param, IO_ QUEUE queue; qsort2_cmp cmp; void *first_cmp_arg; - volatile THD::killed_state *killed= ¤t_thd->killed; - THD::killed_state not_killable; DBUG_ENTER("merge_buffers"); current_thd->inc_status_sort_merge_passes(); - if (param->not_killable) - { - killed= ¬_killable; - not_killable= THD::NOT_KILLED; - } error=0; rec_length= param->rec_length; @@ -1891,7 +1883,7 @@ int merge_buffers(Sort_param *param, IO_ while (queue.elements > 1) { - if (*killed) + if (!param->not_killable && current_thd->is_killed()) { error= 1; goto err; /* purecov: inspected */ } Index: mysql-5.7.5-m15/sql/mysqld.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/mysqld.cc +++ mysql-5.7.5-m15/sql/mysqld.cc @@ -1049,7 +1049,7 @@ public: };); } mysql_mutex_lock(&killing_thd->LOCK_thd_data); - killing_thd->killed= THD::KILL_CONNECTION; + killing_thd->set_killed_state(THD::KILL_CONNECTION); MYSQL_CALLBACK(Connection_handler_manager::event_functions, post_kill_notification, (killing_thd)); if (killing_thd->mysys_var) Index: mysql-5.7.5-m15/sql/sql_base.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_base.cc +++ mysql-5.7.5-m15/sql/sql_base.cc @@ -202,7 +202,7 @@ bool Strict_error_handler::handle_condit || (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES))) { (*level)= Sql_condition::SL_ERROR; - thd->killed= THD::KILL_BAD_DATA; + thd->set_killed_state(THD::KILL_BAD_DATA); } break; default: @@ -1237,7 +1237,7 @@ bool close_cached_tables(THD *thd, TABLE /* Wait until all threads have closed all the tables we are flushing. */ DBUG_PRINT("info", ("Waiting for other threads to close their open tables")); - while (found && ! thd->killed) + while (found && ! thd->is_killed()) { TABLE_SHARE *share; found= FALSE; @@ -2913,7 +2913,7 @@ bool open_table(THD *thd, TABLE_LIST *ta if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias)) DBUG_RETURN(TRUE); - if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed) + if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->is_killed()) DBUG_RETURN(TRUE); /* @@ -3913,7 +3913,7 @@ Locked_tables_list::reopen_tables(THD *t mysql_lock_merge(thd->lock, lock)) == NULL) { unlink_all_closed_tables(thd, lock, reopen_count); - if (! thd->killed) + if (! thd->is_killed()) my_error(ER_LOCK_DEADLOCK, MYF(0)); return TRUE; } Index: mysql-5.7.5-m15/sql/sql_optimizer.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_optimizer.cc +++ mysql-5.7.5-m15/sql/sql_optimizer.cc @@ -4671,8 +4671,8 @@ bool JOIN::make_join_plan() if (Optimize_table_order(thd, this, NULL).choose_table_order()) DBUG_RETURN(true); - DBUG_EXECUTE_IF("bug13820776_1", thd->killed= THD::KILL_QUERY;); - if (thd->killed || thd->is_error()) + DBUG_EXECUTE_IF("bug13820776_1", thd->set_killed_state(THD::KILL_QUERY);); + if (thd->is_killed() || thd->is_error()) DBUG_RETURN(true); // If this is a subquery, decide between In-to-exists and materialization Index: mysql-5.7.5-m15/sql/sql_parse.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_parse.cc +++ mysql-5.7.5-m15/sql/sql_parse.cc @@ -1167,7 +1167,7 @@ bool dispatch_command(enum enum_server_c thd->security_ctx->user, thd->security_ctx->host_or_ip, (thd->password ? ER(ER_YES) : ER(ER_NO))); - thd->killed= THD::KILL_CONNECTION; + thd->set_killed_state(THD::KILL_CONNECTION); error=true; } else @@ -1249,7 +1249,7 @@ bool dispatch_command(enum enum_server_c mysql_parse(thd, &parser_state); - while (!thd->killed && (parser_state.m_lip.found_semicolon != NULL) && + while (!thd->is_killed() && (parser_state.m_lip.found_semicolon != NULL) && ! thd->is_error()) { /* @@ -1670,7 +1670,7 @@ done: /* Finalize server status flags after executing a command. */ thd->update_server_status(); - if (thd->killed) + if (thd->is_killed()) thd->send_kill_message(); thd->protocol->end_statement(); query_cache.end_of_result(thd); @@ -4267,7 +4267,7 @@ end_with_restore_list: } /* Disconnect the current client connection. */ if (tx_release) - thd->killed= THD::KILL_CONNECTION; + thd->set_killed_state(THD::KILL_CONNECTION); my_ok(thd); break; } @@ -4298,7 +4298,7 @@ end_with_restore_list: } /* Disconnect the current client connection. */ if (tx_release) - thd->killed= THD::KILL_CONNECTION; + thd->set_killed_state(THD::KILL_CONNECTION); my_ok(thd); break; } @@ -4518,7 +4518,7 @@ end_with_restore_list: } else { - DBUG_ASSERT(thd->is_error() || thd->killed); + DBUG_ASSERT(thd->is_error() || thd->is_killed()); goto error; // Substatement should already have sent error } } @@ -4544,7 +4544,7 @@ end_with_restore_list: /* Conditionally writes to binlog */ int sp_result= sp_update_routine(thd, sp_type, lex->spname, &lex->sp_chistics); - if (thd->killed) + if (thd->is_killed()) goto error; switch (sp_result) { @@ -4886,11 +4886,12 @@ finish: trans_commit_stmt(thd); thd->get_stmt_da()->set_overwrite_status(false); } - if (thd->killed == THD::KILL_QUERY || - thd->killed == THD::KILL_TIMEOUT || - thd->killed == THD::KILL_BAD_DATA) + THD::killed_state thd_killed_state = thd->get_killed_state(); + if (thd_killed_state == THD::KILL_QUERY || + thd_killed_state == THD::KILL_TIMEOUT || + thd_killed_state == THD::KILL_BAD_DATA) { - thd->killed= THD::NOT_KILLED; + thd->set_killed_state(THD::NOT_KILLED); thd->mysys_var->abort= 0; } } @@ -6345,7 +6346,7 @@ uint kill_one_thread(THD *thd, my_thread /* process the kill only if thread is not already undergoing any kill connection. */ - if (tmp->killed != THD::KILL_CONNECTION) + if (tmp->get_killed_state() != THD::KILL_CONNECTION) { tmp->awake(only_kill_query ? THD::KILL_QUERY : THD::KILL_CONNECTION); } @@ -6377,7 +6378,7 @@ void sql_kill(THD *thd, my_thread_id id, uint error; if (!(error= kill_one_thread(thd, id, only_kill_query))) { - if (! thd->killed) + if (! thd->is_killed()) my_ok(thd); } else @@ -6408,7 +6409,7 @@ public: /* Kill only if non super thread and non slave thread */ if (!(thd_to_kill->security_ctx->master_access & SUPER_ACL) - && thd_to_kill->killed != THD::KILL_CONNECTION + && thd_to_kill->get_killed_state() != THD::KILL_CONNECTION && !thd_to_kill->slave_thread) thd_to_kill->awake(THD::KILL_CONNECTION); Index: mysql-5.7.5-m15/sql/sql_planner.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_planner.cc +++ mysql-5.7.5-m15/sql/sql_planner.cc @@ -2491,8 +2491,8 @@ bool Optimize_table_order::best_extensio { DBUG_ENTER("Optimize_table_order::best_extension_by_limited_search"); - DBUG_EXECUTE_IF("bug13820776_2", thd->killed= THD::KILL_QUERY;); - if (thd->killed) // Abort + DBUG_EXECUTE_IF("bug13820776_2", thd->set_killed_state(THD::KILL_QUERY)); + if (thd->is_killed()) // Abort DBUG_RETURN(true); const Cost_model_server *const cost_model= join->cost_model(); Index: mysql-5.7.5-m15/sql/sql_table.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_table.cc +++ mysql-5.7.5-m15/sql/sql_table.cc @@ -2399,7 +2399,7 @@ int mysql_rm_table_no_locks(THD *thd, TA DBUG_ASSERT(thd->mdl_context.owns_equal_or_stronger_lock(MDL_key::TABLE, table->db, table->table_name, MDL_EXCLUSIVE)); - if (thd->killed) + if (thd->is_killed()) { error= -1; goto err; @@ -9168,7 +9168,7 @@ copy_data_between_tables(PSI_stage_progr while (!(error=info.read_record(&info))) { - if (thd->killed) + if (thd->is_killed()) { thd->send_kill_message(); error= 1; @@ -9388,7 +9388,7 @@ bool mysql_checksum_table(THD *thd, TABL { for (;;) { - if (thd->killed) + if (thd->is_killed()) { /* we've been killed; let handler clean up, and remove the Index: mysql-5.7.5-m15/sql/sql_update.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_update.cc +++ mysql-5.7.5-m15/sql/sql_update.cc @@ -681,7 +681,7 @@ bool mysql_update(THD *thd, THD_STAGE_INFO(thd, stage_searching_rows_for_update); ha_rows tmp_limit= limit; - while (!(error=info.read_record(&info)) && !thd->killed) + while (!(error=info.read_record(&info)) && !thd->is_killed()) { thd->inc_examined_row_count(1); bool skip_record= FALSE; @@ -715,7 +715,7 @@ bool mysql_update(THD *thd, else table->file->unlock_row(); } - if (thd->killed && !error) // Aborted + if (thd->is_killed() && !error) // Aborted error= 1; /* purecov: inspected */ limit= tmp_limit; table->file->try_semi_consistent_read(0); @@ -795,7 +795,7 @@ bool mysql_update(THD *thd, while (true) { error= info.read_record(&info); - if (error || thd->killed) + if (error || thd->is_killed()) break; thd->inc_examined_row_count(1); bool skip_record; @@ -971,11 +971,11 @@ bool mysql_update(THD *thd, It's assumed that if an error was set in combination with an effective killed status then the error is due to killing. */ - killed_status= thd->killed; // get the status of the volatile + killed_status= thd->get_killed_state(); // get the status of the volatile // simulated killing after the loop must be ineffective for binlogging DBUG_EXECUTE_IF("simulate_kill_bug27571", { - thd->killed= THD::KILL_QUERY; + thd->set_killed_state(THD::KILL_QUERY); };); error= (killed_status == THD::NOT_KILLED)? error : 1; @@ -2318,7 +2318,7 @@ void multi_update::abort_result_set() got caught and if happens later the killed error is written into repl event. */ - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); /* the error of binary logging is ignored */ (void)thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query().str, thd->query().length, @@ -2400,7 +2400,7 @@ int multi_update::do_updates() for (;;) { - if (thd->killed && trans_safe) + if (thd->is_killed() && trans_safe) // No known handler error code present, print_error makes no sense goto err; if ((local_error=tmp_table->file->ha_rnd_next(tmp_table->record[0]))) @@ -2560,7 +2560,7 @@ bool multi_update::send_eof() if local_error is not set ON until after do_updates() then later carried out killing should not affect binlogging. */ - killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed; + killed_status= (local_error == 0)? THD::NOT_KILLED : thd->get_killed_state(); THD_STAGE_INFO(thd, stage_end); /* We must invalidate the query cache before binlog writing and Index: mysql-5.7.5-m15/sql/handler.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/handler.cc +++ mysql-5.7.5-m15/sql/handler.cc @@ -1863,7 +1863,7 @@ int ha_rollback_trans(THD *thd, bool all if (is_real_trans && trn_ctx->cannot_safely_rollback( Transaction_ctx::SESSION) && - !thd->slave_thread && thd->killed != THD::KILL_CONNECTION) + !thd->slave_thread && thd->get_killed_state() != THD::KILL_CONNECTION) trn_ctx->push_unsafe_rollback_warnings(thd); DBUG_RETURN(error); } @@ -3318,7 +3318,7 @@ int handler::update_auto_increment() /* first test if the query was aborted due to strict mode constraints */ - if (thd->killed == THD::KILL_BAD_DATA) + if (thd->get_killed_state() == THD::KILL_BAD_DATA) DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); /* @@ -5751,12 +5751,12 @@ handler::multi_range_read_info_const(uin /* Default MRR implementation doesn't need buffer */ *bufsz= 0; - DBUG_EXECUTE_IF("bug13822652_2", thd->killed= THD::KILL_QUERY;); + DBUG_EXECUTE_IF("bug13822652_2", thd->set_killed_state(THD::KILL_QUERY);); seq_it= seq->init(seq_init_param, n_ranges, *flags); while (!seq->next(seq_it, &range)) { - if (unlikely(thd->killed != 0)) + if (unlikely(thd->is_killed())) return HA_POS_ERROR; n_ranges++; Index: mysql-5.7.5-m15/sql/item_func.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/item_func.cc +++ mysql-5.7.5-m15/sql/item_func.cc @@ -5410,7 +5410,7 @@ longlong Item_func_benchmark::val_int() } null_value=0; - for (ulonglong loop=0 ; loop < loop_count && !thd->killed; loop++) + for (ulonglong loop=0 ; loop < loop_count && !thd->is_killed(); loop++) { switch (args[1]->result_type()) { case REAL_RESULT: @@ -5568,7 +5568,7 @@ longlong Item_func_sleep::val_int() error= 0; thd_wait_begin(thd, THD_WAIT_SLEEP); - while (!thd->killed) + while (!thd->is_killed()) { error= timed_cond.wait(&cond, &LOCK_item_func_sleep); if (error == ETIMEDOUT || error == ETIME) @@ -8022,7 +8022,7 @@ Item_func_sp::execute() { null_value= 1; context->process_error(thd); - if (thd->killed) + if (thd->is_killed()) thd->send_kill_message(); return TRUE; } Index: mysql-5.7.5-m15/sql/lock.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/lock.cc +++ mysql-5.7.5-m15/sql/lock.cc @@ -318,11 +318,11 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, if (sql_lock->table_count) (void) unlock_external(thd, sql_lock->table, sql_lock->table_count); reset_lock_data_and_free(&sql_lock); - if (! thd->killed) + if (! thd->is_killed()) my_error(rc, MYF(0)); } end: - if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed) + if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->is_killed()) { thd->send_kill_message(); if (sql_lock) Index: mysql-5.7.5-m15/sql/opt_explain.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/opt_explain.cc +++ mysql-5.7.5-m15/sql/opt_explain.cc @@ -2347,7 +2347,7 @@ void mysql_explain_other(THD *thd) } // Pick thread - if (!thd->killed) + if (!thd->is_killed()) { Find_thd_query_lock find_thd_query_lock(thd->lex->query_id); query_thd= Global_THD_manager:: Index: mysql-5.7.5-m15/sql/rpl_mts_submode.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_mts_submode.cc +++ mysql-5.7.5-m15/sql/rpl_mts_submode.cc @@ -118,7 +118,7 @@ Mts_submode_database::wait_for_workers_t continue; } - if (entry->usage > 0 && !thd->killed) + if (entry->usage > 0 && !thd->is_killed()) { PSI_stage_info old_stage; Slave_worker *w_entry= entry->worker; @@ -135,7 +135,7 @@ Mts_submode_database::wait_for_workers_t ("Either got awakened of notified: " "entry %p, usage %lu, worker %lu", entry, entry->usage, w_entry->id)); - } while (entry->usage != 0 && !thd->killed); + } while (entry->usage != 0 && !thd->is_killed()); entry->worker= w_entry; // restoring last association, needed only for assert thd->EXIT_COND(&old_stage); ret++; @@ -601,7 +601,7 @@ Mts_submode_logical_clock::get_least_occ { /* wait and get a free worker */ worker= get_free_worker(rli); - } while (!worker && !thd->killed && + } while (!worker && !thd->is_killed() && (my_sleep(rli->mts_coordinator_basic_nap), 1)); // Restore old stage info. @@ -624,7 +624,7 @@ Mts_submode_logical_clock::get_least_occ DBUG_ASSERT(ptr_group); // assert that we have a worker thread for this event or the slave has // stopped. - DBUG_ASSERT(worker != NULL || thd->killed); + DBUG_ASSERT(worker != NULL || thd->is_killed()); /* The master my have send db partition info. make sure we never use them*/ if (ev->get_type_code() == QUERY_EVENT) static_cast(ev)->mts_accessed_dbs= 0; @@ -670,7 +670,7 @@ Mts_submode_logical_clock:: // Update thd info as waiting for workers to finish. thd->enter_stage(&stage_slave_waiting_for_workers_to_finish, old_stage, __func__, __FILE__, __LINE__); - while (delegated_jobs > jobs_done && !thd->killed) + while (delegated_jobs > jobs_done && !thd->is_killed()) { if (mts_checkpoint_routine(rli, 0, true, true /*need_data_lock=true*/)) DBUG_RETURN(-1); Index: mysql-5.7.5-m15/sql/sp_head.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sp_head.cc +++ mysql-5.7.5-m15/sql/sp_head.cc @@ -848,7 +848,7 @@ bool sp_head::execute(THD *thd, bool mer /* Reset sp_rcontext::end_partial_result_set flag. */ thd->sp_runtime_ctx->end_partial_result_set= FALSE; - } while (!err_status && !thd->killed && !thd->is_fatal_error); + } while (!err_status && !thd->is_killed() && !thd->is_fatal_error); #if defined(ENABLED_PROFILING) thd->profiling.finish_current_query(); @@ -947,16 +947,16 @@ bool sp_head::execute(THD *thd, bool mer done: DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d", - err_status, thd->killed, thd->is_slave_error, + err_status, thd->get_killed_state(), thd->is_slave_error, thd->is_error())); - if (thd->killed) + if (thd->is_killed()) err_status= TRUE; /* If the DB has changed, the pointer has changed too, but the original thd->db will then have been freed */ - if (cur_db_changed && thd->killed != THD::KILL_CONNECTION) + if (cur_db_changed && thd->get_killed_state() != THD::KILL_CONNECTION) { /* Force switching back to the saved current database, because it may be @@ -1111,7 +1111,7 @@ err_with_cleanup: free_root(&call_mem_root, MYF(0)); thd->sp_runtime_ctx= parent_sp_runtime_ctx; - if (thd->killed) + if (thd->is_killed()) thd->send_kill_message(); DBUG_RETURN(err_status); @@ -1316,7 +1316,7 @@ bool sp_head::execute_function(THD *thd, thd->variables.option_bits= binlog_save_options; if (thd->binlog_evt_union.unioned_events) { - int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode = query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); Query_log_event qinfo(thd, binlog_buf.ptr(), binlog_buf.length(), thd->binlog_evt_union.unioned_events_trans, FALSE, FALSE, errcode); if (mysql_bin_log.write_event(&qinfo) && Index: mysql-5.7.5-m15/sql/binlog.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/binlog.cc +++ mysql-5.7.5-m15/sql/binlog.cc @@ -1804,7 +1804,7 @@ static int binlog_savepoint_set(handlert append_identifier(thd, &log_query, thd->lex->ident.str, thd->lex->ident.length); - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(), TRUE, FALSE, TRUE, errcode); /* @@ -1846,7 +1846,7 @@ static int binlog_savepoint_rollback(han log_query.append(thd->lex->ident.str, thd->lex->ident.length) || log_query.append("`")) DBUG_RETURN(1); - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(), TRUE, FALSE, TRUE, errcode); DBUG_RETURN(mysql_bin_log.write_event(&qinfo)); @@ -2237,7 +2237,7 @@ int query_error_code(THD *thd, bool not_ { int error; - if (not_killed || (thd->killed == THD::KILL_BAD_DATA)) + if (not_killed || (thd->get_killed_state() == THD::KILL_BAD_DATA)) { error= thd->is_error() ? thd->get_stmt_da()->mysql_errno() : 0; Index: mysql-5.7.5-m15/sql/records.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/records.cc +++ mysql-5.7.5-m15/sql/records.cc @@ -369,7 +369,7 @@ void end_read_record(READ_RECORD *info) static int rr_handle_error(READ_RECORD *info, int error) { - if (info->thd->killed) + if (info->thd->is_killed()) { info->thd->send_kill_message(); return 1; @@ -395,7 +395,7 @@ static int rr_quick(READ_RECORD *info) int tmp; while ((tmp= info->quick->get_next())) { - if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED)) + if (info->thd->is_killed() || (tmp != HA_ERR_RECORD_DELETED)) { tmp= rr_handle_error(info, tmp); break; @@ -510,7 +510,7 @@ int rr_sequential(READ_RECORD *info) ha_rnd_next can return RECORD_DELETED for MyISAM when one thread is reading and another deleting without locks. */ - if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED)) + if (info->thd->is_killed() || (tmp != HA_ERR_RECORD_DELETED)) { tmp= rr_handle_error(info, tmp); break; Index: mysql-5.7.5-m15/sql/sp.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sp.cc +++ mysql-5.7.5-m15/sql/sp.cc @@ -1538,7 +1538,7 @@ bool lock_db_routines(THD *thd, const ch or is outdated. We therefore only abort mysql_rm_db() if we have errors not handled by the error handler. */ - DBUG_RETURN(thd->is_error() || thd->killed); + DBUG_RETURN(thd->is_error() || thd->is_killed()); } table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info); @@ -2146,7 +2146,7 @@ int sp_cache_routine(THD *thd, enum_sp_t break; default: /* Query might have been killed, don't set error. */ - if (thd->killed) + if (thd->is_killed()) break; /* Any error when loading an existing routine is either some problem Index: mysql-5.7.5-m15/sql/sp_instr.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sp_instr.cc +++ mysql-5.7.5-m15/sql/sp_instr.cc @@ -658,7 +658,7 @@ bool sp_lex_instr::validate_lex_and_exec */ if (stmt_reprepare_observer && !thd->is_fatal_error && - !thd->killed && + !thd->is_killed() && thd->get_stmt_da()->mysql_errno() == ER_NEED_REPREPARE && reprepare_attempt++ < 3) { Index: mysql-5.7.5-m15/sql/sql_cache.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_cache.cc +++ mysql-5.7.5-m15/sql/sql_cache.cc @@ -1054,7 +1054,7 @@ void Query_cache::end_of_result(THD *thd if (query_cache_tls->first_query_block == NULL) DBUG_VOID_RETURN; - if (thd->killed || thd->is_error()) + if (thd->is_killed() || thd->is_error()) { abort(&thd->query_cache_tls); DBUG_VOID_RETURN; @@ -4339,7 +4339,7 @@ void Query_cache::wreck(uint line, const DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line)); DBUG_PRINT("warning", ("==================================")); if (thd) - thd->killed= THD::KILL_CONNECTION; + thd->set_killed_state(THD::KILL_CONNECTION); cache_dump(); bins_dump(); DBUG_VOID_RETURN; Index: mysql-5.7.5-m15/sql/sql_delete.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_delete.cc +++ mysql-5.7.5-m15/sql/sql_delete.cc @@ -457,7 +457,7 @@ bool mysql_delete(THD *thd, ha_rows limi qep_tab.quick() && qep_tab.quick()->index != MAX_KEY) read_removal= table->check_read_removal(qep_tab.quick()->index); - while (!(error=info.read_record(&info)) && !thd->killed && + while (!(error=info.read_record(&info)) && !thd->is_killed() && ! thd->is_error()) { thd->inc_examined_row_count(1); @@ -520,7 +520,7 @@ bool mysql_delete(THD *thd, ha_rows limi break; } - killed_status= thd->killed; + killed_status= thd->get_killed_state(); if (killed_status != THD::NOT_KILLED || thd->is_error()) error= 1; // Aborted if (will_batch && (loc_error= table->file->end_bulk_delete())) @@ -601,12 +601,12 @@ cleanup: my_ok(thd, deleted); DBUG_PRINT("info",("%ld records deleted",(long) deleted)); } - DBUG_RETURN(thd->is_error() || thd->killed); + DBUG_RETURN(thd->is_error() || thd->is_killed()); exit_without_my_ok: free_underlaid_joins(thd, select_lex); table->set_keyread(false); - DBUG_RETURN((err || thd->is_error() || thd->killed) ? 1 : 0); + DBUG_RETURN((err || thd->is_error() || thd->is_killed()) ? 1 : 0); } @@ -1074,7 +1074,7 @@ void multi_delete::abort_result_set() */ if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); /* possible error of writing binary log is ignored deliberately */ (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query().str, thd->query().length, @@ -1119,7 +1119,7 @@ int multi_delete::do_deletes() int local_error= do_table_deletes(table); - if (thd->killed && !local_error) + if (thd->is_killed() && !local_error) DBUG_RETURN(1); if (local_error == -1) // End of file @@ -1159,7 +1159,7 @@ int multi_delete::do_table_deletes(TABLE */ info.ignore_not_found_rows= 1; bool will_batch= !table->file->start_bulk_delete(); - while (!(local_error= info.read_record(&info)) && !thd->killed) + while (!(local_error= info.read_record(&info)) && !thd->is_killed()) { if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, @@ -1243,7 +1243,7 @@ bool multi_delete::send_eof() /* compute a total error to know if something failed */ local_error= local_error || error; - killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed; + killed_status= (local_error == 0)? THD::NOT_KILLED : thd->get_killed_state(); /* reset used flags */ THD_STAGE_INFO(thd, stage_end); Index: mysql-5.7.5-m15/sql/sql_insert.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_insert.cc +++ mysql-5.7.5-m15/sql/sql_insert.cc @@ -778,7 +778,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t thd->clear_error(); } else - errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); /* bug#22725: @@ -792,7 +792,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t routines did not result in any error due to the KILLED. In such case the flag is ignored for constructing binlog event. */ - DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0); + DBUG_ASSERT(thd->get_killed_state() != THD::KILL_BAD_DATA || error > 0); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query().str, thd->query().length, transactional_table, FALSE, FALSE, @@ -2126,7 +2126,7 @@ bool select_insert::send_eof() bool const trans_table= table->file->has_transactions(); ulonglong id, row_count; bool changed; - THD::killed_state killed_status= thd->killed; + THD::killed_state killed_status= thd->get_killed_state(); DBUG_ENTER("select_insert::send_eof"); DBUG_PRINT("enter", ("trans_table=%d, table_type='%s'", trans_table, table->file->table_type())); @@ -2262,7 +2262,7 @@ void select_insert::abort_result_set() { { if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); /* error of writing binary log is ignored */ (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query().str, thd->query().length, @@ -2710,7 +2710,7 @@ select_create::binlog_show_create_table( if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->get_killed_state() == THD::NOT_KILLED); result= thd->binlog_query(THD::STMT_QUERY_TYPE, query.ptr(), query.length(), /* is_trans */ TRUE, Index: mysql-5.7.5-m15/sql/item_subselect.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/item_subselect.cc +++ mysql-5.7.5-m15/sql/item_subselect.cc @@ -566,7 +566,7 @@ bool Item_subselect::exec() or if the query has been killed. */ THD * const thd= unit->thd; - if (thd->is_error() || thd->killed) + if (thd->is_error() || thd->is_killed()) DBUG_RETURN(true); DBUG_ASSERT(!thd->lex->context_analysis_only); Index: mysql-5.7.5-m15/sql/opt_range.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/opt_range.cc +++ mysql-5.7.5-m15/sql/opt_range.cc @@ -10430,7 +10430,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_ break; } - if (thd->killed) + if (thd->is_killed()) DBUG_RETURN(1); /* skip row if it will be retrieved by clustered PK scan */ Index: mysql-5.7.5-m15/sql/rpl_gtid.h =================================================================== --- mysql-5.7.5-m15.orig/sql/rpl_gtid.h +++ mysql-5.7.5-m15/sql/rpl_gtid.h @@ -681,7 +681,7 @@ public: sid_lock will be released, whereas the mutex will be released during the wait and (atomically) re-acquired when the wait ends. */ - inline void wait(const THD* thd, int n) const + inline void wait(THD* thd, int n) const { DBUG_ENTER("Mutex_cond_array::wait"); Mutex_cond *mutex_cond= get_mutex_cond(n); @@ -710,7 +710,7 @@ public: @retval - 0 - success !=0 - failure */ - inline int wait(const THD* thd, int sidno, struct timespec* abstime) const + inline int wait(THD* thd, int sidno, struct timespec* abstime) const { DBUG_ENTER("Mutex_cond_array::wait"); int error= 0; @@ -755,7 +755,7 @@ public: @retval true - thread is killed false - thread not killed */ - bool check_thd_killed(const THD* thd) const; + bool check_thd_killed(THD* thd) const; private: /// A mutex/cond pair. struct Mutex_cond Index: mysql-5.7.5-m15/sql/sql_executor.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_executor.cc +++ mysql-5.7.5-m15/sql/sql_executor.cc @@ -1023,7 +1023,7 @@ sub_select_op(JOIN *join, QEP_TAB *qep_t { DBUG_ENTER("sub_select_op"); - if (join->thd->killed) + if (join->thd->is_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); @@ -1251,13 +1251,13 @@ sub_select(JOIN *join, QEP_TAB *const qe else error= info->read_record(info); - DBUG_EXECUTE_IF("bug13822652_1", join->thd->killed= THD::KILL_QUERY;); + DBUG_EXECUTE_IF("bug13822652_1", join->thd->set_killed_state(THD::KILL_QUERY);); if (error > 0 || (join->thd->is_error())) // Fatal error rc= NESTED_LOOP_ERROR; else if (error < 0) break; - else if (join->thd->killed) // Aborted by user + else if (join->thd->is_killed()) // Aborted by user { join->thd->send_kill_message(); rc= NESTED_LOOP_KILLED; @@ -1462,7 +1462,7 @@ evaluate_join_record(JOIN *join, QEP_TAB { found= MY_TEST(condition->val_int()); - if (join->thd->killed) + if (join->thd->is_killed()) { join->thd->send_kill_message(); DBUG_RETURN(NESTED_LOOP_KILLED); @@ -1706,7 +1706,7 @@ evaluate_null_complemented_join_record(J /* Check all attached conditions for inner table rows. */ if (qep_tab->condition() && !qep_tab->condition()->val_int()) { - if (join->thd->killed) + if (join->thd->is_killed()) { join->thd->send_kill_message(); DBUG_RETURN(NESTED_LOOP_KILLED); @@ -1766,7 +1766,7 @@ int report_handler_error(TABLE *table, i if (error != HA_ERR_LOCK_DEADLOCK && error != HA_ERR_LOCK_WAIT_TIMEOUT && error != HA_ERR_TABLE_DEF_CHANGED && - !table->in_use->killed) + !table->in_use->is_killed()) sql_print_error("Got error %d when reading table '%s'", error, table->s->path.str); table->file->print_error(error,MYF(0)); @@ -3232,7 +3232,7 @@ end_write(JOIN *join, QEP_TAB *const qep TABLE *const table= qep_tab->table(); DBUG_ENTER("end_write"); - if (join->thd->killed) // Aborted by user + if (join->thd->is_killed()) // Aborted by user { join->thd->send_kill_message(); DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */ @@ -3294,7 +3294,7 @@ end_update(JOIN *join, QEP_TAB *const qe if (end_of_records) DBUG_RETURN(NESTED_LOOP_OK); - if (join->thd->killed) // Aborted by user + if (join->thd->is_killed()) // Aborted by user { join->thd->send_kill_message(); DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */ @@ -3399,7 +3399,7 @@ end_write_group(JOIN *join, QEP_TAB *con int idx= -1; DBUG_ENTER("end_write_group"); - if (join->thd->killed) + if (join->thd->is_killed()) { // Aborted by user join->thd->send_kill_message(); DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */ @@ -3675,7 +3675,7 @@ static bool remove_dup_with_compare(THD error=file->ha_rnd_next(record); for (;;) { - if (thd->killed) + if (thd->is_killed()) { thd->send_kill_message(); error=0; @@ -3807,7 +3807,7 @@ static bool remove_dup_with_hash_index(T for (;;) { uchar *org_key_pos; - if (thd->killed) + if (thd->is_killed()) { thd->send_kill_message(); error=0; @@ -4569,7 +4569,7 @@ QEP_tmp_table::end_send() rc= NESTED_LOOP_ERROR; else if (error < 0) break; - else if (join->thd->killed) // Aborted by user + else if (join->thd->is_killed()) // Aborted by user { join->thd->send_kill_message(); rc= NESTED_LOOP_KILLED; Index: mysql-5.7.5-m15/sql/sql_join_buffer.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_join_buffer.cc +++ mysql-5.7.5-m15/sql/sql_join_buffer.cc @@ -1885,7 +1885,7 @@ enum_nested_loop_state JOIN_CACHE_BNL::j if (qep_tab->keep_current_rowid) qep_tab->table()->file->position(qep_tab->table()->record[0]); - if (join->thd->killed) + if (join->thd->is_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); @@ -2185,7 +2185,7 @@ enum_nested_loop_state JOIN_CACHE::join_ for ( ; cnt; cnt--) { - if (join->thd->killed) + if (join->thd->is_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); @@ -2395,7 +2395,7 @@ enum_nested_loop_state JOIN_CACHE_BKA::j while (!(error= file->multi_range_read_next((char **) &rec_ptr))) { - if (join->thd->killed) + if (join->thd->is_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); @@ -3325,7 +3325,7 @@ JOIN_CACHE_BKA_UNIQUE::join_matching_rec next_rec_ref_ptr= get_next_rec_ref(next_rec_ref_ptr); uchar *rec_ptr= next_rec_ref_ptr+rec_fields_offset; - if (join->thd->killed) + if (join->thd->is_killed()) { /* The user has aborted the execution of the query */ join->thd->send_kill_message(); Index: mysql-5.7.5-m15/include/mysql/plugin.h =================================================================== --- mysql-5.7.5-m15.orig/include/mysql/plugin.h +++ mysql-5.7.5-m15/include/mysql/plugin.h @@ -604,14 +604,14 @@ int mysql_tmpfile(const char *prefix); @retval 0 the connection is active @retval 1 the connection has been killed */ -int thd_killed(const MYSQL_THD thd); +int thd_killed(MYSQL_THD thd); /** Set the killed status of the current statement. @param thd user thread connection handle */ -void thd_set_kill_status(const MYSQL_THD thd); +void thd_set_kill_status(MYSQL_THD thd); /** Get binary log position for latest written entry. Index: mysql-5.7.5-m15/include/mysql/plugin_audit.h.pp =================================================================== --- mysql-5.7.5-m15.orig/include/mysql/plugin_audit.h.pp +++ mysql-5.7.5-m15/include/mysql/plugin_audit.h.pp @@ -268,8 +268,8 @@ void thd_inc_row_count(void* thd); int thd_allow_batch(void* thd); void thd_mark_transaction_to_rollback(void* thd, int all); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); -void thd_set_kill_status(const void* thd); +int thd_killed(void* thd); +void thd_set_kill_status(void* thd); void thd_binlog_pos(const void* thd, const char **file_var, unsigned long long *pos_var); Index: mysql-5.7.5-m15/include/mysql/plugin_ftparser.h.pp =================================================================== --- mysql-5.7.5-m15.orig/include/mysql/plugin_ftparser.h.pp +++ mysql-5.7.5-m15/include/mysql/plugin_ftparser.h.pp @@ -220,8 +220,8 @@ void thd_inc_row_count(void* thd); int thd_allow_batch(void* thd); void thd_mark_transaction_to_rollback(void* thd, int all); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); -void thd_set_kill_status(const void* thd); +int thd_killed(void* thd); +void thd_set_kill_status(void* thd); void thd_binlog_pos(const void* thd, const char **file_var, unsigned long long *pos_var); Index: mysql-5.7.5-m15/include/mysql/plugin_auth.h.pp =================================================================== --- mysql-5.7.5-m15.orig/include/mysql/plugin_auth.h.pp +++ mysql-5.7.5-m15/include/mysql/plugin_auth.h.pp @@ -268,8 +268,8 @@ void thd_inc_row_count(void* thd); int thd_allow_batch(void* thd); void thd_mark_transaction_to_rollback(void* thd, int all); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); -void thd_set_kill_status(const void* thd); +int thd_killed(void* thd); +void thd_set_kill_status(void* thd); void thd_binlog_pos(const void* thd, const char **file_var, unsigned long long *pos_var); Index: mysql-5.7.5-m15/sql/event_queue.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/event_queue.cc +++ mysql-5.7.5-m15/sql/event_queue.cc @@ -580,9 +580,9 @@ Event_queue::get_top_for_execution_if_ti Event_queue_element *top= NULL; /* Break loop if thd has been killed */ - if (thd->killed) + if (thd->is_killed()) { - DBUG_PRINT("info", ("thd->killed=%d", thd->killed)); + DBUG_PRINT("info", ("thd->killed=%d", thd->get_killed_state())); goto end; } @@ -764,7 +764,7 @@ Event_queue::cond_wait(THD *thd, struct thd->enter_cond(&COND_queue_state, &LOCK_event_queue, stage, NULL, src_func, src_file, src_line); - if (!thd->killed) + if (!thd->is_killed()) { if (!abstime) mysql_cond_wait(&COND_queue_state, &LOCK_event_queue); Index: mysql-5.7.5-m15/sql/signal_handler.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/signal_handler.cc +++ mysql-5.7.5-m15/sql/signal_handler.cc @@ -149,7 +149,7 @@ extern "C" void handle_fatal_signal(int if (thd) { const char *kreason= "UNKNOWN"; - switch (thd->killed) { + switch (thd->get_killed_state()) { case THD::NOT_KILLED: kreason= "NOT_KILLED"; break; Index: mysql-5.7.5-m15/sql/sp_rcontext.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sp_rcontext.cc +++ mysql-5.7.5-m15/sql/sp_rcontext.cc @@ -429,7 +429,7 @@ bool sp_rcontext::handle_sql_condition(T /* Reset error state. */ thd->clear_error(); - thd->killed= THD::NOT_KILLED; // Some errors set thd->killed + thd->set_killed_state(THD::NOT_KILLED); // Some errors set thd->killed // (e.g. "bad data"). thd->push_diagnostics_area(&frame->handler_da); Index: mysql-5.7.5-m15/sql/sql_connect.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_connect.cc +++ mysql-5.7.5-m15/sql/sql_connect.cc @@ -742,14 +742,14 @@ void end_connection(THD *thd) */ release_user_connection(thd); - if (thd->killed || (net->error && net->vio != 0)) + if (thd->is_killed() || (net->error && net->vio != 0)) { aborted_threads++; } if (net->error && net->vio != 0) { - if (!thd->killed) + if (!thd->is_killed()) { Security_context *sctx= thd->security_ctx; @@ -824,7 +824,7 @@ static void prepare_new_connection_state thd->server_status&= ~SERVER_STATUS_CLEAR_SET; thd->protocol->end_statement(); - thd->killed = THD::KILL_CONNECTION; + thd->set_killed_state(THD::KILL_CONNECTION); errors.m_init_connect= 1; inc_host_errors(thd->main_security_ctx.get_ip()->ptr(), &errors); return; @@ -889,7 +889,7 @@ bool thd_is_connection_alive(THD *thd) NET *net= &thd->net; if (!net->error && net->vio != 0 && - !(thd->killed == THD::KILL_CONNECTION)) + !(thd->get_killed_state() == THD::KILL_CONNECTION)) return TRUE; return FALSE; } Index: mysql-5.7.5-m15/sql/sql_db.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_db.cc +++ mysql-5.7.5-m15/sql/sql_db.cc @@ -856,7 +856,7 @@ bool mysql_rm_db(THD *thd,const LEX_CSTR } thd->push_internal_handler(&err_handler); - if (!thd->killed && + if (!thd->is_killed() && !(tables && mysql_rm_table_no_locks(thd, tables, true, false, true, true))) { @@ -1054,7 +1054,7 @@ static bool find_db_tables_and_rm_known_ tot_list_next_local= tot_list_next_global= &tot_list; for (uint idx=0 ; - idx < (uint) dirp->number_off_files && !thd->killed ; + idx < (uint) dirp->number_off_files && !thd->is_killed() ; idx++) { FILEINFO *file=dirp->dir_entry+idx; @@ -1237,7 +1237,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR DBUG_PRINT("enter", ("path: %s", org_path)); for (uint idx=0 ; - idx < (uint) dirp->number_off_files && !thd->killed ; + idx < (uint) dirp->number_off_files && !thd->is_killed() ; idx++) { FILEINFO *file=dirp->dir_entry+idx; @@ -1272,7 +1272,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR } deleted++; } - if (thd->killed) + if (thd->is_killed()) goto err; my_dirend(dirp); @@ -1761,7 +1761,7 @@ bool mysql_upgrade_db(THD *thd, const LE if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) { uint nfiles= (uint) dirp->number_off_files; - for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++) + for (uint idx=0 ; idx < nfiles && !thd->is_killed() ; idx++) { FILEINFO *file= dirp->dir_entry + idx; char *extension, tname[FN_REFLEN + 1]; Index: mysql-5.7.5-m15/sql/sql_help.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_help.cc +++ mysql-5.7.5-m15/sql/sql_help.cc @@ -833,7 +833,7 @@ bool mysqld_help(THD *thd, const char *m goto error; } - if (thd->killed) + if (thd->is_killed()) goto error; my_eof(thd); Index: mysql-5.7.5-m15/sql/sql_load.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_load.cc +++ mysql-5.7.5-m15/sql/sql_load.cc @@ -540,11 +540,11 @@ int mysql_load(THD *thd,sql_exchange *ex DBUG_EXECUTE_IF("simulate_kill_bug27571", { error=1; - thd->killed= THD::KILL_QUERY; + thd->set_killed_state(THD::KILL_QUERY); };); #ifndef EMBEDDED_LIBRARY - killed_status= (error == 0) ? THD::NOT_KILLED : thd->killed; + killed_status= (error == 0) ? THD::NOT_KILLED : thd->get_killed_state(); #endif /* @@ -818,7 +818,7 @@ read_fixed_length(THD *thd, COPY_INFO &i while (!read_info.read_fixed_length()) { - if (thd->killed) + if (thd->is_killed()) { thd->send_kill_message(); DBUG_RETURN(1); @@ -903,7 +903,7 @@ read_fixed_length(THD *thd, COPY_INFO &i thd->get_stmt_da()->current_row_for_condition()); } - if (thd->killed || + if (thd->is_killed() || fill_record_n_invoke_before_triggers(thd, set_fields, set_values, table, TRG_EVENT_INSERT, table->s->fields)) @@ -988,7 +988,7 @@ read_sep_field(THD *thd, COPY_INFO &info for (;;it.rewind()) { - if (thd->killed) + if (thd->is_killed()) { thd->send_kill_message(); DBUG_RETURN(1); @@ -1152,7 +1152,7 @@ read_sep_field(THD *thd, COPY_INFO &info } } - if (thd->killed || + if (thd->is_killed() || fill_record_n_invoke_before_triggers(thd, set_fields, set_values, table, TRG_EVENT_INSERT, table->s->fields)) @@ -1206,7 +1206,7 @@ read_sep_field(THD *thd, COPY_INFO &info push_warning_printf(thd, Sql_condition::SL_WARNING, ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS), thd->get_stmt_da()->current_row_for_condition()); - if (thd->killed) + if (thd->is_killed()) DBUG_RETURN(1); } thd->get_stmt_da()->inc_current_row_for_condition(); @@ -1233,7 +1233,7 @@ read_xml_field(THD *thd, COPY_INFO &info for ( ; ; it.rewind()) { - if (thd->killed) + if (thd->is_killed()) { thd->send_kill_message(); DBUG_RETURN(1); @@ -1366,7 +1366,7 @@ read_xml_field(THD *thd, COPY_INFO &info } } - if (thd->killed || + if (thd->is_killed() || fill_record_n_invoke_before_triggers(thd, set_fields, set_values, table, TRG_EVENT_INSERT, table->s->fields)) Index: mysql-5.7.5-m15/sql/sql_prepare.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_prepare.cc +++ mysql-5.7.5-m15/sql/sql_prepare.cc @@ -3593,7 +3593,7 @@ reexecute: thd->pop_reprepare_observer(); if ((sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) && - error && !thd->is_fatal_error && !thd->killed && + error && !thd->is_fatal_error && !thd->is_killed() && reprepare_observer.is_invalidated() && reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS) { Index: mysql-5.7.5-m15/sql/sql_reload.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_reload.cc +++ mysql-5.7.5-m15/sql/sql_reload.cc @@ -363,7 +363,7 @@ bool reload_acl_and_cache(THD *thd, unsi /* If the query was killed then this function must fail. */ - return result || (thd ? thd->killed : 0); + return result || (thd ? thd->is_killed() : 0); } Index: mysql-5.7.5-m15/sql/sql_servers.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_servers.cc +++ mysql-5.7.5-m15/sql/sql_servers.cc @@ -716,9 +716,9 @@ bool Sql_cmd_create_server::execute(THD mysql_rwlock_unlock(&THR_LOCK_servers); close_mysql_tables(thd); - if (error == 0 && !thd->killed) + if (error == 0 && !thd->is_killed()) my_ok(thd, 1); - DBUG_RETURN(error != 0 || thd->killed); + DBUG_RETURN(error != 0 || thd->is_killed()); } @@ -798,9 +798,9 @@ bool Sql_cmd_alter_server::execute(THD * ER_UNKNOWN_ERROR, "Server connection in use"); } - if (error == 0 && !thd->killed) + if (error == 0 && !thd->is_killed()) my_ok(thd, 1); - DBUG_RETURN(error != 0 || thd->killed); + DBUG_RETURN(error != 0 || thd->is_killed()); } @@ -869,9 +869,9 @@ bool Sql_cmd_drop_server::execute(THD *t ER_UNKNOWN_ERROR, "Server connection in use"); } - if (error == 0 && !thd->killed) + if (error == 0 && !thd->is_killed()) my_ok(thd, 1); - DBUG_RETURN(error != 0 || thd->killed); + DBUG_RETURN(error != 0 || thd->is_killed()); } Index: mysql-5.7.5-m15/sql/sql_show.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_show.cc +++ mysql-5.7.5-m15/sql/sql_show.cc @@ -883,7 +883,7 @@ mysqld_show_create(THD *thd, TABLE_LIST MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) || mysql_handle_derived(thd->lex, &mysql_derived_prepare); thd->pop_internal_handler(); - if (open_error && (thd->killed || thd->is_error())) + if (open_error && (thd->is_killed() || thd->is_error())) goto exit; } @@ -2157,7 +2157,7 @@ public: mysql_mutex_lock(&inspect_thd->mysys_var->mutex); /* COMMAND */ - if (inspect_thd->killed == THD::KILL_CONNECTION) + if (inspect_thd->get_killed_state() == THD::KILL_CONNECTION) thd_info->proc_info= "Killed"; thd_info->command=(int) inspect_thd->get_command(); // Used for !killed. @@ -2217,7 +2217,7 @@ void mysqld_list_processes(THD *thd,cons Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_VOID_RETURN; - if (!thd->killed) + if (!thd->is_killed()) { thread_infos.reserve(Global_THD_manager::get_instance()->get_thd_count()); List_process_list list_process_list(user, &thread_infos, thd, @@ -2334,7 +2334,7 @@ public: mysql_mutex_lock(&inspect_thd->mysys_var->mutex); /* COMMAND */ - if (inspect_thd->killed == THD::KILL_CONNECTION) + if (inspect_thd->get_killed_state() == THD::KILL_CONNECTION) { val= "Killed"; table->field[4]->store(val, strlen(val), system_charset_info); @@ -2385,7 +2385,7 @@ int fill_schema_processlist(THD* thd, TA DBUG_ENTER("fill_schema_processlist"); Fill_process_list fill_process_list(thd, tables); - if (!thd->killed) + if (!thd->is_killed()) { Global_THD_manager::get_instance()->do_for_all_thd_copy(&fill_process_list); } Index: mysql-5.7.5-m15/sql/sql_timer.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/sql_timer.cc +++ mysql-5.7.5-m15/sql/sql_timer.cc @@ -90,7 +90,7 @@ timer_notify(THD_timer_info *thd_timer) if (thd) { /* process only if thread is not already undergoing any kill connection. */ - if (thd->killed != THD::KILL_CONNECTION) + if (thd->get_killed_state() != THD::KILL_CONNECTION) { thd->awake(THD::KILL_TIMEOUT); } Index: mysql-5.7.5-m15/sql/table.cc =================================================================== --- mysql-5.7.5-m15.orig/sql/table.cc +++ mysql-5.7.5-m15/sql/table.cc @@ -4231,7 +4231,7 @@ bool TABLE_LIST::prep_check_option(THD * void TABLE_LIST::hide_view_error(THD *thd) { - if (thd->killed || thd->get_internal_handler()) + if (thd->is_killed() || thd->get_internal_handler()) return; /* Hide "Unknown column" or "Unknown function" error */ DBUG_ASSERT(thd->is_error());