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

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

王林
Release: 2023-09-02 11:45:02
forward
759 people have browsed it

什么是递归存储过程以及为什么 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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template