Skip to content

Commit 89e08bf

Browse files
committed
cleanup: reformat
* reformat long lines * remove useless 'const' * remove unneeded do { ... } while(false} wrapper * remove unneeded method
1 parent 5018a66 commit 89e08bf

File tree

3 files changed

+121
-142
lines changed

3 files changed

+121
-142
lines changed

sql/log_event.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4439,12 +4439,6 @@ START SLAVE; . Query: '%s'", expected_error, thd->query());
44394439
DBUG_RETURN(thd->is_slave_error);
44404440
}
44414441

4442-
int Query_log_event::do_update_pos(rpl_group_info *rgi)
4443-
{
4444-
return Log_event::do_update_pos(rgi);
4445-
}
4446-
4447-
44484442
Log_event::enum_skip_reason
44494443
Query_log_event::do_shall_skip(rpl_group_info *rgi)
44504444
{
@@ -4980,7 +4974,7 @@ bool Format_description_log_event::write(IO_CACHE* file)
49804974
slave does it via marking the event according to
49814975
FD_queue checksum_alg value.
49824976
*/
4983-
compile_time_assert(sizeof(BINLOG_CHECKSUM_ALG_DESC_LEN == 1));
4977+
compile_time_assert(BINLOG_CHECKSUM_ALG_DESC_LEN == 1);
49844978
#ifndef DBUG_OFF
49854979
data_written= 0; // to prepare for need_checksum assert
49864980
#endif
@@ -5019,7 +5013,7 @@ bool Format_description_log_event::write(IO_CACHE* file)
50195013
int Format_description_log_event::do_apply_event(rpl_group_info *rgi)
50205014
{
50215015
int ret= 0;
5022-
Relay_log_info const *rli= rgi->rli;
5016+
Relay_log_info *rli= rgi->rli;
50235017
DBUG_ENTER("Format_description_log_event::do_apply_event");
50245018

50255019
/*
@@ -5067,7 +5061,7 @@ int Format_description_log_event::do_apply_event(rpl_group_info *rgi)
50675061
{
50685062
/* Save the information describing this binlog */
50695063
delete rli->relay_log.description_event_for_exec;
5070-
const_cast<Relay_log_info *>(rli)->relay_log.description_event_for_exec= this;
5064+
rli->relay_log.description_event_for_exec= this;
50715065
}
50725066

50735067
DBUG_RETURN(ret);

sql/log_event.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,6 @@ class Query_log_event: public Log_event
20142014
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
20152015
virtual enum_skip_reason do_shall_skip(rpl_group_info *rgi);
20162016
virtual int do_apply_event(rpl_group_info *rgi);
2017-
virtual int do_update_pos(rpl_group_info *rgi);
20182017

20192018
int do_apply_event(rpl_group_info *rgi,
20202019
const char *query_arg,

sql/sql_repl.cc

Lines changed: 118 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,10 +2193,8 @@ static int init_binlog_sender(binlog_send_info *info,
21932193
/**
21942194
* send format descriptor event for one binlog file
21952195
*/
2196-
static int send_format_descriptor_event(binlog_send_info *info,
2197-
IO_CACHE *log,
2198-
LOG_INFO *linfo,
2199-
my_off_t start_pos)
2196+
static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
2197+
LOG_INFO *linfo, my_off_t start_pos)
22002198
{
22012199
int error;
22022200
ulong ev_offset;
@@ -2220,145 +2218,139 @@ static int send_format_descriptor_event(binlog_send_info *info,
22202218
return 1;
22212219
}
22222220

2223-
do
2221+
/* reset transmit packet for the event read from binary log file */
2222+
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
2223+
return 1;
2224+
2225+
/*
2226+
Try to find a Format_description_log_event at the beginning of
2227+
the binlog
2228+
*/
2229+
info->last_pos= my_b_tell(log);
2230+
error= Log_event::read_log_event(log, packet,
2231+
opt_master_verify_checksum
2232+
? info->current_checksum_alg : 0);
2233+
linfo->pos= my_b_tell(log);
2234+
2235+
if (error)
22242236
{
2225-
/* reset transmit packet for the event read from binary log file */
2226-
if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
2227-
break;
2237+
set_read_error(info, error);
2238+
return 1;
2239+
}
22282240

2229-
/*
2230-
Try to find a Format_description_log_event at the beginning of
2231-
the binlog
2232-
*/
2233-
info->last_pos= my_b_tell(log);
2234-
error= Log_event::read_log_event(log, packet,
2235-
opt_master_verify_checksum
2236-
? info->current_checksum_alg : 0);
2237-
linfo->pos= my_b_tell(log);
2241+
event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
22382242

2239-
if (error)
2240-
{
2241-
set_read_error(info, error);
2242-
break;
2243-
}
2243+
/*
2244+
The packet has offsets equal to the normal offsets in a
2245+
binlog event + ev_offset (the first ev_offset characters are
2246+
the header (default \0)).
2247+
*/
2248+
DBUG_PRINT("info",
2249+
("Looked for a Format_description_log_event, "
2250+
"found event type %d", (int)event_type));
22442251

2245-
event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
2252+
if (event_type != FORMAT_DESCRIPTION_EVENT)
2253+
{
2254+
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
2255+
info->errmsg= "Failed to find format descriptor event in start of binlog";
2256+
sql_print_warning("Failed to find format descriptor event in "
2257+
"start of binlog: %s",
2258+
info->log_file_name);
2259+
return 1;
2260+
}
22462261

2247-
/*
2248-
The packet has offsets equal to the normal offsets in a
2249-
binlog event + ev_offset (the first ev_offset characters are
2250-
the header (default \0)).
2251-
*/
2252-
DBUG_PRINT("info",
2253-
("Looked for a Format_description_log_event, "
2254-
"found event type %d", (int)event_type));
2262+
info->current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
2263+
packet->length() - ev_offset);
22552264

2256-
if (event_type != FORMAT_DESCRIPTION_EVENT)
2257-
{
2258-
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
2259-
info->errmsg= "Failed to find format descriptor event in start of binlog";
2260-
sql_print_warning("Failed to find format descriptor event in "
2261-
"start of binlog: %s",
2262-
info->log_file_name);
2263-
break;
2264-
}
2265+
DBUG_ASSERT(info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
2266+
info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
2267+
info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
22652268

2266-
info->current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
2267-
packet->length() - ev_offset);
2269+
if (!is_slave_checksum_aware(thd) &&
2270+
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2271+
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2272+
{
2273+
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
2274+
info->errmsg= "Slave can not handle replication events with the "
2275+
"checksum that master is configured to log";
2276+
sql_print_warning("Master is configured to log replication events "
2277+
"with checksum, but will not send such events to "
2278+
"slaves that cannot process them");
2279+
return 1;
2280+
}
22682281

2269-
DBUG_ASSERT(info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
2270-
info->current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
2271-
info->current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
2282+
Format_description_log_event *tmp;
2283+
if (!(tmp= new Format_description_log_event(packet->ptr()+ev_offset,
2284+
packet->length()-ev_offset,
2285+
info->fdev)))
2286+
{
2287+
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
2288+
info->errmsg= "Corrupt Format_description event found "
2289+
"or out-of-memory";
2290+
return 1;
2291+
}
2292+
delete info->fdev;
2293+
info->fdev= tmp;
22722294

2273-
if (!is_slave_checksum_aware(thd) &&
2274-
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2275-
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2276-
{
2277-
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
2278-
info->errmsg= "Slave can not handle replication events with the "
2279-
"checksum that master is configured to log";
2280-
sql_print_warning("Master is configured to log replication events "
2281-
"with checksum, but will not send such events to "
2282-
"slaves that cannot process them");
2283-
break;
2284-
}
2295+
(*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
22852296

2286-
Format_description_log_event *tmp;
2287-
if (!(tmp= new Format_description_log_event(packet->ptr()+ev_offset,
2288-
packet->length()-ev_offset,
2289-
info->fdev)))
2290-
{
2291-
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
2292-
info->errmsg= "Corrupt Format_description event found "
2293-
"or out-of-memory";
2294-
break;
2295-
}
2296-
delete info->fdev;
2297-
info->fdev= tmp;
2297+
if (info->clear_initial_log_pos)
2298+
{
2299+
info->clear_initial_log_pos= false;
2300+
/*
2301+
mark that this event with "log_pos=0", so the slave
2302+
should not increment master's binlog position
2303+
(rli->group_master_log_pos)
2304+
*/
2305+
int4store((char*) packet->ptr()+LOG_POS_OFFSET+ev_offset, (ulong) 0);
22982306

2299-
(*packet)[FLAGS_OFFSET+ev_offset] &= ~LOG_EVENT_BINLOG_IN_USE_F;
2307+
/*
2308+
if reconnect master sends FD event with `created' as 0
2309+
to avoid destroying temp tables.
2310+
*/
2311+
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
2312+
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
23002313

2301-
if (info->clear_initial_log_pos)
2314+
/* fix the checksum due to latest changes in header */
2315+
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2316+
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2317+
fix_checksum(packet, ev_offset);
2318+
}
2319+
else if (info->using_gtid_state)
2320+
{
2321+
/*
2322+
If this event has the field `created' set, then it will cause the
2323+
slave to delete all active temporary tables. This must not happen
2324+
if the slave received any later GTIDs in a previous connect, as
2325+
those GTIDs might have created new temporary tables that are still
2326+
needed.
2327+
2328+
So here, we check if the starting GTID position was already
2329+
reached before this format description event. If not, we clear the
2330+
`created' flag to preserve temporary tables on the slave. (If the
2331+
slave connects at a position past this event, it means that it
2332+
already received and handled it in a previous connect).
2333+
*/
2334+
if (!info->gtid_state.is_pos_reached())
23022335
{
2303-
info->clear_initial_log_pos= false;
2304-
/*
2305-
mark that this event with "log_pos=0", so the slave
2306-
should not increment master's binlog position
2307-
(rli->group_master_log_pos)
2308-
*/
2309-
int4store((char*) packet->ptr()+LOG_POS_OFFSET+ev_offset, (ulong) 0);
2310-
2311-
/*
2312-
if reconnect master sends FD event with `created' as 0
2313-
to avoid destroying temp tables.
2314-
*/
23152336
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
23162337
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
2317-
2318-
/* fix the checksum due to latest changes in header */
23192338
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2320-
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2339+
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
23212340
fix_checksum(packet, ev_offset);
23222341
}
2323-
else if (info->using_gtid_state)
2324-
{
2325-
/*
2326-
If this event has the field `created' set, then it will cause the
2327-
slave to delete all active temporary tables. This must not happen
2328-
if the slave received any later GTIDs in a previous connect, as
2329-
those GTIDs might have created new temporary tables that are still
2330-
needed.
2331-
2332-
So here, we check if the starting GTID position was already
2333-
reached before this format description event. If not, we clear the
2334-
`created' flag to preserve temporary tables on the slave. (If the
2335-
slave connects at a position past this event, it means that it
2336-
already received and handled it in a previous connect).
2337-
*/
2338-
if (!info->gtid_state.is_pos_reached())
2339-
{
2340-
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
2341-
ST_CREATED_OFFSET+ev_offset, (ulong) 0);
2342-
if (info->current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
2343-
info->current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
2344-
fix_checksum(packet, ev_offset);
2345-
}
2346-
}
2347-
2348-
/* send it */
2349-
if (my_net_write(info->net, (uchar*) packet->ptr(), packet->length()))
2350-
{
2351-
info->errmsg= "Failed on my_net_write()";
2352-
info->error= ER_UNKNOWN_ERROR;
2353-
break;
2354-
}
2355-
2356-
/** all done */
2357-
return 0;
2342+
}
23582343

2359-
} while (false);
2344+
/* send it */
2345+
if (my_net_write(info->net, (uchar*) packet->ptr(), packet->length()))
2346+
{
2347+
info->errmsg= "Failed on my_net_write()";
2348+
info->error= ER_UNKNOWN_ERROR;
2349+
return 1;
2350+
}
23602351

2361-
return 1;
2352+
/** all done */
2353+
return 0;
23622354
}
23632355

23642356
static bool should_stop(binlog_send_info *info)
@@ -2545,9 +2537,7 @@ static my_off_t get_binlog_end_pos(binlog_send_info *info,
25452537
* return 0 - OK
25462538
* else NOK
25472539
*/
2548-
static int send_events(binlog_send_info *info,
2549-
IO_CACHE* log,
2550-
LOG_INFO* linfo,
2540+
static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
25512541
my_off_t end_pos)
25522542
{
25532543
int error;
@@ -2575,7 +2565,8 @@ static int send_events(binlog_send_info *info,
25752565

25762566
if (error)
25772567
{
2578-
goto read_err;
2568+
set_read_error(info, error);
2569+
return 1;
25792570
}
25802571

25812572
Log_event_type event_type=
@@ -2661,11 +2652,6 @@ static int send_events(binlog_send_info *info,
26612652
}
26622653

26632654
return 0;
2664-
2665-
read_err:
2666-
set_read_error(info, error);
2667-
2668-
return 1;
26692655
}
26702656

26712657
/**

0 commit comments

Comments
 (0)