MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kroki Date:August 29 2006 12:59pm
Subject:bk commit into 4.1 tree (kroki:1.2530) BUG#21096
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of tomash. When tomash does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-08-29 16:59:20+04:00, kroki@stripped +3 -0
  BUG#21096: locking issue ; temporary table conflicts.
  
  The problem was that during DROP TEMPORARY TABLE we tried to acquire
  the name lock, though temporary tables belongs to one connection, and
  no race is possible.
  
  The solution is to not use table name locking while executing
  DROP TEMPORARY TABLE.

  mysql-test/r/temp_table.result@stripped, 2006-08-29 16:59:18+04:00, kroki@stripped +17 -0
    Add result for bug#21096: locking issue ; temporary table conflicts.

  mysql-test/t/temp_table.test@stripped, 2006-08-29 16:59:18+04:00, kroki@stripped +47 -1
    Add test case for bug#21096: locking issue ; temporary table conflicts.

  sql/sql_table.cc@stripped, 2006-08-29 16:59:18+04:00, kroki@stripped +3 -2
    Do not use table name locking while executing DROP TEMPORARY TABLE.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-4.1-bug21096

--- 1.307/sql/sql_table.cc	2006-08-29 16:59:24 +04:00
+++ 1.308/sql/sql_table.cc	2006-08-29 16:59:24 +04:00
@@ -214,7 +214,7 @@ int mysql_rm_table_part2(THD *thd, TABLE
   bool some_tables_deleted=0, tmp_table_deleted=0, foreign_key_error=0;
   DBUG_ENTER("mysql_rm_table_part2");
 
-  if (lock_table_names(thd, tables))
+  if (!drop_temporary && lock_table_names(thd, tables))
     DBUG_RETURN(1);
 
   for (table=tables ; table ; table=table->next)
@@ -311,7 +311,8 @@ int mysql_rm_table_part2(THD *thd, TABLE
     }
   }
 
-  unlock_table_names(thd, tables);
+  if (!drop_temporary)
+    unlock_table_names(thd, tables);
   DBUG_RETURN(error);
 }
 

--- 1.11/mysql-test/r/temp_table.result	2006-08-29 16:59:24 +04:00
+++ 1.12/mysql-test/r/temp_table.result	2006-08-29 16:59:24 +04:00
@@ -108,3 +108,20 @@ d	c
 bar	2
 foo	1
 drop table t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT);
+LOCK TABLE t1 WRITE;
+CREATE TEMPORARY TABLE t1 (i INT);
+The following command should not block
+DROP TEMPORARY TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (i INT);
+CREATE TEMPORARY TABLE t2 (i INT);
+DROP TEMPORARY TABLE t2, t1;
+ERROR 42S02: Unknown table 't1'
+SELECT * FROM t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+SELECT * FROM t1;
+i
+DROP TABLE t1;
+End of 4.1 tests.

--- 1.10/mysql-test/t/temp_table.test	2006-08-29 16:59:24 +04:00
+++ 1.11/mysql-test/t/temp_table.test	2006-08-29 16:59:24 +04:00
@@ -99,4 +99,50 @@ insert into t2 values (NULL, 'foo'), (NU
 select d, c from t1 left join t2 on b = c where a = 3 order by d;
 drop table t1, t2;
 
-# End of 4.1 tests
+
+#
+# BUG#21096: locking issue ; temporary table conflicts.
+#
+# The problem was that on DROP TEMPORARY table name lock was acquired,
+# which should not be done.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+LOCK TABLE t1 WRITE;
+
+connect (conn1, localhost, root,,);
+
+CREATE TEMPORARY TABLE t1 (i INT);
+
+--echo The following command should not block
+DROP TEMPORARY TABLE t1;
+
+disconnect conn1;
+connection default;
+
+DROP TABLE t1;
+
+#
+# Check that it's not possible to drop a base table with
+# DROP TEMPORARY statement.
+#
+CREATE TABLE t1 (i INT);
+CREATE TEMPORARY TABLE t2 (i INT);
+
+--error 1051
+DROP TEMPORARY TABLE t2, t1;
+
+# Table t2 should have been dropped.
+--error 1146
+SELECT * FROM t2;
+# But table t1 should still be there.
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+
+--echo End of 4.1 tests.
Thread
bk commit into 4.1 tree (kroki:1.2530) BUG#21096kroki29 Aug