Bug #14434 Crashes when creating stored procedure without selecting database
Submitted: 28 Oct 2005 18:07 Modified: 28 Oct 2005 18:17
Reporter: rene Henzinger Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:5.0.15-nt OS:Windows (Windows XP Sp2)
Assigned to: MySQL Verification Team CPU Architecture:Any

[28 Oct 2005 18:07] rene Henzinger
Description:
MySQL Crashes if you try to create a stored procedure and there is no database selected

How to repeat:
just execute mysql without selecting a database and create a stored procedure
----
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.15-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> DELIMITER $
mysql> CREATE PROCEDURE test()
    -> BEGIN
    -> SHOW DATABASES;
    -> END$
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
----

Suggested fix:
check if a database is selected before allow the execution of any create procedure or create function statement.
[28 Oct 2005 18:17] MySQL Verification Team
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:

C:\mysql\bin>mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 650 to server version: 5.0.16-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> DELIMITER $
mysql> CREATE PROCEDURE test()
    -> BEGIN
    -> SHOW DATABASES;
    -> END$
ERROR 1046 (3D000): No database selected
mysql>