Bug #5000 SPs can be created with no default database
Submitted: 11 Aug 2004 19:35 Modified: 8 Sep 2004 12:28
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.2 OS:
Assigned to: Per-Erik Martin CPU Architecture:Any

[11 Aug 2004 19:35] Paul DuBois
Description:
SPs now are supposed to be associated with a
particular database. However, the server allows
you to create a stored routine when there is no
default database.  Attempts to use the routine
might crash the server.

How to repeat:
Start mysql without naming a databse on the command line.
Then do this:

mysql> delimiter //
mysql> create function f () returns int return 1;//
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> show create function f;
ERROR 2013 (HY000): Lost connection to MySQL server during query
[8 Sep 2004 12:28] 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:

 Easy to prevent crash, but the question was how to treat this case?
 We ended up implementing the "global" SPs (i.e. with no associated
 db), which were planned but left unresolved when SPs moved into dbs.
 So now things like "call .p()" work too.