Bug #14248 CREATE SP crashes mysqld-nt in case there's no default database
Submitted: 23 Oct 2005 22:59 Modified: 24 Oct 2005 13:39
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.15-nt OS:Windows (winxp)
Assigned to: CPU Architecture:Any

[23 Oct 2005 22:59] Roland Bouman
Description:
An arbitrary create procedure statement crashses the server when it executed without having set a default database. 
After issuing the command it takes a couple of seconds, then windows signals that an error ocurrred in mysqld-nt.exe, and that it has to close because of that.

How to repeat:
D:\Data\Roland's Projects\MySQLScripts>mysql -uroot -pmysqlroot
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 go
mysql> create procedure p()
    -> begin
    ->    select 1;
    -> end
    -> go
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> connect
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

Suggested fix:
Don't crash the server when creating an SP without having a default database set. Instead, show an error message like you do with tables:

mysql> create table table1(column1 char(10)) go
ERROR 1046 (3D000): No database selected
[24 Oct 2005 9:26] Hartmut Holzgraefe
verified using latest 5.0 source on linux
[24 Oct 2005 13:00] MySQL Verification Team
I was unable to repeat with BK source:
ChangeSet@1.2025.1.2, 2005-10-21 16:58:10+05:00, bar@mysql.com
  ctype_utf8.result:
    After merge fix.

miguel@hegel:~/dbs/5.0> bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.16-debug

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

mysql> delimiter //
mysql> create procedure p()
    -> begin
    -> select 1;
    -> end
    -> //
ERROR 1046 (3D000): No database selected
mysql> 

I will test on Windows.
[24 Oct 2005 13:39] 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 1 to server version: 5.0.16-nt

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

mysql> delimiter go
mysql> create procedure p()
    -> begin
    -> select 1;
    -> end
    -> go
ERROR 1046 (3D000): No database selected
mysql> select version() go
+-----------+
| version() |
+-----------+
| 5.0.16-nt |
+-----------+
1 row in set (0.05 sec)

mysql>