Re: Tuplestore should remember the memory context it's created in

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Tuplestore should remember the memory context it's created in
Дата
Msg-id 4B31080A.6040402@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Tuplestore should remember the memory context it's created in  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Tuplestore should remember the memory context it's created in  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
>> Patch against CVS HEAD to do that and fix the reported bug attached. Now
>> that the tuplestore_put* switches to the right memory context, we could
>> remove that from all the callers, but this patch only does it for pl_exec.c.
> 
> BTW, I'm not convinced that the owner-switchery you added to pl_exec.c
> is necessary/appropriate.  Under what circumstances would that be a good
> idea?

A PL/pgSQL normally runs in the whatever resource owner is current when
the function is called. When we allocate the tuplestore for return
tuples, it's associated with the current resource owner.

But if you have an exception-block, we start a new subtransaction and
switch to the subtransaction resource owner. If you have a RETURN
NEXT/QUERY in the block, the tuplestore (or the temporary file backing
it, to be precise) is initialized into the subtransaction resource
owner, which is released at subtransaction commit. The subtransaction
resource owner is not the right owner for the tuplestore holding return
tuples.

We already take care to use the right memory context for the tuplestore,
but now that temp files are associated with resource owners, we need to
use the right resource owner as well.

--  Heikki Linnakangas EnterpriseDB   http://www.enterprisedb.com


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Backup history file should be replicated in Streaming Replication?
Следующее
От: "David E. Wheeler"
Дата:
Сообщение: Re: Segfault from PL/Perl Returning vstring