Bug #5176 Stored procedure crash if SELECT missing
Submitted: 24 Aug 2004 3:07 Modified: 10 Sep 2004 15:13
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[24 Aug 2004 3:07] Peter Gulutzan
Description:
I have two stored procedures which are almost identical, except that the first procedure 
contains "SELECT 'hello';" and the second procedure does not contain "SELECT 'hello';". 
The first procedure does not crash. The second procedure crashes. 
 
A handler is involved. The handler should be activated because there is an illegal CREATE 
VIEW in the procedure. But the activation only causes a single call to the procedure, with a 
parameter value that will cause the procedure's WHILE loop to be skipped. 
 

How to repeat:
mysql> delimiter // 
mysql> create procedure p_1 (x int) begin declare v int default 0; declare continue handler 
for sqlstate 'HY000' call p_1(1); select 'hello'; while v < 10 and x <> 1 do create view vv as 
select * from t where s1 > v; drop view vv; set v = v + 1; end while; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p_1(0)// 
+-------+ 
| hello | 
+-------+ 
| hello | 
+-------+ 
1 row in set (0.00 sec) 
 
+-------+ 
| hello | 
+-------+ 
| hello | 
+-------+ 
1 row in set (0.00 sec) 
 
ERROR 1051 (42S02): Unknown table 'db5.vv' 
mysql> create procedure p_2 (x int) begin declare v int default 0; declare continue handler 
for sqlstate 'HY000' call p_2(1); while v < 10 and x <> 1 do create view vv as select * from t 
where s1 > v; drop view vv; set v = v + 1; end while; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p_2(0)//
[24 Aug 2004 3:33] MySQL Verification Team
I wasn't able for to get the server crash instead the client just hangs:

mysql> call p_2(0)//

Aborted
miguel@hegel:~/5.0/bin$ mysql --defaults-file=../my.cnf -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.2-alpha-debug-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
[10 Sep 2004 15:13] 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