Bug #45704 Stored procedures code missing from Workbench editor
Submitted: 24 Jun 2009 13:46 Modified: 16 Sep 2009 10:40
Reporter: Vasile Ceteras Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.2.1 OS:Windows (XP SP3)
Assigned to: CPU Architecture:Any
Tags: stored procedure

[24 Jun 2009 13:46] Vasile Ceteras
Description:
Stored routines cannot be edited, their code is not shown in the editor.
Also, more than one stored routine cannot be opened in the editor.

How to repeat:
Create a test database, with two test stored procedures:

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

CREATE DATABASE /*!32312 IF NOT EXISTS*/`test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;

USE `test`;

/* Procedure structure for procedure `testSP` */

/*!50003 DROP PROCEDURE IF EXISTS  `testSP` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `testSP`()
BEGIN
		select 10*rand();
    END */$$
DELIMITER ;

/* Procedure structure for procedure `testSP` */

/*!50003 DROP PROCEDURE IF EXISTS  `testSP` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `testSP2`()
BEGIN
		select 100*rand();
    END */$$
DELIMITER ;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

Backup the database, and import the resulting file into Mysql Workbench 5.2.1 OSS (reverse engineer).

Select the `test` database tab, right-click on testSP routine, and click `Edit Routine`.

Expected result: 
The editor shows the stored procedure's code:
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER //

CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.`testSP`()

BEGIN

		select 10*rand();

    END//
The code above is shown in Workbench 5.0.26 OSS.

Actual result:
The editor shows an empty stored procedure:
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER //

CREATE PROCEDURE `test`.`testSP` ()
BEGIN
  
END//

Also, if I you try to edit the second routine, a new tab should be created in the editor, but instead only the previous routine's tab is renamed to the second routine's name.
[24 Jun 2009 20:41] MySQL Verification Team
Thank you for the bug report. Could you please provide the model file which presents the behavior reported?. Thanks in advance.
[25 Jun 2009 10:25] Vasile Ceteras
database dump to be imported in mysql workbench with "Reverse Engineering  MYSQL Create Script"

Attachment: testSP.sql (application/octet-stream, text), 872 bytes.

[25 Jun 2009 11:26] Vasile Ceteras
this is the model file, thank you!

Attachment: testSP.mwb (application/octet-stream, text), 3.63 KiB.

[25 Jun 2009 18:37] Valeriy Kravchuk
Bug #45761 was marked as a duplicate of this one.
[26 Jun 2009 9:33] Sergei Tkachenko
Looks like routine editor was buggy in 5.2.1. For some reason editor determined existing routine as new one & replaced existing SQL with template for new routines. Provided model file contains original definition for testSP2 procedure, however it's not so for testSP procedure - I guess because testSP was opened in WB routine editor at least once before saving the model.
Failed to repeat with snapshot version. Most probably it's already fixed & the bug will not affect next version.
[26 Jun 2009 13:48] Vasile Ceteras
That's right, Sergei, I've only opened testSP in WB editor, testSP2 was never opened.
[6 Aug 2009 12:44] S P
A connected issue - Attempting to open an existing routine (function or sp) does not open what's been saved, it opens a new template. This makes it appear as if the routine has not been saved, however, saving the MWB file while the routine editor is open and filled in correctly seems to save it ok. You just can't open it again.

In order to make sure that the routine is uploaded - 
1 open routine editor
2 write routine - (hopefully code validates)
3 save MWB file
4 upload/sync model

This makes sure that the routine is uploaded correctly, however it is now impossible to edit this within the Workbench app.

(There is also an issue with the delimiter being set to '//' in Workbench and '$$' on the server so it always shows up in the synchronise - this may be a setting I don't know about)

Client - Win XP sp 3, Workbench 5.1.16 OSS rev 4210
Server - Win 2003 R2 sp2, MySQL 5.0.51b
[11 Sep 2009 20:17] Johannes Taxacher
the editing issue has been corrected. the "replacing" of the editor is expected behaviour.
fix will be included in 5.2.3 alpha
[16 Sep 2009 10:40] Tony Bedford
An entry was added to the 5.2.3 changelog:

When a database with Stored Procedures was reverse-engineered into MySQL Workbench the Stored Procedures were not displayed in the Routine Editor, and so could not be edited.