| 4189 | #ifdef HAVE_REPLICATION |
| 4190 | |
| 4191 | int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included) |
| 4192 | { |
| 4193 | int error; |
| 4194 | char *to_purge_if_included= NULL; |
| 4195 | DBUG_ENTER("purge_first_log"); |
| 4196 | |
| 4197 | DBUG_ASSERT(current_thd->system_thread == SYSTEM_THREAD_SLAVE_SQL); |
| 4198 | DBUG_ASSERT(is_relay_log); |
| 4199 | DBUG_ASSERT(is_open()); |
| 4200 | DBUG_ASSERT(rli->slave_running == 1); |
| 4201 | DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->get_event_relay_log_name())); |
| 4202 | |
| 4203 | mysql_mutex_assert_owner(&rli->data_lock); |
| 4204 | |
| 4205 | mysql_mutex_lock(&LOCK_index); |
| 4206 | to_purge_if_included= my_strdup(rli->get_group_relay_log_name(), MYF(0)); |
| 4207 | |
| 4208 | /* |
| 4209 | Read the next log file name from the index file and pass it back to |
| 4210 | the caller. |
| 4211 | */ |
| 4212 | if((error=find_log_pos(&rli->linfo, rli->get_event_relay_log_name(), |
| 4213 | false/*need_lock_index=false*/)) || |
| 4214 | (error=find_next_log(&rli->linfo, false/*need_lock_index=false*/))) |
| 4215 | { |
| 4216 | char buff[22]; |
| 4217 | sql_print_error("next log error: %d offset: %s log: %s included: %d", |
| 4218 | error, |
| 4219 | llstr(rli->linfo.index_file_offset,buff), |
| 4220 | rli->get_event_relay_log_name(), |
| 4221 | included); |
| 4222 | goto err; |
| 4223 | } |
| 4224 | |
| 4225 | /* |
| 4226 | Reset rli's coordinates to the current log. |
| 4227 | */ |
| 4228 | rli->set_event_relay_log_pos(BIN_LOG_HEADER_SIZE); |
| 4229 | rli->set_event_relay_log_name(rli->linfo.log_file_name); |
| 4230 | |
| 4231 | /* |
| 4232 | If we removed the rli->group_relay_log_name file, |
| 4233 | we must update the rli->group* coordinates, otherwise do not touch it as the |
| 4234 | group's execution is not finished (e.g. COMMIT not executed) |
| 4235 | */ |
| 4236 | if (included) |
| 4237 | { |
| 4238 | rli->set_group_relay_log_pos(BIN_LOG_HEADER_SIZE); |
| 4239 | rli->set_group_relay_log_name(rli->linfo.log_file_name); |
| 4240 | rli->notify_group_relay_log_name_update(); |
| 4241 | } |
| 4242 | /* |
| 4243 | Store where we are in the new file for the execution thread. |
| 4244 | If we are in the middle of a group), then we should not store |
| 4245 | the position in the repository, instead in that case set a flag |
| 4246 | to true which indicates that a 'forced flush' is postponed due |
| 4247 | to transaction split across the relaylogs. |
| 4248 | */ |
nothing calls this directly
no test coverage detected