Bug #24771 ALTER PROCEDURE syntax doesnt work as described in manual
Submitted: 2 Dec 2006 2:31 Modified: 3 Dec 2006 10:30
Reporter: Luis Felipe Saldamando Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.24a OS:Windows (Win2k)
Assigned to: CPU Architecture:Any
Tags: alter procedure header definition error 1064

[2 Dec 2006 2:31] Luis Felipe Saldamando
Description:
Using SQLyog enterprise 5.19 or MySQL Query browser 1.2.3 beta, ALTER PROCEDURE doesnt work as described in manual.

ALTER {PROCEDURE | FUNCTION} sp_name [characteristic ...]
characteristic:
{ CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'

This statement can be used to change the characteristics of a stored procedure or function. You must
have the ALTER ROUTINE privilege for the routine. (That privilege is granted automatically to the
routine creator.)

How to repeat:
When you execute the following script:

DELIMITER $$
ALTER PROCEDURE `Prueba`()
BEGIN
  SELECT 1;
END$$
DELIMITER ;

Returns

Error Code : 1064
Algo está equivocado en su sintax cerca '()
BEGIN
  SELECT 1;
END' en la linea 1
(0 ms taken)

The script was executed with "admin" user who has ALTER ROUTINE privileges. Binary logging is OFF.

Id tried every combination between the first $$ and the BEGIN clause. Including DEFINER, INVOKER and adding Database to the name (`database`.`Prueba`) and many other posibilities.

Alter Procedure does not have workaround when you define security like:
- "admin" user can alter procedures but doesnt have GRANT permissions
- "admin" user cant select tables

If anyone knows "admin" password cant get data of the database writing new procedures with select statements.

Suggested fix:
Please verify and fix (if it is then case).
[3 Dec 2006 10:30] Valeriy Kravchuk
Please, read the manual (http://dev.mysql.com/doc/refman/5.0/en/alter-procedure.html, http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html) carefully. You can not use ALTER to change procedure's body (routine_body). You have to DROP and CREATE it with a new code.