Bug #9674 Stored Procs: Using declared vars in algebric operation causes system crash.
Submitted: 6 Apr 2005 11:29 Modified: 13 Apr 2005 16:21
Reporter: Disha Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.3 Beta OS:Microsoft Windows (Windows 2003)
Assigned to: Bugs System CPU Architecture:Any

[6 Apr 2005 11:29] Disha
Description:
In stored procedures, declaring variables and using them in algebric operation like division '/', causes system to crash.

Note that this does not occur when the variable used in not declared in the procedure and a session variable is used.

How to repeat:

1. DROP PROCEDURE IF EXISTS SP02//

2. CREATE PROCEDURE SP02 (OUT ARG INT)
    P2: BEGIN
        DECLARE TEMP_IN1 INT DEFAULT 0;
        DECLARE TEMP_FL1 INT DEFAULT 0;

        SET TEMP_IN1 = 100;
        SET TEMP_FL1 = TEMP_IN1/10;
        SET ARG = TEMP_FL1;

    END P2//

3. Set @a=0//
4. Call sp02(@a)//

ACTUAL RESULT
ERROR 2013 (HY000): Lost connection to MySQL server during query

EXPECTED RESULT
No system crash.
[6 Apr 2005 14:55] Victoria Reznichenko
Hi!

Thank you for the report!
I was able reproduce it with 5.0.3, but  it works like a charm with latest 5.0 BK tree. So it's already fixed.
[11 Apr 2005 14:21] Peter Gulutzan
It's still possible to get a crash with a similar case, using 5.0.5-beta-debug, SUSE 9.2,
after starting mysqld:
delimiter //
create procedure p90 () begin declare v int default 100; select v/10; end//
call p90()//
[13 Apr 2005 16:03] 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/23975