mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +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:
@ -247,6 +247,69 @@ a i
|
||||
3 3
|
||||
drop table t1,t3;
|
||||
#
|
||||
# Test the meta data locks are freed properly
|
||||
#
|
||||
create database mysqltest2;
|
||||
drop table if exists test.t1,mysqltest2.t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 'test.t1'
|
||||
Note 1051 Unknown table '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;
|
||||
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
|
||||
3 MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
|
||||
3 MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2
|
||||
create or replace table test.t1;
|
||||
ERROR 42000: A table must have at least 1 column
|
||||
show tables;
|
||||
Tables_in_test
|
||||
t2
|
||||
select * from information_schema.metadata_lock_info;
|
||||
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
|
||||
3 MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2
|
||||
create or replace table mysqltest2.t2;
|
||||
ERROR 42000: A table must have at least 1 column
|
||||
select * from information_schema.metadata_lock_info;
|
||||
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
|
||||
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;
|
||||
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
|
||||
3 MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
|
||||
3 MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2
|
||||
create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a';
|
||||
ERROR 42S21: Duplicate column name 'a'
|
||||
show tables;
|
||||
Tables_in_test
|
||||
t2
|
||||
select * from information_schema.metadata_lock_info;
|
||||
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock mysqltest2
|
||||
3 MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
|
||||
3 MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock mysqltest2 t2
|
||||
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
|
||||
ERROR 42S21: Duplicate column name 'a'
|
||||
select * from information_schema.metadata_lock_info;
|
||||
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
|
||||
create table t1 (i int);
|
||||
drop table t1;
|
||||
drop database mysqltest2;
|
||||
#
|
||||
# Testing CREATE .. LIKE
|
||||
#
|
||||
create or replace table t1 like t2;
|
||||
|
@ -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 #
|
||||
|
Reference in New Issue
Block a user