Bug #52587 Syntax checker deletes code
Submitted: 5 Apr 2010 1:33 Modified: 21 Apr 2010 12:55
Reporter: Barry Galbraith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.17 OS:Windows (XP Pro SP3)
Assigned to: Sergei Tkachenko CPU Architecture:Any
Tags: Trigger syntax checker deletes code

[5 Apr 2010 1:33] Barry Galbraith
Description:
Adding triggers in "Alter table" is still a problem. 
If you add a "after insert" trigger, then copy/paste your code so that you can alter it to "after update", the "syntax checker" deletes the code before you get to edit it! 
This forces you to type ALL of your code again

How to repeat:
Open a schema. Select a table. select "alter table"
Select the trigger tab.

Add a trigger for after insert. When the code is complete, copy/paste the code to make a "after update" trigger by editing the code, but syntax checker deletes all the pasted code before you edit it.

Suggested fix:
Change syntax check to only check when you go to apply the code rather than on the fly.
[9 Apr 2010 4:50] Valeriy Kravchuk
Please, provide exact code of the trigger and indicate what exact part of it to copy and where exactly to paste it. I can not repeat this with my simple triggers.
[9 Apr 2010 6:26] Barry Galbraith
In SQL Development.

Select schema, select a table.
Right click, Alter table.
Select Trigger tab.

You get this

- Trigger DDL Statements
DELIMITER $$

USE `mydb`$$

I then type this code

CREATE DEFINER=`root`@`localhost` TRIGGER ai_table1 AFTER INSERT ON table1
	FOR EACH ROW INSERT INTO tbllog (ch_type,chdate) VALUES ("insert", NOW())$$

So now it reads

- Trigger DDL Statements
DELIMITER $$

USE `mydb`$$CREATE DEFINER=`root`@`localhost` TRIGGER ai_table1 AFTER INSERT ON table1 FOR EACH ROW INSERT INTO tbllog (ch_type,chdate) VALUES ("insert", NOW())$$

Then insert the same code again to create a AFTER UPDATE trigger on the same table.
It now reads

- Trigger DDL Statements
DELIMITER $$

USE `mydb`$$CREATE DEFINER=`root`@`localhost` TRIGGER ai_table1 AFTER INSERT ON table1 FOR EACH ROW INSERT INTO tbllog (ch_type,chdate) VALUES ("insert", NOW())$$CREATE DEFINER=`root`@`localhost` TRIGGER ai_table1 AFTER INSERT ON table1 FOR EACH ROW INSERT INTO tbllog (ch_type,chdate) VALUES ("insert", NOW())$$

for about 2 seconds, then the second trigger is deleted before I can get to edit it.
[10 Apr 2010 7:45] Valeriy Kravchuk
Still not repeatable for me on Mac OS X. Will check on XP next week.
[11 Apr 2010 21:51] Robert Nowotny
I can confirm the behaviour on XP. 
I do the edit of the triggers in Ultraedit and the paste it back to the workbench, thats my workaround ....

I think the code in the editor should not be deleted, just marked in red for instance.
[12 Apr 2010 8:32] Valeriy Kravchuk
Verified just as described on XP.
[12 Apr 2010 11:56] Sergei Tkachenko
All alike problems have been fixed in windows version.
Editor contents isn't affected by background actions anymore.
[12 Apr 2010 23:35] Johannes Taxacher
fix confirmed in repository
[21 Apr 2010 12:55] Tony Bedford
An entry has been added to the 5.2.18 changelog:

The Triggers tab in the Alter Table dialog of the SQL Editor erased all typed code, when an attempt was made to copy and paste text within the tab.