1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Ensure that one can drop a trigger with an orphan .TRN file

Before this fix, one would get a 'Trigger ... already exists' when trying
to create a trigger matching the original name and 'Trigger ... does not
exists" when trying to drop it.

Fixes a reported bug in MDEV-25180 Atomic ALTER TABLE

MDEV-25517 Atomic DDL: Assertion `query_arg' in THD::binlog_query
upon DROP TRIGGER

The bug was that the stmt_query variable was not populated
with the query in case of DROP TRIGGER of an orphan trigger
(.TRN file exists & table exists, but the trigger was not in
table->triggers).
This commit is contained in:
Monty
2021-03-21 17:47:56 +02:00
committed by Sergei Golubchik
parent ffe7f19fa6
commit c844a76b0a
6 changed files with 195 additions and 16 deletions

View File

@ -2782,3 +2782,48 @@ DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
--echo #
--echo # Test dropping orphan .trn file
--echo #
let $MYSQLD_DATADIR= `select @@datadir`;
create table t1 (a int);
delimiter |;
create trigger t1_trg before insert on t1 for each row
begin
if isnull(new.a) then
set new.a:= 1000;
end if;
end|
delimiter ;|
insert into t1 values (null);
select * from t1;
--copy_file $MYSQLD_DATADIR/test/t1_trg.TRN $MYSQLD_DATADIR/test/t1_trg.TMP
drop table t1;
--copy_file $MYSQLD_DATADIR/test/t1_trg.TMP $MYSQLD_DATADIR/test/t1_trg.TRN
drop trigger t1_trg;
create table t1 (a int);
--copy_file $MYSQLD_DATADIR/test/t1_trg.TMP $MYSQLD_DATADIR/test/t1_trg.TRN
drop trigger t1_trg;
# Test creating an additonal trigger for t1, but with different names
delimiter |;
create trigger t1_trg_2 before insert on t1 for each row
begin
if isnull(new.a) then
set new.a:= 1000;
end if;
end|
delimiter ;|
--copy_file $MYSQLD_DATADIR/test/t1_trg.TMP $MYSQLD_DATADIR/test/t1_trg.TRN
drop trigger t1_trg;
drop trigger t1_trg_2;
drop table t1;
--remove_file $MYSQLD_DATADIR/test/t1_trg.TMP
--echo #
--echo # End of 10.6 tests
--echo #