Bug #5286 Stored procedures: crash if SET statement used in function used in update
Submitted: 29 Aug 2004 6:49 Modified: 14 Sep 2004 13:06
Reporter: Peter Gulutzan Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: CPU Architecture:Any

[29 Aug 2004 6:49] Peter Gulutzan
Description:
If I change mysql_updatable_view_key within a function, and use the function in an update 
so that the update will become illegal while being executed, and do so twice, I get a crash. 

How to repeat:
mysql> delimiter // 
mysql> create function f11 () returns int begin set s 
ql_updatable_view_key='YES'; return 5; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> set sql_updatable_view_key='NO'; 
    -> // 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> create table t11 (s1 int, s2 int)// 
Query OK, 0 rows affected (0.29 sec) 
 
mysql> create view v11 as select s1 from t11// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> insert into v11 values (1)// 
Query OK, 1 row affected, 1 warning (0.00 sec) 
 
mysql> update t11 set s2 = f11()// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> update t11 set s2 = f11()// 
ERROR 2006 (HY000): MySQL server has gone away 
No connection. Trying to reconnect... 
ERROR 2002 (HY000): Can't connect to local MySQL serv                                                                              
er through socket '/tmp/mysql.sock' (111) 
ERROR: 
Can't connect to the server
[2 Sep 2004 10:03] Oleksandr Byelkin
It is not VIEW specific bug, but SP specific one. Following sequance lead to debug 
assertion, too, because SP statement trys to close thread tables during function execution. 
delimiter //; 
set @xxx='NO'// 
create function f11 () returns int begin set @xxx='YES'; return 5; end;// 
create table t11 (s1 int, s2 int)// 
insert into t11 values (1,2)// 
update t11 set s2 = f11()// 
update t11 set s2 = f11()// 
delimiter ;//
[14 Sep 2004 13:06] Dmitry Lenev
As Sanja already mentioned it is problem of implementation of stored functions and not views,
so this bug is actually duplicate of bug #3671 "Stored procedure crash if function has "set @variable=param"".