Bug #38752 Trigger DDL editor trims down DROP IF EXISTS statements
Submitted: 12 Aug 2008 15:48 Modified: 13 Aug 2008 19:58
Reporter: Alex Saavedra Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.0.24 OS:Windows (SP3)
Assigned to: CPU Architecture:Any

[12 Aug 2008 15:48] Alex Saavedra
Description:
It's common practice to include "DROP TRIGGER IF EXISTS myTable_ai" before a trigger definition. When you try to include such statements using the embedded trigger editor, they are trimmed down.

How to repeat:
1. create table t1 with 2 fields: id INT NOT NULL AUTO_INCREMENT, descrip VARCHAR(45)
2. create table t2 with 2 fields: id INT NOT NULL AUTO_INCREMENT, log TEXT
3. on table t1 create AFTER INSERT trigger as follows, using the embedded triggers editor:

DROP TRIGGER IF EXISTS t1_ai;

DELIMITER //
CREATE TRIGGER t1_ai AFTER INSERT ON t1
  FOR EACH ROW BEGIN 
    SET @x = CONCAT('new record on t1: ', NEW.id);
    INSERT INTO t2 (log) VALUES (@x);
  END
//

DELIMITER ;

4. save the project
5. switch to table t2 in edit mode (right click on t2 >> Edit table)
6. switch back to table t1 in edit mode
7. go to Triggers tab. You will see that DROP TRIGGER IF EXISTS t1_ai statement has been trimmed down.
[12 Aug 2008 18:41] Alex Saavedra
In fact this could be solved by including an "Include DROP TRIGGER statement" in the "Forward Engineer" assistant (see attached image)
[12 Aug 2008 18:42] Alex Saavedra
Include DROP TRIGGER statements

Attachment: drop-trigger.PNG (image/x-png, text), 24.20 KiB.

[13 Aug 2008 3:45] Valeriy Kravchuk
Thank you for a problem report. Please, try to repeat with a newer version, 5.0.24, and inform about the results.
[13 Aug 2008 14:35] Alex Saavedra
This problem remains in v 5.0.24
[13 Aug 2008 19:58] Alex Saavedra
The Forward Engineer CREATE SQL Script creates the required DROP TRIGGER IF EXISTS clause appropriately in version 5.0.24. Thus I'm closing this ticket.