Bug #10604 Stored procedure with output parameter, SQL prepared statement crashes
Submitted: 12 May 2005 17:11 Modified: 23 May 2005 14:24
Reporter: Dean Ellis Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.6 OS:
Assigned to: Assigned Account CPU Architecture:Any

[12 May 2005 17:11] Dean Ellis
Description:
A stored procedure with an output parameter which executes a SQL prepared statement crashes the server.

If the input paramter is not OUT, the crash does not occur.

How to repeat:
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS p1;
CREATE TABLE t1 ( a INT );
DELIMITER //
CREATE PROCEDURE p1 (OUT a INT)
 LANGUAGE SQL
 DETERMINISTIC
 BEGIN
  DECLARE rsql VARCHAR(100);
  DECLARE prm INT;
  SET @rsql:= "INSERT INTO t1 VALUES (?)";
  SET @prm:= 1;
  PREPARE pst FROM @rsql;
  EXECUTE pst USING @prm;
 END//
DELIMITER ;
SET @a:=0;
CALL p1(@a);
SELECT @a;

Suggested fix:
n/a
[23 May 2005 14:24] Per-Erik Martin
Duplicate of BUG#7115. (Prepared statements in general don't work in stored procedures.)