diff options
| author | Aleksey Midenkov <midenok@gmail.com> | 2022-08-31 11:55:05 +0300 |
|---|---|---|
| committer | Aleksey Midenkov <midenok@gmail.com> | 2022-08-31 11:55:05 +0300 |
| commit | a228ec80e30cae59c2057b786fd3559171ce794f (patch) | |
| tree | 6bcfdf0ec97f32c97a1dfc28120856334f591407 /mysql-test/main/create_or_replace2.result | |
| parent | 24fff8267d0722b20ca780cf144ce27560df1394 (diff) | |
| download | mariadb-git-a228ec80e30cae59c2057b786fd3559171ce794f.tar.gz | |
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.
Diffstat (limited to 'mysql-test/main/create_or_replace2.result')
| -rw-r--r-- | mysql-test/main/create_or_replace2.result | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_or_replace2.result index f7bbb7417e6..dd183441e42 100644 --- a/mysql-test/main/create_or_replace2.result +++ b/mysql-test/main/create_or_replace2.result @@ -72,3 +72,22 @@ ERROR 42000: Duplicate key name 'k' create or replace table t1 (a int, b int, key k (a), key k (b)); ERROR 42000: Duplicate key name 'k' drop table t1; +# +# MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES +# +# Non-atomic CREATE OR REPLACE part: +# +set @saved_debug_dbug= @@session.debug_dbug; +set @@debug_dbug="+d,ddl_log_expensive_rename"; +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; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop tables t1; +set @@debug_dbug= @saved_debug_dbug; |
