| 4156 | */ |
| 4157 | |
| 4158 | int reset_slave(THD *thd, Master_info* mi) |
| 4159 | { |
| 4160 | MY_STAT stat_area; |
| 4161 | char fname[FN_REFLEN]; |
| 4162 | int thread_mask= 0, error= 0; |
| 4163 | uint sql_errno=ER_UNKNOWN_ERROR; |
| 4164 | const char* errmsg= "Unknown error occurred while resetting slave"; |
| 4165 | char master_info_file_tmp[FN_REFLEN]; |
| 4166 | char relay_log_info_file_tmp[FN_REFLEN]; |
| 4167 | DBUG_ENTER("reset_slave"); |
| 4168 | |
| 4169 | mi->lock_slave_threads(); |
| 4170 | if (mi->killed) |
| 4171 | { |
| 4172 | /* connection was deleted while we waited for lock_slave_threads */ |
| 4173 | mi->unlock_slave_threads(); |
| 4174 | my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length, |
| 4175 | mi->connection_name.str); |
| 4176 | DBUG_RETURN(-1); |
| 4177 | } |
| 4178 | |
| 4179 | init_thread_mask(&thread_mask,mi,0 /* not inverse */); |
| 4180 | if (thread_mask) // We refuse if any slave thread is running |
| 4181 | { |
| 4182 | mi->unlock_slave_threads(); |
| 4183 | my_error(ER_SLAVE_MUST_STOP, MYF(0), (int) mi->connection_name.length, |
| 4184 | mi->connection_name.str); |
| 4185 | DBUG_RETURN(ER_SLAVE_MUST_STOP); |
| 4186 | } |
| 4187 | |
| 4188 | // delete relay logs, clear relay log coordinates |
| 4189 | if (unlikely((error= purge_relay_logs(&mi->rli, thd, |
| 4190 | 1 /* just reset */, |
| 4191 | &errmsg)))) |
| 4192 | { |
| 4193 | sql_errno= ER_RELAY_LOG_FAIL; |
| 4194 | goto err; |
| 4195 | } |
| 4196 | |
| 4197 | if (mi->using_gtid != Master_info::USE_GTID_SLAVE_POS && |
| 4198 | mi->master_supports_gtid) |
| 4199 | { |
| 4200 | push_warning_printf( |
| 4201 | thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_CHANGING, |
| 4202 | ER_THD(thd, WARN_OPTION_CHANGING), "RESET SLAVE", "Using_Gtid", |
| 4203 | mi->using_gtid_astext(mi->using_gtid), |
| 4204 | mi->using_gtid_astext(Master_info::USE_GTID_SLAVE_POS)); |
| 4205 | } |
| 4206 | |
| 4207 | /* Clear master's log coordinates and associated information */ |
| 4208 | mi->clear_in_memory_info(thd->lex->reset_slave_info.all); |
| 4209 | |
| 4210 | /* |
| 4211 | Reset errors (the idea is that we forget about the |
| 4212 | old master). |
| 4213 | */ |
| 4214 | mi->clear_error(); |
| 4215 | mi->rli.clear_error(); |
no test coverage detected