Re: Unstable C Function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ian Campbell <ianrc72(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unstable C Function
Date: 2016-09-22 16:41:21
Message-ID: 27894.1474562481@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ian Campbell <ianrc72(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafia Sabih 2016-09-23 08:13:38 Re: Question about "grant create on database" and pg_dump/pg_dumpall
Previous Message Ian Campbell 2016-09-22 16:22:07 Re: Unstable C Function