Bug #4319 Stored procedure crash if self-referencing function
Submitted: 29 Jun 2004 1:30 Modified: 10 Sep 2004 13:21
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: Per-Erik Martin CPU Architecture:Any

[29 Jun 2004 1:30] Peter Gulutzan
Description:
If I use a function's return value as an input value for the same function, I crash the server. 

How to repeat:
mysql> create table t (s1 int); 
Query OK, 0 rows affected (0.27 sec) 
 
mysql> insert into t values (5); 
Query OK, 1 row affected (0.00 sec) 
 
mysql> delimiter // 
 
mysql> create function f (p int) returns int begin declare v int; if p = 0 then set v = 0; else s                                  
et v = 1; end if; return v; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> select f(f()) from t;// 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[10 Sep 2004 13:21] 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

Additional info:

The example given results in a "Incorrect number of arguments" (as it should).
When giving an argument to the innermost function, it works.