Bug #6820 Stored procedure crash with handler, cursor, and rollback
Submitted: 25 Nov 2004 2:03 Modified: 19 Apr 2005 14:43
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[25 Nov 2004 2:03] Peter Gulutzan
Description:
A certain sequence of statements in a stored procedure -- a continue handler with more than 
one condition, some transaction control, and some cursor management -- cause the server 
to crash. 
 

How to repeat:
mysql> create table tx (s2 char primary key); 
Query OK, 0 rows affected (0.08 sec) 
 
mysql> delimiter // 
mysql> create procedure pax () 
    ->   begin 
    ->  declare v2 char; 
    ->  declare c cursor for select s2 from tx; 
    ->  declare continue handler for sqlexception, sqlwarning, not found begin end; 
    ->  start transaction; 
    ->  open c; 
    ->  rollback; 
    ->  fetch c into v2; 
    ->  end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call pax()// 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[25 Nov 2004 15:31] MySQL Verification Team
Verified with 5.0.2-alpha-debug-log

Back trace:
(gdb) bt
#0  sp_cursor::pre_open (this=0x2, thd=0x8d2db28) at sp_rcontext.cc:154
#1  0x08279b7a in sp_instr_copen::execute (this=0x8d3ff48, thd=0x8d2db28, nextp=0xbe5ff1a0)
    at sp_head.cc:1698
#2  0x082765d0 in sp_head::execute (this=0x8d3f8a0, thd=0x8d2db28) at sp_head.cc:480
#3  0x08276d7a in sp_head::execute_procedure (this=0x8d3f8a0, thd=0x8d2db28, args=0x8d2df90)
    at sp_head.cc:695
#4  0x081838e0 in mysql_execute_command (thd=0x8d2db28) at sql_parse.cc:3728
#5  0x0818544d in mysql_parse (thd=0x8d2db28, inBuf=0x8d3a820 "call pax()", length=10)
    at sql_parse.cc:4588
#6  0x0817e36f in dispatch_command (command=COM_QUERY, thd=0x8d2db28,
    packet=0x8d253a9 "call pax()", packet_length=11) at sql_parse.cc:1503
#7  0x0817dd28 in do_command (thd=0x8d2db28) at sql_parse.cc:1311
#8  0x0817d28a in handle_one_connection (arg=0x8d2db28) at sql_parse.cc:1047
#9  0xb7e4714b in pthread_start_thread () from /lib/libpthread.so.0
#10 0xb7e471df in pthread_start_thread_event () from /lib/libpthread.so.0
#11 0xb7d7a50a in clone () from /lib/libc.so.6
[19 Apr 2005 14:43] Per-Erik Martin
No longer repeatable.