MySQL Lists are EOL. Please join:

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

 2877 Jon Olav Hauglid	2009-08-26
      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_parse.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-26 09:05:48 +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-26 09:05:48 +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_parse.cc'
--- a/sql/sql_parse.cc	2009-08-25 07:22:47 +0000
+++ b/sql/sql_parse.cc	2009-08-26 09:05:48 +0000
@@ -4110,16 +4110,31 @@ end_with_restore_list:
 #endif
   case SQLCOM_HA_OPEN:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
+    if (thd->locked_tables_mode)
+    {
+      my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+      goto error;
+    }
     if (check_table_access(thd, SELECT_ACL, all_tables, FALSE, FALSE, UINT_MAX))
       goto error;
     res= mysql_ha_open(thd, first_table, 0);
     break;
   case SQLCOM_HA_CLOSE:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
+    if (thd->locked_tables_mode)
+    {
+      my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+      goto error;
+    }
     res= mysql_ha_close(thd, first_table);
     break;
   case SQLCOM_HA_READ:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
+    if (thd->locked_tables_mode)
+    {
+      my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+      goto error;
+    }
     /*
       There is no need to check for table permissions here, because
       if a user has no permissions to read a table, he won't be


Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20090826090548-pkwbmxtwb58zmphq.bundle
Thread
bzr commit into mysql-5.4 branch (jon.hauglid:2877) Bug#43272Jon Olav Hauglid26 Aug
  • Re: bzr commit into mysql-5.4 branch (jon.hauglid:2877) Bug#43272Davi Arnaut31 Aug