1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-03 05:41:09 +03:00

MDEV-5619: CREATE OR REPLACE does not release MDL_EXCLUSIVE upon failure

mysql-test/r/create_or_replace.result:
  Added test of releasing of metadata locks
mysql-test/t/create_or_replace.test:
  Added test of releasing of metadata locks
sql/handler.h:
  Added marker if table was deleted as part of CREATE OR REPLACE
sql/sql_base.cc:
  Added Locked_tables_list::unlock_locked_table()
sql/sql_class.h:
  New prototypes
sql/sql_insert.cc:
  Unlock metadata locks for deleted table in case of error. Also do unlock tables if this was the only locked table.
sql/sql_table.cc:
  Unlock metadata locks for deleted table in case of error. Also do unlock tables if this was the only locked table.
This commit is contained in:
Michael Widenius
2014-03-12 11:26:40 +02:00
parent 49ca12a107
commit f320b12ca5
7 changed files with 157 additions and 3 deletions

View File

@@ -202,6 +202,42 @@ unlock tables;
select * from t1 order by a,i;
drop table t1,t3;
--echo #
--echo # Test the meta data locks are freed properly
--echo #
create database mysqltest2;
drop table if exists test.t1,mysqltest2.t2;
create table test.t1 (i int);
create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
select * from information_schema.metadata_lock_info;
--error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table test.t1;
show tables;
select * from information_schema.metadata_lock_info;
--error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table mysqltest2.t2;
select * from information_schema.metadata_lock_info;
create table t1 (i int);
drop table t1;
create table test.t1 (i int);
create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
select * from information_schema.metadata_lock_info;
--error ER_DUP_FIELDNAME
create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a';
show tables;
select * from information_schema.metadata_lock_info;
--error ER_DUP_FIELDNAME
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
select * from information_schema.metadata_lock_info;
create table t1 (i int);
drop table t1;
drop database mysqltest2;
--echo #
--echo # Testing CREATE .. LIKE
--echo #