2

An user should only execute functions and procedures. I grant EXECUTE to this user and revoke other privileges from the same user for security reasons.

How to check if this user has only the EXECUTE privilege for a stored function?

Sam
  • 7,252
  • 16
  • 46
  • 65
Sergey L. Mokeev
  • 21
  • 1
  • 2
  • 5
  • Please refer this link http://dev.mysql.com/doc/refman/5.0/en/show-grants.html – Shashi Nov 20 '12 at 14:17
  • I want to check grant in stored function. CREATE FUNCTION `get_max_price`() RETURNS int(11) unsigned begin declare l int(11) unsigned; if "check user has just execute grant" then select max(price)+1 into l from cars; return l; end if; return 0; end; I can call show grants. But how to check output in stored function? – Sergey L. Mokeev Nov 20 '12 at 14:25
  • You can define an exception using declare handler.. if user didn't have the privileges for certain operation, it will throws error which will be handled by the defined exception handler. http://dev.mysql.com/doc/refman/5.0/en/declare-handler.html – Shashi Nov 20 '12 at 14:56

1 Answers1

0
SHOW GRANTS FOR '<user>'@'<host>'

shows the grants for user. You can check user's grants.

SELECT * FROM  mysql.procs_priv WHERE Proc_priv='Execute' AND Routine_type='PROCEDURE' AND Routine_name='<routine_name>' AND User='<user>' Db='<db_name>' AND Host='<host>';

Db and Host may not be necessary