diff options
author | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-02-26 13:40:25 +0100 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-02-26 13:40:25 +0100 |
commit | 7fd30bf61007af9bfe8114724375da18cabb04a9 (patch) | |
tree | c944c10b15f768923b923f396b95a99b30e60bc5 /mysql-test/t/lock_multi.test | |
parent | a42cbe060c989ddc3d181a687b9628c459830c2c (diff) | |
download | mariadb-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/t/lock_multi.test')
-rw-r--r-- | mysql-test/t/lock_multi.test | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index c34dcb05dd4..6983947d1c4 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -1092,5 +1092,31 @@ disconnect con2; drop table t3; +--echo # +--echo # Test for the bug where upgradable metadata locks was acquired +--echo # even if the table to altered was temporary. +--echo # Bug found while working on the related bug #51240. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (id INT); +LOCK TABLE t1 WRITE; + +--echo # Connection con1 +connect (con1, localhost, root); +CREATE TEMPORARY TABLE t1 (id INT); +# This alter should not block and timeout. +ALTER TABLE t1 ADD COLUMN j INT; + +--echo # Connection default +connection default; +disconnect con1; +UNLOCK TABLES; +DROP TABLE t1; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc |