848
849
thread_mask&= thd->lex->slave_thd_opt;
849
850
if (thread_mask) //some threads are stopped, start them
851
if (mi->init_master_info(master_info_file, relay_log_info_file, thread_mask))
852
if (init_master_info(mi,master_info_file,relay_log_info_file, 0,
852
854
slave_errno=ER_MASTER_INFO;
853
else if (server_id_supplied && *mi->getHostname())
855
else if (server_id_supplied && *mi->host)
856
858
If we will start SQL thread we will care about UNTIL options If
1136
thd->set_proc_info("Changing master");
1140
thd_proc_info(thd, "Changing master");
1137
1141
LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
1138
1142
// TODO: see if needs re-write
1139
if (mi->init_master_info(master_info_file, relay_log_info_file, thread_mask))
1143
if (init_master_info(mi, master_info_file, relay_log_info_file, 0,
1141
1146
my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
1142
1147
unlock_slave_threads(mi);
1157
1162
if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
1164
mi->master_log_name[0] = 0;
1165
mi->master_log_pos= BIN_LOG_HEADER_SIZE;
1160
1168
if (lex_mi->log_file_name)
1161
mi->setLogName(lex_mi->log_file_name);
1169
strmake(mi->master_log_name, lex_mi->log_file_name,
1170
sizeof(mi->master_log_name)-1);
1162
1171
if (lex_mi->pos)
1164
mi->setLogPosition(lex_mi->pos);
1173
mi->master_log_pos= lex_mi->pos;
1167
1176
if (lex_mi->host)
1168
mi->setHost(lex_mi->host, lex_mi->port);
1177
strmake(mi->host, lex_mi->host, sizeof(mi->host)-1);
1169
1178
if (lex_mi->user)
1170
mi->setUsername(lex_mi->user);
1179
strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);
1171
1180
if (lex_mi->password)
1172
mi->setPassword(lex_mi->password);
1181
strmake(mi->password, lex_mi->password, sizeof(mi->password)-1);
1183
mi->port = lex_mi->port;
1173
1184
if (lex_mi->connect_retry)
1174
1185
mi->connect_retry = lex_mi->connect_retry;
1175
1186
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1178
1189
mi->heartbeat_period= (float) cmin((double)SLAVE_MAX_HEARTBEAT_PERIOD,
1179
1190
(slave_net_timeout/2.0));
1180
1191
mi->received_heartbeats= 0L; // counter lives until master is CHANGEd
1192
if (lex_mi->ssl != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1193
mi->ssl= (lex_mi->ssl == LEX_MASTER_INFO::LEX_MI_ENABLE);
1195
if (lex_mi->ssl_verify_server_cert != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1196
mi->ssl_verify_server_cert=
1197
(lex_mi->ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE);
1200
strmake(mi->ssl_ca, lex_mi->ssl_ca, sizeof(mi->ssl_ca)-1);
1201
if (lex_mi->ssl_capath)
1202
strmake(mi->ssl_capath, lex_mi->ssl_capath, sizeof(mi->ssl_capath)-1);
1203
if (lex_mi->ssl_cert)
1204
strmake(mi->ssl_cert, lex_mi->ssl_cert, sizeof(mi->ssl_cert)-1);
1205
if (lex_mi->ssl_cipher)
1206
strmake(mi->ssl_cipher, lex_mi->ssl_cipher, sizeof(mi->ssl_cipher)-1);
1207
if (lex_mi->ssl_key)
1208
strmake(mi->ssl_key, lex_mi->ssl_key, sizeof(mi->ssl_key)-1);
1209
if (lex_mi->ssl || lex_mi->ssl_ca || lex_mi->ssl_capath ||
1210
lex_mi->ssl_cert || lex_mi->ssl_cipher || lex_mi->ssl_key ||
1211
lex_mi->ssl_verify_server_cert )
1212
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1213
ER_SLAVE_IGNORED_SSL_PARAMS, ER(ER_SLAVE_IGNORED_SSL_PARAMS));
1182
1215
if (lex_mi->relay_log_name)
1184
1217
need_relay_log_purge= 0;
1185
mi->rli.event_relay_log_name.assign(lex_mi->relay_log_name);
1218
strmake(mi->rli.group_relay_log_name,lex_mi->relay_log_name,
1219
sizeof(mi->rli.group_relay_log_name)-1);
1220
strmake(mi->rli.event_relay_log_name,lex_mi->relay_log_name,
1221
sizeof(mi->rli.event_relay_log_name)-1);
1188
1224
if (lex_mi->relay_log_pos)
1216
1252
of replication is not 100% clear, so we guard against problems using
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());
1255
mi->master_log_pos = ((BIN_LOG_HEADER_SIZE > mi->rli.group_master_log_pos)
1256
? BIN_LOG_HEADER_SIZE
1257
: mi->rli.group_master_log_pos);
1258
strmake(mi->master_log_name, mi->rli.group_master_log_name,
1259
sizeof(mi->master_log_name)-1);
1225
1262
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
1226
1263
a slave before).
1265
if (flush_master_info(mi, 0))
1230
1267
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
1231
1268
unlock_slave_threads(mi);
1270
1307
''/0: we have lost all copies of the original good coordinates.
1271
1308
That's why we always save good coords in rli.
1273
mi->rli.group_master_log_pos= mi->getLogPosition();
1274
mi->rli.group_master_log_name.assign(mi->getLogName());
1310
mi->rli.group_master_log_pos= mi->master_log_pos;
1311
strmake(mi->rli.group_master_log_name,mi->master_log_name,
1312
sizeof(mi->rli.group_master_log_name)-1);
1276
if (mi->rli.group_master_log_name.size() == 0) // uninitialized case
1277
mi->rli.group_master_log_pos= 0;
1314
if (!mi->rli.group_master_log_name[0]) // uninitialized case
1315
mi->rli.group_master_log_pos=0;
1279
1317
pthread_mutex_lock(&mi->rli.data_lock);
1280
1318
mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */
1368
bool mysql_show_binlog_events(THD* thd)
1370
Protocol *protocol= thd->protocol;
1371
List<Item> field_list;
1372
const char *errmsg= 0;
1377
Log_event::init_show_field_list(&field_list);
1378
if (protocol->send_fields(&field_list,
1379
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1382
Format_description_log_event *description_event= new
1383
Format_description_log_event(3); /* MySQL 4.0 by default */
1386
Wait for handlers to insert any pending information
1387
into the binlog. For e.g. ndb which updates the binlog asynchronously
1388
this is needed so that the uses sees all its own commands in the binlog
1390
ha_binlog_wait(thd);
1392
if (mysql_bin_log.is_open())
1394
LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
1395
SELECT_LEX_UNIT *unit= &thd->lex->unit;
1396
ha_rows event_count, limit_start, limit_end;
1397
my_off_t pos = cmax((uint64_t)BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
1398
char search_file_name[FN_REFLEN], *name;
1399
const char *log_file_name = lex_mi->log_file_name;
1400
pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
1404
unit->set_limit(thd->lex->current_select);
1405
limit_start= unit->offset_limit_cnt;
1406
limit_end= unit->select_limit_cnt;
1408
name= search_file_name;
1410
mysql_bin_log.make_log_name(search_file_name, log_file_name);
1412
name=0; // Find first log
1414
linfo.index_file_offset = 0;
1416
if (mysql_bin_log.find_log_pos(&linfo, name, 1))
1418
errmsg = "Could not find target log";
1422
pthread_mutex_lock(&LOCK_thread_count);
1423
thd->current_linfo = &linfo;
1424
pthread_mutex_unlock(&LOCK_thread_count);
1426
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
1430
to account binlog event header size
1432
thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
1434
pthread_mutex_lock(log_lock);
1437
open_binlog() sought to position 4.
1438
Read the first event in case it's a Format_description_log_event, to
1439
know the format. If there's no such event, we are 3.23 or 4.x. This
1440
code, like before, can't read 3.23 binlogs.
1441
This code will fail on a mixed relay log (one which has Format_desc then
1442
Rotate then Format_desc).
1444
ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
1447
if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
1449
delete description_event;
1450
description_event= (Format_description_log_event*) ev;
1456
my_b_seek(&log, pos);
1458
if (!description_event->is_valid())
1460
errmsg="Invalid Format_description event; could be out of memory";
1464
for (event_count = 0;
1465
(ev = Log_event::read_log_event(&log,(pthread_mutex_t*) 0,
1466
description_event)); )
1468
if (event_count >= limit_start &&
1469
ev->net_send(protocol, linfo.log_file_name, pos))
1471
errmsg = "Net error";
1473
pthread_mutex_unlock(log_lock);
1477
pos = my_b_tell(&log);
1480
if (++event_count >= limit_end)
1484
if (event_count < limit_end && log.error)
1486
errmsg = "Wrong offset or I/O error";
1487
pthread_mutex_unlock(log_lock);
1491
pthread_mutex_unlock(log_lock);
1497
delete description_event;
1501
(void) my_close(file, MYF(MY_WME));
1505
my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),
1506
"SHOW BINLOG EVENTS", errmsg);
1510
pthread_mutex_lock(&LOCK_thread_count);
1511
thd->current_linfo = 0;
1512
pthread_mutex_unlock(&LOCK_thread_count);
1330
1517
bool show_binlog_info(THD* thd)
1332
1519
Protocol *protocol= thd->protocol;