List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:February 24 2009 10:24am
Subject:bzr commit into mysql-6.0-bugteam branch (Davi.Arnaut:3072) Bug#41110
View as plain text  
#At file:///data0/my/darnaut/mysql-repo/work/mysql-6.0-bugteam/ based on revid:azundris@stripped

 3072 Davi Arnaut	2009-02-24 [merge]
      Merge Bug#41110 into 6.0-bugteam.

    modified:
      mysql-test/include/handler.inc
      mysql-test/r/handler_innodb.result
      mysql-test/r/handler_myisam.result
      sql/sql_handler.cc
=== modified file 'mysql-test/include/handler.inc'
--- a/mysql-test/include/handler.inc	2008-05-23 13:54:03 +0000
+++ b/mysql-test/include/handler.inc	2009-02-24 10:22:54 +0000
@@ -697,3 +697,34 @@ unlock tables;
 drop table t1;
 --error ER_UNKNOWN_TABLE
 handler t1 read a next;
+
+#
+# Bug#41110: crash with handler command when used concurrently with alter table
+# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
+#
+
+connect(con1,localhost,root,,);
+
+connection default;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+insert into t1 values (1);
+handler t1 open;
+connection con1;
+send alter table t1 engine=memory;
+connection con2;
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Waiting for table" and info = "alter table t1 engine=memory";
+--source include/wait_condition.inc
+connection default;
+--error ER_ILLEGAL_HA
+handler t1 read a next;
+handler t1 close;
+connection con1;
+--reap
+drop table t1;
+connection default;
+disconnect con1;

=== modified file 'mysql-test/r/handler_innodb.result'
--- a/mysql-test/r/handler_innodb.result	2008-08-11 19:37:53 +0000
+++ b/mysql-test/r/handler_innodb.result	2009-02-24 10:22:54 +0000
@@ -732,3 +732,12 @@ unlock tables;
 drop table t1;
 handler t1 read a next;
 ERROR 42S02: Unknown table 't1' in HANDLER
+drop table if exists t1;
+create table t1 (a int);
+insert into t1 values (1);
+handler t1 open;
+alter table t1 engine=memory;
+handler t1 read a next;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+handler t1 close;
+drop table t1;

=== modified file 'mysql-test/r/handler_myisam.result'
--- a/mysql-test/r/handler_myisam.result	2008-05-23 13:54:03 +0000
+++ b/mysql-test/r/handler_myisam.result	2009-02-24 10:22:54 +0000
@@ -730,3 +730,12 @@ unlock tables;
 drop table t1;
 handler t1 read a next;
 ERROR 42S02: Unknown table 't1' in HANDLER
+drop table if exists t1;
+create table t1 (a int);
+insert into t1 values (1);
+handler t1 open;
+alter table t1 engine=memory;
+handler t1 read a next;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+handler t1 close;
+drop table t1;

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2009-01-27 02:08:48 +0000
+++ b/sql/sql_handler.cc	2009-02-24 10:22:54 +0000
@@ -160,6 +160,9 @@ static void mysql_ha_close_table(THD *th
     table->query_id= thd->query_id;
     table->open_by_handler= 0;
   }
+
+  /* Mark table as closed, ready for re-open if necessary. */
+  tables->table= NULL;
 }
 
 /*
@@ -177,8 +180,7 @@ static void mysql_ha_close_table(THD *th
     'reopen' is set when a handler table is to be re-opened. In this case,
     'tables' is the pointer to the hashed TABLE_LIST object which has been
     saved on the original open.
-    'reopen' is also used to suppress the sending of an 'ok' message or
-    error messages.
+    'reopen' is also used to suppress the sending of an 'ok' message.
 
   RETURN
     FALSE OK
@@ -308,8 +310,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST 
   /* There can be only one table in '*tables'. */
   if (! (hash_tables->table->file->ha_table_flags() & HA_CAN_SQL_HANDLER))
   {
-    if (! reopen)
-      my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
+    my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
     goto err;
   }
 
@@ -500,8 +501,7 @@ retry:
 
   if (need_reopen)
   {
-    mysql_ha_close_table(thd, tables);
-    hash_tables->table= NULL;
+    mysql_ha_close_table(thd, hash_tables);
     /*
       The lock might have been aborted, we need to manually reset
       thd->some_tables_deleted because handler's tables are closed
@@ -780,11 +780,7 @@ void mysql_ha_flush(THD *thd)
         (hash_tables->table->mdl_lock_data &&
          mdl_has_pending_conflicting_lock(hash_tables->table->mdl_lock_data) ||
          hash_tables->table->needs_reopen()))
-    {
       mysql_ha_close_table(thd, hash_tables);
-      /* Mark table as closed, ready for re-open. */
-      hash_tables->table= NULL;
-    }
   }
 
   DBUG_VOID_RETURN;


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20090224102254-36qv5h5k1j1tmfsw.bundle
Thread
bzr commit into mysql-6.0-bugteam branch (Davi.Arnaut:3072) Bug#41110Davi Arnaut24 Feb