Re: PL/pgSQL: recursion?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PL/pgSQL: recursion?
Дата
Msg-id 16774.978545364@sss.pgh.pa.us
обсуждение исходный текст
Ответ на PL/pgSQL: recursion?  ("Albert REINER" <areiner@tph.tuwien.ac.at>)
Список pgsql-sql
"Albert REINER" <areiner@tph.tuwien.ac.at> writes:
> is there any possibility to do recursion in plpgsql-functions?

Recursion works fine ... but an infinite recursion, such as you have
here, will quickly overflow the available stack space and cause the
backend to crash.  You're invoking idPath with the same argument it
was passed, no?

I changed
> |     str2 := idPath(r.id);
to
> |     str2 := idPath(r.id-1);
and got

regression=# select idPath(5);idpath
---------5:4:3:2
(1 row)

which may or may not be the answer you wanted, but it does demonstrate
that a plpgsql function can recurse.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Francis Solomon"
Дата:
Сообщение: RE: order by day or month, etc
Следующее
От: Michael Davis
Дата:
Сообщение: Numeric and money