Bug #51929 Unnecessary Sync Updates
Submitted: 10 Mar 2010 19:12 Modified: 29 Jun 2010 12:56
Reporter: Martin Pirringer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S3 (Non-critical)
Version:5.2.16 OS:Any (Windows 7, Mac OS X)
Assigned to: Alexander Musienko CPU Architecture:Any
Tags: SP, synchronize, trigger

[10 Mar 2010 19:12] Martin Pirringer
Description:
Avoid unnecessary synchronizations

Also avoid cursor from jumping around

How to repeat:
1.) Create a new Model with schema "test"
2.) CREATE table `table` with a couple of fields
3.) Click on triggers and you get
-- Trigger DDL Statements
USE `test`;
DELIMITER $$

4 under delimiters Start typing

CREATE Definer = `admin`@`%` TRIGGER `beforeinsert`
BEFORE INSERT On table1
FOR EACH ROW
BEGIN 
    SET new.field = new.idtable1;
END

$$

this is a copy @ paste the $$ should be next to the END
5.) Synchronize it (it will work)
6.) From now on it will always send this trigger to the Schema as the file does not say END$$ 

Same happens with SP or if you put a comment before the "CREATE statement". 

7.) GO after the $$

Start Typing "CREATE TRIGGER" The program will add $$ right after "TRIGGER" And the cursor will jump to the top of the window (DDL statements)

 

Suggested fix:
ideally to solve
1.) Make a seperate TAB for each Trigger.
2.) add some fields for trigger name and definer etc  and just show 
FOR EACH ROW
BEGIN
END

In each edit area. The program can later build the complete "CREATE TRIGGER" statement. This should also make "Syncing" easier "SHOW TRIGGERS" in the statement field just stores the "BEGIN..END" block as a string. It also has one record per trigger (BEFORE, AFTER, INSERT,UPDATE, DELETE) So if the edit/add trigger would mimmick this structure then syncinc should be easier and so should editing be.
[1 Apr 2010 16:26] Valeriy Kravchuk
Verified just as described on Mac OS X (sync part). Indeed, DROP TRIGGER and CREATE TRIGGER are always generated by Syncronize Model, even when trigger is not changed in the model.
[20 Apr 2010 13:13] Johannes Taxacher
the cursor-jumping has been fixed in release.
[23 Jun 2010 15:14] Mike Lischke
Fix confirmed in repository.
[29 Jun 2010 12:56] Tony Bedford
An entry has been added to the 5.2.25 changelog:

When synchronizing a model that contained triggers, erroneous DROP trigger and CREATE trigger statements were generated, even when the triggers had not been changed.