Commit 2d2286fa authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: use enum_binlog_checksum_alg, not uint8

* fix unireg.h includes
* use enum_binlog_checksum_alg for binlog checksum variables,
  not uint8
parent 86b06a0e
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <my_global.h> #include <my_global.h>
#include "sql_priv.h" #include "sql_priv.h"
#include "hostname.h" #include "hostname.h"
#include "my_global.h" #include "unireg.h"
#ifndef __WIN__ #ifndef __WIN__
#include <netdb.h> // getservbyname, servent #include <netdb.h> // getservbyname, servent
#endif #endif
......
...@@ -3450,12 +3450,12 @@ bool MYSQL_BIN_LOG::open(const char *log_name, ...@@ -3450,12 +3450,12 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
{ {
if (relay_log_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF) if (relay_log_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF)
relay_log_checksum_alg= relay_log_checksum_alg=
opt_slave_sql_verify_checksum ? (uint8) binlog_checksum_options opt_slave_sql_verify_checksum ? (enum_binlog_checksum_alg) binlog_checksum_options
: (uint8) BINLOG_CHECKSUM_ALG_OFF; : BINLOG_CHECKSUM_ALG_OFF;
s.checksum_alg= relay_log_checksum_alg; s.checksum_alg= relay_log_checksum_alg;
} }
else else
s.checksum_alg= (uint8) binlog_checksum_options; s.checksum_alg= (enum_binlog_checksum_alg)binlog_checksum_options;
DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF); DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
if (!s.is_valid()) if (!s.is_valid())
...@@ -8068,8 +8068,8 @@ void MYSQL_BIN_LOG::close(uint exiting) ...@@ -8068,8 +8068,8 @@ void MYSQL_BIN_LOG::close(uint exiting)
{ {
Stop_log_event s; Stop_log_event s;
// the checksumming rule for relay-log case is similar to Rotate // the checksumming rule for relay-log case is similar to Rotate
s.checksum_alg= is_relay_log ? s.checksum_alg= is_relay_log ? relay_log_checksum_alg
(uint8) relay_log_checksum_alg : (uint8) binlog_checksum_options; : (enum_binlog_checksum_alg)binlog_checksum_options;
DBUG_ASSERT(!is_relay_log || DBUG_ASSERT(!is_relay_log ||
relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF); relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
s.write(&log_file); s.write(&log_file);
...@@ -10007,7 +10007,7 @@ binlog_checksum_update(MYSQL_THD thd, struct st_mysql_sys_var *var, ...@@ -10007,7 +10007,7 @@ binlog_checksum_update(MYSQL_THD thd, struct st_mysql_sys_var *var,
{ {
prev_binlog_id= mysql_bin_log.current_binlog_id; prev_binlog_id= mysql_bin_log.current_binlog_id;
if (binlog_checksum_options != value) if (binlog_checksum_options != value)
mysql_bin_log.checksum_alg_reset= (uint8) value; mysql_bin_log.checksum_alg_reset= (enum_binlog_checksum_alg)value;
if (mysql_bin_log.rotate(true, &check_purge)) if (mysql_bin_log.rotate(true, &check_purge))
check_purge= false; check_purge= false;
} }
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#ifndef LOG_H #ifndef LOG_H
#define LOG_H #define LOG_H
#include "unireg.h" // REQUIRED: for other includes
#include "handler.h" /* my_xid */ #include "handler.h" /* my_xid */
#include "wsrep.h" #include "wsrep.h"
#include "wsrep_mysqld.h" #include "wsrep_mysqld.h"
#include "rpl_constants.h"
class Relay_log_info; class Relay_log_info;
...@@ -591,7 +591,7 @@ public: ...@@ -591,7 +591,7 @@ public:
/* This is relay log */ /* This is relay log */
bool is_relay_log; bool is_relay_log;
ulong signal_cnt; // update of the counter is checked by heartbeat ulong signal_cnt; // update of the counter is checked by heartbeat
uint8 checksum_alg_reset; // to contain a new value when binlog is rotated enum enum_binlog_checksum_alg checksum_alg_reset; // to contain a new value when binlog is rotated
/* /*
Holds the last seen in Relay-Log FD's checksum alg value. Holds the last seen in Relay-Log FD's checksum alg value.
The initial value comes from the slave's local FD that heads The initial value comes from the slave's local FD that heads
...@@ -625,7 +625,7 @@ public: ...@@ -625,7 +625,7 @@ public:
(A) - checksum algorithm descriptor value (A) - checksum algorithm descriptor value
FD.(A) - the value of (A) in FD FD.(A) - the value of (A) in FD
*/ */
uint8 relay_log_checksum_alg; enum enum_binlog_checksum_alg relay_log_checksum_alg;
/* /*
These describe the log's format. This is used only for relay logs. These describe the log's format. This is used only for relay logs.
_for_exec is used by the SQL thread, _for_queue by the I/O thread. It's _for_exec is used by the SQL thread, _for_queue by the I/O thread. It's
......
...@@ -1091,20 +1091,12 @@ my_bool Log_event::need_checksum() ...@@ -1091,20 +1091,12 @@ my_bool Log_event::need_checksum()
provides their checksum alg preference through Log_event::checksum_alg. provides their checksum alg preference through Log_event::checksum_alg.
*/ */
if (checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF) if (checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
ret= (checksum_alg != BINLOG_CHECKSUM_ALG_OFF); ret= checksum_alg != BINLOG_CHECKSUM_ALG_OFF;
else else
{ {
if (binlog_checksum_options != BINLOG_CHECKSUM_ALG_OFF && ret= binlog_checksum_options && cache_type == Log_event::EVENT_NO_CACHE;
cache_type == Log_event::EVENT_NO_CACHE) checksum_alg= ret ? (enum_binlog_checksum_alg)binlog_checksum_options
{ : BINLOG_CHECKSUM_ALG_OFF;
checksum_alg= binlog_checksum_options;
ret= MY_TEST(binlog_checksum_options);
}
else
{
ret= FALSE;
checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_OFF;
}
} }
/* /*
FD calls the methods before data_written has been calculated. FD calls the methods before data_written has been calculated.
...@@ -1269,7 +1261,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) ...@@ -1269,7 +1261,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
*/ */
int Log_event::read_log_event(IO_CACHE* file, String* packet, int Log_event::read_log_event(IO_CACHE* file, String* packet,
uint8 checksum_alg_arg) enum enum_binlog_checksum_alg checksum_alg_arg)
{ {
ulong data_len; ulong data_len;
char buf[LOG_EVENT_MINIMAL_HEADER_LEN]; char buf[LOG_EVENT_MINIMAL_HEADER_LEN];
...@@ -1367,7 +1359,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, ...@@ -1367,7 +1359,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file,
if (log_lock) if (log_lock)
mysql_mutex_lock(log_lock); mysql_mutex_lock(log_lock);
switch (read_log_event(file, &event, (uint8)BINLOG_CHECKSUM_ALG_OFF)) switch (read_log_event(file, &event, BINLOG_CHECKSUM_ALG_OFF))
{ {
case 0: case 0:
break; break;
...@@ -1437,7 +1429,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, ...@@ -1437,7 +1429,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
my_bool crc_check) my_bool crc_check)
{ {
Log_event* ev; Log_event* ev;
uint8 alg; enum enum_binlog_checksum_alg alg;
DBUG_ENTER("Log_event::read_log_event(char*,...)"); DBUG_ENTER("Log_event::read_log_event(char*,...)");
DBUG_ASSERT(description_event != 0); DBUG_ASSERT(description_event != 0);
DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version)); DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version));
...@@ -3589,7 +3581,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, ...@@ -3589,7 +3581,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
*/ */
int int
Query_log_event::dummy_event(String *packet, ulong ev_offset, Query_log_event::dummy_event(String *packet, ulong ev_offset,
uint8 checksum_alg) enum enum_binlog_checksum_alg checksum_alg)
{ {
uchar *p= (uchar *)packet->ptr() + ev_offset; uchar *p= (uchar *)packet->ptr() + ev_offset;
size_t data_len= packet->length() - ev_offset; size_t data_len= packet->length() - ev_offset;
...@@ -3681,7 +3673,7 @@ Query_log_event::dummy_event(String *packet, ulong ev_offset, ...@@ -3681,7 +3673,7 @@ Query_log_event::dummy_event(String *packet, ulong ev_offset,
*/ */
int int
Query_log_event::begin_event(String *packet, ulong ev_offset, Query_log_event::begin_event(String *packet, ulong ev_offset,
uint8 checksum_alg) enum enum_binlog_checksum_alg checksum_alg)
{ {
uchar *p= (uchar *)packet->ptr() + ev_offset; uchar *p= (uchar *)packet->ptr() + ev_offset;
uchar *q= p + LOG_EVENT_HEADER_LEN; uchar *q= p + LOG_EVENT_HEADER_LEN;
...@@ -4470,7 +4462,8 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi) ...@@ -4470,7 +4462,8 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi)
bool bool
Query_log_event::peek_is_commit_rollback(const char *event_start, Query_log_event::peek_is_commit_rollback(const char *event_start,
size_t event_len, uint8 checksum_alg) size_t event_len,
enum enum_binlog_checksum_alg checksum_alg)
{ {
if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32) if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32)
{ {
...@@ -4864,7 +4857,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) ...@@ -4864,7 +4857,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
break; break;
} }
calc_server_version_split(); calc_server_version_split();
checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_UNDEF; checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF;
} }
...@@ -4916,11 +4909,11 @@ Format_description_log_event(const char* buf, ...@@ -4916,11 +4909,11 @@ Format_description_log_event(const char* buf,
{ {
/* the last bytes are the checksum alg desc and value (or value's room) */ /* the last bytes are the checksum alg desc and value (or value's room) */
number_of_event_types -= BINLOG_CHECKSUM_ALG_DESC_LEN; number_of_event_types -= BINLOG_CHECKSUM_ALG_DESC_LEN;
checksum_alg= post_header_len[number_of_event_types]; checksum_alg= (enum_binlog_checksum_alg)post_header_len[number_of_event_types];
} }
else else
{ {
checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_UNDEF; checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF;
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -4956,8 +4949,8 @@ bool Format_description_log_event::write(IO_CACHE* file) ...@@ -4956,8 +4949,8 @@ bool Format_description_log_event::write(IO_CACHE* file)
#ifndef DBUG_OFF #ifndef DBUG_OFF
data_written= 0; // to prepare for need_checksum assert data_written= 0; // to prepare for need_checksum assert
#endif #endif
uchar checksum_byte= need_checksum() ? uint8 checksum_byte= (uint8)
checksum_alg : (uint8) BINLOG_CHECKSUM_ALG_OFF; (need_checksum() ? checksum_alg : BINLOG_CHECKSUM_ALG_OFF);
/* /*
FD of checksum-aware server is always checksum-equipped, (V) is in, FD of checksum-aware server is always checksum-equipped, (V) is in,
regardless of @@global.binlog_checksum policy. regardless of @@global.binlog_checksum policy.
...@@ -5162,9 +5155,9 @@ Format_description_log_event::is_version_before_checksum(const master_version_sp ...@@ -5162,9 +5155,9 @@ Format_description_log_event::is_version_before_checksum(const master_version_sp
checksum-unaware (effectively no checksum) and the actuall checksum-unaware (effectively no checksum) and the actuall
[1-254] range alg descriptor. [1-254] range alg descriptor.
*/ */
uint8 get_checksum_alg(const char* buf, ulong len) enum enum_binlog_checksum_alg get_checksum_alg(const char* buf, ulong len)
{ {
uint8 ret; enum enum_binlog_checksum_alg ret;
char version[ST_SERVER_VER_LEN]; char version[ST_SERVER_VER_LEN];
Format_description_log_event::master_version_split version_split; Format_description_log_event::master_version_split version_split;
...@@ -5177,9 +5170,9 @@ uint8 get_checksum_alg(const char* buf, ulong len) ...@@ -5177,9 +5170,9 @@ uint8 get_checksum_alg(const char* buf, ulong len)
version[ST_SERVER_VER_LEN - 1]= 0; version[ST_SERVER_VER_LEN - 1]= 0;
do_server_version_split(version, &version_split); do_server_version_split(version, &version_split);
ret= Format_description_log_event::is_version_before_checksum(&version_split) ? ret= Format_description_log_event::is_version_before_checksum(&version_split)
(uint8) BINLOG_CHECKSUM_ALG_UNDEF : ? BINLOG_CHECKSUM_ALG_UNDEF
* (uint8*) (buf + len - BINLOG_CHECKSUM_LEN - BINLOG_CHECKSUM_ALG_DESC_LEN); : (enum_binlog_checksum_alg)buf[len - BINLOG_CHECKSUM_LEN - BINLOG_CHECKSUM_ALG_DESC_LEN];
DBUG_ASSERT(ret == BINLOG_CHECKSUM_ALG_OFF || DBUG_ASSERT(ret == BINLOG_CHECKSUM_ALG_OFF ||
ret == BINLOG_CHECKSUM_ALG_UNDEF || ret == BINLOG_CHECKSUM_ALG_UNDEF ||
ret == BINLOG_CHECKSUM_ALG_CRC32); ret == BINLOG_CHECKSUM_ALG_CRC32);
...@@ -6358,7 +6351,7 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, ...@@ -6358,7 +6351,7 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg,
*/ */
bool bool
Gtid_log_event::peek(const char *event_start, size_t event_len, Gtid_log_event::peek(const char *event_start, size_t event_len,
uint8 checksum_alg, enum enum_binlog_checksum_alg checksum_alg,
uint32 *domain_id, uint32 *server_id, uint64 *seq_no, uint32 *domain_id, uint32 *server_id, uint64 *seq_no,
uchar *flags2, const Format_description_log_event *fdev) uchar *flags2, const Format_description_log_event *fdev)
{ {
...@@ -6424,7 +6417,8 @@ Gtid_log_event::write(IO_CACHE *file) ...@@ -6424,7 +6417,8 @@ Gtid_log_event::write(IO_CACHE *file)
*/ */
int int
Gtid_log_event::make_compatible_event(String *packet, bool *need_dummy_event, Gtid_log_event::make_compatible_event(String *packet, bool *need_dummy_event,
ulong ev_offset, uint8 checksum_alg) ulong ev_offset,
enum enum_binlog_checksum_alg checksum_alg)
{ {
uchar flags2; uchar flags2;
if (packet->length() - ev_offset < LOG_EVENT_HEADER_LEN + GTID_HEADER_LEN) if (packet->length() - ev_offset < LOG_EVENT_HEADER_LEN + GTID_HEADER_LEN)
...@@ -6879,7 +6873,7 @@ Gtid_list_log_event::print(FILE *file, PRINT_EVENT_INFO *print_event_info) ...@@ -6879,7 +6873,7 @@ Gtid_list_log_event::print(FILE *file, PRINT_EVENT_INFO *print_event_info)
*/ */
bool bool
Gtid_list_log_event::peek(const char *event_start, uint32 event_len, Gtid_list_log_event::peek(const char *event_start, uint32 event_len,
uint8 checksum_alg, enum enum_binlog_checksum_alg checksum_alg,
rpl_gtid **out_gtid_list, uint32 *out_list_len, rpl_gtid **out_gtid_list, uint32 *out_list_len,
const Format_description_log_event *fdev) const Format_description_log_event *fdev)
{ {
......
...@@ -566,15 +566,6 @@ struct sql_ex_info ...@@ -566,15 +566,6 @@ struct sql_ex_info
#endif #endif
#undef EXPECTED_OPTIONS /* You shouldn't use this one */ #undef EXPECTED_OPTIONS /* You shouldn't use this one */
enum enum_binlog_checksum_alg {
BINLOG_CHECKSUM_ALG_OFF= 0, // Events are without checksum though its generator
// is checksum-capable New Master (NM).
BINLOG_CHECKSUM_ALG_CRC32= 1, // CRC32 of zlib algorithm.
BINLOG_CHECKSUM_ALG_ENUM_END, // the cut line: valid alg range is [1, 0x7f].
BINLOG_CHECKSUM_ALG_UNDEF= 255 // special value to tag undetermined yet checksum
// or events from checksum-unaware servers
};
#define CHECKSUM_CRC32_SIGNATURE_LEN 4 #define CHECKSUM_CRC32_SIGNATURE_LEN 4
/** /**
defined statically while there is just one alg implemented defined statically while there is just one alg implemented
...@@ -1201,7 +1192,7 @@ public: ...@@ -1201,7 +1192,7 @@ public:
@retval LOG_READ_TOO_LARGE event too large @retval LOG_READ_TOO_LARGE event too large
*/ */
static int read_log_event(IO_CACHE* file, String* packet, static int read_log_event(IO_CACHE* file, String* packet,
uint8 checksum_alg_arg); enum enum_binlog_checksum_alg checksum_alg_arg);
/* /*
The value is set by caller of FD constructor and The value is set by caller of FD constructor and
Log_event::write_header() for the rest. Log_event::write_header() for the rest.
...@@ -1210,7 +1201,7 @@ public: ...@@ -1210,7 +1201,7 @@ public:
On the slave side the value is assigned from post_header_len[last] On the slave side the value is assigned from post_header_len[last]
of the last seen FD event. of the last seen FD event.
*/ */
uint8 checksum_alg; enum enum_binlog_checksum_alg checksum_alg;
static void *operator new(size_t size) static void *operator new(size_t size)
{ {
...@@ -1995,8 +1986,8 @@ public: ...@@ -1995,8 +1986,8 @@ public:
my_free(data_buf); my_free(data_buf);
} }
Log_event_type get_type_code() { return QUERY_EVENT; } Log_event_type get_type_code() { return QUERY_EVENT; }
static int dummy_event(String *packet, ulong ev_offset, uint8 checksum_alg); static int dummy_event(String *packet, ulong ev_offset, enum enum_binlog_checksum_alg checksum_alg);
static int begin_event(String *packet, ulong ev_offset, uint8 checksum_alg); static int begin_event(String *packet, ulong ev_offset, enum enum_binlog_checksum_alg checksum_alg);
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
bool write(IO_CACHE* file); bool write(IO_CACHE* file);
virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; } virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
...@@ -2019,7 +2010,7 @@ public: /* !!! Public in this patch to allow old usage */ ...@@ -2019,7 +2010,7 @@ public: /* !!! Public in this patch to allow old usage */
const char *query_arg, const char *query_arg,
uint32 q_len_arg); uint32 q_len_arg);
static bool peek_is_commit_rollback(const char *event_start, static bool peek_is_commit_rollback(const char *event_start,
size_t event_len, uint8 checksum_alg); size_t event_len, enum enum_binlog_checksum_alg checksum_alg);
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
/* /*
If true, the event always be applied by slave SQL thread or be printed by If true, the event always be applied by slave SQL thread or be printed by
...@@ -3206,9 +3197,9 @@ public: ...@@ -3206,9 +3197,9 @@ public:
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
bool write(IO_CACHE *file); bool write(IO_CACHE *file);
static int make_compatible_event(String *packet, bool *need_dummy_event, static int make_compatible_event(String *packet, bool *need_dummy_event,
ulong ev_offset, uint8 checksum_alg); ulong ev_offset, enum enum_binlog_checksum_alg checksum_alg);
static bool peek(const char *event_start, size_t event_len, static bool peek(const char *event_start, size_t event_len,
uint8 checksum_alg, enum enum_binlog_checksum_alg checksum_alg,
uint32 *domain_id, uint32 *server_id, uint64 *seq_no, uint32 *domain_id, uint32 *server_id, uint64 *seq_no,
uchar *flags2, const Format_description_log_event *fdev); uchar *flags2, const Format_description_log_event *fdev);
#endif #endif
...@@ -3324,7 +3315,7 @@ public: ...@@ -3324,7 +3315,7 @@ public:
enum_skip_reason do_shall_skip(rpl_group_info *rgi); enum_skip_reason do_shall_skip(rpl_group_info *rgi);
#endif #endif
static bool peek(const char *event_start, uint32 event_len, static bool peek(const char *event_start, uint32 event_len,
uint8 checksum_alg, enum enum_binlog_checksum_alg checksum_alg,
rpl_gtid **out_gtid_list, uint32 *out_list_len, rpl_gtid **out_gtid_list, uint32 *out_list_len,
const Format_description_log_event *fdev); const Format_description_log_event *fdev);
}; };
...@@ -4864,8 +4855,8 @@ bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos, ...@@ -4864,8 +4855,8 @@ bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
const char **group_relay_log_name, const char **group_relay_log_name,
ulonglong *relay_log_pos); ulonglong *relay_log_pos);
bool event_checksum_test(uchar *buf, ulong event_len, uint8 alg); bool event_checksum_test(uchar *buf, ulong event_len, enum_binlog_checksum_alg alg);
uint8 get_checksum_alg(const char* buf, ulong len); enum enum_binlog_checksum_alg get_checksum_alg(const char* buf, ulong len);
extern TYPELIB binlog_checksum_typelib; extern TYPELIB binlog_checksum_typelib;
/** /**
......
...@@ -69,4 +69,13 @@ enum ExtraRowInfoFormat { ...@@ -69,4 +69,13 @@ enum ExtraRowInfoFormat {
#define EXTRA_ROW_INFO_HDR_BYTES 2 #define EXTRA_ROW_INFO_HDR_BYTES 2
#define EXTRA_ROW_INFO_MAX_PAYLOAD (255 - EXTRA_ROW_INFO_HDR_BYTES) #define EXTRA_ROW_INFO_MAX_PAYLOAD (255 - EXTRA_ROW_INFO_HDR_BYTES)
enum enum_binlog_checksum_alg {
BINLOG_CHECKSUM_ALG_OFF= 0, // Events are without checksum though its generator
// is checksum-capable New Master (NM).
BINLOG_CHECKSUM_ALG_CRC32= 1, // CRC32 of zlib algorithm.
BINLOG_CHECKSUM_ALG_ENUM_END, // the cut line: valid alg range is [1, 0x7f].
BINLOG_CHECKSUM_ALG_UNDEF= 255 // special value to tag undetermined yet checksum
// or events from checksum-unaware servers
};
#endif /* RPL_CONSTANTS_H */ #endif /* RPL_CONSTANTS_H */
...@@ -218,7 +218,7 @@ class Master_info : public Slave_reporting_capability ...@@ -218,7 +218,7 @@ class Master_info : public Slave_reporting_capability
Initialized to novalue, then set to the queried from master Initialized to novalue, then set to the queried from master
@@global.binlog_checksum and deactivated once FD has been received. @@global.binlog_checksum and deactivated once FD has been received.
*/ */
uint8 checksum_alg_before_fd; enum enum_binlog_checksum_alg checksum_alg_before_fd;
uint connect_retry; uint connect_retry;
#ifndef DBUG_OFF #ifndef DBUG_OFF
int events_till_disconnect; int events_till_disconnect;
......
...@@ -1158,7 +1158,7 @@ table_def::~table_def() ...@@ -1158,7 +1158,7 @@ table_def::~table_def()
@return TRUE if test fails @return TRUE if test fails
FALSE as success FALSE as success
*/ */
bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg) bool event_checksum_test(uchar *event_buf, ulong event_len, enum enum_binlog_checksum_alg alg)
{ {
bool res= FALSE; bool res= FALSE;
uint16 flags= 0; // to store in FD's buffer flags orig value uint16 flags= 0; // to store in FD's buffer flags orig value
......
...@@ -1881,8 +1881,8 @@ when it try to get the value of TIME_ZONE global variable from master."; ...@@ -1881,8 +1881,8 @@ when it try to get the value of TIME_ZONE global variable from master.";
(master_row= mysql_fetch_row(master_res)) && (master_row= mysql_fetch_row(master_res)) &&
(master_row[0] != NULL)) (master_row[0] != NULL))
{ {
mi->checksum_alg_before_fd= (uint8) mi->checksum_alg_before_fd= (enum_binlog_checksum_alg)
find_type(master_row[0], &binlog_checksum_typelib, 1) - 1; (find_type(master_row[0], &binlog_checksum_typelib, 1) - 1);
// valid outcome is either of // valid outcome is either of
DBUG_ASSERT(mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_OFF || DBUG_ASSERT(mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_OFF ||
mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_CRC32); mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_CRC32);
...@@ -5408,9 +5408,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len) ...@@ -5408,9 +5408,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
Show-up of FD:s affects checksum_alg at once because Show-up of FD:s affects checksum_alg at once because
that changes FD_queue. that changes FD_queue.
*/ */
uint8 checksum_alg= mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF ? enum enum_binlog_checksum_alg checksum_alg=
mi->checksum_alg_before_fd : mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF ?
mi->rli.relay_log.relay_log_checksum_alg; mi->checksum_alg_before_fd : mi->rli.relay_log.relay_log_checksum_alg;
char *save_buf= NULL; // needed for checksumming the fake Rotate event char *save_buf= NULL; // needed for checksumming the fake Rotate event
char rot_buf[LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN + FN_REFLEN]; char rot_buf[LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN + FN_REFLEN];
......
...@@ -51,7 +51,7 @@ extern TYPELIB binlog_checksum_typelib; ...@@ -51,7 +51,7 @@ extern TYPELIB binlog_checksum_typelib;
static int static int
fake_event_header(String* packet, Log_event_type event_type, ulong extra_len, fake_event_header(String* packet, Log_event_type event_type, ulong extra_len,
my_bool *do_checksum, ha_checksum *crc, const char** errmsg, my_bool *do_checksum, ha_checksum *crc, const char** errmsg,
uint8 checksum_alg_arg, uint32 end_pos) enum enum_binlog_checksum_alg checksum_alg_arg, uint32 end_pos)
{ {
char header[LOG_EVENT_HEADER_LEN]; char header[LOG_EVENT_HEADER_LEN];
ulong event_len; ulong event_len;
...@@ -132,7 +132,7 @@ struct binlog_send_info { ...@@ -132,7 +132,7 @@ struct binlog_send_info {
enum_gtid_skip_type gtid_skip_group; enum_gtid_skip_type gtid_skip_group;
enum_gtid_until_state gtid_until_group; enum_gtid_until_state gtid_until_group;
ushort flags; ushort flags;
uint8 current_checksum_alg; enum enum_binlog_checksum_alg current_checksum_alg;
bool slave_gtid_strict_mode; bool slave_gtid_strict_mode;
bool send_fake_gtid_list; bool send_fake_gtid_list;
bool slave_gtid_ignore_duplicates; bool slave_gtid_ignore_duplicates;
...@@ -208,7 +208,7 @@ static int reset_transmit_packet(struct binlog_send_info *info, ushort flags, ...@@ -208,7 +208,7 @@ static int reset_transmit_packet(struct binlog_send_info *info, ushort flags,
*/ */
static int fake_rotate_event(binlog_send_info *info, ulonglong position, static int fake_rotate_event(binlog_send_info *info, ulonglong position,
const char** errmsg, uint8 checksum_alg_arg) const char** errmsg, enum enum_binlog_checksum_alg checksum_alg_arg)
{ {
DBUG_ENTER("fake_rotate_event"); DBUG_ENTER("fake_rotate_event");
ulong ev_offset; ulong ev_offset;
...@@ -453,9 +453,9 @@ static bool is_slave_checksum_aware(THD * thd) ...@@ -453,9 +453,9 @@ static bool is_slave_checksum_aware(THD * thd)
@c enum enum_binlog_checksum_alg @c enum enum_binlog_checksum_alg
*/ */
static uint8 get_binlog_checksum_value_at_connect(THD * thd) static enum enum_binlog_checksum_alg get_binlog_checksum_value_at_connect(THD * thd)
{ {
uint8 ret; enum enum_binlog_checksum_alg ret;
DBUG_ENTER("get_binlog_checksum_value_at_connect"); DBUG_ENTER("get_binlog_checksum_value_at_connect");
user_var_entry *entry= get_binlog_checksum_uservar(thd); user_var_entry *entry= get_binlog_checksum_uservar(thd);
...@@ -470,7 +470,8 @@ static uint8 get_binlog_checksum_value_at_connect(THD * thd) ...@@ -470,7 +470,8 @@ static uint8 get_binlog_checksum_value_at_connect(THD * thd)
uint dummy_errors; uint dummy_errors;
str.copy(entry->value, entry->length, &my_charset_bin, &my_charset_bin, str.copy(entry->value, entry->length, &my_charset_bin, &my_charset_bin,
&dummy_errors); &dummy_errors);
ret= (uint8) find_type ((char*) str.ptr(), &binlog_checksum_typelib, 1) - 1; ret= (enum_binlog_checksum_alg)
(find_type ((char*) str.ptr(), &binlog_checksum_typelib, 1) - 1);
DBUG_ASSERT(ret <= BINLOG_CHECKSUM_ALG_CRC32); // while it's just on CRC32 alg DBUG_ASSERT(ret <= BINLOG_CHECKSUM_ALG_CRC32); // while it's just on CRC32 alg
} }
DBUG_RETURN(ret); DBUG_RETURN(ret);
...@@ -774,7 +775,7 @@ get_slave_until_gtid(THD *thd, String *out_str) ...@@ -774,7 +775,7 @@ get_slave_until_gtid(THD *thd, String *out_str)
static int send_heartbeat_event(binlog_send_info *info, static int send_heartbeat_event(binlog_send_info *info,
NET* net, String* packet, NET* net, String* packet,
const struct event_coordinates *coord, const struct event_coordinates *coord,
uint8 checksum_alg_arg) enum enum_binlog_checksum_alg checksum_alg_arg)
{ {
DBUG_ENTER("send_heartbeat_event"); DBUG_ENTER("send_heartbeat_event");
...@@ -1394,7 +1395,7 @@ gtid_state_from_pos(const char *name, uint32 offset, ...@@ -1394,7 +1395,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
bool found_gtid_list_event= false; bool found_gtid_list_event= false;
bool found_format_description_event= false; bool found_format_description_event= false;
bool valid_pos= false; bool valid_pos= false;
uint8 current_checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF; enum enum_binlog_checksum_alg current_checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF;
int err; int err;
String packet; String packet;
Format_description_log_event *fdev= NULL; Format_description_log_event *fdev= NULL;
...@@ -1437,8 +1438,8 @@ gtid_state_from_pos(const char *name, uint32 offset, ...@@ -1437,8 +1438,8 @@ gtid_state_from_pos(const char *name, uint32 offset,
packet.length(0); packet.length(0);
err= Log_event::read_log_event(&cache, &packet, err= Log_event::read_log_event(&cache, &packet,
opt_master_verify_checksum opt_master_verify_checksum ? current_checksum_alg
? current_checksum_alg : 0); : BINLOG_CHECKSUM_ALG_OFF);
if (err) if (err)
{ {
errormsg= "Could not read binlog while searching for slave start " errormsg= "Could not read binlog while searching for slave start "
...@@ -1646,7 +1647,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type, ...@@ -1646,7 +1647,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
String* const packet= info->packet; String* const packet= info->packet;
size_t len= packet->length(); size_t len= packet->length();
int mariadb_slave_capability= info->mariadb_slave_capability; int mariadb_slave_capability= info->mariadb_slave_capability;
uint8 current_checksum_alg= info->current_checksum_alg; enum enum_binlog_checksum_alg current_checksum_alg= info->current_checksum_alg;
slave_connection_state *gtid_state= &info->gtid_state; slave_connection_state *gtid_state= &info->gtid_state;
slave_connection_state *until_gtid_state= info->until_gtid_state; slave_connection_state *until_gtid_state= info->until_gtid_state;
...@@ -2229,7 +2230,7 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log, ...@@ -2229,7 +2230,7 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
info->last_pos= my_b_tell(log); info->last_pos= my_b_tell(log);
error= Log_event::read_log_event(log, packet, error= Log_event::read_log_event(log, packet,
opt_master_verify_checksum opt_master_verify_checksum
? info->current_checksum_alg : 0); ? info->current_checksum_alg : BINLOG_CHECKSUM_ALG_OFF);
linfo->pos= my_b_tell(log); linfo->pos= my_b_tell(log);
if (error) if (error)
...@@ -2559,8 +2560,8 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo, ...@@ -2559,8 +2560,8 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
info->last_pos= linfo->pos; info->last_pos= linfo->pos;
error= Log_event::read_log_event(log, packet, error= Log_event::read_log_event(log, packet,
opt_master_verify_checksum opt_master_verify_checksum ? info->current_checksum_alg
? info->current_checksum_alg : 0); : BINLOG_CHECKSUM_ALG_OFF);
linfo->pos= my_b_tell(log); linfo->pos= my_b_tell(log);
if (error) if (error)
......
...@@ -1221,7 +1221,7 @@ int wsrep_to_buf_helper( ...@@ -1221,7 +1221,7 @@ int wsrep_to_buf_helper(
int ret(0); int ret(0);
Format_description_log_event *tmp_fd= new Format_description_log_event(4); Format_description_log_event *tmp_fd= new Format_description_log_event(4);
tmp_fd->checksum_alg= binlog_checksum_options; tmp_fd->checksum_alg= (enum_binlog_checksum_alg)binlog_checksum_options;
tmp_fd->write(&tmp_io_cache); tmp_fd->write(&tmp_io_cache);
delete tmp_fd; delete tmp_fd;
......
...@@ -30,6 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -30,6 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MYSQL_SERVER 1 #define MYSQL_SERVER 1
#include <my_global.h> #include <my_global.h>
#include "sql_priv.h" #include "sql_priv.h"
#include <mysqld_error.h>
#include "ha_federatedx.h" #include "ha_federatedx.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment