什么是递归存储过程?为什么MySQL限制递归?

如果存储过程调用自身,则称为递归过程。基本上,此概念称为递归。MySQL限制了递归,因此错误将不那么严格。我们可以在以下查询的帮助下检查此限制-

mysql> Show variables LIKE '%recur%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| max_sp_recursion_depth |   0   |
+------------------------+-------+
1 row in set (0.01 sec)

我们可以在以下查询的帮助下将此值最多更改为255-

mysql> SET @@GLOBAL.max_sp_recursion_depth = 255//

mysql> Show variables LIKE '%recur%'//
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| max_sp_recursion_depth | 255   |
+------------------------+-------+
1 row in set (0.01 sec)

也可以在编写过程时扩展该限制。

猜你喜欢