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!