Home  >  Article  >  Database  >  What is a recursive stored procedure and why does MySQL limit recursion?

What is a recursive stored procedure and why does MySQL limit recursion?

王林
王林forward
2023-09-02 11:45:02708browse

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

If a stored procedure calls itself, the stored procedure is called recursive. Basically, this concept is called recursion. MySQL limits recursion so errors won't be as strict. We can check this limit with the help of the following query -

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

We can change this value to 255 with the help of the following query -

mysql> SET @@GLOBAL.max_sp_recursion_depth = 255//
Query OK, 0 rows affected (0.00 sec)

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

This limit can also be extended while writing the program.

The above is the detailed content of What is a recursive stored procedure and why does MySQL limit recursion?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete