Bug #10854 mysql died when using function combine with select
Submitted: 25 May 2005 7:21 Modified: 30 May 2005 7:45
Reporter: ferdinan firmansyah Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S1 (Critical)
Version:5.0.4 OS:Windows (Win 2K)
Assigned to: CPU Architecture:Any

[25 May 2005 7:21] ferdinan firmansyah
Description:
				
Can anyone help me ?
The server was stopped immediately When I try to retrieve more than 1 records with a function aplied on one of the field.

I've got no problem when I'm doing this on MS-SQL 2K or Postgre SQL
Is it a crash ?
Is it because the functions development in mysql is not finished yet ?

Detailed Commands & Responses :
==============================
- I have a function named hello and a table named t_user

- When I type "select hello('ANDY');" 
  I got no error

     mysql> select hello('ANDY') ;
     +---------------+
     | hello('ANDY') |
     +---------------+
     | Hello, ANDY!  |
     +---------------+
     1 row in set (0.00 sec)

- When I type "select hello(uname) from t_user limit 1;"
  I got no error either ( see the limit statement )

     mysql> select hello(uname) from t_user limit 1;
     +---------------+
     | hello(uname)  |
     +---------------+
     | Hello, JACK! |
     +---------------+
     1 row in set (0.02 sec)

- When I type "select hello(uname) from t_user;" 
  I got error ( see the error below )

     mysql> select hello(uname) from t_user;
     ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
please fix this bug on the next release.
[25 May 2005 12:14] MySQL Verification Team
Could you please provide a test case with your table schema and function
creation? The message error sometimes means that the client losses the
connection with the server.

Thanks in advance.
[26 May 2005 11:14] ferdinan firmansyah
Lately I found the similar problem on the report bug
(I forgot which one)

- It seems that the problem occured on INNODB table only.
- The problem exists on every INNODB table I've got.
- After I convert my table to MYISAM the code work perfectly

But I still need it on INNODB table. 

Will it fixed on the near future ?
[27 May 2005 8:30] Vasily Kishkin
Could you please attach your UDF that we can try to reproduce the bug ?
[27 May 2005 11:17] ferdinan firmansyah
Sorry , but I'm not familiar with udf.

  What is udf ?
  Is it a dump file created by mysqldump program ?
  And where should I attach it ?

Thanx
[27 May 2005 11:44] Sergei Golubchik
could you show the definition of the function hello() ?
[27 May 2005 20:01] ferdinan firmansyah
I got the function from the mysql manual (function hello).
Here I Attach the database dump file (2kb)

The working code :
==================
select hello(uname) from t_user limit 1;

or 

select hello('ferdinan');

The error code :
================
select hello(uname) from t_user;

PS : 
The error code works well after I change t_user into myisam
I need this to works on InnoDB.

Thanx
[27 May 2005 20:02] ferdinan firmansyah
the database dump file (2kb)

Attachment: test.sql (application/octet-stream, text), 1.51 KiB.

[30 May 2005 7:31] Vasily Kishkin
I was able to reproduce it:

mysql> delimiter //
mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)
    -> RETURN CONCAT('Hello, ',s,'!');
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> DROP TABLE IF EXISTS `t_user`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE `t_user` (
    ->   `uname` varchar(8) default NULL,
    ->   `pwd` varchar(8) default NULL
    -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Query OK, 0 rows affected (0.09 sec)

mysql> LOCK TABLES `t_user` WRITE;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO `t_user` VALUES ('ANDY','XX'),('JACK','XXX');
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> select hello(uname) from t_user;
ERROR 2013 (HY000): Lost connection to MySQL server during query

Tested on Win 2000 Sp4, MySQL server 5.0.7
[30 May 2005 7:45] Dmitry Lenev
Hi, Ferdinan!

Thank you for your bug report!

This is duplicate of bug #10015.
(Look at http://bugs.mysql.com/bug.php?id=10015 for more info)