List:Commits« Previous MessageNext Message »
From:Dmitry Lenev Date:October 5 2010 6:34am
Subject:Re: bzr commit into mysql-5.5-runtime branch (jon.hauglid:3152)
Bug#57002
View as plain text  
Hello Jon Olav!

* Jon Olav Hauglid <jon.hauglid@stripped> [10/10/04 13:32]:
> #At file:///export/home/x/mysql-5.5-runtime-bug57002/ based on
> revid:jon.hauglid@stripped
> 
>  3152 Jon Olav Hauglid	2010-10-04
>       Bug #57002 Assert in upgrade_shared_lock_to_exclusive()
>                  for ALTER TABLE + MERGE tables
>       
>       The patch for Bug#56292 changed how metadata locks are taken for MERGE
>       tables. After the patch, locking the MERGE table will also lock the
>       children tables with the same metadata lock type. This means that 
>       LOCK TABLES on a MERGE table also will implicitly do LOCK TABLES on
>       the children tables.

...

> === modified file 'mysql-test/r/lock.result'
> --- a/mysql-test/r/lock.result	2010-02-01 11:43:06 +0000
> +++ b/mysql-test/r/lock.result	2010-10-04 09:23:26 +0000
> @@ -8,7 +8,7 @@ NULL	1
>  update t1 set id=-1 where id=1;
>  LOCK TABLE t1 READ;
>  update t1 set id=1 where id=1;
> -ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
> +ERROR HY000: Table 't1' was not locked with LOCK TABLES
>  create table t2 SELECT * from t1;
>  ERROR HY000: Table 't2' was not locked with LOCK TABLES
>  create temporary table t2 SELECT * from t1;

...

> === modified file 'sql/sql_base.cc'
> --- a/sql/sql_base.cc	2010-09-30 13:29:12 +0000
> +++ b/sql/sql_base.cc	2010-10-04 09:23:26 +0000
> @@ -2742,8 +2742,11 @@ bool open_table(THD *thd, TABLE_LIST *ta
>              distance >  0 - we have lock mode higher then we require
>              distance == 0 - we have lock mode exactly which we need
>            */
> -          if ((best_distance < 0 && distance > best_distance) ||
> -              (distance >= 0 && distance < best_distance))
> +          if (((best_distance < 0 && distance > best_distance) ||
> +               (distance >= 0 && distance < best_distance))
> &&
> +              ((flags & (MYSQL_OPEN_FORCE_SHARED_MDL |
> +                         MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL)) ||
> +              
> table->mdl_ticket->has_stronger_or_equal_type(table_list->mdl_request.type)))
>            {
>              best_distance= distance;
>              best_table= table;
> 

The following patch:

=== modified file 'sql/sql_base.cc'
--- sql/sql_base.cc     2010-09-30 13:29:12 +0000
+++ sql/sql_base.cc     2010-10-05 05:59:40 +0000
@@ -2730,6 +2730,12 @@ bool open_table(THD *thd, TABLE_LIST *ta
           int distance= ((int) table->reginfo.lock_type -
                          (int) table_list->lock_type);
 
+          if (table_list->mdl_request.type >= MDL_SHARED_NO_WRITE &&
+              ! (flags & (MYSQL_OPEN_FORCE_SHARED_MDL |
+                          MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL)) &&
+              ! table->mdl_ticket->is_upgradable_or_exclusive())
+            distance= -1;
+
           /*
             Find a table that either has the exact lock type requested,
             or has the best suitable lock. In case there is no locked


fixes the bug as well.

OTOH it doesn't change error codes and messages in so many cases.

So maybe we should follow this approach instead?

Or even make a more radical change and also remove similar check
which is done in open_tables_check_upgradable_mdl() and which
becomes redundant with this patch?

What do you think?

-- 
Dmitry Lenev, Software Developer
Oracle Development SPB/MySQL, www.mysql.com

Are you MySQL certified?  http://www.mysql.com/certification
Thread
bzr commit into mysql-5.5-runtime branch (jon.hauglid:3152) Bug#57002Jon Olav Hauglid4 Oct
  • Re: bzr commit into mysql-5.5-runtime branch (jon.hauglid:3152)Bug#57002Dmitry Lenev5 Oct
    • Re: bzr commit into mysql-5.5-runtime branch (jon.hauglid:3152)Bug#57002Dmitry Lenev5 Oct
      • Re: bzr commit into mysql-5.5-runtime branch (jon.hauglid:3152) Bug#57002Jon Olav Hauglid5 Oct
        • Re: bzr commit into mysql-5.5-runtime branch (jon.hauglid:3152)Bug#57002Dmitry Lenev5 Oct