848
848
thread_mask&= thd->lex->slave_thd_opt;
849
849
if (thread_mask) //some threads are stopped, start them
851
if (init_master_info(mi,master_info_file,relay_log_info_file, 0,
851
if (mi->init_master_info(master_info_file, relay_log_info_file, thread_mask))
853
852
slave_errno=ER_MASTER_INFO;
854
else if (server_id_supplied && *mi->host)
853
else if (server_id_supplied && *mi->getHostname())
857
856
If we will start SQL thread we will care about UNTIL options If
1137
thd_proc_info(thd, "Changing master");
1136
thd->set_proc_info("Changing master");
1138
1137
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
1139
1138
// TODO: see if needs re-write
1140
if (init_master_info(mi, master_info_file, relay_log_info_file, 0,
1139
if (mi->init_master_info(master_info_file, relay_log_info_file, thread_mask))
1143
1141
my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
1144
1142
unlock_slave_threads(mi);
1159
1157
if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
1161
mi->master_log_name[0] = 0;
1162
mi->master_log_pos= BIN_LOG_HEADER_SIZE;
1165
1160
if (lex_mi->log_file_name)
1166
strmake(mi->master_log_name, lex_mi->log_file_name,
1167
sizeof(mi->master_log_name)-1);
1161
mi->setLogName(lex_mi->log_file_name);
1168
1162
if (lex_mi->pos)
1170
mi->master_log_pos= lex_mi->pos;
1164
mi->setLogPosition(lex_mi->pos);
1173
1167
if (lex_mi->host)
1174
strmake(mi->host, lex_mi->host, sizeof(mi->host)-1);
1168
mi->setHost(lex_mi->host, lex_mi->port);
1175
1169
if (lex_mi->user)
1176
strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);
1170
mi->setUsername(lex_mi->user);
1177
1171
if (lex_mi->password)
1178
strmake(mi->password, lex_mi->password, sizeof(mi->password)-1);
1180
mi->port = lex_mi->port;
1172
mi->setPassword(lex_mi->password);
1181
1173
if (lex_mi->connect_retry)
1182
1174
mi->connect_retry = lex_mi->connect_retry;
1183
1175
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1186
1178
mi->heartbeat_period= (float) cmin((double)SLAVE_MAX_HEARTBEAT_PERIOD,
1187
1179
(slave_net_timeout/2.0));
1188
1180
mi->received_heartbeats= 0L; // counter lives until master is CHANGEd
1189
if (lex_mi->ssl != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1190
mi->ssl= (lex_mi->ssl == LEX_MASTER_INFO::LEX_MI_ENABLE);
1192
if (lex_mi->ssl_verify_server_cert != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1193
mi->ssl_verify_server_cert=
1194
(lex_mi->ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE);
1197
strmake(mi->ssl_ca, lex_mi->ssl_ca, sizeof(mi->ssl_ca)-1);
1198
if (lex_mi->ssl_capath)
1199
strmake(mi->ssl_capath, lex_mi->ssl_capath, sizeof(mi->ssl_capath)-1);
1200
if (lex_mi->ssl_cert)
1201
strmake(mi->ssl_cert, lex_mi->ssl_cert, sizeof(mi->ssl_cert)-1);
1202
if (lex_mi->ssl_cipher)
1203
strmake(mi->ssl_cipher, lex_mi->ssl_cipher, sizeof(mi->ssl_cipher)-1);
1204
if (lex_mi->ssl_key)
1205
strmake(mi->ssl_key, lex_mi->ssl_key, sizeof(mi->ssl_key)-1);
1206
if (lex_mi->ssl || lex_mi->ssl_ca || lex_mi->ssl_capath ||
1207
lex_mi->ssl_cert || lex_mi->ssl_cipher || lex_mi->ssl_key ||
1208
lex_mi->ssl_verify_server_cert )
1209
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1210
ER_SLAVE_IGNORED_SSL_PARAMS, ER(ER_SLAVE_IGNORED_SSL_PARAMS));
1212
1182
if (lex_mi->relay_log_name)
1214
1184
need_relay_log_purge= 0;
1215
strmake(mi->rli.group_relay_log_name,lex_mi->relay_log_name,
1216
sizeof(mi->rli.group_relay_log_name)-1);
1217
strmake(mi->rli.event_relay_log_name,lex_mi->relay_log_name,
1218
sizeof(mi->rli.event_relay_log_name)-1);
1185
mi->rli.event_relay_log_name.assign(lex_mi->relay_log_name);
1221
1188
if (lex_mi->relay_log_pos)
1249
1216
of replication is not 100% clear, so we guard against problems using
1252
mi->master_log_pos = ((BIN_LOG_HEADER_SIZE > mi->rli.group_master_log_pos)
1253
? BIN_LOG_HEADER_SIZE
1254
: mi->rli.group_master_log_pos);
1255
strmake(mi->master_log_name, mi->rli.group_master_log_name,
1256
sizeof(mi->master_log_name)-1);
1219
mi->setLogPosition(((BIN_LOG_HEADER_SIZE > mi->rli.group_master_log_pos)
1220
? BIN_LOG_HEADER_SIZE
1221
: mi->rli.group_master_log_pos));
1222
mi->setLogName(mi->rli.group_master_log_name.c_str());
1259
1225
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
1260
1226
a slave before).
1262
if (flush_master_info(mi, 0))
1264
1230
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
1265
1231
unlock_slave_threads(mi);
1304
1270
''/0: we have lost all copies of the original good coordinates.
1305
1271
That's why we always save good coords in rli.
1307
mi->rli.group_master_log_pos= mi->master_log_pos;
1308
strmake(mi->rli.group_master_log_name,mi->master_log_name,
1309
sizeof(mi->rli.group_master_log_name)-1);
1273
mi->rli.group_master_log_pos= mi->getLogPosition();
1274
mi->rli.group_master_log_name.assign(mi->getLogName());
1311
if (!mi->rli.group_master_log_name[0]) // uninitialized case
1312
mi->rli.group_master_log_pos=0;
1276
if (mi->rli.group_master_log_name.size() == 0) // uninitialized case
1277
mi->rli.group_master_log_pos= 0;
1314
1279
pthread_mutex_lock(&mi->rli.data_lock);
1315
1280
mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */
1365
bool mysql_show_binlog_events(THD* thd)
1367
Protocol *protocol= thd->protocol;
1368
List<Item> field_list;
1369
const char *errmsg= 0;
1374
Log_event::init_show_field_list(&field_list);
1375
if (protocol->send_fields(&field_list,
1376
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1379
Format_description_log_event *description_event= new
1380
Format_description_log_event(3); /* MySQL 4.0 by default */
1382
if (mysql_bin_log.is_open())
1384
LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
1385
SELECT_LEX_UNIT *unit= &thd->lex->unit;
1386
ha_rows event_count, limit_start, limit_end;
1387
my_off_t pos = cmax((uint64_t)BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
1388
char search_file_name[FN_REFLEN], *name;
1389
const char *log_file_name = lex_mi->log_file_name;
1390
pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
1394
unit->set_limit(thd->lex->current_select);
1395
limit_start= unit->offset_limit_cnt;
1396
limit_end= unit->select_limit_cnt;
1398
name= search_file_name;
1400
mysql_bin_log.make_log_name(search_file_name, log_file_name);
1402
name=0; // Find first log
1404
linfo.index_file_offset = 0;
1406
if (mysql_bin_log.find_log_pos(&linfo, name, 1))
1408
errmsg = "Could not find target log";
1412
pthread_mutex_lock(&LOCK_thread_count);
1413
thd->current_linfo = &linfo;
1414
pthread_mutex_unlock(&LOCK_thread_count);
1416
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
1420
to account binlog event header size
1422
thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
1424
pthread_mutex_lock(log_lock);
1427
open_binlog() sought to position 4.
1428
Read the first event in case it's a Format_description_log_event, to
1429
know the format. If there's no such event, we are 3.23 or 4.x. This
1430
code, like before, can't read 3.23 binlogs.
1431
This code will fail on a mixed relay log (one which has Format_desc then
1432
Rotate then Format_desc).
1434
ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
1437
if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
1439
delete description_event;
1440
description_event= (Format_description_log_event*) ev;
1446
my_b_seek(&log, pos);
1448
if (!description_event->is_valid())
1450
errmsg="Invalid Format_description event; could be out of memory";
1454
for (event_count = 0;
1455
(ev = Log_event::read_log_event(&log,(pthread_mutex_t*) 0,
1456
description_event)); )
1458
if (event_count >= limit_start &&
1459
ev->net_send(protocol, linfo.log_file_name, pos))
1461
errmsg = "Net error";
1463
pthread_mutex_unlock(log_lock);
1467
pos = my_b_tell(&log);
1470
if (++event_count >= limit_end)
1474
if (event_count < limit_end && log.error)
1476
errmsg = "Wrong offset or I/O error";
1477
pthread_mutex_unlock(log_lock);
1481
pthread_mutex_unlock(log_lock);
1487
delete description_event;
1491
(void) my_close(file, MYF(MY_WME));
1495
my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),
1496
"SHOW BINLOG EVENTS", errmsg);
1500
pthread_mutex_lock(&LOCK_thread_count);
1501
thd->current_linfo = 0;
1502
pthread_mutex_unlock(&LOCK_thread_count);
1507
1330
bool show_binlog_info(THD* thd)
1509
1332
Protocol *protocol= thd->protocol;