List:Commits« Previous MessageNext Message »
From:Sven Sandberg Date:January 30 2008 1:55pm
Subject:Re: bk commit into 5.1 tree (sven:1.2660) BUG#34141
View as plain text  
Hi Zhenxing,

You are absolutely right, I added a test case. Thanks.

The test case revealed another problem which I also fixed. See the 
re-commit.

/Sven


He Zhenxing wrote:
> Hi Sven
> 
> Nice work, I think the patch is OK, except I think a test case should be
> add for this bug.
> 
> On 2008-01-29 Tue 20:18 +0100,Sven Sandberg wrote:
>> Below is the list of changes that have just been committed into a local
>> 5.1 repository of sven. When sven does a push these changes will
>> be propagated to the main repository and, within 24 hours after the
>> push, to the public repository.
>> For information on how to access the public repository
>> see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
>>
>> ChangeSet@stripped, 2008-01-29 20:18:14+01:00, sven@riska.(none) +2 -0
>>   BUG#34141: mysqlbinlog cannot read 4.1 binlogs containing load data infile
>>   Problem: mysql 5.1 cannot read binlogs from 4.1.
>>   The reason is a mistake in sql_ex_info::init. The read_str() function
>>   updates its first argument to point to the next character to read.
>>   However, it is applied only to a copy of the buffer pointer, so the real
>>   buffer pointer is not updated.
>>   Fix: do not take a copy of the buffer pointer. The copy was needed because
>>   sql_ex_info::init does not use the const attribute on some of its
>>   arguments. So we add the const attribute, too.
>>
>>   sql/log_event.cc@stripped, 2008-01-29 20:18:11+01:00, sven@riska.(none) +12 -12
>>     1. Added const keyword at the following places:
>>      - input buffer for pretty_print_str
>>      - input buffer for write_str
>>      - input buffer, end pointer, and return value from sql_ex_info::init
>>     2. Fixed the bug by not taking a copy of buf before calling read_str in
>>     sql_ex_info::init().
>>
>>   sql/log_event.h@stripped, 2008-01-29 20:18:11+01:00, sven@riska.(none) +6 -6
>>     Added const keyword to fields of the sql_ex_info struct.
>>     Added const keyword to arguments and return value of sql_ex_info::init
>>
>> diff -Nrup a/sql/log_event.cc b/sql/log_event.cc
>> --- a/sql/log_event.cc	2007-12-19 11:35:14 +01:00
>> +++ b/sql/log_event.cc	2008-01-29 20:18:11 +01:00
>> @@ -212,9 +212,9 @@ uint debug_not_change_ts_if_art_event= 1
>>  */
>>  
>>  #ifdef MYSQL_CLIENT
>> -static void pretty_print_str(IO_CACHE* cache, char* str, int len)
>> +static void pretty_print_str(IO_CACHE* cache, const char* str, int len)
>>  {
>> -  char* end = str + len;
>> +  const char* end = str + len;
>>    my_b_printf(cache, "\'");
>>    while (str < end)
>>    {
>> @@ -277,9 +277,9 @@ inline int ignored_error_code(int err_co
>>  */
>>  
>>  #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
>> -static char *pretty_print_str(char *packet, char *str, int len)
>> +static char *pretty_print_str(char *packet, const char *str, int len)
>>  {
>> -  char *end= str + len;
>> +  const char *end= str + len;
>>    char *pos= packet;
>>    *pos++= '\'';
>>    while (str < end)
>> @@ -388,7 +388,7 @@ static void cleanup_load_tmpdir()
>>    write_str()
>>  */
>>  
>> -static bool write_str(IO_CACHE *file, char *str, uint length)
>> +static bool write_str(IO_CACHE *file, const char *str, uint length)
>>  {
>>    uchar tmp[1];
>>    tmp[0]= (uchar) length;
>> @@ -5929,7 +5929,8 @@ bool sql_ex_info::write_data(IO_CACHE* f
>>    sql_ex_info::init()
>>  */
>>  
>> -char *sql_ex_info::init(char *buf, char *buf_end, bool use_new_format)
>> +const char *sql_ex_info::init(const char *buf, const char *buf_end,
>> +                              bool use_new_format)
>>  {
>>    cached_new_format = use_new_format;
>>    if (use_new_format)
>> @@ -5942,12 +5943,11 @@ char *sql_ex_info::init(char *buf, char 
>>        the case when we have old format because we will be reusing net buffer
>>        to read the actual file before we write out the Create_file event.
>>      */
>> -    const char *ptr= buf;
>> -    if (read_str(&ptr, buf_end, (const char **) &field_term,
> &field_term_len) ||
>> -	read_str(&ptr, buf_end, (const char **) &enclosed,   &enclosed_len)
> ||
>> -	read_str(&ptr, buf_end, (const char **) &line_term, 
> &line_term_len) ||
>> -	read_str(&ptr, buf_end, (const char **) &line_start,
> &line_start_len) ||
>> -	read_str(&ptr, buf_end, (const char **) &escaped,   
> &escaped_len))
>> +    if (read_str(&buf, buf_end, (const char **) &field_term,
> &field_term_len) ||
>> +        read_str(&buf, buf_end, (const char **) &enclosed,  
> &enclosed_len) ||
>> +        read_str(&buf, buf_end, (const char **) &line_term, 
> &line_term_len) ||
>> +        read_str(&buf, buf_end, (const char **) &line_start,
> &line_start_len) ||
>> +        read_str(&buf, buf_end, (const char **) &escaped,   
> &escaped_len))
>>        return 0;
>>      opt_flags = *buf++;
>>    }
>> diff -Nrup a/sql/log_event.h b/sql/log_event.h
>> --- a/sql/log_event.h	2007-12-14 19:01:59 +01:00
>> +++ b/sql/log_event.h	2008-01-29 20:18:11 +01:00
>> @@ -152,11 +152,11 @@ struct old_sql_ex
>>  struct sql_ex_info
>>  {
>>    sql_ex_info() {}                            /* Remove gcc warning */
>> -  char* field_term;
>> -  char* enclosed;
>> -  char* line_term;
>> -  char* line_start;
>> -  char* escaped;
>> +  const char* field_term;
>> +  const char* enclosed;
>> +  const char* line_term;
>> +  const char* line_start;
>> +  const char* escaped;
>>    int cached_new_format;
>>    uint8 field_term_len,enclosed_len,line_term_len,line_start_len, escaped_len;
>>    char opt_flags;
>> @@ -171,7 +171,7 @@ struct sql_ex_info
>>  	    line_start_len + escaped_len + 6 : 7);
>>    }
>>    bool write_data(IO_CACHE* file);
>> -  char* init(char* buf,char* buf_end,bool use_new_format);
>> +  const char* init(const char* buf, const char* buf_end, bool use_new_format);
>>    bool new_format()
>>    {
>>      return ((cached_new_format != -1) ? cached_new_format :
> 
> 

-- 
Sven Sandberg, Software Engineer
MySQL AB, www.mysql.com
Thread
bk commit into 5.1 tree (sven:1.2660) BUG#34141Sven Sandberg29 Jan
  • Re: bk commit into 5.1 tree (sven:1.2660) BUG#34141He Zhenxing30 Jan
    • Re: bk commit into 5.1 tree (sven:1.2660) BUG#34141Sven Sandberg30 Jan
  • Re: bk commit into 5.1 tree (sven:1.2660) BUG#34141Andrei Elkin30 Jan