MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:July 2 2008 3:35am
Subject:Re: bk commit into 6.0 tree (aelkin:1.2634) BUG#25998
View as plain text  
Hi Andrei

I think this is a nice piece of work, thank you!

Patch approved, please have a look of some minor comments below.

Andrei Elkin wrote:
> Below is the list of changes that have just been committed into a local
> 6.0 repository of aelkin.  When aelkin 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-06-04 19:39:28+03:00, aelkin@stripped +12 -0
>   Bug #25998 problems about circle replication
>   Bug #27808 Infinite looping in circular replication
>   

[snip]

>  
> +/**
> +   A comparison function to be supplied as argument to @c sort_dynamic()
> +   and @c bsearch()
> +
> +   @return -1 if first argument is less, 0 if it equal to, 1 if it is greater
> +   than the second
> +*/
> +int change_master_server_id_cmp(ulong *id1, ulong *id2)
> +{
> +  return *id1 < *id2? -1 : (*id1 > *id2? 1 : 0);
> +}
> +

I'd suggest to remove the 'change_master_' prefix of this function, just
name it 'server_id_cmp' is OK, and can encourage others to use this
function to do comparison of server_ids instead of writing their own.

[snip]

>  
> +/**
> +   A master info read method
> +

A more descriptive brief would be perfect.

> +   This function is called from @c init_master_info() along with
> +   relatives to restore some of @c active_mi members.
> +   Particularly, this function is responsible for restoring
> +   IGNORE_SERVER_IDS list of servers whose events the slave is
> +   going to ignore (to not log them in the relay log).
> +   Items being read are supposed to be decimal output of values of a
> +   type shorter or equal of @c long and separated by the single space.
> +
> +   @param arr         @c DYNAMIC_ARRAY pointer to storage for servers id
> +   @param f           @c IO_CACHE pointer to the source file
> +
> +   @retval 0         All OK
> +   @retval non-zero  An error
> +*/
> +
> +int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f)
> +{
> +  int ret= 0;
> +  char buf[16 * (sizeof(long)*4 + 1)]; // static buffer to use most of times
> +  char *buf_act= buf; // actual buffer can be dynamic if static is short
> +  char *token, *last;
> +  uint num_items;     // number of items of `arr'
> +  size_t read_size;
> +  DBUG_ENTER("init_dynarray_intvar_from_file");
> +
> +  if ((read_size= my_b_gets(f, buf_act, sizeof(buf))) == 0)
> +  {
> +    return 0; // no line in master.info
> +  }
> +  if (read_size + 1 == sizeof(buf) && buf[sizeof(buf) - 2] != '\n')
> +  {
> +    /*
> +      short read happend; allocate sufficient memory and make the 2nd read
> +    */
> +    char buf_work[(sizeof(long)*3 + 1)*16];
> +    memcpy(buf_work, buf, sizeof(buf_work));
> +    num_items= atoi(strtok_r(buf_work, " ", &last));
> +    size_t snd_size;
> +    /*
> +      max size lower bound approximate estimation bases on the formula:
> +      (the items number + items themselves) * 
> +          (decimal size + space) - 1 + `\n' + '\0'
> +    */
> +    size_t max_size= (1 + num_items) * (sizeof(long)*3 + 1) + 1;
> +    buf_act= (char*) my_malloc(max_size, MYF(MY_WME));
> +    memcpy(buf_act, buf, read_size);
> +    snd_size= my_b_gets(f, buf_act + read_size, max_size - read_size);
> +    if (snd_size == 0 ||
> +        (snd_size + 1 == max_size - read_size) &&  buf[max_size - 2] !=
> '\n')
> +    {
> +      /*
> +        failure to make the 2nd read or short read again
> +      */
> +      ret= 1;
> +      goto err;
> +    }
> +  }
> +  token= strtok_r(buf_act, " ", &last);
> +  if (token == NULL)
> +  {
> +    ret= 1;
> +    goto err;
> +  }
> +  num_items= atoi(token);
> +  for (uint i=0; i < num_items; i++)
> +  {
> +    token= strtok_r(NULL, " ", &last);
> +    if (token == NULL)
> +    {
> +      ret= 1;
> +      goto err;
> +    }
> +    else
> +    {
> +      ulong val= atol(token);
> +      insert_dynamic(arr, (uchar *) &val);
> +    }
> +  }
> +err:
> +  if (buf_act != buf)
> +    my_free(buf_act, MYF(0));
> +  DBUG_RETURN(ret);
> +}
> +
> +

[snip]


Thread
bk commit into 6.0 tree (aelkin:1.2634) BUG#25998Andrei Elkin4 Jun
  • Re: bk commit into 6.0 tree (aelkin:1.2634) BUG#25998Mats Kindahl17 Jun
  • Re: bk commit into 6.0 tree (aelkin:1.2634) BUG#25998He Zhenxing2 Jul