Change replication to use uchar for all buffers instead of char

This change is to get rid of randomly failing tests, especially those
that reads random position of the binary log. From looking at the logs
it's clear that some failures is because of a read char (with value >= 128)
is converted to a big long value. Using uchar everywhere makes this much
less likely to happen.
Another benefit is that a lot of cast of char to uchar could be removed.

Other things:
- Removed some extra space before '=' and '+=' in assignments
- Fixed indentations and lines > 80 characters
- Replace '16' with 'element_size' (from class definition) in
  Gtid_list_log_event()
This commit is contained in:
Monty 2021-01-26 02:20:05 +02:00 committed by Sergei Golubchik
parent db9398ba5e
commit 85d6278fed
15 changed files with 554 additions and 531 deletions

View file

@ -216,7 +216,7 @@ Log_event* read_remote_annotate_event(uchar* net_buf, ulong event_len,
memcpy(event_buf, net_buf, event_len);
event_buf[event_len]= 0;
if (!(event= Log_event::read_log_event((const char*) event_buf, event_len,
if (!(event= Log_event::read_log_event(event_buf, event_len,
error_msg, glob_description_event,
opt_verify_binlog_checksum)))
{
@ -227,7 +227,7 @@ Log_event* read_remote_annotate_event(uchar* net_buf, ulong event_len,
Ensure the event->temp_buf is pointing to the allocated buffer.
(TRUE = free temp_buf on the event deletion)
*/
event->register_temp_buf((char*)event_buf, TRUE);
event->register_temp_buf(event_buf, TRUE);
return event;
}
@ -512,8 +512,7 @@ Exit_status Load_log_processor::load_old_format_file(NET* net,
error("Illegal length of packet read from net.");
return ERROR_STOP;
}
if (my_write(file, (uchar*) net->read_pos,
(uint) packet_len, MYF(MY_WME|MY_NABP)))
if (my_write(file, net->read_pos, (uint) packet_len, MYF(MY_WME|MY_NABP)))
return ERROR_STOP;
}
@ -2350,7 +2349,7 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info,
}
else
{
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
if (!(ev= Log_event::read_log_event(net->read_pos + 1 ,
*len - 1, &error_msg,
glob_description_event,
opt_verify_binlog_checksum)))
@ -2362,7 +2361,7 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info,
If reading from a remote host, ensure the temp_buf for the
Log_event class is pointing to the incoming stream.
*/
ev->register_temp_buf((char *) net->read_pos + 1, FALSE);
ev->register_temp_buf(net->read_pos + 1, FALSE);
}
Log_event_type type= ev->get_type_code();
@ -2463,7 +2462,7 @@ static Exit_status handle_event_raw_mode(PRINT_EVENT_INFO *print_event_info,
const char* logname, uint logname_len)
{
const char *error_msg;
const unsigned char *read_pos= mysql->net.read_pos + 1;
const uchar *read_pos= mysql->net.read_pos + 1;
Log_event_type type;
DBUG_ENTER("handle_event_raw_mode");
DBUG_ASSERT(opt_raw_mode && remote_opt);
@ -2476,7 +2475,7 @@ static Exit_status handle_event_raw_mode(PRINT_EVENT_INFO *print_event_info,
if (type == ROTATE_EVENT || type == FORMAT_DESCRIPTION_EVENT)
{
Log_event *ev;
if (!(ev= Log_event::read_log_event((const char*) read_pos ,
if (!(ev= Log_event::read_log_event(read_pos ,
*len - 1, &error_msg,
glob_description_event,
opt_verify_binlog_checksum)))
@ -2489,7 +2488,7 @@ static Exit_status handle_event_raw_mode(PRINT_EVENT_INFO *print_event_info,
If reading from a remote host, ensure the temp_buf for the
Log_event class is pointing to the incoming stream.
*/
ev->register_temp_buf((char *) read_pos, FALSE);
ev->register_temp_buf(const_cast<uchar*>(read_pos), FALSE);
if (type == ROTATE_EVENT)
{

File diff suppressed because it is too large Load diff

View file

@ -1205,7 +1205,7 @@ public:
A temp buffer for read_log_event; it is later analysed according to the
event's type, and its content is distributed in the event-specific fields.
*/
char *temp_buf;
uchar *temp_buf;
/*
TRUE <=> this event 'owns' temp_buf and should call my_free() when done
@ -1453,10 +1453,10 @@ public:
{
return (cache_type == Log_event::EVENT_NO_CACHE);
}
Log_event(const char* buf, const Format_description_log_event
Log_event(const uchar *buf, const Format_description_log_event
*description_event);
virtual ~Log_event() { free_temp_buf();}
void register_temp_buf(char* buf, bool must_free)
void register_temp_buf(uchar* buf, bool must_free)
{
temp_buf= buf;
event_owns_temp_buf= must_free;
@ -1475,7 +1475,7 @@ public:
is calculated during write()
*/
virtual int get_data_size() { return 0;}
static Log_event* read_log_event(const char* buf, uint event_len,
static Log_event* read_log_event(const uchar *buf, uint event_len,
const char **error,
const Format_description_log_event
*description_event, my_bool crc_check);
@ -2150,7 +2150,7 @@ public:
#endif
Query_log_event();
Query_log_event(const char* buf, uint event_len,
Query_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event,
Log_event_type event_type);
~Query_log_event()
@ -2182,8 +2182,10 @@ public: /* !!! Public in this patch to allow old usage */
int do_apply_event(rpl_group_info *rgi,
const char *query_arg,
uint32 q_len_arg);
static bool peek_is_commit_rollback(const char *event_start,
size_t event_len, enum enum_binlog_checksum_alg checksum_alg);
static bool peek_is_commit_rollback(const uchar *event_start,
size_t event_len,
enum enum_binlog_checksum_alg
checksum_alg);
#endif /* HAVE_REPLICATION */
/*
If true, the event always be applied by slave SQL thread or be printed by
@ -2216,7 +2218,7 @@ class Query_compressed_log_event:public Query_log_event{
protected:
Log_event::Byte* query_buf; // point to the uncompressed query
public:
Query_compressed_log_event(const char* buf, uint event_len,
Query_compressed_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event,
Log_event_type event_type);
~Query_compressed_log_event()
@ -2227,7 +2229,7 @@ public:
Log_event_type get_type_code() { return QUERY_COMPRESSED_EVENT; }
/*
the min length of log_bin_compress_min_len is 10,
the min length of log_bin_compress_min_len is 10,
means that Begin/Commit/Rollback would never be compressed!
*/
virtual bool is_begin() { return false; }
@ -2268,7 +2270,7 @@ struct sql_ex_info
line_start_len + escaped_len + 6 : 7);
}
bool write_data(Log_event_writer *writer);
const char* init(const char* buf, const char* buf_end, bool use_new_format);
const uchar *init(const uchar *buf, const uchar* buf_end, bool use_new_format);
bool new_format()
{
return ((cached_new_format != -1) ? cached_new_format :
@ -2482,7 +2484,7 @@ class Load_log_event: public Log_event
{
private:
protected:
int copy_log_event(const char *buf, ulong event_len,
int copy_log_event(const uchar *buf, ulong event_len,
int body_offset,
const Format_description_log_event* description_event);
@ -2563,7 +2565,7 @@ public:
logging of LOAD DATA is going to be changed in 4.1 or 5.0, this is only used
for the common_header_len (post_header_len will not be changed).
*/
Load_log_event(const char* buf, uint event_len,
Load_log_event(const uchar *buf, uint event_len,
const Format_description_log_event* description_event);
~Load_log_event()
{}
@ -2654,7 +2656,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Start_log_event_v3(const char* buf, uint event_len,
Start_log_event_v3(const uchar *buf, uint event_len,
const Format_description_log_event* description_event);
~Start_log_event_v3() {}
Log_event_type get_type_code() { return START_EVENT_V3;}
@ -2723,9 +2725,9 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Start_encryption_log_event(
const char* buf, uint event_len,
const Format_description_log_event* description_event);
Start_encryption_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
bool is_valid() const { return crypto_scheme == 1; }
@ -2828,7 +2830,7 @@ public:
const uint8 *event_type_permutation;
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
Format_description_log_event(const char* buf, uint event_len,
Format_description_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
~Format_description_log_event()
@ -2942,7 +2944,7 @@ Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg,
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Intvar_log_event(const char* buf,
Intvar_log_event(const uchar *buf,
const Format_description_log_event *description_event);
~Intvar_log_event() {}
Log_event_type get_type_code() { return INTVAR_EVENT;}
@ -3023,7 +3025,7 @@ class Rand_log_event: public Log_event
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Rand_log_event(const char* buf,
Rand_log_event(const uchar *buf,
const Format_description_log_event *description_event);
~Rand_log_event() {}
Log_event_type get_type_code() { return RAND_EVENT;}
@ -3050,9 +3052,9 @@ public:
Xid_apply_log_event(THD* thd_arg):
Log_event(thd_arg, 0, TRUE) {}
#endif
Xid_apply_log_event(const char* buf,
Xid_apply_log_event(const uchar *buf,
const Format_description_log_event *description_event):
Log_event(buf, description_event) {}
Log_event(buf, description_event) {}
~Xid_apply_log_event() {}
bool is_valid() const { return 1; }
@ -3103,7 +3105,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Xid_log_event(const char* buf,
Xid_log_event(const uchar *buf,
const Format_description_log_event *description_event);
~Xid_log_event() {}
Log_event_type get_type_code() { return XID_EVENT;}
@ -3248,7 +3250,7 @@ public:
#else
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
XA_prepare_log_event(const char* buf,
XA_prepare_log_event(const uchar *buf,
const Format_description_log_event *description_event);
~XA_prepare_log_event() {}
Log_event_type get_type_code() { return XA_PREPARE_LOG_EVENT; }
@ -3305,7 +3307,8 @@ public:
bool deferred;
query_id_t query_id;
User_var_log_event(THD* thd_arg, const char *name_arg, size_t name_len_arg,
const char *val_arg, size_t val_len_arg, Item_result type_arg,
const char *val_arg, size_t val_len_arg,
Item_result type_arg,
uint charset_number_arg, uchar flags_arg,
bool using_trans, bool direct)
:Log_event(thd_arg, 0, using_trans),
@ -3322,7 +3325,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
User_var_log_event(const char* buf, uint event_len,
User_var_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
~User_var_log_event() {}
Log_event_type get_type_code() { return USER_VAR_EVENT;}
@ -3370,7 +3373,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Stop_log_event(const char* buf,
Stop_log_event(const uchar *buf,
const Format_description_log_event *description_event):
Log_event(buf, description_event)
{}
@ -3451,7 +3454,7 @@ public:
DUP_NAME= 2, // if constructor should dup the string argument
RELAY_LOG=4 // rotate event for relay log
};
const char* new_log_ident;
const char *new_log_ident;
ulonglong pos;
uint ident_len;
uint flags;
@ -3466,7 +3469,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Rotate_log_event(const char* buf, uint event_len,
Rotate_log_event(const uchar *buf, uint event_len,
const Format_description_log_event* description_event);
~Rotate_log_event()
{
@ -3505,11 +3508,12 @@ public:
#else
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
#endif
Binlog_checkpoint_log_event(const char *buf, uint event_len,
const Format_description_log_event *description_event);
Binlog_checkpoint_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
~Binlog_checkpoint_log_event() { my_free(binlog_file_name); }
Log_event_type get_type_code() { return BINLOG_CHECKPOINT_EVENT;}
int get_data_size() { return binlog_file_len + BINLOG_CHECKPOINT_HEADER_LEN;}
int get_data_size() { return binlog_file_len + BINLOG_CHECKPOINT_HEADER_LEN;}
bool is_valid() const { return binlog_file_name != 0; }
#ifdef MYSQL_SERVER
bool write();
@ -3638,7 +3642,7 @@ public:
#else
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
#endif
Gtid_log_event(const char *buf, uint event_len,
Gtid_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
~Gtid_log_event() { }
Log_event_type get_type_code() { return GTID_EVENT; }
@ -3652,7 +3656,7 @@ public:
bool write();
static int make_compatible_event(String *packet, bool *need_dummy_event,
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 uchar *event_start, size_t event_len,
enum enum_binlog_checksum_alg checksum_alg,
uint32 *domain_id, uint32 *server_id, uint64 *seq_no,
uchar *flags2, const Format_description_log_event *fdev);
@ -3752,7 +3756,7 @@ public:
#else
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info);
#endif
Gtid_list_log_event(const char *buf, uint event_len,
Gtid_list_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
~Gtid_list_log_event() { my_free(list); my_free(sub_id_list); }
Log_event_type get_type_code() { return GTID_LIST_EVENT; }
@ -3796,8 +3800,8 @@ protected:
*/
bool fake_base;
public:
uchar* block;
const char *event_buf;
uchar *block;
const uchar *event_buf;
uint block_len;
uint file_id;
bool inited_from_old;
@ -3819,7 +3823,7 @@ public:
bool enable_local);
#endif
Create_file_log_event(const char* buf, uint event_len,
Create_file_log_event(const uchar *buf, uint event_len,
const Format_description_log_event* description_event);
~Create_file_log_event()
{
@ -3871,7 +3875,7 @@ public:
event needs to have a 'db' member to be well filtered by
binlog-*-db rules). 'db' is not written to the binlog (it's not
used by Append_block_log_event::write()), so it can't be read in
the Append_block_log_event(const char* buf, int event_len)
the Append_block_log_event(const uchar *buf, int event_len)
constructor. In other words, 'db' is used only for filtering by
binlog-*-db rules. Create_file_log_event is different: it's 'db'
(which is inherited from Load_log_event) is written to the binlog
@ -3890,7 +3894,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Append_block_log_event(const char* buf, uint event_len,
Append_block_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
~Append_block_log_event() {}
@ -3932,7 +3936,7 @@ public:
bool enable_local);
#endif
Delete_file_log_event(const char* buf, uint event_len,
Delete_file_log_event(const uchar *buf, uint event_len,
const Format_description_log_event* description_event);
~Delete_file_log_event() {}
Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
@ -3971,7 +3975,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Execute_load_log_event(const char* buf, uint event_len,
Execute_load_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
~Execute_load_log_event() {}
@ -4011,7 +4015,7 @@ public:
int get_create_or_append() const;
#endif /* HAVE_REPLICATION */
#endif
Begin_load_query_log_event(const char* buf, uint event_len,
Begin_load_query_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
~Begin_load_query_log_event() {}
@ -4069,7 +4073,7 @@ public:
bool print(FILE* file, PRINT_EVENT_INFO* print_event_info,
const char *local_fname);
#endif
Execute_load_query_log_event(const char* buf, uint event_len,
Execute_load_query_log_event(const uchar *buf, uint event_len,
const Format_description_log_event
*description_event);
~Execute_load_query_log_event() {}
@ -4104,7 +4108,7 @@ public:
Log_event's ctor, this way we can extract maximum information from the
event's header (the unique ID for example).
*/
Unknown_log_event(const char* buf,
Unknown_log_event(const uchar *buf,
const Format_description_log_event *description_event):
Log_event(buf, description_event), what(UNKNOWN)
{}
@ -4136,7 +4140,7 @@ public:
#ifndef MYSQL_CLIENT
Annotate_rows_log_event(THD*, bool using_trans, bool direct);
#endif
Annotate_rows_log_event(const char *buf, uint event_len,
Annotate_rows_log_event(const uchar *buf, uint event_len,
const Format_description_log_event*);
~Annotate_rows_log_event();
@ -4786,7 +4790,7 @@ public:
Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, bool is_transactional);
#endif
#ifdef HAVE_REPLICATION
Table_map_log_event(const char *buf, uint event_len,
Table_map_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
@ -5109,11 +5113,11 @@ protected:
this class, not create instances of this class.
*/
#ifdef MYSQL_SERVER
Rows_log_event(THD*, TABLE*, ulong table_id,
Rows_log_event(THD*, TABLE*, ulong table_id,
MY_BITMAP const *cols, bool is_transactional,
Log_event_type event_type);
#endif
Rows_log_event(const char *row_data, uint event_len,
Rows_log_event(const uchar *row_data, uint event_len,
const Format_description_log_event *description_event);
void uncompress_buf();
@ -5265,7 +5269,7 @@ private:
DESCRIPTION
The member function will do the actual execution needed to handle a row.
The row is located at m_curr_row. When the function returns,
The row is located at m_curr_row. When the function returns,
m_curr_row_end should point at the next row (one byte after the end
of the current row).
@ -5302,7 +5306,7 @@ public:
bool is_transactional);
#endif
#ifdef HAVE_REPLICATION
Write_rows_log_event(const char *buf, uint event_len,
Write_rows_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
#if defined(MYSQL_SERVER)
@ -5344,7 +5348,7 @@ public:
virtual bool write();
#endif
#ifdef HAVE_REPLICATION
Write_rows_compressed_log_event(const char *buf, uint event_len,
Write_rows_compressed_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
private:
@ -5384,7 +5388,7 @@ public:
virtual ~Update_rows_log_event();
#ifdef HAVE_REPLICATION
Update_rows_log_event(const char *buf, uint event_len,
Update_rows_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
@ -5432,7 +5436,7 @@ public:
virtual bool write();
#endif
#ifdef HAVE_REPLICATION
Update_rows_compressed_log_event(const char *buf, uint event_len,
Update_rows_compressed_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
private:
@ -5474,7 +5478,7 @@ public:
Delete_rows_log_event(THD*, TABLE*, ulong, bool is_transactional);
#endif
#ifdef HAVE_REPLICATION
Delete_rows_log_event(const char *buf, uint event_len,
Delete_rows_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
#ifdef MYSQL_SERVER
@ -5516,7 +5520,7 @@ public:
virtual bool write();
#endif
#ifdef HAVE_REPLICATION
Delete_rows_compressed_log_event(const char *buf, uint event_len,
Delete_rows_compressed_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
private:
@ -5610,7 +5614,7 @@ public:
virtual bool write_data_body();
#endif
Incident_log_event(const char *buf, uint event_len,
Incident_log_event(const uchar *buf, uint event_len,
const Format_description_log_event *descr_event);
virtual ~Incident_log_event();
@ -5673,7 +5677,7 @@ public:
}
#endif
Ignorable_log_event(const char *buf,
Ignorable_log_event(const uchar *buf,
const Format_description_log_event *descr_event,
const char *event_name);
virtual ~Ignorable_log_event();
@ -5726,7 +5730,7 @@ class Heartbeat_log_event: public Log_event
{
public:
uint8 hb_flags;
Heartbeat_log_event(const char* buf, ulong event_len,
Heartbeat_log_event(const uchar *buf, uint event_len,
const Format_description_log_event* description_event);
Log_event_type get_type_code() { return HEARTBEAT_LOG_EVENT; }
bool is_valid() const
@ -5734,12 +5738,12 @@ public:
return (log_ident != NULL && ident_len <= FN_REFLEN-1 &&
log_pos >= BIN_LOG_HEADER_SIZE);
}
const char * get_log_ident() { return log_ident; }
const uchar * get_log_ident() { return log_ident; }
uint get_ident_len() { return ident_len; }
private:
const char* log_ident;
uint ident_len;
const uchar *log_ident;
};
inline int Log_event_writer::write(Log_event *ev)
@ -5760,9 +5764,10 @@ inline int Log_event_writer::write(Log_event *ev)
bool slave_execute_deferred_events(THD *thd);
#endif
bool event_that_should_be_ignored(const char *buf);
bool event_checksum_test(uchar *buf, ulong event_len, enum_binlog_checksum_alg alg);
enum enum_binlog_checksum_alg get_checksum_alg(const char* buf, ulong len);
bool event_that_should_be_ignored(const uchar *buf);
bool event_checksum_test(uchar *buf, ulong event_len,
enum_binlog_checksum_alg alg);
enum enum_binlog_checksum_alg get_checksum_alg(const uchar *buf, ulong len);
extern TYPELIB binlog_checksum_typelib;
#ifdef WITH_WSREP
enum Log_event_type wsrep_peak_event(rpl_group_info *rgi, ulonglong* event_size);
@ -5773,17 +5778,23 @@ enum Log_event_type wsrep_peak_event(rpl_group_info *rgi, ulonglong* event_size)
*/
int binlog_buf_compress(const char *src, char *dst, uint32 len, uint32 *comlen);
int binlog_buf_uncompress(const char *src, char *dst, uint32 len, uint32 *newlen);
int binlog_buf_compress(const uchar *src, uchar *dst, uint32 len,
uint32 *comlen);
int binlog_buf_uncompress(const uchar *src, uchar *dst, uint32 len,
uint32 *newlen);
uint32 binlog_get_compress_len(uint32 len);
uint32 binlog_get_uncompress_len(const char *buf);
uint32 binlog_get_uncompress_len(const uchar *buf);
int query_event_uncompress(const Format_description_log_event *description_event, bool contain_checksum,
const char *src, ulong src_len, char* buf, ulong buf_size, bool* is_malloc,
char **dst, ulong *newlen);
int row_log_event_uncompress(const Format_description_log_event *description_event, bool contain_checksum,
const char *src, ulong src_len, char* buf, ulong buf_size, bool* is_malloc,
char **dst, ulong *newlen);
int query_event_uncompress(const Format_description_log_event *description_event,
bool contain_checksum,
const uchar *src, ulong src_len, uchar *buf,
ulong buf_size, bool* is_malloc,
uchar **dst, ulong *newlen);
int row_log_event_uncompress(const Format_description_log_event
*description_event,
bool contain_checksum,
const uchar *src, ulong src_len,
uchar* buf, ulong buf_size, bool *is_malloc,
uchar **dst, ulong *newlen);
#endif /* _log_event_h */

View file

@ -1587,7 +1587,7 @@ bool Log_event::print_base64(IO_CACHE* file,
PRINT_EVENT_INFO* print_event_info,
bool do_print_encoded)
{
uchar *ptr= (uchar *)temp_buf;
uchar *ptr= temp_buf;
uint32 size= uint4korr(ptr + EVENT_LEN_OFFSET);
DBUG_ENTER("Log_event::print_base64");
@ -1602,31 +1602,31 @@ bool Log_event::print_base64(IO_CACHE* file,
switch (ev_type) {
case WRITE_ROWS_EVENT:
ptr[EVENT_TYPE_OFFSET]= DELETE_ROWS_EVENT;
ev= new Delete_rows_log_event((const char*) ptr, tmp_size,
ev= new Delete_rows_log_event(ptr, tmp_size,
glob_description_event);
ev->change_to_flashback_event(print_event_info, ptr, ev_type);
break;
case WRITE_ROWS_EVENT_V1:
ptr[EVENT_TYPE_OFFSET]= DELETE_ROWS_EVENT_V1;
ev= new Delete_rows_log_event((const char*) ptr, tmp_size,
ev= new Delete_rows_log_event(ptr, tmp_size,
glob_description_event);
ev->change_to_flashback_event(print_event_info, ptr, ev_type);
break;
case DELETE_ROWS_EVENT:
ptr[EVENT_TYPE_OFFSET]= WRITE_ROWS_EVENT;
ev= new Write_rows_log_event((const char*) ptr, tmp_size,
ev= new Write_rows_log_event(ptr, tmp_size,
glob_description_event);
ev->change_to_flashback_event(print_event_info, ptr, ev_type);
break;
case DELETE_ROWS_EVENT_V1:
ptr[EVENT_TYPE_OFFSET]= WRITE_ROWS_EVENT_V1;
ev= new Write_rows_log_event((const char*) ptr, tmp_size,
ev= new Write_rows_log_event(ptr, tmp_size,
glob_description_event);
ev->change_to_flashback_event(print_event_info, ptr, ev_type);
break;
case UPDATE_ROWS_EVENT:
case UPDATE_ROWS_EVENT_V1:
ev= new Update_rows_log_event((const char*) ptr, tmp_size,
ev= new Update_rows_log_event(ptr, tmp_size,
glob_description_event);
ev->change_to_flashback_event(print_event_info, ptr, ev_type);
break;
@ -1673,7 +1673,7 @@ bool Log_event::print_base64(IO_CACHE* file,
case TABLE_MAP_EVENT:
{
Table_map_log_event *map;
map= new Table_map_log_event((const char*) ptr, size,
map= new Table_map_log_event(ptr, size,
glob_description_event);
#ifdef WHEN_FLASHBACK_REVIEW_READY
if (need_flashback_review)
@ -1688,42 +1688,42 @@ bool Log_event::print_base64(IO_CACHE* file,
case WRITE_ROWS_EVENT:
case WRITE_ROWS_EVENT_V1:
{
ev= new Write_rows_log_event((const char*) ptr, size,
ev= new Write_rows_log_event(ptr, size,
glob_description_event);
break;
}
case DELETE_ROWS_EVENT:
case DELETE_ROWS_EVENT_V1:
{
ev= new Delete_rows_log_event((const char*) ptr, size,
ev= new Delete_rows_log_event(ptr, size,
glob_description_event);
break;
}
case UPDATE_ROWS_EVENT:
case UPDATE_ROWS_EVENT_V1:
{
ev= new Update_rows_log_event((const char*) ptr, size,
ev= new Update_rows_log_event(ptr, size,
glob_description_event);
break;
}
case WRITE_ROWS_COMPRESSED_EVENT:
case WRITE_ROWS_COMPRESSED_EVENT_V1:
{
ev= new Write_rows_compressed_log_event((const char*) ptr, size,
ev= new Write_rows_compressed_log_event(ptr, size,
glob_description_event);
break;
}
case UPDATE_ROWS_COMPRESSED_EVENT:
case UPDATE_ROWS_COMPRESSED_EVENT_V1:
{
ev= new Update_rows_compressed_log_event((const char*) ptr, size,
ev= new Update_rows_compressed_log_event(ptr, size,
glob_description_event);
break;
}
case DELETE_ROWS_COMPRESSED_EVENT:
case DELETE_ROWS_COMPRESSED_EVENT_V1:
{
ev= new Delete_rows_compressed_log_event((const char*) ptr, size,
ev= new Delete_rows_compressed_log_event(ptr, size,
glob_description_event);
break;
}
@ -3103,7 +3103,8 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len,
// Create new temp_buf
ulong event_cur_len= uint4korr(temp_buf + EVENT_LEN_OFFSET);
ulong event_new_len= event_cur_len + len_diff;
char* new_temp_buf= (char*) my_malloc(PSI_NOT_INSTRUMENTED, event_new_len, MYF(MY_WME));
uchar* new_temp_buf= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, event_new_len,
MYF(MY_WME));
if (!new_temp_buf)
{
@ -3114,7 +3115,7 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len,
}
// Rewrite temp_buf
char* ptr= new_temp_buf;
uchar *ptr= new_temp_buf;
size_t cnt= 0;
// Copy header and change event length
@ -3612,12 +3613,13 @@ bool Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info)
bool Write_rows_compressed_log_event::print(FILE *file,
PRINT_EVENT_INFO* print_event_info)
{
char *new_buf;
uchar *new_buf;
ulong len;
bool is_malloc = false;
if(!row_log_event_uncompress(glob_description_event,
checksum_alg == BINLOG_CHECKSUM_ALG_CRC32,
temp_buf, UINT_MAX32, NULL, 0, &is_malloc, &new_buf, &len))
temp_buf, UINT_MAX32, NULL, 0, &is_malloc,
&new_buf, &len))
{
free_temp_buf();
register_temp_buf(new_buf, true);
@ -3648,12 +3650,13 @@ bool Delete_rows_log_event::print(FILE *file,
bool Delete_rows_compressed_log_event::print(FILE *file,
PRINT_EVENT_INFO* print_event_info)
{
char *new_buf;
uchar *new_buf;
ulong len;
bool is_malloc = false;
if(!row_log_event_uncompress(glob_description_event,
checksum_alg == BINLOG_CHECKSUM_ALG_CRC32,
temp_buf, UINT_MAX32, NULL, 0, &is_malloc, &new_buf, &len))
temp_buf, UINT_MAX32, NULL, 0, &is_malloc,
&new_buf, &len))
{
free_temp_buf();
register_temp_buf(new_buf, true);
@ -3684,12 +3687,13 @@ bool
Update_rows_compressed_log_event::print(FILE *file,
PRINT_EVENT_INFO *print_event_info)
{
char *new_buf;
uchar *new_buf;
ulong len;
bool is_malloc= false;
if(!row_log_event_uncompress(glob_description_event,
checksum_alg == BINLOG_CHECKSUM_ALG_CRC32,
temp_buf, UINT_MAX32, NULL, 0, &is_malloc, &new_buf, &len))
temp_buf, UINT_MAX32, NULL, 0, &is_malloc,
&new_buf, &len))
{
free_temp_buf();
register_temp_buf(new_buf, true);

View file

@ -1175,7 +1175,7 @@ Old_rows_log_event::Old_rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
#endif
Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len,
Old_rows_log_event::Old_rows_log_event(const uchar *buf, uint event_len,
Log_event_type event_type,
const Format_description_log_event
*description_event)
@ -1198,8 +1198,8 @@ Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len,
event_len, common_header_len,
post_header_len));
const char *post_start= buf + common_header_len;
DBUG_DUMP("post_header", (uchar*) post_start, post_header_len);
const uchar *post_start= buf + common_header_len;
DBUG_DUMP("post_header", post_start, post_header_len);
post_start+= RW_MAPID_OFFSET;
if (post_header_len == 6)
{
@ -2417,7 +2417,7 @@ Write_rows_log_event_old::Write_rows_log_event_old(THD *thd_arg,
Constructor used by slave to read the event from the binary log.
*/
#ifdef HAVE_REPLICATION
Write_rows_log_event_old::Write_rows_log_event_old(const char *buf,
Write_rows_log_event_old::Write_rows_log_event_old(const uchar *buf,
uint event_len,
const Format_description_log_event
*description_event)
@ -2530,12 +2530,13 @@ Delete_rows_log_event_old::Delete_rows_log_event_old(THD *thd_arg,
Constructor used by slave to read the event from the binary log.
*/
#ifdef HAVE_REPLICATION
Delete_rows_log_event_old::Delete_rows_log_event_old(const char *buf,
uint event_len,
const Format_description_log_event
*description_event)
: Old_rows_log_event(buf, event_len, PRE_GA_DELETE_ROWS_EVENT,
description_event),
Delete_rows_log_event_old::
Delete_rows_log_event_old(const uchar *buf,
uint event_len,
const Format_description_log_event
*description_event)
:Old_rows_log_event(buf, event_len, PRE_GA_DELETE_ROWS_EVENT,
description_event),
m_after_image(NULL), m_memory(NULL)
{
}
@ -2544,8 +2545,8 @@ Delete_rows_log_event_old::Delete_rows_log_event_old(const char *buf,
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
int
Delete_rows_log_event_old::do_before_row_operations(const Slave_reporting_capability *const)
int Delete_rows_log_event_old::
do_before_row_operations(const Slave_reporting_capability *const)
{
if ((m_table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) &&
m_table->s->primary_key < MAX_KEY)
@ -2636,7 +2637,7 @@ Update_rows_log_event_old::Update_rows_log_event_old(THD *thd_arg,
Constructor used by slave to read the event from the binary log.
*/
#ifdef HAVE_REPLICATION
Update_rows_log_event_old::Update_rows_log_event_old(const char *buf,
Update_rows_log_event_old::Update_rows_log_event_old(const uchar *buf,
uint event_len,
const
Format_description_log_event
@ -2652,12 +2653,14 @@ Update_rows_log_event_old::Update_rows_log_event_old(const char *buf,
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
int
Update_rows_log_event_old::do_before_row_operations(const Slave_reporting_capability *const)
Update_rows_log_event_old::
do_before_row_operations(const Slave_reporting_capability *const)
{
if (m_table->s->keys > 0)
{
// Allocate buffer for key searches
m_key= (uchar*)my_malloc(key_memory_log_event_old, m_table->key_info->key_length, MYF(MY_WME));
m_key= (uchar*)my_malloc(key_memory_log_event_old,
m_table->key_info->key_length, MYF(MY_WME));
if (!m_key)
return HA_ERR_OUT_OF_MEM;
}
@ -2667,8 +2670,8 @@ Update_rows_log_event_old::do_before_row_operations(const Slave_reporting_capabi
int
Update_rows_log_event_old::do_after_row_operations(const Slave_reporting_capability *const,
int error)
Update_rows_log_event_old::
do_after_row_operations(const Slave_reporting_capability *const, int error)
{
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
m_table->file->ha_index_or_rnd_end();

View file

@ -161,7 +161,7 @@ protected:
Old_rows_log_event(THD*, TABLE*, ulong table_id,
MY_BITMAP const *cols, bool is_transactional);
#endif
Old_rows_log_event(const char *row_data, uint event_len,
Old_rows_log_event(const uchar *row_data, uint event_len,
Log_event_type event_type,
const Format_description_log_event *description_event);
@ -363,7 +363,7 @@ public:
MY_BITMAP const *cols, bool is_transactional);
#endif
#ifdef HAVE_REPLICATION
Write_rows_log_event_old(const char *buf, uint event_len,
Write_rows_log_event_old(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
#if !defined(MYSQL_CLIENT)
@ -436,7 +436,7 @@ public:
#endif
#ifdef HAVE_REPLICATION
Update_rows_log_event_old(const char *buf, uint event_len,
Update_rows_log_event_old(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
@ -511,7 +511,7 @@ public:
MY_BITMAP const *cols, bool is_transactional);
#endif
#ifdef HAVE_REPLICATION
Delete_rows_log_event_old(const char *buf, uint event_len,
Delete_rows_log_event_old(const uchar *buf, uint event_len,
const Format_description_log_event *description_event);
#endif
#if !defined(MYSQL_CLIENT)

View file

@ -1331,14 +1331,14 @@ bool Query_log_event::write()
bool Query_compressed_log_event::write()
{
char *buffer;
uchar *buffer;
uint32 alloc_size, compressed_size;
bool ret= true;
compressed_size= alloc_size= binlog_get_compress_len(q_len);
buffer= (char*) my_safe_alloca(alloc_size);
buffer= (uchar*) my_safe_alloca(alloc_size);
if (buffer &&
!binlog_buf_compress(query, buffer, q_len, &compressed_size))
!binlog_buf_compress((uchar*) query, buffer, q_len, &compressed_size))
{
/*
Write the compressed event. We have to temporarily store the event
@ -1346,7 +1346,7 @@ bool Query_compressed_log_event::write()
*/
const char *query_tmp= query;
uint32 q_len_tmp= q_len;
query= buffer;
query= (char*) buffer;
q_len= compressed_size;
ret= Query_log_event::write();
query= query_tmp;
@ -2161,9 +2161,10 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi)
bool
Query_log_event::peek_is_commit_rollback(const char *event_start,
Query_log_event::peek_is_commit_rollback(const uchar *event_start,
size_t event_len,
enum enum_binlog_checksum_alg checksum_alg)
enum enum_binlog_checksum_alg
checksum_alg)
{
if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32)
{
@ -3295,12 +3296,12 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg,
fully contruct every Gtid_log_event() needlessly.
*/
bool
Gtid_log_event::peek(const char *event_start, size_t event_len,
Gtid_log_event::peek(const uchar *event_start, size_t event_len,
enum enum_binlog_checksum_alg checksum_alg,
uint32 *domain_id, uint32 *server_id, uint64 *seq_no,
uchar *flags2, const Format_description_log_event *fdev)
{
const char *p;
const uchar *p;
if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32)
{
@ -3321,7 +3322,7 @@ Gtid_log_event::peek(const char *event_start, size_t event_len,
p+= 8;
*domain_id= uint4korr(p);
p+= 4;
*flags2= (uchar)*p;
*flags2= *p;
return false;
}
@ -6006,14 +6007,15 @@ bool Rows_log_event::write_data_body()
bool Rows_log_event::write_compressed()
{
uchar *m_rows_buf_tmp = m_rows_buf;
uchar *m_rows_cur_tmp = m_rows_cur;
bool ret = true;
uchar *m_rows_buf_tmp= m_rows_buf;
uchar *m_rows_cur_tmp= m_rows_cur;
bool ret= true;
uint32 comlen, alloc_size;
comlen= alloc_size= binlog_get_compress_len((uint32)(m_rows_cur_tmp - m_rows_buf_tmp));
m_rows_buf = (uchar *)my_safe_alloca(alloc_size);
comlen= alloc_size= binlog_get_compress_len((uint32)(m_rows_cur_tmp -
m_rows_buf_tmp));
m_rows_buf= (uchar*) my_safe_alloca(alloc_size);
if(m_rows_buf &&
!binlog_buf_compress((const char *)m_rows_buf_tmp, (char *)m_rows_buf,
!binlog_buf_compress(m_rows_buf_tmp, m_rows_buf,
(uint32)(m_rows_cur_tmp - m_rows_buf_tmp), &comlen))
{
m_rows_cur= comlen + m_rows_buf;
@ -8447,9 +8449,8 @@ Log_event* wsrep_read_log_event(
char **arg_buf, size_t *arg_buf_len,
const Format_description_log_event *description_event)
{
char *head= (*arg_buf);
uchar *head= (uchar*) (*arg_buf);
uint data_len = uint4korr(head + EVENT_LEN_OFFSET);
char *buf= (*arg_buf);
const char *error= 0;
Log_event *res= 0;
DBUG_ENTER("wsrep_read_log_event");
@ -8460,15 +8461,16 @@ Log_event* wsrep_read_log_event(
goto err;
}
res= Log_event::read_log_event(buf, data_len, &error, description_event, false);
res= Log_event::read_log_event(head, data_len, &error, description_event,
false);
err:
if (!res)
{
DBUG_ASSERT(error != 0);
sql_print_error("Error in Log_event::read_log_event(): "
"'%s', data_len: %d, event_type: %d",
error,data_len,(uchar)head[EVENT_TYPE_OFFSET]);
"'%s', data_len: %u, event_type: %d",
error, data_len, (int) head[EVENT_TYPE_OFFSET]);
}
(*arg_buf)+= data_len;
(*arg_buf_len)-= data_len;
@ -8478,8 +8480,7 @@ err:
#if defined(HAVE_REPLICATION)
int
Incident_log_event::do_apply_event(rpl_group_info *rgi)
int Incident_log_event::do_apply_event(rpl_group_info *rgi)
{
Relay_log_info const *rli= rgi->rli;
DBUG_ENTER("Incident_log_event::do_apply_event");
@ -8532,7 +8533,7 @@ void Ignorable_log_event::pack_info(Protocol *protocol)
#if defined(HAVE_REPLICATION)
Heartbeat_log_event::Heartbeat_log_event(const char* buf, ulong event_len,
Heartbeat_log_event::Heartbeat_log_event(const uchar *buf, uint event_len,
const Format_description_log_event* description_event)
:Log_event(buf, description_event)
{
@ -8562,9 +8563,9 @@ Heartbeat_log_event::Heartbeat_log_event(const char* buf, ulong event_len,
1 Don't write event
*/
bool event_that_should_be_ignored(const char *buf)
bool event_that_should_be_ignored(const uchar *buf)
{
uint event_type= (uchar)buf[EVENT_TYPE_OFFSET];
uint event_type= buf[EVENT_TYPE_OFFSET];
if (event_type == GTID_LOG_EVENT ||
event_type == ANONYMOUS_GTID_LOG_EVENT ||
event_type == PREVIOUS_GTIDS_LOG_EVENT ||

View file

@ -139,8 +139,8 @@ typedef struct st_rows_event_tracker
my_off_t first_seen;
my_off_t last_seen;
bool stmt_end_seen;
void update(const char* file_name, my_off_t pos,
const char* buf,
void update(const char *file_name, my_off_t pos,
const uchar *buf,
const Format_description_log_event *fdle);
void reset();
bool check_and_report(const char* file_name, my_off_t pos);

View file

@ -288,8 +288,15 @@ table_def::~table_def()
@return TRUE if test fails
FALSE as success
@notes
event_buf will have same values on return. However during the process of
caluclating the checksum, it's temporary changed. Because of this the
event_buf argument is not a pointer to const.
*/
bool event_checksum_test(uchar *event_buf, ulong event_len, enum enum_binlog_checksum_alg alg)
bool event_checksum_test(uchar *event_buf, ulong event_len,
enum enum_binlog_checksum_alg alg)
{
bool res= FALSE;
uint16 flags= 0; // to store in FD's buffer flags orig value

View file

@ -52,10 +52,10 @@ int Repl_semi_sync_slave::init_object()
return result;
}
int Repl_semi_sync_slave::slave_read_sync_header(const char *header,
int Repl_semi_sync_slave::slave_read_sync_header(const uchar *header,
unsigned long total_len,
int *semi_flags,
const char **payload,
const uchar **payload,
unsigned long *payload_len)
{
int read_res = 0;
@ -64,7 +64,7 @@ int Repl_semi_sync_slave::slave_read_sync_header(const char *header,
if (rpl_semi_sync_slave_status)
{
if (DBUG_EVALUATE_IF("semislave_corrupt_log", 0, 1)
&& (unsigned char)(header[0]) == k_packet_magic_num)
&& header[0] == k_packet_magic_num)
{
semi_sync_need_reply = (header[1] & k_packet_flag_sync);
*payload_len = total_len - 2;

View file

@ -78,9 +78,9 @@ public:
* Return:
* 0: success; non-zero: error
*/
int slave_read_sync_header(const char *header, unsigned long total_len,
int slave_read_sync_header(const uchar *header, unsigned long total_len,
int *semi_flags,
const char **payload, unsigned long *payload_len);
const uchar **payload, unsigned long *payload_len);
/* A slave replies to the master indicating its replication process. It
* indicates that the slave has received all events before the specified

View file

@ -171,7 +171,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi);
static int safe_reconnect(THD*, MYSQL*, Master_info*, bool);
static int connect_to_master(THD*, MYSQL*, Master_info*, bool, bool);
static Log_event* next_event(rpl_group_info* rgi, ulonglong *event_size);
static int queue_event(Master_info* mi,const char* buf,ulong event_len);
static int queue_event(Master_info *mi,const uchar *buf, ulong event_len);
static int terminate_slave_thread(THD *, mysql_mutex_t *, mysql_cond_t *,
volatile uint *, bool);
static bool check_io_slave_killed(Master_info *mi, const char *info);
@ -4794,6 +4794,8 @@ connected:
thd->set_command(COM_SLAVE_IO);
while (!io_slave_killed(mi))
{
const uchar *event_buf;
THD_STAGE_INFO(thd, stage_requesting_binlog_dump);
if (request_dump(thd, mysql, mi, &suppress_warnings))
{
@ -4805,8 +4807,6 @@ connected:
goto connected;
}
const char *event_buf;
mi->slave_running= MYSQL_SLAVE_RUN_READING;
DBUG_ASSERT(mi->last_error().number == 0);
ulonglong lastchecktime = my_hrtime().val;
@ -4858,10 +4858,11 @@ Stopping slave I/O thread due to out-of-memory error from master");
retry_count=0; // ok event, reset retry counter
THD_STAGE_INFO(thd, stage_queueing_master_event_to_the_relay_log);
event_buf= (const char*)mysql->net.read_pos + 1;
event_buf= mysql->net.read_pos + 1;
mi->semi_ack= 0;
if (repl_semisync_slave.
slave_read_sync_header((const char*)mysql->net.read_pos + 1, event_len,
slave_read_sync_header((const uchar*) mysql->net.read_pos + 1,
event_len,
&(mi->semi_ack), &event_buf, &event_len))
{
mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL,
@ -5941,13 +5942,13 @@ static int process_io_rotate(Master_info *mi, Rotate_log_event *rev)
Reads a 3.23 event and converts it to the slave's format. This code was
copied from MySQL 4.0.
*/
static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
ulong event_len)
static int queue_binlog_ver_1_event(Master_info *mi, const uchar *buf,
ulong event_len)
{
const char *errmsg = 0;
ulong inc_pos;
bool ignore_event= 0;
char *tmp_buf = 0;
uchar *tmp_buf = 0;
Relay_log_info *rli= &mi->rli;
DBUG_ENTER("queue_binlog_ver_1_event");
@ -5957,8 +5958,8 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
*/
if ((uchar)buf[EVENT_TYPE_OFFSET] == LOAD_EVENT)
{
if (unlikely(!(tmp_buf=(char*)my_malloc(key_memory_binlog_ver_1_event,
event_len+1,MYF(MY_WME)))))
if (unlikely(!(tmp_buf= (uchar*) my_malloc(key_memory_binlog_ver_1_event,
event_len+1, MYF(MY_WME)))))
{
mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL,
ER(ER_SLAVE_FATAL_ERROR), "Memory allocation failed");
@ -5974,7 +5975,7 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
*/
tmp_buf[event_len++]=0;
int4store(tmp_buf+EVENT_LEN_OFFSET, event_len);
buf = (const char*)tmp_buf;
buf= tmp_buf;
}
/*
This will transform LOAD_EVENT into CREATE_FILE_EVENT, ask the master to
@ -6061,8 +6062,8 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
Reads a 4.0 event and converts it to the slave's format. This code was copied
from queue_binlog_ver_1_event(), with some affordable simplifications.
*/
static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
ulong event_len)
static int queue_binlog_ver_3_event(Master_info *mi, const uchar *buf,
ulong event_len)
{
const char *errmsg = 0;
ulong inc_pos;
@ -6072,7 +6073,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
/* read_log_event() will adjust log_pos to be end_log_pos */
Log_event *ev=
Log_event::read_log_event(buf,event_len, &errmsg,
Log_event::read_log_event(buf, event_len, &errmsg,
mi->rli.relay_log.description_event_for_queue, 0);
if (unlikely(!ev))
{
@ -6127,13 +6128,11 @@ err:
setup with 3.23 master or 4.0 master
*/
static int queue_old_event(Master_info *mi, const char *buf,
ulong event_len)
static int queue_old_event(Master_info *mi, const uchar *buf, ulong event_len)
{
DBUG_ENTER("queue_old_event");
switch (mi->rli.relay_log.description_event_for_queue->binlog_version)
{
switch (mi->rli.relay_log.description_event_for_queue->binlog_version) {
case 1:
DBUG_RETURN(queue_binlog_ver_1_event(mi,buf,event_len));
case 3:
@ -6155,7 +6154,7 @@ static int queue_old_event(Master_info *mi, const char *buf,
any >=5.0.0 format.
*/
static int queue_event(Master_info* mi,const char* buf, ulong event_len)
static int queue_event(Master_info* mi, const uchar *buf, ulong event_len)
{
int error= 0;
StringBuffer<1024> error_msg;
@ -6170,8 +6169,8 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
rpl_gtid event_gtid;
static uint dbug_rows_event_count __attribute__((unused))= 0;
bool is_compress_event = false;
char* new_buf = NULL;
char new_buf_arr[4096];
uchar *new_buf = NULL;
uchar new_buf_arr[4096];
bool is_malloc = false;
bool is_rows_event= false;
/*
@ -6184,8 +6183,8 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF ?
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 rot_buf[LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN + FN_REFLEN];
const uchar *save_buf= NULL; // needed for checksumming the fake Rotate event
uchar rot_buf[LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN + FN_REFLEN];
DBUG_ASSERT(checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
@ -6219,9 +6218,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
// Emulate the network corruption
DBUG_EXECUTE_IF("corrupt_queue_event",
if ((uchar)buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT)
if (buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT)
{
char *debug_event_buf_c = (char*) buf;
uchar *debug_event_buf_c= const_cast<uchar*>(buf);
int debug_cor_pos = rand() % (event_len - BINLOG_CHECKSUM_LEN);
debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
DBUG_PRINT("info", ("Corrupt the event at queue_event: byte on position %d", debug_cor_pos));
@ -6229,7 +6228,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
}
);
if (event_checksum_test((uchar *) buf, event_len, checksum_alg))
if (event_checksum_test((uchar*) buf, event_len, checksum_alg))
{
error= ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE;
unlock_data_lock= FALSE;
@ -6237,7 +6236,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
}
if (mi->rli.relay_log.description_event_for_queue->binlog_version<4 &&
(uchar)buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */)
buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */)
DBUG_RETURN(queue_old_event(mi,buf,event_len));
#ifdef ENABLED_DEBUG_SYNC
@ -6263,7 +6262,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
#endif
mysql_mutex_lock(&mi->data_lock);
switch ((uchar)buf[EVENT_TYPE_OFFSET]) {
switch (buf[EVENT_TYPE_OFFSET]) {
case STOP_EVENT:
/*
We needn't write this event to the relay log. Indeed, it just indicates a
@ -6398,7 +6397,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
mi->rli.relay_log.relay_log_checksum_alg);
/* the first one */
DBUG_ASSERT(mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF);
save_buf= (char *) buf;
save_buf= buf;
buf= rot_buf;
}
else
@ -6418,7 +6417,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
mi->rli.relay_log.relay_log_checksum_alg);
/* the first one */
DBUG_ASSERT(mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF);
save_buf= (char *) buf;
save_buf= buf;
buf= rot_buf;
}
/*
@ -6503,7 +6502,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
error= ER_SLAVE_HEARTBEAT_FAILURE;
error_msg.append(STRING_WITH_LEN("inconsistent heartbeat event content;"));
error_msg.append(STRING_WITH_LEN("the event's data: log_file_name "));
error_msg.append(hb.get_log_ident(), (uint) hb.get_ident_len());
error_msg.append((char*) hb.get_log_ident(), (uint) hb.get_ident_len());
error_msg.append(STRING_WITH_LEN(" log_pos "));
error_msg.append_ulonglong(hb.log_pos);
goto err;
@ -6529,7 +6528,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
error= ER_SLAVE_HEARTBEAT_FAILURE;
error_msg.append(STRING_WITH_LEN("heartbeat is not compatible with local info;"));
error_msg.append(STRING_WITH_LEN("the event's data: log_file_name "));
error_msg.append(hb.get_log_ident(), (uint) hb.get_ident_len());
error_msg.append((char*) hb.get_log_ident(), (uint) hb.get_ident_len());
error_msg.append(STRING_WITH_LEN(" log_pos "));
error_msg.append_ulonglong(hb.log_pos);
goto err;
@ -6712,7 +6711,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
if (query_event_uncompress(rli->relay_log.description_event_for_queue,
checksum_alg == BINLOG_CHECKSUM_ALG_CRC32,
buf, event_len, new_buf_arr, sizeof(new_buf_arr),
&is_malloc, (char **)&new_buf, &event_len))
&is_malloc, &new_buf, &event_len))
{
char llbuf[22];
error = ER_BINLOG_UNCOMPRESS_ERROR;
@ -6735,8 +6734,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
{
if (row_log_event_uncompress(rli->relay_log.description_event_for_queue,
checksum_alg == BINLOG_CHECKSUM_ALG_CRC32,
buf, event_len, new_buf_arr, sizeof(new_buf_arr),
&is_malloc, (char **)&new_buf, &event_len))
buf, event_len, new_buf_arr,
sizeof(new_buf_arr),
&is_malloc, &new_buf, &event_len))
{
char llbuf[22];
error = ER_BINLOG_UNCOMPRESS_ERROR;
@ -6817,7 +6817,8 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
{
if ((uchar)buf[EVENT_TYPE_OFFSET] == XID_EVENT ||
((uchar)buf[EVENT_TYPE_OFFSET] == QUERY_EVENT && /* QUERY_COMPRESSED_EVENT would never be commmit or rollback */
Query_log_event::peek_is_commit_rollback(buf, event_len,
Query_log_event::peek_is_commit_rollback(buf,
event_len,
checksum_alg)))
{
error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE;
@ -8073,19 +8074,19 @@ bool rpl_master_erroneous_autoinc(THD *thd)
}
static bool get_row_event_stmt_end(const char* buf,
static bool get_row_event_stmt_end(const uchar *buf,
const Format_description_log_event *fdle)
{
uint8 const common_header_len= fdle->common_header_len;
Log_event_type event_type= (Log_event_type)(uchar)buf[EVENT_TYPE_OFFSET];
uint8 const post_header_len= fdle->post_header_len[event_type-1];
const char *flag_start= buf + common_header_len;
const uchar *flag_start= buf + common_header_len;
/*
The term 4 below signifies that master is of 'an intermediate source', see
Rows_log_event::Rows_log_event.
*/
flag_start += RW_MAPID_OFFSET + ((post_header_len == 6) ? 4 : RW_FLAGS_OFFSET);
flag_start += RW_MAPID_OFFSET + ((post_header_len == 6) ? 4 : RW_FLAGS_OFFSET);
return (uint2korr(flag_start) & Rows_log_event::STMT_END_F) != 0;
}
@ -8110,8 +8111,8 @@ void Rows_event_tracker::reset()
well as the end-of-statement status of the last one.
*/
void Rows_event_tracker::update(const char* file_name, my_off_t pos,
const char* buf,
void Rows_event_tracker::update(const char *file_name, my_off_t pos,
const uchar *buf,
const Format_description_log_event *fdle)
{
DBUG_ENTER("Rows_event_tracker::update");

View file

@ -207,7 +207,7 @@ void mysql_client_binlog_statement(THD* thd)
int err;
Relay_log_info *rli;
rpl_group_info *rgi;
char *buf= NULL;
uchar *buf= NULL;
size_t coded_len= 0, decoded_len= 0;
rli= thd->rli_fake;
@ -243,7 +243,7 @@ void mysql_client_binlog_statement(THD* thd)
}
decoded_len= my_base64_needed_decoded_length((int)coded_len);
if (!(buf= (char *) my_malloc(key_memory_binlog_statement_buffer,
if (!(buf= (uchar *) my_malloc(key_memory_binlog_statement_buffer,
decoded_len, MYF(MY_WME))))
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), 1);
@ -299,7 +299,7 @@ void mysql_client_binlog_statement(THD* thd)
Now we start to read events of the buffer, until there are no
more.
*/
for (char *bufptr= buf ; bytes_decoded > 0 ; )
for (uchar *bufptr= buf ; bytes_decoded > 0 ; )
{
/*
Checking that the first event in the buffer is not truncated.

View file

@ -1519,9 +1519,10 @@ gtid_state_from_pos(const char *name, uint32 offset,
goto end;
}
current_checksum_alg= get_checksum_alg(packet.ptr(), packet.length());
current_checksum_alg= get_checksum_alg((uchar*) packet.ptr(),
packet.length());
found_format_description_event= true;
if (unlikely(!(tmp= new Format_description_log_event(packet.ptr(),
if (unlikely(!(tmp= new Format_description_log_event((uchar*) packet.ptr(),
packet.length(),
fdev))))
{
@ -1539,7 +1540,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
{
sele_len -= BINLOG_CHECKSUM_LEN;
}
Start_encryption_log_event sele(packet.ptr(), sele_len, fdev);
Start_encryption_log_event sele((uchar*) packet.ptr(), sele_len, fdev);
if (fdev->start_decryption(&sele))
{
errormsg= "Could not start decryption of binlog.";
@ -1596,7 +1597,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
{
rpl_gtid gtid;
uchar flags2;
if (unlikely(Gtid_log_event::peek(packet.ptr(), packet.length(),
if (unlikely(Gtid_log_event::peek((uchar*) packet.ptr(), packet.length(),
current_checksum_alg, &gtid.domain_id,
&gtid.server_id, &gtid.seq_no, &flags2,
fdev)))
@ -1682,9 +1683,9 @@ is_until_reached(binlog_send_info *info, ulong *ev_offset,
if (event_type != XID_EVENT && event_type != XA_PREPARE_LOG_EVENT &&
(event_type != QUERY_EVENT || /* QUERY_COMPRESSED_EVENT would never be commmit or rollback */
!Query_log_event::peek_is_commit_rollback
(info->packet->ptr()+*ev_offset,
info->packet->length()-*ev_offset,
info->current_checksum_alg)))
((uchar*) info->packet->ptr() + *ev_offset,
info->packet->length() - *ev_offset,
info->current_checksum_alg)))
return false;
break;
}
@ -1762,7 +1763,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
rpl_gtid event_gtid;
if (ev_offset > len ||
Gtid_log_event::peek(packet->ptr()+ev_offset, len - ev_offset,
Gtid_log_event::peek((uchar*) packet->ptr()+ev_offset, len - ev_offset,
current_checksum_alg,
&event_gtid.domain_id, &event_gtid.server_id,
&event_gtid.seq_no, &flags2, info->fdev))
@ -1916,7 +1917,8 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
case GTID_SKIP_TRANSACTION:
if (event_type == XID_EVENT || event_type == XA_PREPARE_LOG_EVENT ||
(event_type == QUERY_EVENT && /* QUERY_COMPRESSED_EVENT would never be commmit or rollback */
Query_log_event::peek_is_commit_rollback(packet->ptr() + ev_offset,
Query_log_event::peek_is_commit_rollback((uchar*) packet->ptr() +
ev_offset,
len - ev_offset,
current_checksum_alg)))
info->gtid_skip_group= GTID_SKIP_NOT;
@ -2320,7 +2322,8 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
DBUG_RETURN(1);
}
info->current_checksum_alg= get_checksum_alg(packet->ptr() + ev_offset,
info->current_checksum_alg= get_checksum_alg((uchar*) packet->ptr() +
ev_offset,
packet->length() - ev_offset);
DBUG_ASSERT(info->current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
@ -2345,7 +2348,7 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
ev_len-= BINLOG_CHECKSUM_LEN;
Format_description_log_event *tmp;
if (!(tmp= new Format_description_log_event(packet->ptr() + ev_offset,
if (!(tmp= new Format_description_log_event((uchar*) packet->ptr() + ev_offset,
ev_len, info->fdev)))
{
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
@ -2437,7 +2440,8 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
if (event_type == START_ENCRYPTION_EVENT)
{
Start_encryption_log_event *sele= (Start_encryption_log_event *)
Log_event::read_log_event(packet->ptr() + ev_offset, packet->length()
Log_event::read_log_event((uchar*) packet->ptr() + ev_offset,
packet->length()
- ev_offset, &info->errmsg, info->fdev,
BINLOG_CHECKSUM_ALG_OFF);
if (!sele)

View file

@ -39,7 +39,7 @@ static Log_event* wsrep_read_log_event(
char *head= (*arg_buf);
uint data_len= uint4korr(head + EVENT_LEN_OFFSET);
char *buf= (*arg_buf);
uchar *buf= (uchar*) (*arg_buf);
const char *error= 0;
Log_event *res= 0;