summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-08-30 14:59:12 +0200
committerSergei Golubchik <serg@mariadb.org>2015-09-04 10:33:51 +0200
commit89e08bf300545f9fec5c3dcd700507293a2dab13 (patch)
tree6a72ef010e303cf18254ad45c98d1f081610174e
parent5018a6606f1c863b197812e3f3c1b8b18134c638 (diff)
downloadmariadb-git-89e08bf300545f9fec5c3dcd700507293a2dab13.tar.gz
cleanup: reformat
* reformat long lines * remove useless 'const' * remove unneeded do { ... } while(false} wrapper * remove unneeded method
-rw-r--r--sql/log_event.cc12
-rw-r--r--sql/log_event.h1
-rw-r--r--sql/sql_repl.cc250
3 files changed, 121 insertions, 142 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index c10eff791b3..a23bc17b157 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -4439,12 +4439,6 @@ end:
DBUG_RETURN(thd->is_slave_error);
}
-int Query_log_event::do_update_pos(rpl_group_info *rgi)
-{
- return Log_event::do_update_pos(rgi);
-}
-
-
Log_event::enum_skip_reason
Query_log_event::do_shall_skip(rpl_group_info *rgi)
{
@@ -4980,7 +4974,7 @@ bool Format_description_log_event::write(IO_CACHE* file)
slave does it via marking the event according to
FD_queue checksum_alg value.
*/
- compile_time_assert(sizeof(BINLOG_CHECKSUM_ALG_DESC_LEN == 1));
+ compile_time_assert(BINLOG_CHECKSUM_ALG_DESC_LEN == 1);
#ifndef DBUG_OFF
data_written= 0; // to prepare for need_checksum assert
#endif
@@ -5019,7 +5013,7 @@ bool Format_description_log_event::write(IO_CACHE* file)
int Format_description_log_event::do_apply_event(rpl_group_info *rgi)
{
int ret= 0;
- Relay_log_info const *rli= rgi->rli;
+ Relay_log_info *rli= rgi->rli;
DBUG_ENTER("Format_description_log_event::do_apply_event");
/*
@@ -5067,7 +5061,7 @@ int Format_description_log_event::do_apply_event(rpl_group_info *rgi)
{
/* Save the information describing this binlog */
delete rli->relay_log.description_event_for_exec;
- const_cast<Relay_log_info *>(rli)->relay_log.description_event_for_exec= this;
+ rli->relay_log.description_event_for_exec= this;
}
DBUG_RETURN(ret);
diff --git a/sql/log_event.h b/sql/log_event.h
index 49c411b52f9..76108fcce0b 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2014,7 +2014,6 @@ public: /* !!! Public in this patch to allow old usage */
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual enum_skip_reason do_shall_skip(rpl_group_info *rgi);
virtual int do_apply_event(rpl_group_info *rgi);
- virtual int do_update_pos(rpl_group_info *rgi);
int do_apply_event(rpl_group_info *rgi,
const char *query_arg,
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index a56047db63e..52e94ec27f8 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -2193,10 +2193,8 @@ static int init_binlog_sender(binlog_send_info *info,
/**
* send format descriptor event for one binlog file
*/
-static int send_format_descriptor_event(binlog_send_info *info,
- IO_CACHE *log,
- LOG_INFO *linfo,
- my_off_t start_pos)
+static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
+ LOG_INFO *linfo, my_off_t start_pos)
{
int error;
ulong ev_offset;
@@ -2220,145 +2218,139 @@ static int send_format_descriptor_event(binlog_send_info *info,
return 1;
}
- do
+ /* reset transmit packet for the event read from binary log file */
+ if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
+ return 1;
+
+ /*
+ Try to find a Format_description_log_event at the beginning of
+ the binlog
+ */
+ info->last_pos= my_b_tell(log);
+ error= Log_event::read_log_event(log, packet,
+ opt_master_verify_checksum
+ ? info->current_checksum_alg : 0);
+ linfo->pos= my_b_tell(log);
+
+ if (error)
{
- /* reset transmit packet for the event read from binary log file */
- if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
- break;
+ set_read_error(info, error);
+ return 1;
+ }
- /*
- Try to find a Format_description_log_event at the beginning of
- the binlog
- */
- info->last_pos= my_b_tell(log);
- error= Log_event::read_log_event(log, packet,
- opt_master_verify_checksum
- ? info->current_checksum_alg : 0);
- linfo->pos= my_b_tell(log);
+ event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
- if (error)
- {
- set_read_error(info, error);
- break;
- }
+ /*
+ The packet has offsets equal to the normal offsets in a
+ binlog event + ev_offset (the first ev_offset characters are
+ the header (default \0)).
+ */
+ DBUG_PRINT("info",
+ ("Looked for a Format_description_log_event, "
+ "found event type %d", (int)event_type));
- event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
+ if (event_type != FORMAT_DESCRIPTION_EVENT)
+ {
+ info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+ info->errmsg= "Failed to find format descriptor event in start of binlog";
+ sql_print_warning("Failed to find format descriptor event in "
+ "start of binlog: %s",
+ info->log_file_name);
+ return 1;
+ }
- /*
- The packet has offsets equal to the normal offsets in a
- binlog event + ev_offset (the first ev_offset characters are
- the header (default \0)).
- */
- DBUG_PRINT("info",
- ("Looked for a Format_description_log_event, "
- "found event type %d", (int)event_type));
+ info->current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
+ packet->length() - ev_offset);
- if (event_type != FORMAT_DESCRIPTION_EVENT)
- {
- info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
- info->errmsg= "Failed to find format descriptor event in start of binlog";
- sql_print_warning("Failed to find format descriptor event in "
- "start of binlog: %s",
- info->log_file_name);
- break;
- }
+ DBUG_ASSERT(info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
+ info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
+ info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
- info->current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
- packet->length() - ev_offset);
+ if (!is_slave_checksum_aware(thd) &&
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ {
+ info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+ info->errmsg= "Slave can not handle replication events with the "
+ "checksum that master is configured to log";
+ sql_print_warning("Master is configured to log replication events "
+ "with checksum, but will not send such events to "
+ "slaves that cannot process them");
+ return 1;
+ }
- DBUG_ASSERT(info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
- info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
- info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
+ Format_description_log_event *tmp;
+ if (!(tmp= new Format_description_log_event(packet->ptr()+ev_offset,
+ packet->length()-ev_offset,
+ info->fdev)))
+ {
+ info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+ info->errmsg= "Corrupt Format_description event found "
+ "or out-of-memory";
+ return 1;
+ }
+ delete info->fdev;
+ info->fdev= tmp;
- if (!is_slave_checksum_aware(thd) &&
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
- {
- info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
- info->errmsg= "Slave can not handle replication events with the "
- "checksum that master is configured to log";
- sql_print_warning("Master is configured to log replication events "
- "with checksum, but will not send such events to "
- "slaves that cannot process them");
- break;
- }
+ (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
- Format_description_log_event *tmp;
- if (!(tmp= new Format_description_log_event(packet->ptr()+ev_offset,
- packet->length()-ev_offset,
- info->fdev)))
- {
- info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
- info->errmsg= "Corrupt Format_description event found "
- "or out-of-memory";
- break;
- }
- delete info->fdev;
- info->fdev= tmp;
+ if (info->clear_initial_log_pos)
+ {
+ info->clear_initial_log_pos= false;
+ /*
+ mark that this event with "log_pos=0", so the slave
+ should not increment master's binlog position
+ (rli->group_master_log_pos)
+ */
+ int4store((char*) packet->ptr()+LOG_POS_OFFSET+ev_offset, (ulong) 0);
- (*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
+ /*
+ if reconnect master sends FD event with `created' as 0
+ to avoid destroying temp tables.
+ */
+ int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
+ ST_CREATED_OFFSET+ev_offset, (ulong) 0);
- if (info->clear_initial_log_pos)
+ /* fix the checksum due to latest changes in header */
+ if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ fix_checksum(packet, ev_offset);
+ }
+ else if (info->using_gtid_state)
+ {
+ /*
+ If this event has the field `created' set, then it will cause the
+ slave to delete all active temporary tables. This must not happen
+ if the slave received any later GTIDs in a previous connect, as
+ those GTIDs might have created new temporary tables that are still
+ needed.
+
+ So here, we check if the starting GTID position was already
+ reached before this format description event. If not, we clear the
+ `created' flag to preserve temporary tables on the slave. (If the
+ slave connects at a position past this event, it means that it
+ already received and handled it in a previous connect).
+ */
+ if (!info->gtid_state.is_pos_reached())
{
- info->clear_initial_log_pos= false;
- /*
- mark that this event with "log_pos=0", so the slave
- should not increment master's binlog position
- (rli->group_master_log_pos)
- */
- int4store((char*) packet->ptr()+LOG_POS_OFFSET+ev_offset, (ulong) 0);
-
- /*
- if reconnect master sends FD event with `created' as 0
- to avoid destroying temp tables.
- */
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
-
- /* fix the checksum due to latest changes in header */
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
fix_checksum(packet, ev_offset);
}
- else if (info->using_gtid_state)
- {
- /*
- If this event has the field `created' set, then it will cause the
- slave to delete all active temporary tables. This must not happen
- if the slave received any later GTIDs in a previous connect, as
- those GTIDs might have created new temporary tables that are still
- needed.
-
- So here, we check if the starting GTID position was already
- reached before this format description event. If not, we clear the
- `created' flag to preserve temporary tables on the slave. (If the
- slave connects at a position past this event, it means that it
- already received and handled it in a previous connect).
- */
- if (!info->gtid_state.is_pos_reached())
- {
- int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
- ST_CREATED_OFFSET+ev_offset, (ulong) 0);
- if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
- info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
- fix_checksum(packet, ev_offset);
- }
- }
-
- /* send it */
- if (my_net_write(info->net, (uchar*) packet->ptr(), packet->length()))
- {
- info->errmsg= "Failed on my_net_write()";
- info->error= ER_UNKNOWN_ERROR;
- break;
- }
-
- /** all done */
- return 0;
+ }
- } while (false);
+ /* send it */
+ if (my_net_write(info->net, (uchar*) packet->ptr(), packet->length()))
+ {
+ info->errmsg= "Failed on my_net_write()";
+ info->error= ER_UNKNOWN_ERROR;
+ return 1;
+ }
- return 1;
+ /** all done */
+ return 0;
}
static bool should_stop(binlog_send_info *info)
@@ -2545,9 +2537,7 @@ static my_off_t get_binlog_end_pos(binlog_send_info *info,
* return 0 - OK
* else NOK
*/
-static int send_events(binlog_send_info *info,
- IO_CACHE* log,
- LOG_INFO* linfo,
+static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
my_off_t end_pos)
{
int error;
@@ -2575,7 +2565,8 @@ static int send_events(binlog_send_info *info,
if (error)
{
- goto read_err;
+ set_read_error(info, error);
+ return 1;
}
Log_event_type event_type=
@@ -2661,11 +2652,6 @@ static int send_events(binlog_send_info *info,
}
return 0;
-
-read_err:
- set_read_error(info, error);
-
- return 1;
}
/**