Hello,
I have encountered a difference in behaviour between versions 9.3.3 and
9.4.3 for a certain query involving tail recursion. In 9.3.3 the
compiled query plan correctly applied tail call optimization. But in
9.4.3 tail call optimization is not applied, resulting in a stack
overflow during execution.
Here is a minimal query that demonstrates the issue:
declare function local:f($n, $xs)
{
if ($n = 0) then $xs
else
let $x :=
copy $node := <a/> modify ( rename node $node as 'x') return $node
return local:f($n - 1, ($xs, $x))
};
local:f(2000, ())
Mark