1 Replies - 180 Views - Last Post: 25 July 2018 - 12:41 AM

#1 djdave106   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-March 12

permission to execute functions but not procedures

Posted 25 July 2018 - 12:19 AM

I want a particular DB user account to have SELECT permission but not EXECUTE permission - they can look but not touch. However, I want SELECT to include being able to run FUNCTIONs - this seems reasonable since FUNCTIONs cannot execute commands that alter the tables. Here's an example

CREATE FUNCTION `intGetMaxTemplateVersionNumber`(
  p_fkTemplate INT
) RETURNS INT
BEGIN
RETURN (SELECT IFNULL((SELECT MAX(ckTemplateVersionNumber) FROM tblTemplateVersions WHERE cfkTemplate = p_fkTemplate), -1));

END




But it appears that there is no such granularity in MySQL. Is that correct? Is what I want to do reasonable? Is there a way to do it?

Is This A Good Question/Topic? 0
  • +

Replies To: permission to execute functions but not procedures

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,272
  • Joined: 12-December 12

Re: permission to execute functions but not procedures

Posted 25 July 2018 - 12:41 AM

From a quick look around it seems you can grant execute for particular functions:

Quote

GRANT EXECUTE
ON FUNCTION `yourdatabase`.`yourfunction`
TO 'youruser'@'localhost';

which is equivalent to select because, as you say, the function will not alter anything.

I am doubtful that you could do this globally for all functions, but I haven't explored in any depth.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1