Bug #14530 Server gets crash if "CREATE PROCEDURE..." before "use dbname".
Submitted: 1 Nov 2005 0:01 Modified: 1 Nov 2005 0:58
Reporter: Tetsuro Ikeda Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.15 OS:Linux (SuSE Linux 9.1 / Windows2000Pro)
Assigned to: Assigned Account CPU Architecture:Any

[1 Nov 2005 0:01] Tetsuro Ikeda
Description:
MySQL Server 5.0.15 got crash if "CREATE PROCEDURE..." is done by MySQL client before "use dbname" is done.

I tried both on SuSE Linux 9.1 and Windows2000Pro SP4 and I got MySQL server crash on both OS.

How to repeat:
1. Start up MySQL Server 5.0.15.
2. Connect to the MySQL Server by MySQL client
3. Change the delimiter from ";" to "//"
4. Execute the "CREATE PROCEDURE..." like followings:
http://dev.mysql.com/doc/refman/5.0/en/cursors.html

CREATE PROCEDURE curdemo()
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE a CHAR(16);
  DECLARE b,c INT;
  DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1;
  DECLARE cur2 CURSOR FOR SELECT i FROM test.t2;
  DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

  OPEN cur1;
  OPEN cur2;

  REPEAT
    FETCH cur1 INTO a, b;
    FETCH cur2 INTO c;
    IF NOT done THEN
       IF b < c THEN
          INSERT INTO test.t3 VALUES (a,b);
       ELSE
          INSERT INTO test.t3 VALUES (a,c);
       END IF;
    END IF;
  UNTIL done END REPEAT;

  CLOSE cur1;
  CLOSE cur2;
END//
[1 Nov 2005 0:03] Tetsuro Ikeda
This is the mysql client console log when I tried.

Attachment: mysqlclientlog.txt (text/plain), 1.06 KiB.

[1 Nov 2005 0:05] Tetsuro Ikeda
This is the mysql server console log when I tried, this says "This could be because you hit a bug" and shows some log for debug.

Attachment: mysqlserverlog.txt (text/plain), 3.31 KiB.

[1 Nov 2005 0:58] MySQL Verification Team
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Additional info:

Duplicate of bug:

http://bugs.mysql.com/bug.php?id=14248

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 curdemo()
    -> BEGIN
    ->   DECLARE done INT DEFAULT 0;
    ->   DECLARE a CHAR(16);
    ->   DECLARE b,c INT;
    ->   DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1;
    ->   DECLARE cur2 CURSOR FOR SELECT i FROM test.t2;
    ->   DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
    -> 
    ->   OPEN cur1;
    ->   OPEN cur2;
    -> 
    ->   REPEAT
    ->     FETCH cur1 INTO a, b;
    ->     FETCH cur2 INTO c;
    ->     IF NOT done THEN
    ->        IF b < c THEN
    ->           INSERT INTO test.t3 VALUES (a,b);
    ->        ELSE
    ->           INSERT INTO test.t3 VALUES (a,c);
    ->        END IF;
    ->     END IF;
    ->   UNTIL done END REPEAT;
    -> 
    ->   CLOSE cur1;
    ->   CLOSE cur2;
    -> END//
ERROR 1046 (3D000): No database selected
mysql>