Bug #13514 server crash when create a stored procedure before choose a database
Submitted: 27 Sep 2005 5:22 Modified: 20 Oct 2005 6:59
Reporter: Peter Yu Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:mysql-5.0.13-rc-win32/5.0.14 BK OS:Microsoft Windows (windows xp sp1/Linux)
Assigned to: Konstantin Osipov CPU Architecture:Any

[27 Sep 2005 5:22] Peter Yu
Description:
server crash when create a stored procedure before  choose a database

How to repeat:
start server with batch file
SET MYSQL_HOME=.
%MYSQL_HOME%\bin\mysqld-max-nt --defaults-file=%MYSQL_HOME%\my-huge.ini --basedir=%MYSQL_HOME%\   --datadir=%MYSQL_HOME%\data   --skip-innodb     --big-tables --server-id=1 --console

use the client app to connect the server 
D:\MYSQL5\mysql-5.0.13-rc-win32\bin>mysql -h 127.0.0.1 -u root

key in the following 
delimiter //
CREATE PROCEDURE simpleproc (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM test1;
END
//

the server crash.
[27 Sep 2005 5:31] Peter Yu
I have test on 5.0.11, It will showing ERROR 1046 (3D000): No database selected
It should be OK.
[27 Sep 2005 5:45] Miguel Solorzano
Thank you for the bug report.

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.14-rc-debug

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

mysql> delimiter //
mysql> CREATE PROCEDURE simpleproc (OUT param1 INT)
    -> BEGIN
    -> SELECT COUNT(*) INTO param1 FROM test1;
    -> END
    -> //
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 

miguel@hegel:~/dbs/5.0> libexec/mysqld
050927  2:38:07  InnoDB: Started; log sequence number 0 43655
050927  2:38:07 [Note] libexec/mysqld: ready for connections.
Version: '5.0.14-rc-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
mysqld got signal 11;

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8e636f8 = CREATE PROCEDURE simpleproc (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM test1;
END
thd->thread_id=1
[19 Oct 2005 11:08] Konstantin Osipov
A duplicate of Bug#13587, which has been fixed.
[20 Oct 2005 6:59] Jon Stephens
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:

Documented fix in 5.0.16 changelog.
[28 Oct 2005 8:53] Raymond den Ouden
I tried to create a procedure
this:
CREATE PROCEDURE `sptest`(in bla int)
BEGIN
  INSERT INTO `test`.`test` (triggerdate, thedate) VALUES (now(), now());
END

will be create with no problem, but

CREATE PROCEDURE `sptest`(in bla int)
BEGIN
  INSERT INTO `test`.`test` (triggerdate, thedate) VALUES (now(), now() - bla);
END`

or

CREATE PROCEDURE `sptest`(in bla int)
BEGIN
  INSERT INTO `test`.`test` (triggerdate, thedate) VALUES (now(), now() - 1);
END`

crashes MySQL 5.0.15 service (at least under windows XP Pro), while INSERT INTO `test`.`test` (triggerdate, thedate) VALUES (now(), now() - 1); executes  correctly
[28 Oct 2005 9:25] Konstantin Osipov
How is that remark relevant to the original bug report?
Please do not report a separate problem in a closed bug report -- our bug verification team may not notice your report and it will never be taken care of.