mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES
add_back_last_deleted_lock() was called when the lock was never removed. Lock is removed in finalize_atomic_replace() in close_all_tables_for_name(). finalize_atomic_replace() is done only for successful operation. In non-atomic codepath it drops the table first, if anything fails later we don't need to return back the lock since there is no table now. So the fix is required as well.
This commit is contained in:
@ -847,3 +847,19 @@ t2 CREATE TABLE `t2` (
|
||||
`a` varchar(2300) DEFAULT NULL
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
||||
drop tables t2, t1;
|
||||
#
|
||||
# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES
|
||||
#
|
||||
# Atomic CREATE OR REPLACE part:
|
||||
#
|
||||
create table t1 (pk int primary key) engine=innodb;
|
||||
create or replace table t2 (a int primary key references t1 (pk)) engine=innodb;
|
||||
lock tables t1 write, t2 write;
|
||||
create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb;
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
select * from t1;
|
||||
pk
|
||||
select * from t2;
|
||||
a
|
||||
unlock tables;
|
||||
drop tables t2, t1;
|
||||
|
Reference in New Issue
Block a user