Re: Unstable C Function - Mailing list pgsql-general

From Tom Lane
Subject Re: Unstable C Function
Date
Msg-id 27894.1474562481@sss.pgh.pa.us
Whole thread Raw
In response to Re: Unstable C Function  (Ian Campbell <ianrc72@gmail.com>)
List pgsql-general
Ian Campbell <ianrc72@gmail.com> writes:
> OK, so SPI is only suitable for single-call functions, right?

It's usable by strictly nested functions, but a multi-call SRF is more
like a coroutine.

> If another
> function in the query attempted to use SPI, I assume there would be a
> deadlock?

No, the second arrival would get a SPI_ERROR_CONNECT failure from
SPI_connect when there's already an open connection.  For the nested-
calls case you can prevent that with SPI_push/SPI_pop around a call that
might wish to use SPI, but that fix doesn't work in a coroutine situation.

            regards, tom lane


pgsql-general by date:

Previous
From: Ian Campbell
Date:
Subject: Re: Unstable C Function
Next
From: Rafia Sabih
Date:
Subject: Re: Question about "grant create on database" and pg_dump/pg_dumpall