| 3228 | */ |
| 3229 | |
| 3230 | static int init_slave_thread(THD* thd, Master_info *mi, |
| 3231 | SLAVE_THD_TYPE thd_type) |
| 3232 | { |
| 3233 | DBUG_ENTER("init_slave_thread"); |
| 3234 | int simulate_error __attribute__((unused))= 0; |
| 3235 | DBUG_EXECUTE_IF("simulate_io_slave_error_on_init", |
| 3236 | simulate_error|= (1 << SLAVE_THD_IO);); |
| 3237 | DBUG_EXECUTE_IF("simulate_sql_slave_error_on_init", |
| 3238 | simulate_error|= (1 << SLAVE_THD_SQL);); |
| 3239 | |
| 3240 | thd->system_thread = (thd_type == SLAVE_THD_SQL) ? |
| 3241 | SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO; |
| 3242 | |
| 3243 | if (init_thr_lock()) |
| 3244 | { |
| 3245 | thd->cleanup(); |
| 3246 | DBUG_RETURN(-1); |
| 3247 | } |
| 3248 | |
| 3249 | /* We must call store_globals() before doing my_net_init() */ |
| 3250 | thd->store_globals(); |
| 3251 | |
| 3252 | if (my_net_init(&thd->net, 0, thd, MYF(MY_THREAD_SPECIFIC)) || |
| 3253 | IF_DBUG(simulate_error & (1<< thd_type), 0)) |
| 3254 | { |
| 3255 | thd->cleanup(); |
| 3256 | DBUG_RETURN(-1); |
| 3257 | } |
| 3258 | |
| 3259 | thd->security_ctx->skip_grants(); |
| 3260 | thd->security_ctx->user=(char*) slave_user; |
| 3261 | thd->slave_thread= 1; |
| 3262 | thd->connection_name= mi->connection_name; |
| 3263 | thd->variables.sql_log_slow= !MY_TEST(thd->variables.log_slow_disabled_statements & LOG_SLOW_DISABLE_SLAVE); |
| 3264 | set_slave_thread_options(thd); |
| 3265 | |
| 3266 | if (thd_type == SLAVE_THD_SQL) |
| 3267 | THD_STAGE_INFO(thd, stage_waiting_for_the_next_event_in_relay_log); |
| 3268 | else |
| 3269 | THD_STAGE_INFO(thd, stage_waiting_for_master_update); |
| 3270 | thd->set_time(); |
| 3271 | /* Do not use user-supplied timeout value for system threads. */ |
| 3272 | thd->variables.lock_wait_timeout= LONG_TIMEOUT; |
| 3273 | DBUG_RETURN(0); |
| 3274 | } |
| 3275 | |
| 3276 | /* |
| 3277 | Sleep for a given amount of time or until killed. |
no test coverage detected