Bug #3157 Crash if stored procedure contains IF EXISTS
Submitted: 12 Mar 2004 10:40 Modified: 24 Aug 2004 16:23
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[12 Mar 2004 10:40] Peter Gulutzan
Usually "IF (condition)" works in a stored procedure, but if the condition is an EXISTS 
clause, there's a crash. It happens only if the EXISTS has a SELECT with a table 
reference. That is: "EXISTS(SELECT 1)" causes no crash but "EXISTS (SELECT * FROM 
tablename)" causes a crash. Also "if (select count(*) from Table1) = 5" causes a crash. 

How to repeat:
mysql> create table Table1 (s1 int)// 
Query OK, 0 rows affected (0.29 sec) 
mysql> create procedure p4 () begin if exists(select * from Table1) then set @n = 5; end if; 
Query OK, 0 rows affected (0.00 sec) 
mysql> call p4()// 
ERROR 2013 (HY000): Lost connection to MySQL server during query 

Suggested fix:
At least there should be an error return. If so, the error message should not contain the 
word "subselect" -- the proper word is "subquery".
[12 Mar 2004 13:44] Dean Ellis
Verified against 5.0.1-alpha-log.
[24 Aug 2004 16:23] 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