List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:July 21 2010 3:24pm
Subject:Re: bzr commit into mysql-trunk-runtime branch (jon.hauglid:3081)
Bug#54905
View as plain text  
* Jon Olav Hauglid <jon.hauglid@stripped> [10/07/21 18:52]:
 
> === modified file 'sql/sql_show.cc'
> --- a/sql/sql_show.cc	2010-07-15 15:46:41 +0000
> +++ b/sql/sql_show.cc	2010-07-21 14:27:38 +0000
> @@ -649,22 +649,33 @@ mysqld_show_create(THD *thd, TABLE_LIST 
>    Protocol *protocol= thd->protocol;
>    char buff[2048];
>    String buffer(buff, sizeof(buff), system_charset_info);
> +  List<Item> field_list;
> +  bool error= FALSE;
>    DBUG_ENTER("mysqld_show_create");
>    DBUG_PRINT("enter",("db: %s  table: %s",table_list->db,
>                        table_list->table_name));
>  
> +  /*
> +    Metadata locks taken during SHOW CREATE should be released when
> +    the statmement completes as it is an information statement.
> +  */
> +  MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint();
> +
>    /* We want to preserve the tree for views. */
>    thd->lex->view_prepare_mode= TRUE;
>  
>    {
>      Show_create_error_handler view_error_suppressor(thd, table_list);
>      thd->push_internal_handler(&view_error_suppressor);
> -    bool error=
> +    bool open_error=
>        open_normal_and_derived_tables(thd, table_list,
>                                       MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL);
>      thd->pop_internal_handler();
> -    if (error && (thd->killed || thd->is_error()))
> -      DBUG_RETURN(TRUE);
> +    if (open_error && (thd->killed || thd->is_error()))
> +    {
> +      error= TRUE;
> +      goto exit;
> +    }

Perhaps a matter of taste, but assigning the error to TRUE 
at the beginning and resetting to FALSE only at the very end
would save you a few lines.

<cut>

>  
>    if (protocol->write())
> -    DBUG_RETURN(TRUE);
> +  {
> +    error= TRUE;
> +    goto exit;
> +  }
>  
>    my_eof(thd);
> -  DBUG_RETURN(FALSE);
> +
> +exit:
> +  /* Release any metadata locks taken during SHOW CREATE. */
> +  thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
> +  DBUG_RETURN(error);

We should not release metadata locks on tables before calling
close_thread_tables(). In my current patch I have an assert for
it in close_thread_table().
Thus here you also should call close_thread_tables() first.

-- 
Thread
bzr commit into mysql-trunk-runtime branch (jon.hauglid:3081) Bug#54905Jon Olav Hauglid21 Jul
  • Re: bzr commit into mysql-trunk-runtime branch (jon.hauglid:3081)Bug#54905Konstantin Osipov21 Jul
    • Re: bzr commit into mysql-trunk-runtime branch (jon.hauglid:3081)Bug#54905Jon Olav Hauglid22 Jul