40
52
cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
41
53
group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0),
42
54
last_master_timestamp(0), slave_skip_counter(0),
43
abort_pos_wait(0), slave_run_id(0), sql_thd(0),
55
abort_pos_wait(0), slave_run_id(0), sql_session(0),
44
56
inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
45
57
until_log_pos(0), retried_trans(0),
46
58
tables_to_lock(0), tables_to_lock_count(0),
157
168
/* if file does not exist */
158
169
if (access(fname,F_OK))
161
If someone removed the file from underneath our feet, just close
162
the old descriptor and re-create the old file
165
my_close(info_fd, MYF(MY_WME));
166
if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
168
sql_print_error(_("Failed to create a new relay log info file "
169
"( file '%s', errno %d)"), fname, my_errno);
170
msg= current_thd->main_da.message();
173
if (init_io_cache(&rli->info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,
176
sql_print_error(_("Failed to create a cache on relay log info file '%s'"),
178
msg= current_thd->main_da.message();
182
/* Init relay log with first entry in the relay index file */
183
if (init_relay_log_pos(rli,NULL,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
186
sql_print_error(_("Failed to open the relay log 'FIRST' (relay_log_pos 4)"));
189
rli->group_master_log_name[0]= 0;
190
rli->group_master_log_pos= 0;
191
rli->info_fd= info_fd;
171
/* Create a new file */
193
173
else // file exists
196
reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0);
200
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
202
sql_print_error(_("Failed to open the existing relay log info "
203
"file '%s' (errno %d)"),
207
else if (init_io_cache(&rli->info_file, info_fd,
208
IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
210
sql_print_error(_("Failed to create a cache on relay log info "
218
my_close(info_fd, MYF(0));
220
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
221
pthread_mutex_unlock(&rli->data_lock);
226
rli->info_fd = info_fd;
227
int32_t relay_log_pos, master_log_pos;
228
if (init_strvar_from_file(rli->group_relay_log_name,
229
sizeof(rli->group_relay_log_name),
230
&rli->info_file, "") ||
231
init_intvar_from_file(&relay_log_pos,
232
&rli->info_file, BIN_LOG_HEADER_SIZE) ||
233
init_strvar_from_file(rli->group_master_log_name,
234
sizeof(rli->group_master_log_name),
235
&rli->info_file, "") ||
236
init_intvar_from_file(&master_log_pos, &rli->info_file, 0))
238
msg="Error reading slave log configuration";
241
strmake(rli->event_relay_log_name,rli->group_relay_log_name,
242
sizeof(rli->event_relay_log_name)-1);
243
rli->group_relay_log_pos= rli->event_relay_log_pos= relay_log_pos;
244
rli->group_master_log_pos= master_log_pos;
246
if (init_relay_log_pos(rli,
247
rli->group_relay_log_name,
248
rli->group_relay_log_pos,
253
sql_print_error(_("Failed to open the relay log '%s' (relay_log_pos %s)"),
254
rli->group_relay_log_name,
255
llstr(rli->group_relay_log_pos, llbuf));
175
/* Open up fname here and pull out the relay.info data */
259
assert(rli->event_relay_log_pos >= BIN_LOG_HEADER_SIZE);
260
assert(my_b_tell(rli->cur_log) == rli->event_relay_log_pos);
263
179
Now change the cache from READ to WRITE - must do this
654
570
configuration which does nothing), then group_master_log_pos
655
571
will grow and group_master_log_name will stay "".
657
if (*group_master_log_name)
573
if (group_master_log_name.length())
659
char *basename= (group_master_log_name +
660
dirname_length(group_master_log_name));
575
const char *basename= (group_master_log_name.c_str() +
576
dirname_length(group_master_log_name.c_str()));
662
578
First compare the parts before the extension.
663
579
Find the dot in the master's log basename,
855
770
rli->cur_log_fd= -1;
858
if (rli->relay_log.reset_logs(thd))
773
if (rli->relay_log.reset_logs(session))
860
775
*errmsg = "Failed during log reset";
864
779
/* Save name of used relay log file */
865
strmake(rli->group_relay_log_name, rli->relay_log.get_log_fname(),
866
sizeof(rli->group_relay_log_name)-1);
867
strmake(rli->event_relay_log_name, rli->relay_log.get_log_fname(),
868
sizeof(rli->event_relay_log_name)-1);
780
rli->group_relay_log_name.assign(rli->relay_log.get_log_fname());
781
rli->event_relay_log_name.assign(rli->relay_log.get_log_fname());
869
782
rli->group_relay_log_pos= rli->event_relay_log_pos= BIN_LOG_HEADER_SIZE;
870
783
if (count_relay_log_space(rli))
982
void Relay_log_info::cached_charset_invalidate()
984
/* Full of zeroes means uninitialized. */
985
memset(cached_charset, 0, sizeof(cached_charset));
990
bool Relay_log_info::cached_charset_compare(char *charset) const
992
if (memcmp(cached_charset, charset, sizeof(cached_charset)))
994
memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset));
1001
895
void Relay_log_info::stmt_done(my_off_t event_master_log_pos,
1002
896
time_t event_creation_time)
1066
ha_autocommit_or_rollback(thd, 1); // if a "statement transaction"
1067
end_trans(thd, ROLLBACK); // if a "real transaction"
960
ha_autocommit_or_rollback(session, 1); // if a "statement transaction"
961
end_trans(session, ROLLBACK); // if a "real transaction"
1069
963
m_table_map.clear_tables();
1070
close_thread_tables(thd);
964
close_thread_tables(session);
1071
965
clear_tables_to_lock();
1072
966
clear_flag(IN_STMT);
1074
968
Cleanup for the flags that have been set at do_apply_event.
1076
thd->options&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
1077
thd->options&= ~OPTION_RELAXED_UNIQUE_CHECKS;
970
session->options&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
971
session->options&= ~OPTION_RELAXED_UNIQUE_CHECKS;
1078
972
last_event_start_time= 0;