Bug #5211 Stored procedure crash if function compared to column
Submitted: 25 Aug 2004 19:22 Modified: 10 Sep 2004 15:18
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Per-Erik Martin CPU Architecture:Any

[25 Aug 2004 19:22] Peter Gulutzan
Description:
I create a function which sets a variable and then returns the variable. I use the function in 
a WHERE clause which compares to a column (not a literal). I get a crash. 

How to repeat:
mysql> delimiter // 
 
mysql> create table t100 (s1 int)// 
Query OK, 0 rows affected (0.41 sec) 
 
mysql> insert into t100 values (1)// 
Query OK, 1 row affected (0.00 sec) 
 
mysql> create function f100 () returns int begin declare v int; set v = 5; return v; end;// 
Query OK, 0 rows affected (0.01 sec) 
 
mysql> select s1 from t100 where f100()<>s1// 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[26 Aug 2004 7:52] MySQL Verification Team
mysql> delimiter //
mysql> create table t100 (s1 int)//
Query OK, 0 rows affected (0.20 sec)

mysql> insert into t100 values (1)//
Query OK, 1 row affected (0.09 sec)

mysql> create function f100 () returns int begin declare v int; set v = 5;
    -> return v; end;//
Query OK, 0 rows affected (0.08 sec)

mysql> select s1 from t100 where f100()<>s1//
+------+
| s1   |
+------+
|    1 |
+------+
1 row in set (0.14 sec)

mysql>
[27 Aug 2004 3:18] MySQL Verification Team
Thank you for the bug report, testing against latest BK source 5.0
I was able to repeat:

Version: '5.0.2-alpha-debug-log'  socket: '/misc/dbs/5.0/tmp/mysql.sock'  port: 3350
mysqld: field.cc:1918: virtual longlong Field_long::val_int(): Assertion `table->in_use == _current_thd()' failed.
mysqld got signal 6;
[10 Sep 2004 15:18] 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:

Works after merge with 4.1.