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>
27
#include <drizzled/item/return_int.h>
28
#include <drizzled/item/empty_string.h>
21
#include "log_event.h"
22
#include "rpl_filter.h"
23
#include <drizzled/drizzled_error_messages.h>
30
25
int max_binlog_dump_events = 0; // unlimited
33
fake_rotate_event() builds a fake (=which does not exist physically in any
34
binlog) Rotate event, which contains the name of the binlog we are going to
35
send to the slave (because the slave may not know it if it just asked for
36
MASTER_LOG_FILE='', MASTER_LOG_POS=4).
37
< 4.0.14, fake_rotate_event() was called only if the requested pos was 4.
38
After this version we always call it, so that a 3.23.58 slave can rely on
39
it to detect if the master is 4.0 (and stop) (the _fake_ Rotate event has
40
zeros in the good positions which, by chance, make it possible for the 3.23
41
slave to detect that this event is unexpected) (this is luck which happens
42
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
45
Relying on the event length of the Rotate event instead of these
46
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
49
44
static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
50
45
uint64_t position, const char** errmsg)
248
244
my_message(errmsg, ER(errmsg), MYF(0));
256
bool purge_master_logs(Session* session, const char* to_log)
252
bool purge_master_logs(THD* thd, const char* to_log)
258
254
char search_file_name[FN_REFLEN];
259
if (!drizzle_bin_log.is_open())
255
if (!mysql_bin_log.is_open())
265
drizzle_bin_log.make_log_name(search_file_name, to_log);
266
return purge_error_message(session,
267
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,
272
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)
274
if (!drizzle_bin_log.is_open())
270
if (!mysql_bin_log.is_open())
279
return purge_error_message(session,
280
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));
283
279
int test_for_non_eof_log_read_errors(int error, const char **errmsg)
381
377
TODO: Clean up loop to only have one call to send_file()
384
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,
388
384
char *log_file_name = linfo.log_file_name;
389
385
char search_file_name[FN_REFLEN], *name;
392
String* packet = &session->packet;
388
String* packet = &thd->packet;
394
390
const char *errmsg = "Unknown error";
395
NET* net = &session->net;
391
NET* net = &thd->net;
396
392
pthread_mutex_t *log_lock;
397
393
bool binlog_can_be_corrupted= false;
399
memset(&log, 0, sizeof(log));
395
memset((char*) &log, 0, sizeof(log));
401
397
heartbeat_period from @master_heartbeat_period user variable
403
uint64_t heartbeat_period= get_heartbeat_period(session);
399
uint64_t heartbeat_period= get_heartbeat_period(thd);
404
400
struct timespec heartbeat_buf;
405
401
struct event_coordinates coord_buf;
406
402
struct timespec *heartbeat_ts= NULL;
407
403
struct event_coordinates *coord= NULL;
408
if (heartbeat_period != 0L)
404
if (heartbeat_period != 0LL)
410
406
heartbeat_ts= &heartbeat_buf;
411
407
set_timespec_nsec(*heartbeat_ts, 0);
506
502
packet->set("\0", 1, &my_charset_bin);
508
504
Adding MAX_LOG_EVENT_HEADER_LEN, since a binlog event can become
509
this larger than the corresponding packet (query) sent
505
this larger than the corresponding packet (query) sent
510
506
from client to master.
512
session->variables.max_allowed_packet+= MAX_LOG_EVENT_HEADER;
508
thd->variables.max_allowed_packet+= MAX_LOG_EVENT_HEADER;
515
511
We can set log_lock now, it does not move (it's a member of
516
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
517
513
only at shutdown).
519
log_lock = drizzle_bin_log.get_log_lock();
515
log_lock = mysql_bin_log.get_log_lock();
520
516
if (pos > BIN_LOG_HEADER_SIZE)
809
805
end_io_cache(&log);
810
806
(void)my_close(file, MYF(MY_WME));
813
session->set_proc_info("Waiting to finalize termination");
809
thd_proc_info(thd, "Waiting to finalize termination");
814
810
pthread_mutex_lock(&LOCK_thread_count);
815
session->current_linfo = 0;
811
thd->current_linfo = 0;
816
812
pthread_mutex_unlock(&LOCK_thread_count);
820
session->set_proc_info("Waiting to finalize termination");
816
thd_proc_info(thd, "Waiting to finalize termination");
821
817
end_io_cache(&log);
823
819
Exclude iteration through thread list
824
820
this is needed for purge_logs() - it will iterate through
825
thread list and update session->current_linfo->index_file_offset
821
thread list and update thd->current_linfo->index_file_offset
826
822
this mutex will make sure that it never tried to update our linfo
827
823
after we return from this stack frame
829
825
pthread_mutex_lock(&LOCK_thread_count);
830
session->current_linfo = 0;
826
thd->current_linfo = 0;
831
827
pthread_mutex_unlock(&LOCK_thread_count);
833
829
(void) my_close(file, MYF(MY_WME));
850
846
don't wan't to touch the other thread), so set the bit to 0 for the
853
if (session->lex->slave_session_opt)
854
thread_mask&= session->lex->slave_session_opt;
849
if (thd->lex->slave_thd_opt)
850
thread_mask&= thd->lex->slave_thd_opt;
855
851
if (thread_mask) //some threads are stopped, start them
857
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,
858
855
slave_errno=ER_MASTER_INFO;
859
else if (server_id_supplied && *mi->getHostname())
856
else if (server_id_supplied && *mi->host)
862
859
If we will start SQL thread we will care about UNTIL options If
868
865
pthread_mutex_lock(&mi->rli.data_lock);
870
if (session->lex->mi.pos)
867
if (thd->lex->mi.pos)
872
869
mi->rli.until_condition= Relay_log_info::UNTIL_MASTER_POS;
873
mi->rli.until_log_pos= session->lex->mi.pos;
870
mi->rli.until_log_pos= thd->lex->mi.pos;
875
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
876
873
since it is checked in sql_yacc.yy
878
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,
879
876
sizeof(mi->rli.until_log_name)-1);
881
else if (session->lex->mi.relay_log_pos)
878
else if (thd->lex->mi.relay_log_pos)
883
880
mi->rli.until_condition= Relay_log_info::UNTIL_RELAY_POS;
884
mi->rli.until_log_pos= session->lex->mi.relay_log_pos;
885
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,
886
883
sizeof(mi->rli.until_log_name)-1);
915
912
/* Issuing warning then started without --skip-slave-start */
916
913
if (!opt_skip_slave_start)
917
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
914
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
918
915
ER_MISSING_SKIP_SLAVE,
919
916
ER(ER_MISSING_SKIP_SLAVE));
922
919
pthread_mutex_unlock(&mi->rli.data_lock);
924
else if (session->lex->mi.pos || session->lex->mi.relay_log_pos)
925
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,
926
923
ER(ER_UNTIL_COND_IGNORED));
928
925
if (!slave_errno)
1052
1051
mi->rli.clear_until_condition();
1054
1053
// close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
1055
mi->end_master_info();
1054
end_master_info(mi);
1056
1055
// and delete these two files
1057
fn_format(fname, master_info_file, drizzle_data_home, "", 4+32);
1056
fn_format(fname, master_info_file, mysql_data_home, "", 4+32);
1058
1057
if (!stat(fname, &stat_area) && my_delete(fname, MYF(MY_WME)))
1063
1062
// delete relay_log_info_file
1064
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);
1065
1064
if (!stat(fname, &stat_area) && my_delete(fname, MYF(MY_WME)))
1163
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;
1166
1169
if (lex_mi->log_file_name)
1167
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);
1168
1172
if (lex_mi->pos)
1170
mi->setLogPosition(lex_mi->pos);
1174
mi->master_log_pos= lex_mi->pos;
1173
1177
if (lex_mi->host)
1174
mi->setHost(lex_mi->host, lex_mi->port);
1178
strmake(mi->host, lex_mi->host, sizeof(mi->host)-1);
1175
1179
if (lex_mi->user)
1176
mi->setUsername(lex_mi->user);
1180
strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);
1177
1181
if (lex_mi->password)
1178
mi->setPassword(lex_mi->password);
1182
strmake(mi->password, lex_mi->password, sizeof(mi->password)-1);
1184
mi->port = lex_mi->port;
1179
1185
if (lex_mi->connect_retry)
1180
1186
mi->connect_retry = lex_mi->connect_retry;
1181
1187
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
1182
1188
mi->heartbeat_period = lex_mi->heartbeat_period;
1184
mi->heartbeat_period= (float) cmin((double)SLAVE_MAX_HEARTBEAT_PERIOD,
1190
mi->heartbeat_period= (float) min(SLAVE_MAX_HEARTBEAT_PERIOD,
1185
1191
(slave_net_timeout/2.0));
1186
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));
1188
1216
if (lex_mi->relay_log_name)
1190
1218
need_relay_log_purge= 0;
1191
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);
1194
1225
if (lex_mi->relay_log_pos)
1219
1250
Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
1220
not initialized), so we use a cmax().
1251
not initialized), so we use a max().
1221
1252
What happens to mi->rli.master_log_pos during the initialization stages
1222
1253
of replication is not 100% clear, so we guard against problems using
1225
mi->setLogPosition(((BIN_LOG_HEADER_SIZE > mi->rli.group_master_log_pos)
1226
? BIN_LOG_HEADER_SIZE
1227
: mi->rli.group_master_log_pos));
1228
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);
1231
1262
Relay log's IO_CACHE may not be inited, if rli->inited==0 (server was never
1232
1263
a slave before).
1265
if (flush_master_info(mi, 0))
1236
1267
my_error(ER_RELAY_LOG_INIT, MYF(0), "Failed to flush master info file");
1237
1268
unlock_slave_threads(mi);
1299
1331
pthread_mutex_unlock(&mi->rli.data_lock);
1301
1333
unlock_slave_threads(mi);
1302
session->set_proc_info(0);
1334
thd_proc_info(thd, 0);
1307
int reset_master(Session* session)
1339
int reset_master(THD* thd)
1309
if (!drizzle_bin_log.is_open())
1341
if (!mysql_bin_log.is_open())
1311
1343
my_message(ER_FLUSH_MASTER_BINLOG_CLOSED,
1312
1344
ER(ER_FLUSH_MASTER_BINLOG_CLOSED), MYF(ME_BELL+ME_WAITTANG));
1315
return drizzle_bin_log.reset_logs(session);
1347
return mysql_bin_log.reset_logs(thd);
1318
1350
int cmp_master_pos(const char* log_file_name1, uint64_t log_pos1,
1319
1351
const char* log_file_name2, uint64_t log_pos2)
1322
uint32_t log_file_name1_len= strlen(log_file_name1);
1323
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);
1325
1357
// We assume that both log names match up to '.'
1326
1358
if (log_file_name1_len == log_file_name2_len)
1336
bool show_binlog_info(Session* session)
1338
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;
1339
1520
List<Item> field_list;
1340
1521
field_list.push_back(new Item_empty_string("File", FN_REFLEN));
1341
1522
field_list.push_back(new Item_return_int("Position",20,
1342
1523
DRIZZLE_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));
1344
1527
if (protocol->send_fields(&field_list,
1345
1528
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1347
1530
protocol->prepare_for_resend();
1349
if (drizzle_bin_log.is_open())
1532
if (mysql_bin_log.is_open())
1352
drizzle_bin_log.get_current_log(&li);
1535
mysql_bin_log.get_current_log(&li);
1353
1536
int dir_len = dirname_length(li.log_file_name);
1354
1537
protocol->store(li.log_file_name + dir_len, &my_charset_bin);
1355
1538
protocol->store((uint64_t) li.pos);
1539
protocol->store(binlog_filter->get_do_db());
1540
protocol->store(binlog_filter->get_ignore_db());
1356
1541
if (protocol->write())
1396
1581
if (protocol->send_fields(&field_list,
1397
1582
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1400
pthread_mutex_lock(drizzle_bin_log.get_log_lock());
1401
drizzle_bin_log.lock_index();
1402
index_file= drizzle_bin_log.get_index_file();
1404
drizzle_bin_log.raw_get_current_log(&cur); // dont take mutex
1405
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
1407
1592
cur_dir_len= dirname_length(cur.log_file_name);
1409
1594
reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0);
1450
1635
before a chunk of data is being read into the cache's buffer
1451
1636
The fuction instantianates and writes into the binlog
1452
1637
replication events along LOAD DATA processing.
1454
1639
@param file pointer to io-cache
1457
1642
int log_loaded_block(IO_CACHE* file)
1459
1644
LOAD_FILE_INFO *lf_info;
1461
1646
/* buffer contains position where we started last read */
1462
unsigned char* buffer= (unsigned char*) my_b_get_buffer_start(file);
1463
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;
1464
1649
lf_info= (LOAD_FILE_INFO*) file->arg;
1650
if (lf_info->thd->current_stmt_binlog_row_based)
1467
1652
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
1468
1653
lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
1471
1656
for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
1472
buffer += cmin(block_len, max_event_size),
1473
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))
1475
1660
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
1476
1661
if (lf_info->wrote_create_file)
1478
Append_block_log_event a(lf_info->session, lf_info->session->db, buffer,
1479
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),
1480
1665
lf_info->log_delayed);
1481
drizzle_bin_log.write(&a);
1666
mysql_bin_log.write(&a);
1485
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,
1487
cmin(block_len, max_event_size),
1672
min(block_len, max_event_size),
1488
1673
lf_info->log_delayed);
1489
drizzle_bin_log.write(&b);
1674
mysql_bin_log.write(&b);
1490
1675
lf_info->wrote_create_file= 1;
1518
1703
sys_var_sync_binlog_period(sys_var_chain *chain, const char *name_arg,
1519
uint64_t *value_ptr)
1520
:sys_var_long_ptr(chain, name_arg, value_ptr) {}
1521
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);
1524
static void fix_slave_net_timeout(Session *session,
1709
static void fix_slave_net_timeout(THD *thd,
1525
1710
enum_var_type type __attribute__((unused)))
1712
#ifdef HAVE_REPLICATION
1527
1713
pthread_mutex_lock(&LOCK_active_mi);
1528
1714
if (active_mi && slave_net_timeout < active_mi->heartbeat_period)
1529
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1715
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1530
1716
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1531
1717
"The currect value for master_heartbeat_period"
1532
1718
" exceeds the new value of `slave_net_timeout' sec."
1533
1719
" A sensible value for the period should be"
1534
1720
" less than the timeout.");
1535
1721
pthread_mutex_unlock(&LOCK_active_mi);
1543
1730
static sys_var_long_ptr sys_slave_net_timeout(&vars, "slave_net_timeout",
1544
1731
&slave_net_timeout,
1545
1732
fix_slave_net_timeout);
1546
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);
1547
1735
static sys_var_sync_binlog_period sys_sync_binlog_period(&vars, "sync_binlog", &sync_binlog_period);
1548
1736
static sys_var_slave_skip_counter sys_slave_skip_counter(&vars, "sql_slave_skip_counter");
1550
static int show_slave_skip_errors(Session *session, SHOW_VAR *var, char *buff);
1553
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)),
1554
1742
SHOW_VAR *var, char *buff)
1556
1744
var->type=SHOW_CHAR;