summaryrefslogtreecommitdiff
path: root/mysql-test/r/lock_multi.result
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2010-02-26 13:40:25 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2010-02-26 13:40:25 +0100
commit7fd30bf61007af9bfe8114724375da18cabb04a9 (patch)
treec944c10b15f768923b923f396b95a99b30e60bc5 /mysql-test/r/lock_multi.result
parenta42cbe060c989ddc3d181a687b9628c459830c2c (diff)
downloadmariadb-git-7fd30bf61007af9bfe8114724375da18cabb04a9.tar.gz
Bug #51240 ALTER TABLE of a locked MERGE table fails
The problem was that ALTER TABLE on a merge table which was locked using LOCK TABLE ... WRITE, by mistake gave ER_TABLE_NOT_LOCKED_FOR_WRITE. During opening of the table to be ALTERed, open_table() tried to get an upgradable metadata lock. In LOCK TABLEs mode, this lock must already exist (i.e. taken by LOCK TABLE) as new locks of this type cannot be acquired for fear of deadlock. So in LOCK TABLEs mode, open_table() tried to find an existing upgradable lock for the table to be altered. The problem was that open_table() also tried to find upgradable metadata locks for children of merge tables even if no such locks are needed to execute ALTER TABLE on merge tables. This patch fixes the problem by making sure that open tables code only searches for upgradable metadata locks for the merge table and not for the merge children tables. The patch also fixes a related bug where an upgradable metadata lock was aquired outside of LOCK TABLEs mode even if the table in question was temporary. This bug meant that LOCK TABLES or DDL on temporary tables by mistake could be blocked/aborted by locks held on base tables with the same table name by other connections. Test cases added to merge.test and lock_multi.test.
Diffstat (limited to 'mysql-test/r/lock_multi.result')
-rw-r--r--mysql-test/r/lock_multi.result14
1 files changed, 14 insertions, 0 deletions
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index c440dafb228..99e1f54e762 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -462,3 +462,17 @@ ERROR 70100: Query execution was interrupted
unlock tables;
# Switching to connection 'default'
drop table t3;
+#
+# Test for the bug where upgradable metadata locks was acquired
+# even if the table to altered was temporary.
+# Bug found while working on the related bug #51240.
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (id INT);
+LOCK TABLE t1 WRITE;
+# Connection con1
+CREATE TEMPORARY TABLE t1 (id INT);
+ALTER TABLE t1 ADD COLUMN j INT;
+# Connection default
+UNLOCK TABLES;
+DROP TABLE t1;