Bug #1656 Stored Procedure Crash if duplicate INTO targets
Submitted: 24 Oct 2003 20:07 Modified: 28 Oct 2003 6:55
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[24 Oct 2003 20:07] Peter Gulutzan
Description:
A stored procedure crashes if it contains SELECT ... INTO p1,p1 ... 
 
Notice the duplication of p1. If it contains SELECT ... INTO p1,p2 ... there's no problem. 

How to repeat:
mysql> create table t70 (s1 int,s2 int); 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> insert into t70 values (1,2); 
Query OK, 1 row affected (0.00 sec) 
 
mysql> create procedure p70 (out p1 int,out p2 int) select * into p1,p1 from t70; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p70(@1,@2); 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[27 Oct 2003 3:12] Indrek Siitan
0x8155e6c in sp_head::execute_procedure (this=0xaa31028, thd=0xa980018,
    args=0xa9805b8) at item_func.h:64
64          with_sum_func= a->with_sum_func;
(gdb) bt
#0  0x8155e6c in sp_head::execute_procedure (this=0xaa31028, thd=0xa980018, 
    args=0xa9805b8) at item_func.h:64
#1  0x80a43e8 in mysql_execute_command (thd=0xa980018) at sql_parse.cc:3376
#2  0x80a5895 in mysql_parse (thd=0xa980018, 
    inBuf=0xaa0a028 "call p70(@1,@2)", length=15) at sql_parse.cc:3977
#3  0x809f4f7 in dispatch_command (command=COM_QUERY, thd=0xa980018, 
    packet=0xa9d0019 "call p70(@1,@2)", packet_length=16) at sql_parse.cc:1310
#4  0x809eefa in do_command (thd=0xa980018) at sql_parse.cc:1144
#5  0x809e593 in handle_one_connection (arg=0xa980018) at sql_parse.cc:911
#6  0x2853541f in _thread_start () from /usr/lib/libc_r.so.4
#7  0x0 in ?? ()
[28 Oct 2003 6:55] Per-Erik Martin
Fixed.
Note: The duplicated INTO targets where inconsequential, the actual problem
was that the second OUT parameter was never set. (The bug being that it wasn't
properly initialized internally.)