非递归过程中超出递归限制

Recursion limit exceeded in non-recusrive procedure(非递归过程中超出递归限制)
本文介绍了非递归过程中超出递归限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个调用另一个过程的过程.他们从不互相打电话或打电话给自己,但我收到一个错误响应,表明他们是.程序如下:

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

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;

这篇关于非递归过程中超出递归限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)