| Bug #33983 | Stored Procedures: wrong end <label> syntax is accepted | ||
|---|---|---|---|
| Submitted: | 22 Jan 2008 15:16 | Modified: | 25 Jan 2008 19:42 |
| Reporter: | Konstantin Osipov (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
| Version: | 5.0.54 | OS: | Any |
| Assigned to: | Marc ALFF | CPU Architecture: | Any |
[22 Jan 2008 18:03]
Valeriy Kravchuk
Thank you for a bug report. Verified just as described:
mysql> select version();
+------------------------------+
| version() |
+------------------------------+
| 5.0.54-enterprise-gpl-nt-log |
+------------------------------+
1 row in set (0.00 sec)
mysql> delimiter //
mysql> create procedure broken_labels()
-> begin
-> label1:
-> begin
-> label2:
-> begin
-> select 1;
-> end label1;
-> end;
-> end//
Query OK, 0 rows affected (0.06 sec)
[24 Jan 2008 1:31]
Marc ALFF
Fixed with Bug#33618
[25 Jan 2008 16:54]
Marc ALFF
Pushed into 5.0.56 Pushed into 5.1.24-rc Pushed into 6.0.5-alpha with bug#33618
[25 Jan 2008 19:42]
Paul DuBois
Noted in 5.0.56, 5.1.24, 6.0.5 changelogs.

Description: Stored procedures compiler accepts a malformed stored procedure definition. In particular it allows 'end' statement to end to a label that is not associated with the corresponding 'begin' statement: create procedure broken_labels() begin label1: begin label2: begin select 1; end label1; end; end| In the example above 'end label1' is syntactically unacceptable, since the block that is being ended is associated with a different label. The code generated in case when there are loops and cursors might be incorrect as well. How to repeat: create procedure broken_labels() begin label1: begin label2: begin select 1; end label1; end; end| Suggested fix: Fix the grammar to not accept malformed procedure definition.