Re: Preventing tuple-table leakage in plpgsql - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Preventing tuple-table leakage in plpgsql
Date
Msg-id 5064.1374419589@sss.pgh.pa.us
Whole thread Raw
In response to Re: Preventing tuple-table leakage in plpgsql  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> On Thu, Jul 11, 2013 at 09:14:38PM -0400, Chad Wagner wrote:
>> Should SPI_connect be called again after the subtransaction is created?  And
>> SPI_finish before the subtransaction is committed or aborted?

> Hmm.  An SPI_push()+SPI_connect() every time PL/pgSQL starts a subtransaction
> would be another way to fix it, yes.

That sounds like a dangerous idea to me.  The procedure would then be
working actively with queries from two different SPI levels, which I'm
pretty sure would cause issues.  It's possible that plpgsql's SPI access
is sufficiently lexically-local that statements within the BEGIN block
couldn't use any SPI resources created by statements outside it nor vice
versa.  But then again maybe not, and in any case we couldn't imagine
that that would be a workable restriction for non-plpgsql scenarios.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Preventing tuple-table leakage in plpgsql
Next
From: Noah Misch
Date:
Subject: Re: Preventing tuple-table leakage in plpgsql