MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:February 5 2010 2:52pm
Subject:bzr commit into mysql-5.5-next-mr branch (jon.hauglid:3076) Bug#50907
View as plain text  
#At file:///export/home/z/mysql-next-4284-bug50907/ based on revid:kostja@stripped

 3076 Jon Olav Hauglid	2010-02-05
      Bug #50907 Assertion `hash_tables->table->next == __null' on 
                 HANDLER OPEN
      
      The problem was a too restrictive assert in the code for 
      HANDLER ... OPEN and HANDLER ... READ that checked table->next
      to verify that we didn't open views or merge tables.
      
      This pointer is also used to link temporary tables together
      (see thd->temporary_tables). In this case TABLE::next can be
      set even if we're trying to open a single table.
      
      This patch adjust the two asserts to also check for the presence
      of temporary tables.
      
      Test case added to handler_myisam.test.

    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	2010-02-02 13:58:15 +0000
+++ b/mysql-test/include/handler.inc	2010-02-05 14:52:17 +0000
@@ -1500,3 +1500,25 @@ connection default;
 handler no_such_table read no_such_index first;
 --error ER_UNKNOWN_TABLE
 handler no_such_table close;
+
+
+--echo #
+--echo # Bug#50907 Assertion `hash_tables->table->next == __null' on 
+--echo #           HANDLER OPEN
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TEMPORARY TABLE t1 (i INT);
+CREATE TEMPORARY TABLE t2 (i INT);
+
+# This used to trigger the assert
+HANDLER t2 OPEN;
+
+# This also used to trigger the assert
+HANDLER t2 READ FIRST;
+
+HANDLER t2 CLOSE;
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/handler_innodb.result'
--- a/mysql-test/r/handler_innodb.result	2010-02-02 13:58:15 +0000
+++ b/mysql-test/r/handler_innodb.result	2010-02-05 14:52:17 +0000
@@ -1464,3 +1464,15 @@ handler no_such_table read no_such_index
 ERROR 42S02: Unknown table 'no_such_table' in HANDLER
 handler no_such_table close;
 ERROR 42S02: Unknown table 'no_such_table' in HANDLER
+#
+# Bug#50907 Assertion `hash_tables->table->next == __null' on 
+#           HANDLER OPEN
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TEMPORARY TABLE t1 (i INT);
+CREATE TEMPORARY TABLE t2 (i INT);
+HANDLER t2 OPEN;
+HANDLER t2 READ FIRST;
+i
+HANDLER t2 CLOSE;
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/handler_myisam.result'
--- a/mysql-test/r/handler_myisam.result	2010-02-02 13:58:15 +0000
+++ b/mysql-test/r/handler_myisam.result	2010-02-05 14:52:17 +0000
@@ -1462,6 +1462,18 @@ ERROR 42S02: Unknown table 'no_such_tabl
 handler no_such_table close;
 ERROR 42S02: Unknown table 'no_such_table' in HANDLER
 #
+# Bug#50907 Assertion `hash_tables->table->next == __null' on 
+#           HANDLER OPEN
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TEMPORARY TABLE t1 (i INT);
+CREATE TEMPORARY TABLE t2 (i INT);
+HANDLER t2 OPEN;
+HANDLER t2 READ FIRST;
+i
+HANDLER t2 CLOSE;
+DROP TABLE t1, t2;
+#
 # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash 
 #
 CREATE TABLE t1 AS SELECT 1 AS f1;

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2010-02-01 23:22:16 +0000
+++ b/sql/sql_handler.cc	2010-02-05 14:52:17 +0000
@@ -322,8 +322,14 @@ bool mysql_ha_open(THD *thd, TABLE_LIST 
     thd->mdl_context.set_needs_thr_lock_abort(TRUE);
   }
 
-  /* Assert that the above check prevent opening of views and merge tables. */
-  DBUG_ASSERT(hash_tables->table->next == NULL);
+  /*
+    Assert that the above check prevents opening of views and merge tables.
+    For temporary tables, TABLE::next can be set even if only one table
+    was opened for HANDLER as it is used to link them together
+    (see thd->temporary_tables).
+  */
+  DBUG_ASSERT(hash_tables->table->next == NULL ||
+              hash_tables->table->s->tmp_table);
   /*
     If it's a temp table, don't reset table->query_id as the table is
     being used by this handler. Otherwise, no meaning at all.
@@ -485,7 +491,8 @@ retry:
   /* save open_tables state */
   backup_open_tables= thd->open_tables;
   /* Always a one-element list, see mysql_ha_open(). */
-  DBUG_ASSERT(hash_tables->table->next == NULL);
+  DBUG_ASSERT(hash_tables->table->next == NULL ||
+              hash_tables->table->s->tmp_table);
   /*
     mysql_lock_tables() needs thd->open_tables to be set correctly to
     be able to handle aborts properly.


Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20100205145217-3b7n3jfx1y47z41u.bundle
Thread
bzr commit into mysql-5.5-next-mr branch (jon.hauglid:3076) Bug#50907Jon Olav Hauglid5 Feb
  • Re: bzr commit into mysql-5.5-next-mr branch (jon.hauglid:3076)Bug#50907Dmitry Lenev5 Feb