我想知道postgresql中的递归查询,例如下面的查询是否是尾递归的?
WITH RECURSIVE category_tree(id, name, path) AS (
SELECT id, name, ARRAY[id]
FROM categories
WHERE parent_id IS NULL
UNION ALL
SELECT categories.id, categories.name, path || categories.id
FROM category_tree
JOIN categories ON categories.parent_id=category_tree.id
WHERE NOT categories.id = ANY(path)
)
SELECT *
FROM category_tree
ORDER BY path;