MySQL Forums
Forum List  »  Newbie

Re: Rename Stored Procedure Syntax
Posted by: Byron Platt
Date: August 04, 2009 06:47AM

(Edit2: Did some more testing. It seems the issue in my first edit goes away when you reconnect to the database. The stored procedures must be in memory or something of that nature)
(Edit: I just tried using the following and it didn't work entirely as expected. The name changed and i could call the procedure using the new name, however, I could also still call it using the old name -- weird)

I had a look around to and couldn't see way to do it using ALTER PROCEDURE. The NAME characteristic isn't documented here.
To rename without doing a DROP then CREATE the following should work. I'd be interested to know if there is a better way of doing this.
UPDATE `mysql`.`proc`
SET name = '<new_proc_name>',
    specific_name = '<new_proc_name>'
WHERE db = '<database>' AND
      name = '<old_proc_name>';

Also note: If have granted privileges to users for this procedure you will need to update the procedure name in procs_priv as well.
UPDATE `mysql`.`procs_priv`
SET Routine_name = '<new_proc_name>'
WHERE Db = '<database>' AND
      Routine_name = '<old_proc_name>';
FLUSH PRIVILEGES;



Edited 3 time(s). Last edit at 08/04/2009 07:21AM by Byron Platt.

Options: ReplyQuote


Subject
Written By
Posted
Re: Rename Stored Procedure Syntax
August 04, 2009 06:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.