Re: Thinking about inventing MemoryContextSetParent

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Thinking about inventing MemoryContextSetParent
Дата
Msg-id 20110911103615.GA28907@svana.org
обсуждение исходный текст
Ответ на Thinking about inventing MemoryContextSetParent  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Sat, Sep 10, 2011 at 06:03:23PM -0400, Tom Lane wrote:
> I'm considering inventing a new mcxt.c primitive,
>
> void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent);
>
> which would have the effect of delinking "context" from its current
> parent context and attaching it as a child of the new specified parent.
> (Any child contexts that it has would naturally follow along.)
> Because of the way that mcxt.c handles parent/child links, there is no
> palloc required and so the operation cannot fail.

I like this idea. Currently the only way to control object lifetime is
at creation time. This means that you can "atomically" change the
lifetime of a collection of object when it reaches a state we like.

It occured to me this might be useful in other places where we copy
data into a longer lived context after checking.  Maybe config file
reading or plan construction.  The only issue I can think of is if
people where allocating in the local context assuming it would be
cleaned up and this data got kept as well.  So it's probably not
appropriate for things that happen really often.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.  -- Arthur Schopenhauer

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

Предыдущее
От: Dimitri Fontaine
Дата:
Сообщение: Re: [REVIEW] prepare plans of embedded sql on function start
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Add missing format attributes