Bug #3863 Stored procedure crash when incrementing variable in a loop
Submitted: 23 May 2004 3:54 Modified: 28 May 2004 18:19
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[23 May 2004 3:54] Peter Gulutzan
Description:
Use a @variable in a WHILE clause. Ensure that there are at least two iterations of the 
WHILE loop.  

How to repeat:
mysql> delimiter // 
mysql> create procedure p () begin set @a = 0; while @a < 5 do set @a = @a + 1; end 
while; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p()// 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[24 May 2004 21:37] Alexander Keremidarski
Here is backtrace:

#0  0xffffe410 in ?? ()
#1  0x401638ac in ?? ()
#2  0x00000006 in ?? ()
#3  0x4e3b3872 in abort () from /lib/tls/libc.so.6
#4  0x4e3ab718 in __assert_fail () from /lib/tls/libc.so.6
#5  0x081090e8 in Item_func_set_user_var::fix_fields(THD*, st_table_list*, Item**) (this=0x86036d8, thd=0x85ea160, tables=0x0, ref=0x0) at item_func.cc:2266
#6  0x08178cff in set_var_user::check(THD*) (this=0x86036d0, thd=0x0) at set_var.cc:2645
#7  0x08178952 in sql_set_variables(THD*, List<set_var_base>*) (thd=0x85ea160, var_list=0x0) at set_var.cc:2544
#8  0x0818736b in mysql_execute_command(THD*) (thd=0x85ea160) at sql_parse.cc:2927
#9  0x08269002 in sp_instr_stmt::exec_stmt(THD*, st_lex*) (this=0x8603a88, thd=0x85ea160, lex=0x85fbad0) at sp_head.cc:977
#10 0x08268db3 in sp_instr_stmt::execute(THD*, unsigned*) (this=0x8603a88, thd=0x0, nextp=0x0) at sp_head.cc:904
#11 0x08267209 in sp_head::execute(THD*) (this=0x8602e30, thd=0x85ea160) at sp_head.cc:404
#12 0x082679ec in sp_head::execute_procedure(THD*, List<Item>*) (this=0x8602e30, thd=0x85ea160, args=0x85ea474) at sp_head.cc:589
#13 0x08188dd5 in mysql_execute_command(THD*) (thd=0x85ea160) at sql_parse.cc:3475
#14 0x0818a58e in mysql_parse(THD*, char*, unsigned) (thd=0x85ea160, inBuf=0x85fcde0 "call p()", length=140419440) at sql_parse.cc:4181
#15 0x08183521 in dispatch_command(enum_server_command, THD*, char*, unsigned) (command=COM_QUERY, thd=0x85ea160, packet=0x85f3999 "call p()", packet_length=9) at sql_parse.cc:1475
#16 0x08182e30 in do_command(THD*) (thd=0x85ea160) at sql_parse.cc:1290
#17 0x081822f3 in handle_one_connection (arg=0x0) at sql_parse.cc:1028
#18 0x4e5c798c in start_thread () from /lib/tls/libpthread.so.0
#19 0x4e44616a in clone () from /lib/tls/libc.so.6
[28 May 2004 18:19] 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