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"
17
#ifdef HAVE_REPLICATION
18
#include <drizzled/replication/mi.h>
19
#include <drizzled/replication/replication.h>
20
#include <drizzled/log_event.h>
21
#include <libdrizzle/libdrizzle.h>
22
#include <mysys/hash.h>
23
#include <drizzled/error.h>
24
#include <drizzled/gettext.h>
25
#include <drizzled/data_home.h>
26
#include <drizzled/unireg.h>
21
#include "log_event.h"
22
#include "rpl_filter.h"
28
25
int max_binlog_dump_events = 0; // unlimited
31
fake_rotate_event() builds a fake (=which does not exist physically in any
32
binlog) Rotate event, which contains the name of the binlog we are going to
33
send to the slave (because the slave may not know it if it just asked for
34
MASTER_LOG_FILE='', MASTER_LOG_POS=4).
35
< 4.0.14, fake_rotate_event() was called only if the requested pos was 4.
36
After this version we always call it, so that a 3.23.58 slave can rely on
37
it to detect if the master is 4.0 (and stop) (the _fake_ Rotate event has
38
zeros in the good positions which, by chance, make it possible for the 3.23
39
slave to detect that this event is unexpected) (this is luck which happens
40
because the master and slave disagree on the size of the header of
28
fake_rotate_event() builds a fake (=which does not exist physically in any
29
binlog) Rotate event, which contains the name of the binlog we are going to
30
send to the slave (because the slave may not know it if it just asked for
31
MASTER_LOG_FILE='', MASTER_LOG_POS=4).
32
< 4.0.14, fake_rotate_event() was called only if the requested pos was 4.
33
After this version we always call it, so that a 3.23.58 slave can rely on
34
it to detect if the master is 4.0 (and stop) (the _fake_ Rotate event has
35
zeros in the good positions which, by chance, make it possible for the 3.23
36
slave to detect that this event is unexpected) (this is luck which happens
37
because the master and slave disagree on the size of the header of
43
Relying on the event length of the Rotate event instead of these
44
well-placed zeros was not possible as Rotate events have a variable-length
40
Relying on the event length of the Rotate event instead of these
41
well-placed zeros was not possible as Rotate events have a variable-length
47
44
static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
48
45
uint64_t position, const char** errmsg)
246
244
my_message(errmsg, ER(errmsg), MYF(0));
254
bool purge_master_logs(Session* session, const char* to_log)
252
bool purge_master_logs(THD* thd, const char* to_log)
256
254
char search_file_name[FN_REFLEN];
257
if (!drizzle_bin_log.is_open())
255
if (!mysql_bin_log.is_open())
263
drizzle_bin_log.make_log_name(search_file_name, to_log);
264
return purge_error_message(session,
265
drizzle_bin_log.purge_logs(search_file_name, 0, 1,
261
mysql_bin_log.make_log_name(search_file_name, to_log);
262
return purge_error_message(thd,
263
mysql_bin_log.purge_logs(search_file_name, 0, 1,
270
bool purge_master_logs_before_date(Session* session, time_t purge_time)
268
bool purge_master_logs_before_date(THD* thd, time_t purge_time)
272
if (!drizzle_bin_log.is_open())
270
if (!mysql_bin_log.is_open())
277
return purge_error_message(session,
278
drizzle_bin_log.purge_logs_before_date(purge_time));
275
return purge_error_message(thd,
276
mysql_bin_log.purge_logs_before_date(purge_time));
281
279
int test_for_non_eof_log_read_errors(int error, const char **errmsg)
379
377
TODO: Clean up loop to only have one call to send_file()
382
void mysql_binlog_send(Session* session, char* log_ident, my_off_t pos,
380
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
386
384
char *log_file_name = linfo.log_file_name;
387
385
char search_file_name[FN_REFLEN], *name;
390
String* packet = &session->packet;
388
String* packet = &thd->packet;
392
390
const char *errmsg = "Unknown error";
393
NET* net = &session->net;
391
NET* net = &thd->net;
394
392
pthread_mutex_t *log_lock;
395
393
bool binlog_can_be_corrupted= false;
397
memset(&log, 0, sizeof(log));
395
bzero((char*) &log,sizeof(log));
399
397
heartbeat_period from @master_heartbeat_period user variable
401
uint64_t heartbeat_period= get_heartbeat_period(session);
399
uint64_t heartbeat_period= get_heartbeat_period(thd);
402
400
struct timespec heartbeat_buf;
403
401
struct event_coordinates coord_buf;
404
402
struct timespec *heartbeat_ts= NULL;
405
403
struct event_coordinates *coord= NULL;
406
if (heartbeat_period != 0L)
404
if (heartbeat_period != 0LL)
408
406
heartbeat_ts= &heartbeat_buf;
409
407
set_timespec_nsec(*heartbeat_ts, 0);
504
502
packet->set("\0", 1, &my_charset_bin);
506
504
Adding MAX_LOG_EVENT_HEADER_LEN, since a binlog event can become
507
this larger than the corresponding packet (query) sent
505
this larger than the corresponding packet (query) sent
508
506
from client to master.
510
session->variables.max_allowed_packet+= MAX_LOG_EVENT_HEADER;
508
thd->variables.max_allowed_packet+= MAX_LOG_EVENT_HEADER;
513
511
We can set log_lock now, it does not move (it's a member of
514
drizzle_bin_log, and it's already inited, and it will be destroyed
512
mysql_bin_log, and it's already inited, and it will be destroyed
515
513
only at shutdown).
517
log_lock = drizzle_bin_log.get_log_lock();
515
log_lock = mysql_bin_log.get_log_lock();
518
516
if (pos > BIN_LOG_HEADER_SIZE)
807
805
end_io_cache(&log);
808
806
(void)my_close(file, MYF(MY_WME));
811
session->set_proc_info("Waiting to finalize termination");
809
thd_proc_info(thd, "Waiting to finalize termination");
812
810
pthread_mutex_lock(&LOCK_thread_count);
813
session->current_linfo = 0;
811
thd->current_linfo = 0;
814
812
pthread_mutex_unlock(&LOCK_thread_count);
818
session->set_proc_info("Waiting to finalize termination");
816
thd_proc_info(thd, "Waiting to finalize termination");
819
817
end_io_cache(&log);
821
819
Exclude iteration through thread list
822
820
this is needed for purge_logs() - it will iterate through
823
thread list and update session->current_linfo->index_file_offset
821
thread list and update thd->current_linfo->index_file_offset
824
822
this mutex will make sure that it never tried to update our linfo
825
823
after we return from this stack frame
827
825
pthread_mutex_lock(&LOCK_thread_count);
828
session->current_linfo = 0;
826
thd->current_linfo = 0;
829
827
pthread_mutex_unlock(&LOCK_thread_count);
831
829
(void) my_close(file, MYF(MY_WME));
848
846
don't wan't to touch the other thread), so set the bit to 0 for the
851
if (session->lex->slave_session_opt)
852
thread_mask&= session->lex->slave_session_opt;
849
if (thd->lex->slave_thd_opt)
850
thread_mask&= thd->lex->slave_thd_opt;
853
851
if (thread_mask) //some threads are stopped, start them
855
if (mi->init_master_info(master_info_file, relay_log_info_file, thread_mask))
853
if (init_master_info(mi,master_info_file,relay_log_info_file, 0,
856
855
slave_errno=ER_MASTER_INFO;
857
else if (server_id_supplied && *mi->getHostname())
856
else if (server_id_supplied && *mi->host)
860
859
If we will start SQL thread we will care about UNTIL options If
866
865
pthread_mutex_lock(&mi->rli.data_lock);
868
if (session->lex->mi.pos)
867
if (thd->lex->mi.pos)
870
869
mi->rli.until_condition= Relay_log_info::UNTIL_MASTER_POS;
871
mi->rli.until_log_pos= session->lex->mi.pos;
870
mi->rli.until_log_pos= thd->lex->mi.pos;
873
We don't check session->lex->mi.log_file_name for NULL here
872
We don't check thd->lex->mi.log_file_name for NULL here
874
873
since it is checked in sql_yacc.yy
876
strncpy(mi->rli.until_log_name, session->lex->mi.log_file_name,
875
strmake(mi->rli.until_log_name, thd->lex->mi.log_file_name,
877
876
sizeof(mi->rli.until_log_name)-1);
879
else if (session->lex->mi.relay_log_pos)
878
else if (thd->lex->mi.relay_log_pos)
881
880
mi->rli.until_condition= Relay_log_info::UNTIL_RELAY_POS;
882
mi->rli.until_log_pos= session->lex->mi.relay_log_pos;
883
strncpy(mi->rli.until_log_name, session->lex->mi.relay_log_name,
881
mi->rli.until_log_pos= thd->lex->mi.relay_log_pos;
882
strmake(mi->rli.until_log_name, thd->lex->mi.relay_log_name,
884
883
sizeof(mi->rli.until_log_name)-1);
913
912
/* Issuing warning then started without --skip-slave-start */
914
913
if (!opt_skip_slave_start)
915
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
914
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
916
915
ER_MISSING_SKIP_SLAVE,
917
916
ER(ER_MISSING_SKIP_SLAVE));
920
919
pthread_mutex_unlock(&mi->rli.data_lock);
922
else if (session->lex->mi.pos || session->lex->mi.relay_log_pos)
923
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
921
else if (thd->lex->mi.pos || thd->lex->mi.relay_log_pos)
922
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
924
923
ER(ER_UNTIL_COND_IGNORED));
926
925
if (!slave_errno)
1050
1051
mi->rli.clear_until_condition();
1052
1053
// close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
1053
mi->end_master_info();
1054
end_master_info(mi);
1054
1055
// and delete these two files
1055
fn_format(fname, master_info_file, drizzle_data_home, "", 4+32);
1056
fn_format(fname, master_info_file, mysql_data_home, "", 4+32);
1056
1057
if (!stat(fname, &stat_area) && my_delete(fname, MYF(MY_WME)))
1061
1062
// delete relay_log_info_file
1062
fn_format(fname, relay_log_info_file, drizzle_data_home, "", 4+32);
1063
fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32);
1063
1064
if (!stat(fname, &stat_area) && my_delete(fname, MYF(MY_WME)))
1161
1163
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;
1164
1169
if (lex_mi->log_file_name)
1165
mi->setLogName(lex_mi->log_file_name);
1170
strmake(mi->master_log_name, lex_mi->log_file_name,
1171
sizeof(mi->master_log_name)-1);
1166
1172
if (lex_mi->pos)
1168
mi->setLogPosition(lex_mi->pos);
1174
mi->master_log_pos= lex_mi->pos;
1171
1177
if (lex_mi->host)
1172
mi->setHost(lex_mi->host, lex_mi->port);
1178
strmake(mi->host, lex_mi->host, sizeof(mi->host)-1);
1173
1179
if (lex_mi->user)
1174
mi->setUsername(lex_mi->user);
1180
strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);
1175
1181
if (lex_mi->password)
1176
mi->setPassword(lex_mi->password);
1182
strmake(mi->password, lex_mi->password, sizeof(mi->password)-1);
1184
mi->port = lex_mi->port;
1177
1185
if (lex_mi->connect_retry)
1178
1186
mi->connect_retry = lex_mi->connect_retry;
1179
1187
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1180
1188
mi->heartbeat_period = lex_mi->heartbeat_period;
1182
mi->heartbeat_period= (float) cmin((double)SLAVE_MAX_HEARTBEAT_PERIOD,
1190
mi->heartbeat_period= (float) min(SLAVE_MAX_HEARTBEAT_PERIOD,
1183
1191
(slave_net_timeout/2.0));
1184
mi->received_heartbeats= 0L; // counter lives until master is CHANGEd
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));
1186
1216
if (lex_mi->relay_log_name)
1188
1218
need_relay_log_purge= 0;
1189
mi->rli.event_relay_log_name.assign(lex_mi->relay_log_name);
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);
1192
1225
if (lex_mi->relay_log_pos)
1217
1250
Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
1218
not initialized), so we use a cmax().
1251
not initialized), so we use a max().
1219
1252
What happens to mi->rli.master_log_pos during the initialization stages
1220
1253
of replication is not 100% clear, so we guard against problems using
1223
mi->setLogPosition(((BIN_LOG_HEADER_SIZE > mi->rli.group_master_log_pos)
1224
? BIN_LOG_HEADER_SIZE
1225
: mi->rli.group_master_log_pos));
1226
mi->setLogName(mi->rli.group_master_log_name.c_str());
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);
1229
1262
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
1230
1263
a slave before).
1265
if (flush_master_info(mi, 0))
1234
1267
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
1235
1268
unlock_slave_threads(mi);
1297
1331
pthread_mutex_unlock(&mi->rli.data_lock);
1299
1333
unlock_slave_threads(mi);
1300
session->set_proc_info(0);
1334
thd_proc_info(thd, 0);
1305
int reset_master(Session* session)
1339
int reset_master(THD* thd)
1307
if (!drizzle_bin_log.is_open())
1341
if (!mysql_bin_log.is_open())
1309
1343
my_message(ER_FLUSH_MASTER_BINLOG_CLOSED,
1310
1344
ER(ER_FLUSH_MASTER_BINLOG_CLOSED), MYF(ME_BELL+ME_WAITTANG));
1313
return drizzle_bin_log.reset_logs(session);
1347
return mysql_bin_log.reset_logs(thd);
1316
1350
int cmp_master_pos(const char* log_file_name1, uint64_t log_pos1,
1317
1351
const char* log_file_name2, uint64_t log_pos2)
1320
uint32_t log_file_name1_len= strlen(log_file_name1);
1321
uint32_t log_file_name2_len= strlen(log_file_name2);
1354
uint log_file_name1_len= strlen(log_file_name1);
1355
uint log_file_name2_len= strlen(log_file_name2);
1323
1357
// We assume that both log names match up to '.'
1324
1358
if (log_file_name1_len == log_file_name2_len)
1334
bool show_binlog_info(Session* session)
1336
Protocol *protocol= session->protocol;
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
bool show_binlog_info(THD* thd)
1519
Protocol *protocol= thd->protocol;
1337
1520
List<Item> field_list;
1338
1521
field_list.push_back(new Item_empty_string("File", FN_REFLEN));
1339
1522
field_list.push_back(new Item_return_int("Position",20,
1340
DRIZZLE_TYPE_LONGLONG));
1523
MYSQL_TYPE_LONGLONG));
1524
field_list.push_back(new Item_empty_string("Binlog_Do_DB",255));
1525
field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255));
1342
1527
if (protocol->send_fields(&field_list,
1343
1528
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1345
1530
protocol->prepare_for_resend();
1347
if (drizzle_bin_log.is_open())
1532
if (mysql_bin_log.is_open())
1350
drizzle_bin_log.get_current_log(&li);
1535
mysql_bin_log.get_current_log(&li);
1351
1536
int dir_len = dirname_length(li.log_file_name);
1352
1537
protocol->store(li.log_file_name + dir_len, &my_charset_bin);
1353
1538
protocol->store((uint64_t) li.pos);
1539
protocol->store(binlog_filter->get_do_db());
1540
protocol->store(binlog_filter->get_ignore_db());
1354
1541
if (protocol->write())
1391
1578
field_list.push_back(new Item_empty_string("Log_name", 255));
1392
1579
field_list.push_back(new Item_return_int("File_size", 20,
1393
DRIZZLE_TYPE_LONGLONG));
1580
MYSQL_TYPE_LONGLONG));
1394
1581
if (protocol->send_fields(&field_list,
1395
1582
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1398
pthread_mutex_lock(drizzle_bin_log.get_log_lock());
1399
drizzle_bin_log.lock_index();
1400
index_file= drizzle_bin_log.get_index_file();
1402
drizzle_bin_log.raw_get_current_log(&cur); // dont take mutex
1403
pthread_mutex_unlock(drizzle_bin_log.get_log_lock()); // lockdep, OK
1585
pthread_mutex_lock(mysql_bin_log.get_log_lock());
1586
mysql_bin_log.lock_index();
1587
index_file=mysql_bin_log.get_index_file();
1589
mysql_bin_log.raw_get_current_log(&cur); // dont take mutex
1590
pthread_mutex_unlock(mysql_bin_log.get_log_lock()); // lockdep, OK
1405
1592
cur_dir_len= dirname_length(cur.log_file_name);
1407
1594
reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0);
1448
1635
before a chunk of data is being read into the cache's buffer
1449
1636
The fuction instantianates and writes into the binlog
1450
1637
replication events along LOAD DATA processing.
1452
1639
@param file pointer to io-cache
1455
1642
int log_loaded_block(IO_CACHE* file)
1457
1644
LOAD_FILE_INFO *lf_info;
1459
1646
/* buffer contains position where we started last read */
1460
unsigned char* buffer= (unsigned char*) my_b_get_buffer_start(file);
1461
uint32_t max_event_size= current_session->variables.max_allowed_packet;
1647
uchar* buffer= (uchar*) my_b_get_buffer_start(file);
1648
uint max_event_size= current_thd->variables.max_allowed_packet;
1462
1649
lf_info= (LOAD_FILE_INFO*) file->arg;
1650
if (lf_info->thd->current_stmt_binlog_row_based)
1465
1652
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
1466
1653
lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
1469
1656
for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
1470
buffer += cmin(block_len, max_event_size),
1471
block_len -= cmin(block_len, max_event_size))
1657
buffer += min(block_len, max_event_size),
1658
block_len -= min(block_len, max_event_size))
1473
1660
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
1474
1661
if (lf_info->wrote_create_file)
1476
Append_block_log_event a(lf_info->session, lf_info->session->db, buffer,
1477
cmin(block_len, max_event_size),
1663
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
1664
min(block_len, max_event_size),
1478
1665
lf_info->log_delayed);
1479
drizzle_bin_log.write(&a);
1666
mysql_bin_log.write(&a);
1483
Begin_load_query_log_event b(lf_info->session, lf_info->session->db,
1670
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
1485
cmin(block_len, max_event_size),
1672
min(block_len, max_event_size),
1486
1673
lf_info->log_delayed);
1487
drizzle_bin_log.write(&b);
1674
mysql_bin_log.write(&b);
1488
1675
lf_info->wrote_create_file= 1;
1516
1703
sys_var_sync_binlog_period(sys_var_chain *chain, const char *name_arg,
1517
uint64_t *value_ptr)
1518
:sys_var_long_ptr(chain, name_arg, value_ptr) {}
1519
bool update(Session *session, set_var *var);
1705
:sys_var_long_ptr(chain, name_arg,value_ptr) {}
1706
bool update(THD *thd, set_var *var);
1522
static void fix_slave_net_timeout(Session *session,
1523
enum_var_type type __attribute__((unused)))
1709
static void fix_slave_net_timeout(THD *thd,
1710
enum_var_type type __attribute__((__unused__)))
1712
#ifdef HAVE_REPLICATION
1525
1713
pthread_mutex_lock(&LOCK_active_mi);
1526
1714
if (active_mi && slave_net_timeout < active_mi->heartbeat_period)
1527
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1715
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1528
1716
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1529
1717
"The currect value for master_heartbeat_period"
1530
1718
" exceeds the new value of `slave_net_timeout' sec."
1531
1719
" A sensible value for the period should be"
1532
1720
" less than the timeout.");
1533
1721
pthread_mutex_unlock(&LOCK_active_mi);
1541
1730
static sys_var_long_ptr sys_slave_net_timeout(&vars, "slave_net_timeout",
1542
1731
&slave_net_timeout,
1543
1732
fix_slave_net_timeout);
1544
static sys_var_long_ptr sys_slave_trans_retries(&vars, "slave_transaction_retries", &slave_trans_retries);
1733
static sys_var_long_ptr sys_slave_trans_retries(&vars, "slave_transaction_retries",
1734
&slave_trans_retries);
1545
1735
static sys_var_sync_binlog_period sys_sync_binlog_period(&vars, "sync_binlog", &sync_binlog_period);
1546
1736
static sys_var_slave_skip_counter sys_slave_skip_counter(&vars, "sql_slave_skip_counter");
1548
static int show_slave_skip_errors(Session *session, SHOW_VAR *var, char *buff);
1551
static int show_slave_skip_errors(Session *session __attribute__((unused)),
1738
static int show_slave_skip_errors(THD *thd, SHOW_VAR *var, char *buff);
1741
static int show_slave_skip_errors(THD *thd __attribute__((__unused__)),
1552
1742
SHOW_VAR *var, char *buff)
1554
1744
var->type=SHOW_CHAR;