Bug #18442 ALTER TABLE with trigger to same name will delete .TRG file
Submitted: 22 Mar 2006 22:19 Modified: 22 Mar 2006 22:41
Reporter: Magnus Blåudd Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 + 5.1 OS:Windows (Windows)
Assigned to: Magnus Blåudd CPU Architecture:Any

[22 Mar 2006 22:19] Magnus Blåudd
Description:
Altering a table  with trigger to the same name will delete the .TRG file and thus drop all triggers for the table.

How to repeat:
create table t1 (id int not null primary key, data int);
create trigger t1_ai after insert on t1 for each row
  set @log:= 1;
alter table t1 add ts timestamp default now();

The t1.TRG file is now missing.

Suggested fix:
Dont delete the "from" file when the to file has same name.
[22 Mar 2006 22:19] Magnus Blåudd
The server does not have this behaviour on Linux.
[22 Mar 2006 22:41] Dmitry Lenev
Hi, Magnus!

This bug has the same cause (and the same fix) as bug #18153 "OPTIMIZE/ALTER on transactional tables corrupt triggers" (which is already in patch pending state).
So I will mark this bug as duplicate.