Re: SPI_exec doesn't return proc context (on 9.1)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SPI_exec doesn't return proc context (on 9.1)
Date: 2011-01-29 19:56:40
Message-ID: AANLkTimcuZ9LxPGpjKT67y+CjHBCo4visJ=HJMF10tBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2011/1/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> I am playing with demos for PostgreSQL's Prague Developer Day and I
>> found a strange behave. SPI_exec should to return to proc context. But
>> it isn't true.
>
> Yes it is.

ah, I though a savedctx, but it restore procctx, that is child context
of SPI too.

>
>> In following demo, I have to play with MemoryContext
>> when I would to get a correct result. Is it ok?
>
> The commented-out lines of code don't appear to have anything to do with
> what you claim the problem is.  What it looks to me like you're doing is
> copying the result out to the function's calling context, which is not
> either of the SPI contexts established by SPI_connect (and removed by
> SPI_finish).

>
> The less crocky way to do that is to use SPI_palloc() for something that
> should be allocated in the outer context.

I understand. Is there some way, where I can use a cstring_to_text
function? There isn't simple way to get a saveCtx.

some like SPI_copyDatum ... ?

Pavel

>
>                        regards, tom lane
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Singer 2011-01-29 20:27:24 Re: pl/python SPI in subtransactions
Previous Message Jeff Davis 2011-01-29 19:53:14 Re: WIP: RangeTypes