MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:August 31 2009 2:03pm
Subject:bzr commit into mysql-5.4 branch (jon.hauglid:2804) Bug#43272
View as plain text  
#At file:///export/home/z/mysql-next-bugfixing-bug43272/ based on revid:alik@stripped

 2804 Jon Olav Hauglid	2009-08-31
      Bug #43272 HANDLER SQL command does not work under LOCK TABLES
      
      HANDLER commands are now explicitly disallowed in LOCK TABLES mode.
      
      Before, HANDLER OPEN gave the misleading error message: "Table x was 
      not locked with LOCK TABLES". This patch changes HANDLER OPEN/READ/CLOSE 
      to give ER_LOCK_OR_ACTIVE_TRANSACTION "Can't execute the given command 
      because you have active locked tables or an active transaction" in
      LOCK TABLES mode.
      
      Test case added to lock.test.

    modified:
      mysql-test/r/lock.result
      mysql-test/t/lock.test
      sql/sql_handler.cc
=== modified file 'mysql-test/r/lock.result'
--- a/mysql-test/r/lock.result	2009-08-03 15:26:04 +0000
+++ b/mysql-test/r/lock.result	2009-08-31 14:03:25 +0000
@@ -341,5 +341,20 @@ alter table t1 add column j int;
 unlock tables;
 drop table t1;
 #
+# Bug #43272 HANDLER SQL command does not work under LOCK TABLES
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT);
+LOCK TABLE t1 WRITE;
+# HANDLER commands are not allowed in LOCK TABLES mode
+HANDLER t1 OPEN;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+HANDLER t1 READ FIRST;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+HANDLER t1 CLOSE;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+DROP TABLE t1;
+#
 # End of 6.0 tests.
 #

=== modified file 'mysql-test/t/lock.test'
--- a/mysql-test/t/lock.test	2009-08-03 15:26:04 +0000
+++ b/mysql-test/t/lock.test	2009-08-31 14:03:25 +0000
@@ -416,6 +416,30 @@ alter table t1 add column j int;
 unlock tables;
 drop table t1;
 
+
+--echo #
+--echo # Bug #43272 HANDLER SQL command does not work under LOCK TABLES
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+LOCK TABLE t1 WRITE;
+
+--echo # HANDLER commands are not allowed in LOCK TABLES mode
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+HANDLER t1 OPEN;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+HANDLER t1 READ FIRST;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+HANDLER t1 CLOSE;
+
+UNLOCK TABLES;
+DROP TABLE t1;
+
+
 --echo #
 --echo # End of 6.0 tests.
 --echo #

=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc	2009-08-25 07:22:47 +0000
+++ b/sql/sql_handler.cc	2009-08-31 14:03:25 +0000
@@ -201,6 +201,11 @@ bool mysql_ha_open(THD *thd, TABLE_LIST 
                       tables->db, tables->table_name, tables->alias,
                       (int) reopen));
 
+  if (thd->locked_tables_mode)
+  {
+    my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+    DBUG_RETURN(TRUE);
+  }
   if (tables->schema_table)
   {
     my_error(ER_WRONG_USAGE, MYF(0), "HANDLER OPEN",
@@ -387,6 +392,11 @@ bool mysql_ha_close(THD *thd, TABLE_LIST
   DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
                       tables->db, tables->table_name, tables->alias));
 
+  if (thd->locked_tables_mode)
+  {
+    my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+    DBUG_RETURN(TRUE);
+  }
   if ((hash_tables= (TABLE_LIST*) my_hash_search(&thd->handler_tables_hash,
                                               (uchar*) tables->alias,
                                               strlen(tables->alias) + 1)))
@@ -449,6 +459,12 @@ bool mysql_ha_read(THD *thd, TABLE_LIST 
   DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
                       tables->db, tables->table_name, tables->alias));
 
+  if (thd->locked_tables_mode)
+  {
+    my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+    DBUG_RETURN(TRUE);
+  }
+
   LINT_INIT(key);
   LINT_INIT(key_len);
 


Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20090831140325-ty0l879gxy6afgkh.bundle
Thread
bzr commit into mysql-5.4 branch (jon.hauglid:2804) Bug#43272Jon Olav Hauglid31 Aug