I have a procedure which calls another procedure. They never call back to each other or call themselves, but I am getting an error response indicating that they are. The procedures are as follows:
CREATE PROCEDURE grantPermission (perm VARCHAR(30), target VARCHAR(30), id VARCHAR(8), host VARCHAR(45), passwd VARCHAR(45))
BEGIN
SET @setPermissionCmd = CONCAT('GRANT ', perm, ' ON ', target, ' TO ''', id, '''@''', host, ''' IDENTIFIED BY ''', passwd, ''';');
PREPARE setPermissionStmt FROM @setPermissionCmd;
EXECUTE setPermissionStmt;
DEALLOCATE PREPARE setPermissionStmt;
FLUSH PRIVILEGES;
END
and
CREATE PROCEDURE grantAdmin (id VARCHAR(8), host VARCHAR(45), passwd VARCHAR(45))
BEGIN
CALL grantPermission('EXECUTE', 'PROCEDURE createUser', id, host, passwd);
CALL grantPermission('EXECUTE', 'PROCEDURE grantAdmin', id, host, passwd);
CALL grantPermission('EXECUTE', 'PROCEDURE revokeAdmin', id, host, passwd);
CALL grantPermission('INSERT,UPDATE', 'TaskType', id, host, passwd);
CALL grantPermission('UPDATE', 'User', id, host, passwd);
UPDATE User SET isAdmin=1 WHERE dbUser=id;
FLUSH PRIVILEGES;
END
When I call the second procedure, I get the following response:
MariaDB [pattsdb]> CALL grantAdmin('patts', '%', 'patts');
ERROR 1456 (HY000): Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine grantAdmin
Why does it think my procedure is recursive? Just because the name is mentioned in the definition text?
Add this to the beginning of the Stored Procedure:
SET max_sp_recursion_depth=255;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With