[MDEV-6733] Can't easily change DEFINER on existing views, stored routines, triggers, events Created: 2014-09-11  Updated: 2024-02-05

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: New Feature Priority: Major
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: None

Issue Links:
Relates
relates to MDEV-4523 Add the possibility to do an ALTER tr... Open

 Description   

http://bugs.mysql.com/bug.php?id=73894

The question came up in the context of "DROP USER, how do I fix procedures afterwards?"

A naive expectation would be that one could simply say

  ALTER PROCEDURE name DEFINER=...;

but this isn't really supported on any of the four object types:

  • ALTER EVENT can change the DEFINER, but only if at least one other
    attribute is changed at the same time

e.g. "ALTER DEFINER=foo@bar EVENT e1 COMMENT='';" works
but just "ALTER DEFINER=foo@bar EVENT e1" doesn't

  • ALTER VIEW allows to change the definer, but you have to
    repeat the "AS SELECT ..." part
  • ALTER PROCEDURE / FUNCTION doesn't support changing the
    definer at all, but you can at least work around it by
    changing it in the mysql.proc table and restarting the
    server afterwards
  • ALTER TRIGGER ... well there is no ALTER TRIGGER statement
    at all to begin with ...

How to repeat:
Try to change the definer of existing EVENTs, VIEWs, PROCEDUREs, FUNCTIONs and TRIGGERs

Suggested fix:
Provide ALTER variants for all object types that have a DEFINER to easily change the definer with just

  ALTER $OBJECTTYPE $name DEFINER=...;



 Comments   
Comment by Federico Razzoli [ 2015-06-04 ]

Note that this cannot be done via a stored procedure, because CREATE PROCEDURE and similar statements are not allowed in a procedure body. If stored procedures were more powerful, implementing this feature in SQL would be simple.

Comment by Sergei Golubchik [ 2023-06-26 ]

SET USER allows to set a definer, so it could also allow changing it

Generated at Thu Feb 08 07:14:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.