61
48
group_relay_log_name[0]= event_relay_log_name[0]=
62
49
group_master_log_name[0]= 0;
63
50
until_log_name[0]= ign_master_log_name_end[0]= 0;
64
memset(&info_file, 0, sizeof(info_file));
65
memset(&cache_buf, 0, sizeof(cache_buf));
51
bzero((char*) &info_file, sizeof(info_file));
52
bzero((char*) &cache_buf, sizeof(cache_buf));
53
cached_charset_invalidate();
66
54
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
67
55
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
68
56
pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST);
168
155
/* if file does not exist */
169
156
if (access(fname,F_OK))
171
/* Create a new file */
159
If someone removed the file from underneath our feet, just close
160
the old descriptor and re-create the old file
163
my_close(info_fd, MYF(MY_WME));
164
if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
166
sql_print_error("Failed to create a new relay log info file (\
167
file '%s', errno %d)", fname, my_errno);
168
msg= current_thd->main_da.message();
171
if (init_io_cache(&rli->info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,
174
sql_print_error("Failed to create a cache on relay log info file '%s'",
176
msg= current_thd->main_da.message();
180
/* Init relay log with first entry in the relay index file */
181
if (init_relay_log_pos(rli,NullS,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
184
sql_print_error("Failed to open the relay log 'FIRST' (relay_log_pos 4)");
187
rli->group_master_log_name[0]= 0;
188
rli->group_master_log_pos= 0;
189
rli->info_fd= info_fd;
173
191
else // file exists
175
/* Open up fname here and pull out the relay.info data */
194
reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0);
198
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
201
Failed to open the existing relay log info file '%s' (errno %d)",
205
else if (init_io_cache(&rli->info_file, info_fd,
206
IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
208
sql_print_error("Failed to create a cache on relay log info file '%s'",
215
my_close(info_fd, MYF(0));
217
rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
218
pthread_mutex_unlock(&rli->data_lock);
223
rli->info_fd = info_fd;
224
int32_t relay_log_pos, master_log_pos;
225
if (init_strvar_from_file(rli->group_relay_log_name,
226
sizeof(rli->group_relay_log_name),
227
&rli->info_file, "") ||
228
init_intvar_from_file(&relay_log_pos,
229
&rli->info_file, BIN_LOG_HEADER_SIZE) ||
230
init_strvar_from_file(rli->group_master_log_name,
231
sizeof(rli->group_master_log_name),
232
&rli->info_file, "") ||
233
init_intvar_from_file(&master_log_pos, &rli->info_file, 0))
235
msg="Error reading slave log configuration";
238
strmake(rli->event_relay_log_name,rli->group_relay_log_name,
239
sizeof(rli->event_relay_log_name)-1);
240
rli->group_relay_log_pos= rli->event_relay_log_pos= relay_log_pos;
241
rli->group_master_log_pos= master_log_pos;
243
if (init_relay_log_pos(rli,
244
rli->group_relay_log_name,
245
rli->group_relay_log_pos,
250
sql_print_error("Failed to open the relay log '%s' (relay_log_pos %s)",
251
rli->group_relay_log_name,
252
llstr(rli->group_relay_log_pos, llbuf));
256
assert(rli->event_relay_log_pos >= BIN_LOG_HEADER_SIZE);
257
assert(my_b_tell(rli->cur_log) == rli->event_relay_log_pos);
179
260
Now change the cache from READ to WRITE - must do this
570
650
configuration which does nothing), then group_master_log_pos
571
651
will grow and group_master_log_name will stay "".
573
if (group_master_log_name.length())
653
if (*group_master_log_name)
575
const char *basename= (group_master_log_name.c_str() +
576
dirname_length(group_master_log_name.c_str()));
655
char *basename= (group_master_log_name +
656
dirname_length(group_master_log_name));
578
658
First compare the parts before the extension.
579
659
Find the dot in the master's log basename,
779
860
/* Save name of used relay log file */
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());
861
strmake(rli->group_relay_log_name, rli->relay_log.get_log_fname(),
862
sizeof(rli->group_relay_log_name)-1);
863
strmake(rli->event_relay_log_name, rli->relay_log.get_log_fname(),
864
sizeof(rli->event_relay_log_name)-1);
782
865
rli->group_relay_log_pos= rli->event_relay_log_pos= BIN_LOG_HEADER_SIZE;
783
866
if (count_relay_log_space(rli))
978
void Relay_log_info::cached_charset_invalidate()
980
/* Full of zeroes means uninitialized. */
981
bzero(cached_charset, sizeof(cached_charset));
986
bool Relay_log_info::cached_charset_compare(char *charset) const
988
if (bcmp((uchar*) cached_charset, (uchar*) charset,
989
sizeof(cached_charset)))
991
memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset));
895
998
void Relay_log_info::stmt_done(my_off_t event_master_log_pos,
896
999
time_t event_creation_time)