Bug #9536 Stored Procedure: Server Crash when AVG is used from within a sproc.
Submitted: 31 Mar 2005 18:18 Modified: 31 Mar 2005 19:18
Reporter: Disha Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.3 Beta OS:Windows (Windows 2000)
Assigned to: CPU Architecture:Any

[31 Mar 2005 18:18] Disha
Description:
Stored Procedure: 
First time execution of the procedure gives error 'Malformed Packet'. 
On executing again, there is a Server Crash when AVG is used from within a sproc.
When the same statement is used outside the sproc scope, it works fine.

This occurs when myisam as well as innodb db engine.

How to repeat:
1. Delimiter //
2. Drop table if exists t1// 
3. Create table t1(f1 INT,f2 INT)//
4. Insert into t1 values(12,34)// 
5. Insert into t1 values(20,10)// 
6. Drop function if exists fn1//
7. CREATE FUNCTION FN1( ) RETURNS int
    Begin
 	SELECT SUM(f1) FROM T1 ;
	RETURN 1;
    End//
8. Select fn1()//
9. Select fn1()//

ACTUAL RESULT:
1) After step 8, following is the error that occurs:
    ERROR 2027 (HY000): Malformed packet
2) After step 9, following is the error that occurs:
    ERROR 2013 (HY000): Lost connection to MySQL server during query
 
    Although error 2 will occur regardless of the sql statement since the connection is already lost.

EXPECTED RESULT:
No error should occur and the function should return 16 correctly.
[31 Mar 2005 18:33] Jorge del Conde
These where the results that I got:

mysql>  Select fn1()//
ERROR 2027 (HY000): Malformed packet
mysql>  Select fn1()//
ERROR 2027 (HY000): Malformed packet
[31 Mar 2005 19:18] MySQL Verification Team
Duplicate of http://bugs.mysql.com/bug.php?id=7185