Bug #11361 SP gets error 1064 using Loop Labels
Submitted: 15 Jun 2005 20:27 Modified: 6 Jul 2005 13:13
Reporter: Ross Rankin Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 OS:Any (Any)
Assigned to: Assigned Account CPU Architecture:Any

[15 Jun 2005 20:27] Ross Rankin
Description:
Any stored procedure using Loop labels fails in the Query Browser when the same SP entered in using the command-line client operates fine.  

Uisng a Loop with a label gives the following error in the Query Browser:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cur_loop: LOOP IF v <> 0 THEN ITERATE cur_loop;END IF; LEAVE cur_loop; END LOOP ' at line 1
ErrorNr. 1064

Fails both in a Query Window and a Script Window

How to repeat:
CREATE PROCEDURE p20 () 
DETERMINISTIC 
BEGIN 
     DECLARE v INT 
     DEFAULT 0; 
     cur_loop: LOOP 
          IF v <> 0 THEN ITERATE cur_loop;
          END IF; 
          LEAVE cur_loop; 
      END LOOP cur_loop; 
END//

Try in the command-line then the Query Browser...
[17 Jun 2005 16:57] Veniamin Konoplev
In my case this problem arose since mysqld version 5.0.2 (same result for 5.0.4),  With mysqld 5.0.1 all was OK.

Another problem (may be from the same origin): since mysqld 5.0.2  Query Browser does not diplay stored prcedures in the shema objet list.
[21 Jun 2005 9:49] Giles McArdell
I think this is a general problem with labels, the following code works fine in the command line client but fails with a syntax error in Query Browser (MySQL v5.0.7, Query Browser v1.1.10):-

DROP PROCEDURE IF EXISTS `dps_report`.`sp_poop`;

DELIMITER $$

CREATE PROCEDURE `dps_report`.`sp_poop` ()
main1: BEGIN
DECLARE V_USER VARCHAR(50);
SET V_USER = CURRENT_USER();
END main1$$
DELIMITER ;
[1 Jul 2005 10:56] Roland Bouman
Hi! 
I can *not* get this to work from the command line:

mysql> delimiter //
mysql> CREATE PROCEDURE p20 ()
    -> DETERMINISTIC
    -> BEGIN
    ->      DECLARE v INT
    ->      DEFAULT 0;
    ->      cur_loop: LOOP
    ->           IF v <> 0 THEN ITERATE cur_loop;
    ->           END IF;
    ->           LEAVE cur_loop;
    ->       END LOOP cur_loop;
    -> END//
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'cur_l
oop: LOOP
          IF v <> 0 THEN ITERATE cur_loop;
          END IF;
  ' at line 3
mysql>

I'm using MySQL 5.0.7 on Win XP Professional SP 2

Is this related to my submissing bug#11653?
[6 Jul 2005 13:13] Per-Erik Martin
According to a post in the forum http://forums.mysql.com/read.php?98,32124,32620#msg-32620) this is a character set issue, and thus a duplicate of BUG#7088.