I wrote:
> I tried it here. I don't get a crash; I get a rather long delay and
> then
> psql:vlad.sql:61: ERROR: Memory exhausted in AllocSetContextCreate(8192)
Some experimentation with other infinitely-recursive plpgsql functions
soon turned up a crash, however: spi.c was being sloppy about not
checking for a failure return from malloc(). I have repaired that,
as well as some other similar omissions elsewhere in the backend.
I can't be sure if that's the case that was biting you, however.
Someday we ought to mount a concerted effort to get rid of all direct
uses of malloc() and friends in the backend; they're too easy to misuse,
and there's no good reason not to funnel everything through palloc.
regards, tom lane