1163
1157
if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
1165
mi->master_log_name[0] = 0;
1166
mi->master_log_pos= BIN_LOG_HEADER_SIZE;
1169
1160
if (lex_mi->log_file_name)
1170
strmake(mi->master_log_name, lex_mi->log_file_name,
1171
sizeof(mi->master_log_name)-1);
1161
mi->setLogName(lex_mi->log_file_name);
1172
1162
if (lex_mi->pos)
1174
mi->master_log_pos= lex_mi->pos;
1164
mi->setLogPosition(lex_mi->pos);
1177
1167
if (lex_mi->host)
1178
strmake(mi->host, lex_mi->host, sizeof(mi->host)-1);
1168
mi->setHost(lex_mi->host, lex_mi->port);
1179
1169
if (lex_mi->user)
1180
strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);
1170
mi->setUsername(lex_mi->user);
1181
1171
if (lex_mi->password)
1182
strmake(mi->password, lex_mi->password, sizeof(mi->password)-1);
1184
mi->port = lex_mi->port;
1172
mi->setPassword(lex_mi->password);
1185
1173
if (lex_mi->connect_retry)
1186
1174
mi->connect_retry = lex_mi->connect_retry;
1187
1175
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1188
1176
mi->heartbeat_period = lex_mi->heartbeat_period;
1190
mi->heartbeat_period= (float) min(SLAVE_MAX_HEARTBEAT_PERIOD,
1178
mi->heartbeat_period= (float) cmin((double)SLAVE_MAX_HEARTBEAT_PERIOD,
1191
1179
(slave_net_timeout/2.0));
1192
mi->received_heartbeats= 0LL; // counter lives until master is CHANGEd
1193
if (lex_mi->ssl != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1194
mi->ssl= (lex_mi->ssl == LEX_MASTER_INFO::LEX_MI_ENABLE);
1196
if (lex_mi->ssl_verify_server_cert != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1197
mi->ssl_verify_server_cert=
1198
(lex_mi->ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE);
1201
strmake(mi->ssl_ca, lex_mi->ssl_ca, sizeof(mi->ssl_ca)-1);
1202
if (lex_mi->ssl_capath)
1203
strmake(mi->ssl_capath, lex_mi->ssl_capath, sizeof(mi->ssl_capath)-1);
1204
if (lex_mi->ssl_cert)
1205
strmake(mi->ssl_cert, lex_mi->ssl_cert, sizeof(mi->ssl_cert)-1);
1206
if (lex_mi->ssl_cipher)
1207
strmake(mi->ssl_cipher, lex_mi->ssl_cipher, sizeof(mi->ssl_cipher)-1);
1208
if (lex_mi->ssl_key)
1209
strmake(mi->ssl_key, lex_mi->ssl_key, sizeof(mi->ssl_key)-1);
1210
if (lex_mi->ssl || lex_mi->ssl_ca || lex_mi->ssl_capath ||
1211
lex_mi->ssl_cert || lex_mi->ssl_cipher || lex_mi->ssl_key ||
1212
lex_mi->ssl_verify_server_cert )
1213
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
1214
ER_SLAVE_IGNORED_SSL_PARAMS, ER(ER_SLAVE_IGNORED_SSL_PARAMS));
1180
mi->received_heartbeats= 0L; // counter lives until master is CHANGEd
1216
1182
if (lex_mi->relay_log_name)
1218
1184
need_relay_log_purge= 0;
1219
strmake(mi->rli.group_relay_log_name,lex_mi->relay_log_name,
1220
sizeof(mi->rli.group_relay_log_name)-1);
1221
strmake(mi->rli.event_relay_log_name,lex_mi->relay_log_name,
1222
sizeof(mi->rli.event_relay_log_name)-1);
1185
mi->rli.event_relay_log_name.assign(lex_mi->relay_log_name);
1225
1188
if (lex_mi->relay_log_pos)
1250
1213
Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
1251
not initialized), so we use a max().
1214
not initialized), so we use a cmax().
1252
1215
What happens to mi->rli.master_log_pos during the initialization stages
1253
1216
of replication is not 100% clear, so we guard against problems using
1256
mi->master_log_pos = max(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);
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());
1262
1225
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
1263
1226
a slave before).
1265
if (flush_master_info(mi, 0))
1267
1230
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
1268
1231
unlock_slave_threads(mi);
1307
1270
''/0: we have lost all copies of the original good coordinates.
1308
1271
That's why we always save good coords in rli.
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);
1273
mi->rli.group_master_log_pos= mi->getLogPosition();
1274
mi->rli.group_master_log_name.assign(mi->getLogName());
1314
if (!mi->rli.group_master_log_name[0]) // uninitialized case
1315
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;
1317
1279
pthread_mutex_lock(&mi->rli.data_lock);
1318
1280
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 = max(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);
1517
1330
bool show_binlog_info(THD* thd)
1519
1332
Protocol *protocol= thd->protocol;
1520
1333
List<Item> field_list;
1521
1334
field_list.push_back(new Item_empty_string("File", FN_REFLEN));
1522
1335
field_list.push_back(new Item_return_int("Position",20,
1523
MYSQL_TYPE_LONGLONG));
1336
DRIZZLE_TYPE_LONGLONG));
1524
1337
field_list.push_back(new Item_empty_string("Binlog_Do_DB",255));
1525
1338
field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255));
1656
1469
for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
1657
buffer += min(block_len, max_event_size),
1658
block_len -= min(block_len, max_event_size))
1470
buffer += cmin(block_len, max_event_size),
1471
block_len -= cmin(block_len, max_event_size))
1660
1473
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
1661
1474
if (lf_info->wrote_create_file)
1663
1476
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
1664
min(block_len, max_event_size),
1477
cmin(block_len, max_event_size),
1665
1478
lf_info->log_delayed);
1666
1479
mysql_bin_log.write(&a);
1709
1522
static void fix_slave_net_timeout(THD *thd,
1710
enum_var_type type __attribute__((__unused__)))
1523
enum_var_type type __attribute__((unused)))
1712
#ifdef HAVE_REPLICATION
1713
1525
pthread_mutex_lock(&LOCK_active_mi);
1714
1526
if (active_mi && slave_net_timeout < active_mi->heartbeat_period)
1715
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1527
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1716
1528
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1717
1529
"The currect value for master_heartbeat_period"
1718
1530
" exceeds the new value of `slave_net_timeout' sec."
1719
1531
" A sensible value for the period should be"
1720
1532
" less than the timeout.");
1721
1533
pthread_mutex_unlock(&LOCK_active_mi);