Bug #14498 Stored procedures: hang if undefined variable and exception
Submitted: 31 Oct 2005 2:13 Modified: 17 Jan 2006 23:56
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0.16-debug OS:Linux (SUSE 10.0)
Assigned to: Per-Erik Martin CPU Architecture:Any

[31 Oct 2005 2:13] Peter Gulutzan
Description:
If there is an undefined variable, and an exception handler,
MySQL hangs (the exception handler loops forever).

How to repeat:
mysql> create procedure p () begin declare continue handler for sqlexception set @a=5;  if v then select 'a'; end if; end//
Query OK, 0 rows affected (0.00 sec)

mysql> call p()//
[31 Oct 2005 7:44] Valeriy Kravchuk
Thank you for a bug report. Verified just as described on 5.0.16-BK (ChangeSet@1.1957, 2005-10-29 13:11:34+04:00, konstantin@mysql.com):

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.16

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> delimiter //
mysql> create procedure p () begin declare continue handler for sqlexception set
    -> @a=5;  if v then select 'a'; end if; end//
Query OK, 0 rows affected (0,04 sec)

mysql> call p()// <--- hangs here until I pressed Ctrl+C
Aborted
[4 Nov 2005 14:40] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31940
[13 Jan 2006 21:00] Konstantin Osipov
Approved with minor comments by email.
[17 Jan 2006 9:57] Per-Erik Martin
Pushed to bk 5.0.19.
[17 Jan 2006 23:56] Mike Hillyer
Added to 5.0.19 changelog:

      <listitem>
        <para>
          A stored procedure with an undefined variable and an exception
          handler would hang the client when called. (Bug #14498)
        </para>
      </listitem>