Bug #9553 Mysql server crashes while creating a function that has TEXT as return type
Submitted: 1 Apr 2005 7:45 Modified: 1 Apr 2005 12:59
Reporter: Hubert MICHEL Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.3-Beta OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[1 Apr 2005 7:45] Hubert MICHEL
Description:
When creating a function that has return type as 'TEXT' Mysql server crashes
and results in lost connection

How to repeat:
1. Create a function TEST, which accepts an any parameter (not used in this example) and returns a "text" datatype.

DROP FUNCTION IF EXISTS TEST;
delimiter // ;
CREATE FUNCTION TEST(s_mem   INT) RETURNS TEXT
BEGIN
	DECLARE		l_tmpmem	TEXT;

	set l_tmpmem = 'test';

	RETURN (l_tmpmem);
END
//
delimiter ; //

2. Observed that the create function fails with a lost connection to the MySQL
server "ERROR 2013 (HY000): Lost connection to MySQL server during query"

Expected Results : The function should be created without any errors

Actual Results : Mysql server crashes during function creation and results in
lost connection.
[1 Apr 2005 12:59] MySQL Verification Team
The source of the crash is the same as bug report:

http://bugs.mysql.com/bug.php?id=9537

Additional Info: Call stack

mysqld.exe!sp_returns_type(THD * thd=0x00efd6a0, String & result={...}, sp_head * sp=0x02fbd040)  Line 346 + 0x7	C++
mysqld.exe!db_create_routine(THD * thd=0x00efd6a0, int type=1, sp_head * sp=0x02fbd040)  Line 407 + 0x14	C++
mysqld.exe!sp_create_function(THD * thd=0x00efd6a0, sp_head * sp=0x02fbd040)  Line 939 + 0xf	C++
mysqld.exe!sp_head::create(THD * thd=0x00efd6a0)  Line 422 + 0xd	C++
mysqld.exe!mysql_execute_command(THD * thd=0x00efd6a0)  Line 3973 + 0x12	C++
mysqld.exe!mysql_parse(THD * thd=0x00efd6a0, char * inBuf=0x02fc1098, unsigned int length=125)  Line 5156 + 0x9	C++
mysqld.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x00efd6a0, char * packet=0x02fb8fd9, unsigned int packet_length=126)  Line 1647 + 0x1d	C++
mysqld.exe!do_command(THD * thd=0x00efd6a0)  Line 1453 + 0x31	C++
mysqld.exe!handle_one_connection(void * arg=0x00efd6a0)  Line 1110 + 0x9	C++
mysqld.exe!pthread_start(void * param=0x00effbf0)  Line 63 + 0x7	C
mysqld.exe!_threadstart(void * ptd=0x02fb4b70)  Line 173 + 0xd	C
kernel32.dll!7c80b50b() 	
kernel32.dll!7c8399f3()