Bug #11554 Server crashes on statement indirectly using non-cached function
Submitted: 24 Jun 2005 20:27 Modified: 13 Jul 2005 18:00
Reporter: Dmitry Lenev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.8 OS:Any (Any)
Assigned to: Dmitry Lenev

[24 Jun 2005 20:27] Dmitry Lenev
Description:
Server crashes if one executes statement which execution should update one of handler_* status variables and which indirectly (i.e. via view) uses stored function and this function was not yet cached in connection specific stored routines cache.

How to repeat:
# This snippet in mysqltest format demonstrates the problem
connect (con1root,localhost,root,,);
connect (con2root,localhost,root,,);

connection con1root;
use test;

--disable_warnings
drop table if exists t1;
drop function if exists f1;
drop view if exists v1;
--enable_warnings

create table t1 (i int);
create function f1 () returns int return 1;
create view v1 as select f1() as f;

connection con2root;
use test;
# This crashes server
insert into t1 (select f from v1);

Suggested fix:
We should not close all tables opened by thread, when we load function definition from mysql.proc table into stored routine cache.
[28 Jun 2005 19:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26494
[13 Jul 2005 9:20] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26982
[13 Jul 2005 9:47] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26983
[13 Jul 2005 12:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26994
[13 Jul 2005 13:16] Dmitry Lenev
Fixed in 5.0.10

Please also note that now we can use stored routines under LOCK TABLES
without explicitly locking 'mysql.proc'. But this puts certain restrictions on
locking of mysql.proc table - you can't use it in any queries which will 
combine locking of this table for writing with any other tables.
[13 Jul 2005 18:00] Paul Dubois
Noted in 5.0.10 changelog.