I've written a stored FUNCTION that calls itself, recursively.
However when I run it in a query I get this shameless error:
Error: 1424 SQLSTATE: HY000 (ER_SP_NO_RECURSION)
Message: Recursive stored functions and triggers are not allowed.
"Not allowed"?
Right. Why don't we just disable WHILE loops also, while we're at it?
Can I enable recursive functions in any way?
I found a bug report, but are there any workarounds?
I'm running MySQL 5.1.41 on Windows XP (XAMPP Server).
MySQL 5.1 supports recursive stored procedures, but not recursive functions. Quoting the docs:
Stored functions cannot be recursive.
Recursion in stored procedures is permitted but disabled by default. To enable recursion, set the
max_sp_recursion_depth
server system variable to a value greater than zero. Stored procedure recursion increases the demand on thread stack space. If you increase the value ofmax_sp_recursion_depth
, it may be necessary to increase thread stack size by increasing the value ofthread_stack
at server startup.