Tom,
>You're right, you can't just return from that inner function while
>leaving its SPI connection open.
>
>It might be interesting to redesign SPI around the notion of independent
>"connection objects" rather than necessarily having a stack of 'em.
>
>
I made the same reflection looking at the SPI code. It would be nice if
something corresponding to _SPI_current could be passed around.
>I think that could be made to work ... but not while preserving the
>existing SPI API.
>
I'm not so sure you'd have to. A public API that can disable stack
handling and instead use something similar to MemoryContextSwitchTo but
for an _SPI_current like structure would perhaps be sufficient?
> I'm hesitant to break a ton of user-written code for
>a feature that only one person has needed :-(
>
>
It is a fairly serious design flaw IMHO. I discovered it and so far no
one else has complained. That's true for all flaws at first.
Regards,
Thomas Hallgren