Bug #2259 Crash after fetch from not-open cursor in stored procedure
Submitted: 2 Jan 2004 14:13 Modified: 8 Jan 2004 1:44
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.0 OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[2 Jan 2004 14:13] Peter Gulutzan
Description:
If a cursor is not open, FETCH from the cursor fails. Fine. But the next statement causes a 
crash. 

How to repeat:
mysql> delimiter | 
mysql> CREATE procedure p15 () begin declare v1 int; declare c1 cursor for select s1 from 
t10; fetch c1 into v1; end| 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p15()| 
ERROR 1310 (24000): Cursor is not open 
mysql> CREATE procedure p15 () begin declare v1 int; declare c1 cursor for select s1 from 
t10; open c1; fetch c1 into v1; end| 
ERROR 2006 (HY000): MySQL server has gone away 
No connection. Trying to reconnect... 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
'/tmp/mysql.sock' (111) 
ERROR: 
Can't connect to the server
[2 Jan 2004 15:16] Dean Ellis
I cannot repeat this with the latest 5.0 sources:

mysql> call p15()|
ERROR 1310 (24000): Cursor is not open
mysql> CREATE procedure p15 () begin declare v1 int; declare c1 cursor for
    -> select s1 from
    -> t10; open c1; fetch c1 into v1; end|
ERROR 1288 (42000): PROCEDURE p15 already exists

which would seem the correct response for this statement.  Other statements immediately following the CALL statement also function correctly.
[3 Jan 2004 7:30] Peter Gulutzan
I checked again with the latest source, and mysqld crashes. I also asked another MySQL 
developer to try the call on his machine, and he sees 'mysqld restarted'.
[5 Jan 2004 11:07] Dean Ellis
Re-tested using a debug build and I was able to repeat.
[8 Jan 2004 1:44] Per-Erik Martin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html