Bug #31201 Stored Procedures now can contain prepared Statements.
Submitted: 26 Sep 2007 9:01 Modified: 13 Nov 2007 23:17
Reporter: Sveta Smirnova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Paul Dubois CPU Architecture:Any
Triage: D4 (Minor)

[26 Sep 2007 9:01] Sveta Smirnova
Description:
Our manual says at http://dev.mysql.com/doc/refman/5.1/en/routine-restrictions.html:

 Stored routines cannot contain arbitrary SQL statements. The following statements are disallowed:
***
    *      SQL prepared statements (PREPARE, EXECUTE, DEALLOCATE PREPARE). Implication: You cannot use dynamic SQL within stored functions or triggers (where you construct dynamically statements as strings and then execute them). 

But they are allowed.

How to repeat:
See bug #31161

Suggested fix:
Fix manual
[13 Nov 2007 23:17] Paul Dubois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

The manual is correct, actually, because it states that the restriction is for stored functions and triggers. That is, prepared statements are allowed in stored *procedures*. However, this distinction isn't so clear in the item in question, so I will attempt to clarify it.