13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <drizzled/server_includes.h>
16
#include "mysql_priv.h"
18
18
#include "rpl_mi.h"
19
19
#include "rpl_rli.h"
20
21
#include "sql_repl.h" // For check_binlog_magic
21
22
#include "rpl_utility.h"
23
#include <libdrizzle/gettext.h>
25
24
static int32_t count_relay_log_space(Relay_log_info* rli);
27
26
// Defined in slave.cc
49
48
group_relay_log_name[0]= event_relay_log_name[0]=
50
49
group_master_log_name[0]= 0;
51
50
until_log_name[0]= ign_master_log_name_end[0]= 0;
52
memset(&info_file, 0, sizeof(info_file));
53
memset(&cache_buf, 0, sizeof(cache_buf));
51
bzero((char*) &info_file, sizeof(info_file));
52
bzero((char*) &cache_buf, sizeof(cache_buf));
54
53
cached_charset_invalidate();
55
54
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
56
55
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
131
130
instead require a name. But as we don't want to break many existing
132
131
setups, we only give warning, not error.
134
sql_print_warning(_("Neither --relay-log nor --relay-log-index were used;"
133
sql_print_warning("Neither --relay-log nor --relay-log-index were used;"
135
134
" so replication "
136
135
"may break when this MySQL server acts as a "
137
136
"slave and has his hostname changed!! Please "
138
"use '--relay-log=%s' to avoid this problem."), ln);
137
"use '--relay-log=%s' to avoid this problem.", ln);
139
138
name_warning_sent= 1;
165
163
my_close(info_fd, MYF(MY_WME));
166
164
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);
166
sql_print_error("Failed to create a new relay log info file (\
167
file '%s', errno %d)", fname, my_errno);
170
168
msg= current_thd->main_da.message();
173
171
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'"),
174
sql_print_error("Failed to create a cache on relay log info file '%s'",
178
176
msg= current_thd->main_da.message();
182
180
/* 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 */,
181
if (init_relay_log_pos(rli,NullS,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
186
sql_print_error(_("Failed to open the relay log 'FIRST' (relay_log_pos 4)"));
184
sql_print_error("Failed to open the relay log 'FIRST' (relay_log_pos 4)");
189
187
rli->group_master_log_name[0]= 0;
200
198
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)"),
201
Failed to open the existing relay log info file '%s' (errno %d)",
204
202
fname, my_errno);
207
205
else if (init_io_cache(&rli->info_file, info_fd,
208
206
IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
210
sql_print_error(_("Failed to create a cache on relay log info "
208
sql_print_error("Failed to create a cache on relay log info file '%s'",
253
sql_print_error(_("Failed to open the relay log '%s' (relay_log_pos %s)"),
250
sql_print_error("Failed to open the relay log '%s' (relay_log_pos %s)",
254
251
rli->group_relay_log_name,
255
252
llstr(rli->group_relay_log_pos, llbuf));
266
263
reinit_io_cache(&rli->info_file, WRITE_CACHE,0L,0,1);
267
264
if ((error= flush_relay_log_info(rli)))
268
sql_print_error(_("Failed to flush relay log info file"));
265
sql_print_error("Failed to flush relay log info file");
269
266
if (count_relay_log_space(rli))
271
msg=_("Error counting relay log space");
268
msg="Error counting relay log space";
293
290
if (stat(linfo->log_file_name,&s))
295
sql_print_error(_("log %s listed in the index, but failed to stat"),
292
sql_print_error("log %s listed in the index, but failed to stat",
296
293
linfo->log_file_name);
307
304
rli->log_space_total= 0;
308
if (rli->relay_log.find_log_pos(&linfo, NULL, 1))
305
if (rli->relay_log.find_log_pos(&linfo, NullS, 1))
310
sql_print_error(_("Could not find first log while counting relay "
307
sql_print_error("Could not find first log while counting relay log space");
420
416
Test to see if the previous run was with the skip of purging
421
417
If yes, we do not purge when we restart
423
if (rli->relay_log.find_log_pos(&rli->linfo, NULL, 1))
419
if (rli->relay_log.find_log_pos(&rli->linfo, NullS, 1))
425
421
*errmsg="Could not find first log during relay log initialization";
609
605
uint32_t log_name_extension;
610
606
char log_name_tmp[FN_REFLEN]; //make a char[] from String
612
strmake(log_name_tmp, log_name->ptr(), cmin(log_name->length(), (uint32_t)FN_REFLEN-1));
608
strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
614
610
char *p= fn_ext(log_name_tmp);
621
617
// Convert 0-3 to 4
622
log_pos= cmax(log_pos, (int64_t)BIN_LOG_HEADER_SIZE);
618
log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
623
619
/* p points to '.' */
624
620
log_name_extension= strtoul(++p, &p_end, 10);
982
978
void Relay_log_info::cached_charset_invalidate()
984
980
/* Full of zeroes means uninitialized. */
985
memset(cached_charset, 0, sizeof(cached_charset));
981
bzero(cached_charset, sizeof(cached_charset));
990
986
bool Relay_log_info::cached_charset_compare(char *charset) const
992
if (memcmp(cached_charset, charset, sizeof(cached_charset)))
988
if (bcmp((uchar*) cached_charset, (uchar*) charset,
989
sizeof(cached_charset)))
994
991
memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset));
1084
1082
while (tables_to_lock)
1086
unsigned char* to_free= reinterpret_cast<unsigned char*>(tables_to_lock);
1084
uchar* to_free= reinterpret_cast<uchar*>(tables_to_lock);
1087
1085
if (tables_to_lock->m_tabledef_valid)
1089
1087
tables_to_lock->m_tabledef.table_def::~table_def();
1090
1088
tables_to_lock->m_tabledef_valid= false;
1092
1090
tables_to_lock=
1093
static_cast<RPL_TableList*>(tables_to_lock->next_global);
1091
static_cast<RPL_TABLE_LIST*>(tables_to_lock->next_global);
1094
1092
tables_to_lock_count--;
1093
my_free(to_free, MYF(MY_WME));
1097
1095
assert(tables_to_lock == NULL && tables_to_lock_count == 0);