From d52812635920a23fb2c6ce4e784eb1d687fe48a7 Mon Sep 17 00:00:00 2001 From: "sasha@mysql.sashanet.com" <> Date: Thu, 16 Nov 2000 22:59:50 -0700 Subject: fixed bugs in IO_CACHE and Load_event constructor. The code now passes replication test suite --- mysys/mf_iocache2.c | 2 +- sql/log_event.cc | 10 +++++----- sql/mf_iocache.cc | 17 +++++++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index b77bddb942a..1a8423981cb 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -32,7 +32,7 @@ void my_b_seek(IO_CACHE *info,my_off_t pos) { - info->seek_not_done=0; + info->seek_not_done=1; info->pos_in_file=pos; info->rc_pos=info->rc_end=info->buffer; } diff --git a/sql/log_event.cc b/sql/log_event.cc index e895914aa4d..be053e2f260 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -256,7 +256,7 @@ void Log_event::print_header(FILE* file) { fputc('#', file); print_timestamp(file); - fprintf(file, " server id %ld ", server_id); + fprintf(file, " server id %d ", server_id); } void Log_event::print_timestamp(FILE* file, time_t* ts) @@ -418,7 +418,7 @@ Query_log_event::Query_log_event(IO_CACHE* file, time_t when_arg, Query_log_event::Query_log_event(const char* buf, int event_len): Log_event(buf),data_buf(0), query(NULL), db(NULL) { - if (event_len < QUERY_EVENT_OVERHEAD) + if ((uint)event_len < QUERY_EVENT_OVERHEAD) return; ulong data_len; buf += EVENT_LEN_OFFSET; @@ -577,10 +577,10 @@ Load_log_event::Load_log_event(const char* buf, int event_len): { ulong data_len; - if(event_len < (LOAD_EVENT_OVERHEAD + LOG_EVENT_HEADER_LEN)) + if((uint)event_len < (LOAD_EVENT_OVERHEAD + LOG_EVENT_HEADER_LEN)) return; - buf += EVENT_LEN_OFFSET; + memcpy(&sql_ex, buf + LOAD_HEADER_LEN + 4, sizeof(sql_ex)); data_len = event_len; if(!(data_buf = (char*)my_malloc(data_len + 1, MYF(MY_WME)))) @@ -671,7 +671,7 @@ void Load_log_event::print(FILE* file, bool short_form) } if((int)skip_lines > 0) - fprintf(file, " IGNORE %ld LINES ", skip_lines); + fprintf(file, " IGNORE %d LINES ", skip_lines); if (num_fields) { diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index 7f85cc06f57..c1e6b37a848 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -240,12 +240,17 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) { uint length,diff_length,left_length; my_off_t max_length, pos_in_file; - - memcpy(Buffer,info->rc_pos, - (size_t) (left_length=(uint) (info->rc_end-info->rc_pos))); - Buffer+=left_length; - Count-=left_length; - pos_in_file=info->pos_in_file+(uint) (info->rc_end - info->buffer); + + if((left_length=(uint) (info->rc_end-info->rc_pos))) + { + if(Count < left_length) + left_length = Count; + memcpy(Buffer,info->rc_pos, + (size_t) (left_length)); + Buffer+=left_length; + Count-=left_length; + } + pos_in_file=info->pos_in_file+ left_length; if (info->seek_not_done) { /* File touched, do seek */ VOID(my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0))); -- cgit v1.2.1