diff options
-rw-r--r-- | client/mysqlbinlog.cc | 17 | ||||
-rw-r--r-- | sql/log_event.cc | 627 | ||||
-rw-r--r-- | sql/log_event.h | 159 | ||||
-rw-r--r-- | sql/log_event_client.cc | 46 | ||||
-rw-r--r-- | sql/log_event_old.cc | 37 | ||||
-rw-r--r-- | sql/log_event_old.h | 8 | ||||
-rw-r--r-- | sql/log_event_server.cc | 51 | ||||
-rw-r--r-- | sql/rpl_mi.h | 4 | ||||
-rw-r--r-- | sql/rpl_utility.cc | 9 | ||||
-rw-r--r-- | sql/semisync_slave.cc | 6 | ||||
-rw-r--r-- | sql/semisync_slave.h | 4 | ||||
-rw-r--r-- | sql/slave.cc | 83 | ||||
-rw-r--r-- | sql/sql_binlog.cc | 6 | ||||
-rw-r--r-- | sql/sql_repl.cc | 28 | ||||
-rw-r--r-- | sql/wsrep_applier.cc | 2 |
15 files changed, 555 insertions, 532 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 81c2e66be46..0d4ec1d50af 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -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) { diff --git a/sql/log_event.cc b/sql/log_event.cc index b35ed1884cb..321980f0a16 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -52,6 +52,7 @@ #include "rpl_constants.h" #include "sql_digest.h" #include "zlib.h" +#include "myisampack.h" #define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1)) @@ -143,7 +144,7 @@ public: constructor, but it would be possible to create a subclass holding the IO_CACHE itself. */ - Write_on_release_cache(IO_CACHE *cache, FILE *file, flag_set flags = 0, Log_event *ev = NULL) + Write_on_release_cache(IO_CACHE *cache, FILE *file, flag_set flags= 0, Log_event *ev= NULL) : m_cache(cache), m_file(file), m_flags(flags), m_ev(ev) { reinit_io_cache(m_cache, WRITE_CACHE, 0L, FALSE, TRUE); @@ -238,13 +239,13 @@ private: read_str() */ -static inline int read_str(const char **buf, const char *buf_end, - const char **str, uint8 *len) +static inline bool read_str(const uchar **buf, const uchar *buf_end, + const char **str, uint8 *len) { - if (*buf + ((uint) (uchar) **buf) >= buf_end) + if (*buf + ((uint) **buf) >= buf_end) return 1; *len= (uint8) **buf; - *str= (*buf)+1; + *str= (char*) (*buf)+1; (*buf)+= (uint) *len+1; return 0; } @@ -304,44 +305,44 @@ uint32 binlog_get_compress_len(uint32 len) return zero if successful, others otherwise. */ -int binlog_buf_compress(const char *src, char *dst, uint32 len, uint32 *comlen) +int binlog_buf_compress(const uchar *src, uchar *dst, uint32 len, uint32 *comlen) { uchar lenlen; if (len & 0xFF000000) { - dst[1] = uchar(len >> 24); - dst[2] = uchar(len >> 16); - dst[3] = uchar(len >> 8); - dst[4] = uchar(len); - lenlen = 4; + dst[1]= uchar(len >> 24); + dst[2]= uchar(len >> 16); + dst[3]= uchar(len >> 8); + dst[4]= uchar(len); + lenlen= 4; } else if (len & 0x00FF0000) { - dst[1] = uchar(len >> 16); - dst[2] = uchar(len >> 8); - dst[3] = uchar(len); - lenlen = 3; + dst[1]= uchar(len >> 16); + dst[2]= uchar(len >> 8); + dst[3]= uchar(len); + lenlen= 3; } else if (len & 0x0000FF00) { - dst[1] = uchar(len >> 8); - dst[2] = uchar(len); - lenlen = 2; + dst[1]= uchar(len >> 8); + dst[2]= uchar(len); + lenlen= 2; } else { - dst[1] = uchar(len); - lenlen = 1; + dst[1]= uchar(len); + lenlen= 1; } - dst[0] = 0x80 | (lenlen & 0x07); + dst[0]= 0x80 | (lenlen & 0x07); - uLongf tmplen = (uLongf)*comlen - BINLOG_COMPRESSED_HEADER_LEN - lenlen - 1; + uLongf tmplen= (uLongf)*comlen - BINLOG_COMPRESSED_HEADER_LEN - lenlen - 1; if (compress((Bytef *)dst + BINLOG_COMPRESSED_HEADER_LEN + lenlen, &tmplen, (const Bytef *)src, (uLongf)len) != Z_OK) { return 1; } - *comlen = (uint32)tmplen + BINLOG_COMPRESSED_HEADER_LEN + lenlen; + *comlen= (uint32)tmplen + BINLOG_COMPRESSED_HEADER_LEN + lenlen; return 0; } @@ -360,16 +361,17 @@ int binlog_buf_compress(const char *src, char *dst, uint32 len, uint32 *comlen) 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, + bool contain_checksum, const uchar *src, ulong src_len, + uchar* buf, ulong buf_size, bool* is_malloc, uchar **dst, ulong *newlen) { - ulong len = uint4korr(src + EVENT_LEN_OFFSET); - const char *tmp = src; - const char *end = src + len; + ulong len= uint4korr(src + EVENT_LEN_OFFSET); + const uchar *tmp= src; + const uchar *end= src + len; + uchar *new_dst; // bad event - if (src_len < len ) + if (src_len < len) return 1; DBUG_ASSERT((uchar)src[EVENT_TYPE_OFFSET] == QUERY_COMPRESSED_EVENT); @@ -378,97 +380,90 @@ query_event_uncompress(const Format_description_log_event *description_event, uint8 post_header_len= description_event->post_header_len[QUERY_COMPRESSED_EVENT-1]; - *is_malloc = false; + *is_malloc= false; - tmp += common_header_len; + tmp+= common_header_len; // bad event if (end <= tmp) return 1; - uint db_len = (uint)tmp[Q_DB_LEN_OFFSET]; + uint db_len= (uint)tmp[Q_DB_LEN_OFFSET]; uint16 status_vars_len= uint2korr(tmp + Q_STATUS_VARS_LEN_OFFSET); - tmp += post_header_len + status_vars_len + db_len + 1; + tmp+= post_header_len + status_vars_len + db_len + 1; // bad event if (end <= tmp) return 1; - int32 comp_len = (int32)(len - (tmp - src) - - (contain_checksum ? BINLOG_CHECKSUM_LEN : 0)); - uint32 un_len = binlog_get_uncompress_len(tmp); + int32 comp_len= (int32)(len - (tmp - src) - + (contain_checksum ? BINLOG_CHECKSUM_LEN : 0)); + uint32 un_len= binlog_get_uncompress_len(tmp); // bad event if (comp_len < 0 || un_len == 0) return 1; - *newlen = (ulong)(tmp - src) + un_len; - if(contain_checksum) - *newlen += BINLOG_CHECKSUM_LEN; + *newlen= (ulong)(tmp - src) + un_len; + if (contain_checksum) + *newlen+= BINLOG_CHECKSUM_LEN; - uint32 alloc_size = (uint32)ALIGN_SIZE(*newlen); - char *new_dst = NULL; - + uint32 alloc_size= (uint32)ALIGN_SIZE(*newlen); if (alloc_size <= buf_size) - { - new_dst = buf; - } + new_dst= buf; else { - new_dst = (char *)my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME)); + new_dst= (uchar *) my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME)); if (!new_dst) return 1; - - *is_malloc = true; + *is_malloc= true; } /* copy the head*/ memcpy(new_dst, src , tmp - src); - if (binlog_buf_uncompress(tmp, new_dst + (tmp - src), - comp_len, &un_len)) + if (binlog_buf_uncompress(tmp, new_dst + (tmp - src), comp_len, &un_len)) { if (*is_malloc) + { + *is_malloc= false; my_free(new_dst); - - *is_malloc = false; - + } return 1; } - new_dst[EVENT_TYPE_OFFSET] = QUERY_EVENT; + new_dst[EVENT_TYPE_OFFSET]= QUERY_EVENT; int4store(new_dst + EVENT_LEN_OFFSET, *newlen); - if(contain_checksum) + if (contain_checksum) { - ulong clear_len = *newlen - BINLOG_CHECKSUM_LEN; + ulong clear_len= *newlen - BINLOG_CHECKSUM_LEN; int4store(new_dst + clear_len, my_checksum(0L, (uchar *)new_dst, clear_len)); } - *dst = new_dst; + *dst= new_dst; return 0; } 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) + bool contain_checksum, const uchar *src, ulong src_len, + uchar* buf, ulong buf_size, bool* is_malloc, + uchar **dst, ulong *newlen) { - Log_event_type type = (Log_event_type)(uchar)src[EVENT_TYPE_OFFSET]; - ulong len = uint4korr(src + EVENT_LEN_OFFSET); - const char *tmp = src; - char *new_dst = NULL; - const char *end = tmp + len; + Log_event_type type= (Log_event_type)(uchar)src[EVENT_TYPE_OFFSET]; + ulong len= uint4korr(src + EVENT_LEN_OFFSET); + const uchar *tmp= src; + uchar *new_dst= NULL; + const uchar *end= tmp + len; - // bad event if (src_len < len) - return 1; + return 1; // bad event DBUG_ASSERT(LOG_EVENT_IS_ROW_COMPRESSED(type)); uint8 common_header_len= description_event->common_header_len; uint8 post_header_len= description_event->post_header_len[type-1]; - tmp += common_header_len + ROWS_HEADER_LEN_V1; + tmp+= common_header_len + ROWS_HEADER_LEN_V1; if (post_header_len == ROWS_HEADER_LEN_V2) { /* @@ -476,15 +471,14 @@ row_log_event_uncompress(const Format_description_log_event *description_event, which includes length bytes */ - // bad event if (end - tmp <= 2) - return 1; + return 1; // bad event uint16 var_header_len= uint2korr(tmp); DBUG_ASSERT(var_header_len >= 2); /* skip over var-len header, extracting 'chunks' */ - tmp += var_header_len; + tmp+= var_header_len; /* get the uncompressed event type */ type= @@ -497,51 +491,46 @@ row_log_event_uncompress(const Format_description_log_event *description_event, (type - WRITE_ROWS_COMPRESSED_EVENT_V1 + WRITE_ROWS_EVENT_V1); } - //bad event if (end <= tmp) - return 1; + return 1; //bad event - ulong m_width = net_field_length((uchar **)&tmp); - tmp += (m_width + 7) / 8; + ulong m_width= net_field_length((uchar **)&tmp); + tmp+= (m_width + 7) / 8; if (type == UPDATE_ROWS_EVENT_V1 || type == UPDATE_ROWS_EVENT) { - tmp += (m_width + 7) / 8; + tmp+= (m_width + 7) / 8; } - //bad event if (end <= tmp) - return 1; + return 1; //bad event - uint32 un_len = binlog_get_uncompress_len(tmp); - //bad event + uint32 un_len= binlog_get_uncompress_len(tmp); if (un_len == 0) - return 1; + return 1; //bad event - int32 comp_len = (int32)(len - (tmp - src) - - (contain_checksum ? BINLOG_CHECKSUM_LEN : 0)); - //bad event + int32 comp_len= (int32)(len - (tmp - src) - + (contain_checksum ? BINLOG_CHECKSUM_LEN : 0)); if (comp_len <=0) - return 1; + return 1; //bad event - *newlen = ulong(tmp - src) + un_len; - if(contain_checksum) - *newlen += BINLOG_CHECKSUM_LEN; + *newlen= ulong(tmp - src) + un_len; + if (contain_checksum) + *newlen+= BINLOG_CHECKSUM_LEN; - size_t alloc_size = ALIGN_SIZE(*newlen); + size_t alloc_size= ALIGN_SIZE(*newlen); - *is_malloc = false; + *is_malloc= false; if (alloc_size <= buf_size) { - new_dst = buf; + new_dst= buf; } else { - new_dst = (char *)my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME)); + new_dst= (uchar*) my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME)); if (!new_dst) return 1; - - *is_malloc = true; + *is_malloc= true; } /* Copy the head. */ @@ -552,18 +541,18 @@ row_log_event_uncompress(const Format_description_log_event *description_event, { if (*is_malloc) my_free(new_dst); - return 1; } - new_dst[EVENT_TYPE_OFFSET] = type; + new_dst[EVENT_TYPE_OFFSET]= type; int4store(new_dst + EVENT_LEN_OFFSET, *newlen); - if(contain_checksum){ - ulong clear_len = *newlen - BINLOG_CHECKSUM_LEN; + if (contain_checksum) + { + ulong clear_len= *newlen - BINLOG_CHECKSUM_LEN; int4store(new_dst + clear_len, my_checksum(0L, (uchar *)new_dst, clear_len)); } - *dst = new_dst; + *dst= new_dst; return 0; } @@ -572,33 +561,33 @@ row_log_event_uncompress(const Format_description_log_event *description_event, return 0 means error. */ -uint32 binlog_get_uncompress_len(const char *buf) +uint32 binlog_get_uncompress_len(const uchar *buf) { - uint32 len = 0; - uint32 lenlen = 0; + uint32 len, lenlen; if ((buf == NULL) || ((buf[0] & 0xe0) != 0x80)) - return len; + return 0; - lenlen = buf[0] & 0x07; + lenlen= buf[0] & 0x07; - switch(lenlen) - { + buf++; + /* Length is stored in high byte first order, like myisam keys */ + switch(lenlen) { case 1: - len = uchar(buf[1]); + len= buf[0]; break; case 2: - len = uchar(buf[1]) << 8 | uchar(buf[2]); + len= mi_uint2korr(buf); break; case 3: - len = uchar(buf[1]) << 16 | uchar(buf[2]) << 8 | uchar(buf[3]); + len= mi_uint3korr(buf); break; case 4: - len = uchar(buf[1]) << 24 | uchar(buf[2]) << 16 | - uchar(buf[3]) << 8 | uchar(buf[4]); + len= mi_uint4korr(buf); break; default: DBUG_ASSERT(lenlen >= 1 && lenlen <= 4); + len= 0; break; } return len; @@ -615,27 +604,22 @@ uint32 binlog_get_uncompress_len(const char *buf) return zero if successful, others otherwise. */ -int binlog_buf_uncompress(const char *src, char *dst, uint32 len, +int binlog_buf_uncompress(const uchar *src, uchar *dst, uint32 len, uint32 *newlen) { - if((src[0] & 0x80) == 0) - { + if ((src[0] & 0x80) == 0) return 1; - } uint32 lenlen= src[0] & 0x07; - uLongf buflen= *newlen; + uLongf buflen= *newlen; // zlib type - uint32 alg = (src[0] & 0x70) >> 4; - switch(alg) - { + uint32 alg= (src[0] & 0x70) >> 4; + switch(alg) { case 0: // zlib - if(uncompress((Bytef *)dst, &buflen, + if (uncompress((Bytef *)dst, &buflen, (const Bytef*)src + 1 + lenlen, len - 1 - lenlen) != Z_OK) - { return 1; - } break; default: //TODO @@ -644,7 +628,7 @@ int binlog_buf_uncompress(const char *src, char *dst, uint32 len, } DBUG_ASSERT(*newlen == (uint32)buflen); - *newlen = (uint32)buflen; + *newlen= (uint32)buflen; return 0; } @@ -728,17 +712,17 @@ const char* Log_event::get_type_str() Log_event::Log_event() */ -Log_event::Log_event(const char* buf, +Log_event::Log_event(const uchar *buf, const Format_description_log_event* description_event) :temp_buf(0), exec_time(0), cache_type(Log_event::EVENT_INVALID_CACHE), checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF) { #ifndef MYSQL_CLIENT - thd = 0; + thd= 0; #endif - when = uint4korr(buf); + when= uint4korr(buf); when_sec_part= ~0UL; - server_id = uint4korr(buf + SERVER_ID_OFFSET); + server_id= uint4korr(buf + SERVER_ID_OFFSET); data_written= uint4korr(buf + EVENT_LEN_OFFSET); if (description_event->binlog_version==1) { @@ -876,7 +860,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, WolfSSL reads memory out of bounds with decryption/NOPAD) We allocate a little more memory therefore. */ - sz += MY_AES_BLOCK_SIZE; + sz+= MY_AES_BLOCK_SIZE; #endif char *newpkt= (char*)my_malloc(PSI_INSTRUMENT_ME, sz, MYF(MY_WME)); if (!newpkt) @@ -909,10 +893,10 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, { /* Corrupt the event for Dump thread*/ DBUG_EXECUTE_IF("corrupt_read_log_event2", - uchar *debug_event_buf_c = (uchar*) packet->ptr() + ev_offset; + uchar *debug_event_buf_c= (uchar*) packet->ptr() + ev_offset; if (debug_event_buf_c[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT) { - int debug_cor_pos = rand() % (data_len - BINLOG_CHECKSUM_LEN); + int debug_cor_pos= rand() % (data_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 Log_event::read_log_event: byte on position %d", debug_cor_pos)); DBUG_SET("-d,corrupt_read_log_event2"); @@ -966,9 +950,9 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, goto err; } - if ((res= read_log_event(event.ptr(), event.length(), + if ((res= read_log_event((uchar*) event.ptr(), event.length(), &error, fdle, crc_check))) - res->register_temp_buf(event.release(), true); + res->register_temp_buf((uchar*) event.release(), true); err: if (unlikely(error)) @@ -1004,8 +988,8 @@ err: constructors. */ -Log_event* Log_event::read_log_event(const char* buf, uint event_len, - const char **error, +Log_event* Log_event::read_log_event(const uchar *buf, uint event_len, + const char **error, const Format_description_log_event *fdle, my_bool crc_check) { @@ -1026,7 +1010,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, DBUG_RETURN(NULL); // general sanity check - will fail on a partial read } - uint event_type= (uchar)buf[EVENT_TYPE_OFFSET]; + uint event_type= buf[EVENT_TYPE_OFFSET]; // all following START events in the current file are without checksum if (event_type == START_EVENT_V3) (const_cast< Format_description_log_event *>(fdle))->checksum_alg= BINLOG_CHECKSUM_ALG_OFF; @@ -1055,15 +1039,14 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, DBUG_EXECUTE_IF("corrupt_read_log_event_char", if (event_type != FORMAT_DESCRIPTION_EVENT) { - char *debug_event_buf_c = (char *)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]; + 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 Log_event::read_log_event(char*,...): byte on position %d", debug_cor_pos)); DBUG_SET("-d,corrupt_read_log_event_char"); } ); - if (crc_check && - event_checksum_test((uchar *) buf, event_len, alg)) + if (crc_check && event_checksum_test(const_cast<uchar*>(buf), event_len, alg)) { #ifdef MYSQL_CLIENT *error= "Event crc check failed! Most likely there is event corruption."; @@ -1135,100 +1118,100 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, } switch(event_type) { case QUERY_EVENT: - ev = new Query_log_event(buf, event_len, fdle, QUERY_EVENT); + ev= new Query_log_event(buf, event_len, fdle, QUERY_EVENT); break; case QUERY_COMPRESSED_EVENT: - ev = new Query_compressed_log_event(buf, event_len, fdle, + ev= new Query_compressed_log_event(buf, event_len, fdle, QUERY_COMPRESSED_EVENT); break; case LOAD_EVENT: - ev = new Load_log_event(buf, event_len, fdle); + ev= new Load_log_event(buf, event_len, fdle); break; case NEW_LOAD_EVENT: - ev = new Load_log_event(buf, event_len, fdle); + ev= new Load_log_event(buf, event_len, fdle); break; case ROTATE_EVENT: - ev = new Rotate_log_event(buf, event_len, fdle); + ev= new Rotate_log_event(buf, event_len, fdle); break; case BINLOG_CHECKPOINT_EVENT: - ev = new Binlog_checkpoint_log_event(buf, event_len, fdle); + ev= new Binlog_checkpoint_log_event(buf, event_len, fdle); break; case GTID_EVENT: - ev = new Gtid_log_event(buf, event_len, fdle); + ev= new Gtid_log_event(buf, event_len, fdle); break; case GTID_LIST_EVENT: - ev = new Gtid_list_log_event(buf, event_len, fdle); + ev= new Gtid_list_log_event(buf, event_len, fdle); break; case CREATE_FILE_EVENT: - ev = new Create_file_log_event(buf, event_len, fdle); + ev= new Create_file_log_event(buf, event_len, fdle); break; case APPEND_BLOCK_EVENT: - ev = new Append_block_log_event(buf, event_len, fdle); + ev= new Append_block_log_event(buf, event_len, fdle); break; case DELETE_FILE_EVENT: - ev = new Delete_file_log_event(buf, event_len, fdle); + ev= new Delete_file_log_event(buf, event_len, fdle); break; case EXEC_LOAD_EVENT: - ev = new Execute_load_log_event(buf, event_len, fdle); + ev= new Execute_load_log_event(buf, event_len, fdle); break; case START_EVENT_V3: /* this is sent only by MySQL <=4.x */ - ev = new Start_log_event_v3(buf, event_len, fdle); + ev= new Start_log_event_v3(buf, event_len, fdle); break; case STOP_EVENT: - ev = new Stop_log_event(buf, fdle); + ev= new Stop_log_event(buf, fdle); break; case INTVAR_EVENT: - ev = new Intvar_log_event(buf, fdle); + ev= new Intvar_log_event(buf, fdle); break; case XID_EVENT: - ev = new Xid_log_event(buf, fdle); + ev= new Xid_log_event(buf, fdle); break; case XA_PREPARE_LOG_EVENT: - ev = new XA_prepare_log_event(buf, fdle); + ev= new XA_prepare_log_event(buf, fdle); break; case RAND_EVENT: - ev = new Rand_log_event(buf, fdle); + ev= new Rand_log_event(buf, fdle); break; case USER_VAR_EVENT: - ev = new User_var_log_event(buf, event_len, fdle); + ev= new User_var_log_event(buf, event_len, fdle); break; case FORMAT_DESCRIPTION_EVENT: - ev = new Format_description_log_event(buf, event_len, fdle); + ev= new Format_description_log_event(buf, event_len, fdle); break; #if defined(HAVE_REPLICATION) case PRE_GA_WRITE_ROWS_EVENT: - ev = new Write_rows_log_event_old(buf, event_len, fdle); + ev= new Write_rows_log_event_old(buf, event_len, fdle); break; case PRE_GA_UPDATE_ROWS_EVENT: - ev = new Update_rows_log_event_old(buf, event_len, fdle); + ev= new Update_rows_log_event_old(buf, event_len, fdle); break; case PRE_GA_DELETE_ROWS_EVENT: - ev = new Delete_rows_log_event_old(buf, event_len, fdle); + ev= new Delete_rows_log_event_old(buf, event_len, fdle); break; case WRITE_ROWS_EVENT_V1: case WRITE_ROWS_EVENT: - ev = new Write_rows_log_event(buf, event_len, fdle); + ev= new Write_rows_log_event(buf, event_len, fdle); break; case UPDATE_ROWS_EVENT_V1: case UPDATE_ROWS_EVENT: - ev = new Update_rows_log_event(buf, event_len, fdle); + ev= new Update_rows_log_event(buf, event_len, fdle); break; case DELETE_ROWS_EVENT_V1: case DELETE_ROWS_EVENT: - ev = new Delete_rows_log_event(buf, event_len, fdle); + ev= new Delete_rows_log_event(buf, event_len, fdle); break; case WRITE_ROWS_COMPRESSED_EVENT: case WRITE_ROWS_COMPRESSED_EVENT_V1: - ev = new Write_rows_compressed_log_event(buf, event_len, fdle); + ev= new Write_rows_compressed_log_event(buf, event_len, fdle); break; case UPDATE_ROWS_COMPRESSED_EVENT: case UPDATE_ROWS_COMPRESSED_EVENT_V1: - ev = new Update_rows_compressed_log_event(buf, event_len, fdle); + ev= new Update_rows_compressed_log_event(buf, event_len, fdle); break; case DELETE_ROWS_COMPRESSED_EVENT: case DELETE_ROWS_COMPRESSED_EVENT_V1: - ev = new Delete_rows_compressed_log_event(buf, event_len, fdle); + ev= new Delete_rows_compressed_log_event(buf, event_len, fdle); break; /* MySQL GTID events are ignored */ @@ -1242,23 +1225,23 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, break; case TABLE_MAP_EVENT: - ev = new Table_map_log_event(buf, event_len, fdle); + ev= new Table_map_log_event(buf, event_len, fdle); break; #endif case BEGIN_LOAD_QUERY_EVENT: - ev = new Begin_load_query_log_event(buf, event_len, fdle); + ev= new Begin_load_query_log_event(buf, event_len, fdle); break; case EXECUTE_LOAD_QUERY_EVENT: ev= new Execute_load_query_log_event(buf, event_len, fdle); break; case INCIDENT_EVENT: - ev = new Incident_log_event(buf, event_len, fdle); + ev= new Incident_log_event(buf, event_len, fdle); break; case ANNOTATE_ROWS_EVENT: - ev = new Annotate_rows_log_event(buf, event_len, fdle); + ev= new Annotate_rows_log_event(buf, event_len, fdle); break; case START_ENCRYPTION_EVENT: - ev = new Start_encryption_log_event(buf, event_len, fdle); + ev= new Start_encryption_log_event(buf, event_len, fdle); break; default: DBUG_PRINT("error",("Unknown event code: %d", @@ -1362,8 +1345,7 @@ get_str_len_and_pointer(const Log_event::Byte **src, return 0; } -static void copy_str_and_move(const char **src, - Log_event::Byte **dst, +static void copy_str_and_move(const char **src, Log_event::Byte **dst, size_t len) { memcpy(*dst, *src, len); @@ -1430,7 +1412,7 @@ code_name(int code) /** This is used by the SQL slave thread to prepare the event before execution. */ -Query_log_event::Query_log_event(const char* buf, uint event_len, +Query_log_event::Query_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event, Log_event_type event_type) @@ -1463,13 +1445,13 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, */ if (event_len < (uint)(common_header_len + post_header_len)) DBUG_VOID_RETURN; - data_len = event_len - (common_header_len + post_header_len); + data_len= event_len - (common_header_len + post_header_len); buf+= common_header_len; - thread_id = slave_proxy_id = uint4korr(buf + Q_THREAD_ID_OFFSET); - exec_time = uint4korr(buf + Q_EXEC_TIME_OFFSET); - db_len = (uchar)buf[Q_DB_LEN_OFFSET]; // TODO: add a check of all *_len vars - error_code = uint2korr(buf + Q_ERR_CODE_OFFSET); + thread_id= slave_proxy_id= uint4korr(buf + Q_THREAD_ID_OFFSET); + exec_time= uint4korr(buf + Q_EXEC_TIME_OFFSET); + db_len= buf[Q_DB_LEN_OFFSET]; // TODO: add a check of all *_len vars + error_code= uint2korr(buf + Q_ERR_CODE_OFFSET); /* 5.0 format starts here. @@ -1672,7 +1654,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, */ #if !defined(MYSQL_CLIENT) && defined(HAVE_QUERY_CACHE) - if (!(start= data_buf = (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME, + if (!(start= data_buf= (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME, catalog_len + 1 + time_zone_len + 1 + user.length + 1 @@ -1684,7 +1666,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, + QUERY_CACHE_FLAGS_SIZE, MYF(MY_WME)))) #else - if (!(start= data_buf = (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME, + if (!(start= data_buf= (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME, catalog_len + 1 + time_zone_len + 1 + user.length + 1 @@ -1753,11 +1735,10 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, DBUG_VOID_RETURN; } - uint32 max_length= uint32(event_len - ((const char*)(end + db_len + 1) - + uint32 max_length= uint32(event_len - ((end + db_len + 1) - (buf - common_header_len))); if (q_len != max_length || - (event_len < uint((const char*)(end + db_len + 1) - - (buf - common_header_len)))) + (event_len < uint((end + db_len + 1) - (buf - common_header_len)))) { q_len= 0; query= NULL; @@ -1774,7 +1755,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, DBUG_VOID_RETURN; } -Query_compressed_log_event::Query_compressed_log_event(const char *buf, +Query_compressed_log_event::Query_compressed_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event, @@ -1782,24 +1763,24 @@ Query_compressed_log_event::Query_compressed_log_event(const char *buf, :Query_log_event(buf, event_len, description_event, event_type), query_buf(NULL) { - if(query) + if (query) { - uint32 un_len=binlog_get_uncompress_len(query); + uint32 un_len= binlog_get_uncompress_len((uchar*) query); if (!un_len) { - query = 0; + query= 0; return; } /* Reserve one byte for '\0' */ - query_buf = (Log_event::Byte*)my_malloc(PSI_INSTRUMENT_ME, + query_buf= (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME, ALIGN_SIZE(un_len + 1), MYF(MY_WME)); - if(query_buf && - !binlog_buf_uncompress(query, (char *)query_buf, q_len, &un_len)) + if (query_buf && !binlog_buf_uncompress((uchar*) query, (uchar *) query_buf, + q_len, &un_len)) { - query_buf[un_len] = 0; - query = (const char *)query_buf; - q_len = un_len; + query_buf[un_len]= 0; + query= (char*) query_buf; + q_len= un_len; } else { @@ -1808,6 +1789,7 @@ Query_compressed_log_event::Query_compressed_log_event(const char *buf, } } + /* Replace a binlog event read into a packet with a dummy event. Either a Query_log_event that has just a comment, or if that will not fit in the @@ -1987,7 +1969,7 @@ Query_log_event::begin_event(String *packet, ulong ev_offset, **************************************************************************/ -Start_log_event_v3::Start_log_event_v3(const char* buf, uint event_len, +Start_log_event_v3::Start_log_event_v3(const uchar *buf, uint event_len, const Format_description_log_event *description_event) :Log_event(buf, description_event), binlog_version(BINLOG_VERSION) @@ -2085,9 +2067,9 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) Hence, we need to be assign some value here, to avoid reading uninitialized memory when the array is written to disk. */ - post_header_len[PRE_GA_WRITE_ROWS_EVENT-1] = 0; - post_header_len[PRE_GA_UPDATE_ROWS_EVENT-1] = 0; - post_header_len[PRE_GA_DELETE_ROWS_EVENT-1] = 0; + post_header_len[PRE_GA_WRITE_ROWS_EVENT-1]= 0; + post_header_len[PRE_GA_UPDATE_ROWS_EVENT-1]= 0; + post_header_len[PRE_GA_DELETE_ROWS_EVENT-1]= 0; post_header_len[TABLE_MAP_EVENT-1]= TABLE_MAP_HEADER_LEN; post_header_len[WRITE_ROWS_EVENT_V1-1]= ROWS_HEADER_LEN_V1; @@ -2219,10 +2201,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) */ Format_description_log_event:: -Format_description_log_event(const char* buf, - uint event_len, - const - Format_description_log_event* +Format_description_log_event(const uchar *buf, uint event_len, + const Format_description_log_event* description_event) :Start_log_event_v3(buf, event_len, description_event), common_header_len(0), post_header_len(NULL), event_type_permutation(0) @@ -2353,7 +2333,7 @@ Format_description_log_event::is_version_before_checksum(const master_version_sp checksum-unaware (effectively no checksum) and the actuall [1-254] range alg descriptor. */ -enum enum_binlog_checksum_alg get_checksum_alg(const char* buf, ulong len) +enum enum_binlog_checksum_alg get_checksum_alg(const uchar *buf, ulong len) { enum enum_binlog_checksum_alg ret; char version[ST_SERVER_VER_LEN]; @@ -2376,17 +2356,17 @@ enum enum_binlog_checksum_alg get_checksum_alg(const char* buf, ulong len) DBUG_RETURN(ret); } -Start_encryption_log_event::Start_encryption_log_event( - const char* buf, uint event_len, - const Format_description_log_event* description_event) +Start_encryption_log_event:: +Start_encryption_log_event(const uchar *buf, uint event_len, + const Format_description_log_event* description_event) :Log_event(buf, description_event) { if ((int)event_len == LOG_EVENT_MINIMAL_HEADER_LEN + Start_encryption_log_event::get_data_size()) { - buf += LOG_EVENT_MINIMAL_HEADER_LEN; - crypto_scheme = *(uchar*)buf; - key_version = uint4korr(buf + BINLOG_CRYPTO_SCHEME_LENGTH); + buf+= LOG_EVENT_MINIMAL_HEADER_LEN; + crypto_scheme= *buf; + key_version= uint4korr(buf + BINLOG_CRYPTO_SCHEME_LENGTH); memcpy(nonce, buf + BINLOG_CRYPTO_SCHEME_LENGTH + BINLOG_KEY_VERSION_LENGTH, BINLOG_NONCE_LENGTH); @@ -2396,7 +2376,7 @@ Start_encryption_log_event::Start_encryption_log_event( } - /************************************************************************** +/************************************************************************** Load_log_event methods General note about Load_log_event: the binlogging of LOAD DATA INFILE is going to be changed in 5.0 (or maybe in 5.1; not decided yet). @@ -2411,16 +2391,18 @@ Start_encryption_log_event::Start_encryption_log_event( Note that I (Guilhem) manually tested replication of a big LOAD DATA INFILE between 3.23 and 5.0, and between 4.0 and 5.0, and it works fine (and the positions displayed in SHOW SLAVE STATUS then are fine too). - **************************************************************************/ +**************************************************************************/ /** @note - The caller must do buf[event_len] = 0 before he starts using the + The caller must do buf[event_len]= 0 before he starts using the constructed event. */ -Load_log_event::Load_log_event(const char *buf, uint event_len, - const Format_description_log_event *description_event) + +Load_log_event::Load_log_event(const uchar *buf, uint event_len, + const Format_description_log_event + *description_event) :Log_event(buf, description_event), num_fields(0), fields(0), field_lens(0),field_block_len(0), table_name(0), db(0), fname(0), local_fname(FALSE), @@ -2452,52 +2434,51 @@ Load_log_event::Load_log_event(const char *buf, uint event_len, Load_log_event::copy_log_event() */ -int Load_log_event::copy_log_event(const char *buf, ulong event_len, +int Load_log_event::copy_log_event(const uchar *buf, ulong event_len, int body_offset, - const Format_description_log_event *description_event) + const Format_description_log_event + *description_event) { DBUG_ENTER("Load_log_event::copy_log_event"); uint data_len; if ((int) event_len <= body_offset) DBUG_RETURN(1); - char* buf_end = (char*)buf + event_len; + const uchar *buf_end= buf + event_len; /* this is the beginning of the post-header */ - const char* data_head = buf + description_event->common_header_len; + const uchar *data_head= buf + description_event->common_header_len; thread_id= slave_proxy_id= uint4korr(data_head + L_THREAD_ID_OFFSET); - exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET); - skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET); - table_name_len = (uint)data_head[L_TBL_LEN_OFFSET]; - db_len = (uint)data_head[L_DB_LEN_OFFSET]; - num_fields = uint4korr(data_head + L_NUM_FIELDS_OFFSET); + exec_time= uint4korr(data_head + L_EXEC_TIME_OFFSET); + skip_lines= uint4korr(data_head + L_SKIP_LINES_OFFSET); + table_name_len= (uint)data_head[L_TBL_LEN_OFFSET]; + db_len= (uint)data_head[L_DB_LEN_OFFSET]; + num_fields= uint4korr(data_head + L_NUM_FIELDS_OFFSET); /* Sql_ex.init() on success returns the pointer to the first byte after the sql_ex structure, which is the start of field lengths array. */ - if (!(field_lens= (uchar*)sql_ex.init((char*)buf + body_offset, - buf_end, - (uchar)buf[EVENT_TYPE_OFFSET] != LOAD_EVENT))) + if (!(field_lens= (uchar*) sql_ex.init(buf + body_offset, buf_end, + buf[EVENT_TYPE_OFFSET] != LOAD_EVENT))) DBUG_RETURN(1); - data_len = event_len - body_offset; + data_len= event_len - body_offset; if (num_fields > data_len) // simple sanity check against corruption DBUG_RETURN(1); - for (uint i = 0; i < num_fields; i++) - field_block_len += (uint)field_lens[i] + 1; + for (uint i= 0; i < num_fields; i++) + field_block_len+= (uint)field_lens[i] + 1; - fields = (char*)field_lens + num_fields; - table_name = fields + field_block_len; + fields= (char*) field_lens + num_fields; + table_name= fields + field_block_len; if (strlen(table_name) > NAME_LEN) goto err; - db = table_name + table_name_len + 1; - DBUG_EXECUTE_IF ("simulate_invalid_address", - db_len = data_len;); - fname = db + db_len + 1; - if ((db_len > data_len) || (fname > buf_end)) + db= table_name + table_name_len + 1; + DBUG_EXECUTE_IF("simulate_invalid_address", db_len= data_len;); + fname= db + db_len + 1; + if ((db_len > data_len) || (fname > (char*) buf_end)) goto err; - fname_len = (uint) strlen(fname); - if ((fname_len > data_len) || (fname + fname_len > buf_end)) + fname_len= (uint) strlen(fname); + if ((fname_len > data_len) || (fname + fname_len > (char*) buf_end)) goto err; // null termination is accomplished by the caller doing buf[event_len]=0 @@ -2505,7 +2486,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, err: // Invalid event. - table_name = 0; + table_name= 0; DBUG_RETURN(1); } @@ -2514,8 +2495,9 @@ err: Rotate_log_event methods **************************************************************************/ -Rotate_log_event::Rotate_log_event(const char* buf, uint event_len, - const Format_description_log_event* description_event) +Rotate_log_event::Rotate_log_event(const uchar *buf, uint event_len, + const Format_description_log_event* + description_event) :Log_event(buf, description_event) ,new_log_ident(0), flags(DUP_NAME) { DBUG_ENTER("Rotate_log_event::Rotate_log_event(char*,...)"); @@ -2529,7 +2511,8 @@ Rotate_log_event::Rotate_log_event(const char* buf, uint event_len, ident_len= (uint)(event_len - (LOG_EVENT_MINIMAL_HEADER_LEN + post_header_len)); ident_offset= post_header_len; set_if_smaller(ident_len,FN_REFLEN-1); - new_log_ident= my_strndup(PSI_INSTRUMENT_ME, buf + ident_offset, (uint) ident_len, MYF(MY_WME)); + new_log_ident= my_strndup(PSI_INSTRUMENT_ME, (char*) buf + ident_offset, + (uint) ident_len, MYF(MY_WME)); DBUG_PRINT("debug", ("new_log_ident: '%s'", new_log_ident)); DBUG_VOID_RETURN; } @@ -2540,7 +2523,7 @@ Rotate_log_event::Rotate_log_event(const char* buf, uint event_len, **************************************************************************/ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event( - const char *buf, uint event_len, + const uchar *buf, uint event_len, const Format_description_log_event *description_event) :Log_event(buf, description_event), binlog_file_name(0) { @@ -2556,8 +2539,8 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event( binlog_file_len= uint4korr(buf); if (event_len - (header_size + post_header_len) < binlog_file_len) return; - binlog_file_name= my_strndup(PSI_INSTRUMENT_ME, buf + post_header_len, binlog_file_len, - MYF(MY_WME)); + binlog_file_name= my_strndup(PSI_INSTRUMENT_ME, (char*) buf + post_header_len, + binlog_file_len, MYF(MY_WME)); return; } @@ -2566,8 +2549,9 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event( Global transaction ID stuff **************************************************************************/ -Gtid_log_event::Gtid_log_event(const char *buf, uint event_len, - const Format_description_log_event *description_event) +Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, + const Format_description_log_event + *description_event) : Log_event(buf, description_event), seq_no(0), commit_id(0) { uint8 header_size= description_event->common_header_len; @@ -2610,8 +2594,9 @@ Gtid_log_event::Gtid_log_event(const char *buf, uint event_len, /* GTID list. */ -Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len, - const Format_description_log_event *description_event) +Gtid_list_log_event::Gtid_list_log_event(const uchar *buf, uint event_len, + const Format_description_log_event + *description_event) : Log_event(buf, description_event), count(0), list(0), sub_id_list(0) { uint32 i; @@ -2702,7 +2687,7 @@ Gtid_list_log_event::peek(const char *event_start, size_t event_len, p+= 4; count= count_field & ((1<<28)-1); if (event_len < (uint32)fdev->common_header_len + GTID_LIST_HEADER_LEN + - 16 * count) + element_size * count) return true; if (!(gtid_list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME, sizeof(rpl_gtid)*count + (count == 0), MYF(MY_WME)))) @@ -2732,7 +2717,7 @@ Gtid_list_log_event::peek(const char *event_start, size_t event_len, Intvar_log_event::Intvar_log_event() */ -Intvar_log_event::Intvar_log_event(const char* buf, +Intvar_log_event::Intvar_log_event(const uchar *buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { @@ -2762,7 +2747,7 @@ const char* Intvar_log_event::get_var_type_name() Rand_log_event methods **************************************************************************/ -Rand_log_event::Rand_log_event(const char* buf, +Rand_log_event::Rand_log_event(const uchar *buf, const Format_description_log_event* description_event) :Log_event(buf, description_event) { @@ -2788,7 +2773,7 @@ Rand_log_event::Rand_log_event(const char* buf, */ Xid_log_event:: -Xid_log_event(const char* buf, +Xid_log_event(const uchar *buf, const Format_description_log_event *description_event) :Xid_apply_log_event(buf, description_event) { @@ -2802,7 +2787,7 @@ Xid_log_event(const char* buf, XA_prepare_log_event methods **************************************************************************/ XA_prepare_log_event:: -XA_prepare_log_event(const char* buf, +XA_prepare_log_event(const uchar *buf, const Format_description_log_event *description_event) :Xid_apply_log_event(buf, description_event) { @@ -2841,7 +2826,7 @@ XA_prepare_log_event(const char* buf, **************************************************************************/ User_var_log_event:: -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) :Log_event(buf, description_event) #ifndef MYSQL_CLIENT @@ -2849,7 +2834,7 @@ User_var_log_event(const char* buf, uint event_len, #endif { bool error= false; - const char* buf_start= buf, *buf_end= buf + event_len; + const uchar *buf_start= buf, *buf_end= buf + event_len; /* The Post-Header is empty. The Variable Data part begins immediately. */ buf+= description_event->common_header_len + @@ -2869,7 +2854,7 @@ User_var_log_event(const char* buf, uint event_len, may have the bigger value possible, is_null= True and there is no payload for val, or even that name_len is 0. */ - if (name + name_len + UV_VAL_IS_NULL > buf_end) + if (name + name_len + UV_VAL_IS_NULL > (char*) buf_end) { error= true; goto err; @@ -2890,7 +2875,7 @@ User_var_log_event(const char* buf, uint event_len, val= (char *) (buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE); - if (val > buf_end) + if (val > (char*) buf_end) { error= true; goto err; @@ -2912,7 +2897,7 @@ User_var_log_event(const char* buf, uint event_len, Old events will not have this extra byte, thence, we keep the flags set to UNDEF_F. */ - size_t bytes_read= (val + val_len) - buf_start; + size_t bytes_read= (val + val_len) - (char*) buf_start; if (bytes_read > event_len) { error= true; @@ -2940,16 +2925,19 @@ err: Create_file_log_event ctor */ -Create_file_log_event::Create_file_log_event(const char* buf, uint len, - const Format_description_log_event* description_event) - :Load_log_event(buf,0,description_event),fake_base(0),block(0),inited_from_old(0) +Create_file_log_event:: +Create_file_log_event(const uchar *buf, uint len, + const Format_description_log_event* description_event) + :Load_log_event(buf,0,description_event),fake_base(0),block(0), + inited_from_old(0) { DBUG_ENTER("Create_file_log_event::Create_file_log_event(char*,...)"); uint block_offset; uint header_len= description_event->common_header_len; uint8 load_header_len= description_event->post_header_len[LOAD_EVENT-1]; uint8 create_file_header_len= description_event->post_header_len[CREATE_FILE_EVENT-1]; - if (!(event_buf= (char*) my_memdup(PSI_INSTRUMENT_ME, buf, len, MYF(MY_WME))) || + if (!(event_buf= (uchar*) my_memdup(PSI_INSTRUMENT_ME, buf, len, + MYF(MY_WME))) || copy_log_event(event_buf,len, (((uchar)buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ? load_header_len + header_len : @@ -2979,13 +2967,13 @@ Create_file_log_event::Create_file_log_event(const char* buf, uint len, create_file_header_len + 1); if (len < block_offset) DBUG_VOID_RETURN; - block = (uchar*)buf + block_offset; - block_len = len - block_offset; + block= const_cast<uchar*>(buf) + block_offset; + block_len= len - block_offset; } else { sql_ex.force_new_format(); - inited_from_old = 1; + inited_from_old= 1; } DBUG_VOID_RETURN; } @@ -2999,8 +2987,9 @@ Create_file_log_event::Create_file_log_event(const char* buf, uint len, Append_block_log_event ctor */ -Append_block_log_event::Append_block_log_event(const char* buf, uint len, - const Format_description_log_event* description_event) +Append_block_log_event:: +Append_block_log_event(const uchar *buf, uint len, + const Format_description_log_event* description_event) :Log_event(buf, description_event),block(0) { DBUG_ENTER("Append_block_log_event::Append_block_log_event(char*,...)"); @@ -3011,7 +3000,7 @@ Append_block_log_event::Append_block_log_event(const char* buf, uint len, if (len < total_header_len) DBUG_VOID_RETURN; file_id= uint4korr(buf + common_header_len + AB_FILE_ID_OFFSET); - block= (uchar*)buf + total_header_len; + block= const_cast<uchar*>(buf) + total_header_len; block_len= len - total_header_len; DBUG_VOID_RETURN; } @@ -3025,8 +3014,9 @@ Append_block_log_event::Append_block_log_event(const char* buf, uint len, Delete_file_log_event ctor */ -Delete_file_log_event::Delete_file_log_event(const char* buf, uint len, - const Format_description_log_event* description_event) +Delete_file_log_event:: +Delete_file_log_event(const uchar *buf, uint len, + const Format_description_log_event* description_event) :Log_event(buf, description_event),file_id(0) { uint8 common_header_len= description_event->common_header_len; @@ -3045,8 +3035,9 @@ Delete_file_log_event::Delete_file_log_event(const char* buf, uint len, Execute_load_log_event ctor */ -Execute_load_log_event::Execute_load_log_event(const char* buf, uint len, - const Format_description_log_event* description_event) +Execute_load_log_event:: +Execute_load_log_event(const uchar *buf, uint len, + const Format_description_log_event* description_event) :Log_event(buf, description_event), file_id(0) { uint8 common_header_len= description_event->common_header_len; @@ -3062,7 +3053,7 @@ Execute_load_log_event::Execute_load_log_event(const char* buf, uint len, **************************************************************************/ Begin_load_query_log_event:: -Begin_load_query_log_event(const char* buf, uint len, +Begin_load_query_log_event(const uchar *buf, uint len, const Format_description_log_event* desc_event) :Append_block_log_event(buf, len, desc_event) { @@ -3075,7 +3066,7 @@ Begin_load_query_log_event(const char* buf, uint len, Execute_load_query_log_event:: -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* desc_event): Query_log_event(buf, event_len, desc_event, EXECUTE_LOAD_QUERY_EVENT), file_id(0), fn_pos_start(0), fn_pos_end(0) @@ -3111,10 +3102,10 @@ ulong Execute_load_query_log_event::get_post_header_size_for_derived() sql_ex_info::init() */ -const char *sql_ex_info::init(const char *buf, const char *buf_end, +const uchar *sql_ex_info::init(const uchar *buf, const uchar *buf_end, bool use_new_format) { - cached_new_format = use_new_format; + cached_new_format= use_new_format; if (use_new_format) { empty_flags=0; @@ -3131,19 +3122,19 @@ const char *sql_ex_info::init(const char *buf, const char *buf_end, read_str(&buf, buf_end, &line_start, &line_start_len) || read_str(&buf, buf_end, &escaped, &escaped_len)) return 0; - opt_flags = *buf++; + opt_flags= *buf++; } else { if (buf_end - buf < 7) return 0; // Wrong data field_term_len= enclosed_len= line_term_len= line_start_len= escaped_len=1; - field_term = buf++; // Use first byte in string - enclosed= buf++; - line_term= buf++; - line_start= buf++; - escaped= buf++; - opt_flags = *buf++; + field_term= (char*) buf++; // Use first byte in string + enclosed= (char*) buf++; + line_term= (char*) buf++; + line_start= (char*) buf++; + escaped= (char*) buf++; + opt_flags= *buf++; empty_flags= *buf++; if (empty_flags & FIELD_TERM_EMPTY) field_term_len=0; @@ -3166,7 +3157,7 @@ const char *sql_ex_info::init(const char *buf, const char *buf_end, **************************************************************************/ -Rows_log_event::Rows_log_event(const char *buf, uint event_len, +Rows_log_event::Rows_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event) : Log_event(buf, description_event), @@ -3201,7 +3192,7 @@ Rows_log_event::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; + const uchar *post_start= buf + common_header_len; post_start+= RW_MAPID_OFFSET; if (post_header_len == 6) { @@ -3238,9 +3229,9 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, var_header_len-= 2; /* Iterate over var-len header, extracting 'chunks' */ - const char* start= post_start + 2; - const char* end= start + var_header_len; - for (const char* pos= start; pos < end;) + const uchar *start= post_start + 2; + const uchar *end= start + var_header_len; + for (const uchar* pos= start; pos < end;) { switch(*pos++) { @@ -3275,7 +3266,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, uchar const *const ptr_width= var_start; uchar *ptr_after_width= (uchar*) ptr_width; DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); - m_width = net_field_length(&ptr_after_width); + m_width= net_field_length(&ptr_after_width); DBUG_PRINT("debug", ("m_width=%lu", m_width)); /* Avoid reading out of buffer */ @@ -3361,18 +3352,19 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, void Rows_log_event::uncompress_buf() { - uint32 un_len = binlog_get_uncompress_len((char *)m_rows_buf); + uint32 un_len= binlog_get_uncompress_len(m_rows_buf); if (!un_len) return; - uchar *new_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, ALIGN_SIZE(un_len), MYF(MY_WME)); + uchar *new_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, ALIGN_SIZE(un_len), + MYF(MY_WME)); if (new_buf) { - if(!binlog_buf_uncompress((char *)m_rows_buf, (char *)new_buf, + if (!binlog_buf_uncompress(m_rows_buf, new_buf, (uint32)(m_rows_cur - m_rows_buf), &un_len)) { my_free(m_rows_buf); - m_rows_buf = new_buf; + m_rows_buf= new_buf; #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) m_curr_row= m_rows_buf; #endif @@ -3409,7 +3401,7 @@ int Rows_log_event::get_data_size() (general_type_code == UPDATE_ROWS_EVENT ? no_bytes_in_map(&m_cols_ai) : 0) + m_rows_cur - m_rows_buf);); int data_size= 0; - Log_event_type type = get_type_code(); + Log_event_type type= get_type_code(); bool is_v2_event= LOG_EVENT_IS_ROW_V2(type); if (is_v2_event) { @@ -3437,9 +3429,10 @@ int Rows_log_event::get_data_size() Annotate_rows_log_event member functions **************************************************************************/ -Annotate_rows_log_event::Annotate_rows_log_event(const char *buf, - uint event_len, - const Format_description_log_event *desc) +Annotate_rows_log_event:: +Annotate_rows_log_event(const uchar *buf, + uint event_len, + const Format_description_log_event *desc) : Log_event(buf, desc), m_save_thd_query_txt(0), m_save_thd_query_len(0), @@ -3518,7 +3511,7 @@ bool Annotate_rows_log_event::is_valid() const Constructor used by slave to read the event from the binary log. */ #if defined(HAVE_REPLICATION) -Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, +Table_map_log_event::Table_map_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event) @@ -3553,7 +3546,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, DBUG_VOID_RETURN; /* Read the post-header */ - const char *post_start= buf + common_header_len; + const uchar *post_start= buf + common_header_len; post_start+= TM_MAPID_OFFSET; VALIDATE_BYTES_READ(post_start, buf, event_len); @@ -3575,7 +3568,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, m_flags= uint2korr(post_start); /* Read the variable part of the event */ - const char *const vpart= buf + common_header_len + post_header_len; + const uchar *const vpart= buf + common_header_len + post_header_len; /* Extract the length of the various parts from the buffer */ uchar const *const ptr_dblen= (uchar const*)vpart + 0; @@ -3594,9 +3587,9 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, m_colcnt= net_field_length(&ptr_after_colcnt); DBUG_PRINT("info",("m_dblen: %lu off: %ld m_tbllen: %lu off: %ld m_colcnt: %lu off: %ld", - (ulong) m_dblen, (long) (ptr_dblen-(const uchar*)vpart), - (ulong) m_tbllen, (long) (ptr_tbllen-(const uchar*)vpart), - m_colcnt, (long) (ptr_colcnt-(const uchar*)vpart))); + (ulong) m_dblen, (long) (ptr_dblen - vpart), + (ulong) m_tbllen, (long) (ptr_tbllen - vpart), + m_colcnt, (long) (ptr_colcnt - vpart))); /* Allocate mem for all fields in one go. If fails, caught in is_valid() */ m_memory= (uchar*) my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), @@ -3906,7 +3899,7 @@ Optional_metadata_fields(unsigned char* optional_metadata, Constructor used by slave to read the event from the binary log. */ #ifdef HAVE_REPLICATION -Write_rows_log_event::Write_rows_log_event(const char *buf, uint event_len, +Write_rows_log_event::Write_rows_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event) : Rows_log_event(buf, event_len, description_event) @@ -3914,7 +3907,7 @@ Write_rows_log_event::Write_rows_log_event(const char *buf, uint event_len, } Write_rows_compressed_log_event::Write_rows_compressed_log_event( - const char *buf, uint event_len, + const uchar *buf, uint event_len, const Format_description_log_event *description_event) : Write_rows_log_event(buf, event_len, description_event) @@ -3932,7 +3925,7 @@ Write_rows_compressed_log_event::Write_rows_compressed_log_event( Constructor used by slave to read the event from the binary log. */ #ifdef HAVE_REPLICATION -Delete_rows_log_event::Delete_rows_log_event(const char *buf, uint event_len, +Delete_rows_log_event::Delete_rows_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event) : Rows_log_event(buf, event_len, description_event) @@ -3940,7 +3933,7 @@ Delete_rows_log_event::Delete_rows_log_event(const char *buf, uint event_len, } Delete_rows_compressed_log_event::Delete_rows_compressed_log_event( - const char *buf, uint event_len, + const uchar *buf, uint event_len, const Format_description_log_event *description_event) : Delete_rows_log_event(buf, event_len, description_event) @@ -3968,7 +3961,7 @@ Update_rows_log_event::~Update_rows_log_event() Constructor used by slave to read the event from the binary log. */ #ifdef HAVE_REPLICATION -Update_rows_log_event::Update_rows_log_event(const char *buf, uint event_len, +Update_rows_log_event::Update_rows_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event) @@ -3977,7 +3970,7 @@ Update_rows_log_event::Update_rows_log_event(const char *buf, uint event_len, } Update_rows_compressed_log_event::Update_rows_compressed_log_event( - const char *buf, uint event_len, + const uchar *buf, uint event_len, const Format_description_log_event *description_event) : Update_rows_log_event(buf, event_len, description_event) @@ -3986,7 +3979,7 @@ Update_rows_compressed_log_event::Update_rows_compressed_log_event( } #endif -Incident_log_event::Incident_log_event(const char *buf, uint event_len, +Incident_log_event::Incident_log_event(const uchar *buf, uint event_len, const Format_description_log_event *descr_event) : Log_event(buf, descr_event) { @@ -4012,8 +4005,8 @@ Incident_log_event::Incident_log_event(const char *buf, uint event_len, DBUG_VOID_RETURN; } m_incident= static_cast<Incident>(incident_number); - char const *ptr= buf + common_header_len + post_header_len; - char const *const str_end= buf + event_len; + uchar const *ptr= buf + common_header_len + post_header_len; + uchar const *const str_end= buf + event_len; uint8 len= 0; // Assignment to keep compiler happy const char *str= NULL; // Assignment to keep compiler happy if (read_str(&ptr, str_end, &str, &len)) @@ -4055,7 +4048,7 @@ Incident_log_event::description() const } -Ignorable_log_event::Ignorable_log_event(const char *buf, +Ignorable_log_event::Ignorable_log_event(const uchar *buf, const Format_description_log_event *descr_event, const char *event_name) diff --git a/sql/log_event.h b/sql/log_event.h index 6a224b7b6a1..5b3fb60bbe1 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -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); - -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); +uint32 binlog_get_uncompress_len(const uchar *buf); + +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 */ diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc index 3db66e4201f..6b5d71348e1 100644 --- a/sql/log_event_client.cc +++ b/sql/log_event_client.cc @@ -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); diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 10d1df4f3e7..4e6b9e3f1c8 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -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(); diff --git a/sql/log_event_old.h b/sql/log_event_old.h index 3a11313a31f..e5aaacec209 100644 --- a/sql/log_event_old.h +++ b/sql/log_event_old.h @@ -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) diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 4c86acb909a..e9057d09c34 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -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 || diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 946d138d618..0d6e959838f 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -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); diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 7c347eba51f..9ea8bb3b822 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -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 diff --git a/sql/semisync_slave.cc b/sql/semisync_slave.cc index df8baf045ac..ccfda7576c2 100644 --- a/sql/semisync_slave.cc +++ b/sql/semisync_slave.cc @@ -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; diff --git a/sql/semisync_slave.h b/sql/semisync_slave.h index d65262f151d..e7ccd952130 100644 --- a/sql/semisync_slave.h +++ b/sql/semisync_slave.h @@ -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 diff --git a/sql/slave.cc b/sql/slave.cc index 09aa1f97936..8c213e0a3eb 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -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"); diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 0011487f1dc..5cd70199645 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -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. diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index eb7524153a4..2cf91adeac4 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -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, >id.domain_id, >id.server_id, >id.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) diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 4005de22e72..90ede81a06a 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -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; |