Bug #61302 Code folding for stored procedures for loops and nesting does not work correctly
Submitted: 26 May 2011 9:56 Modified: 17 Nov 2011 17:38
Reporter: Daniël van Eeden Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.34 OS:Linux (Ubuntu 11.04, RHEL6)
Assigned to: CPU Architecture:Any

[26 May 2011 9:56] Daniël van Eeden
Description:
While editing a stored procedure code folding is available.

There are two related issues:
- Nesting is not supported: the fold starts with BEGIN and ends by the first END and not the END on the same nesting level. 
- "<loop_name>: LOOP" is not recognized as the start of a fold.

How to repeat:
Try to edit a stored procedure with a few loops and if statements.

Suggested fix:
Detect loop start for folding
[26 May 2011 18:03] Valeriy Kravchuk
Had you defined DELIMITER properly? For example, the following code folds OK for me on Mac OS X:

delimiter //
create procedure proc1() 
begin 
declare a int;

begin
declare b int;
label: loop
  begin
  select 3;
  end;
  select 4;
end loop;
select 2;
end; 
select 1; 
end;
//
[27 May 2011 7:56] Daniël van Eeden
screenshot 1

Attachment: test1.png (image/png, text), 50.76 KiB.

[27 May 2011 7:56] Daniël van Eeden
screenshot 2

Attachment: test2.png (image/png, text), 58.17 KiB.

[27 May 2011 7:57] Daniël van Eeden
screenshot 3

Attachment: test3.png (image/png, text), 71.93 KiB.

[27 May 2011 7:59] Daniël van Eeden
screenshot 4

Attachment: test4.png (image/png, text), 57.13 KiB.

[27 May 2011 8:02] Daniël van Eeden
I've created a few screenshots.

Screenshot 1: Procedure created on the commandline
Screenshot 2: Procedure created on the commandline
Screenshot 3: Procedure created in MySQL Workbench
Screenshot 4: Procedure created on the commandline (example from Valeriy Kravchuk)

I've used $$ als delimiter. And the Non Standard SQL Delimiter in MySQL Workbench is also set to $$

I've tried this on Ubuntu 11.04
[27 May 2011 8:37] Daniël van Eeden
------------------------------------
MySQL Generic Runtime Environment 4.1.0

Type '?' for help.
Python Shell initialized. (Use Preferences -> General to set language)
Ready.

>>> print "Delimiter = '" + grt.root.wb.options.options.SqlDelimiter + "'";
Delimiter = '$$'
------------------------------------
[27 May 2011 9:32] Valeriy Kravchuk
Even with $$ as delimiter, I still do not see this problem on Windows. Looks like Linux-specific (if not Ubuntu 11.04-specific).
[27 May 2011 10:58] Daniël van Eeden
Screenshot from RHEL6

Attachment: Screenshot.png (image/png, text), 342.17 KiB.

[27 May 2011 10:59] Daniël van Eeden
It's reproducable on RHEL6. So it could be a Linux specific issue.
[31 May 2011 8:48] Valeriy Kravchuk
Yes, this is easy to repeat on Linux. Verified on 32-bit Ubuntu 10.04.
[17 Nov 2011 17:38] Philip Olson
Fixed as of 5.2.36:
+        On Linux, code folding for stored procedures and loops did not
+        work properly within the SQL editor.