Re: Storing MemoryContext Pointers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Storing MemoryContext Pointers
Date: 2006-10-06 14:23:47
Message-ID: 20393.1160144627@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr> writes:
> On Oct 05 03:34, Tom Lane wrote:
>> Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr> writes:
>>> How can I store the persistent_mcxt in a persistent place that I'll be
>>> able to reach it in my next getting invoked?
>>
>> Make it a static variable.

> I had thought some kind of fcinfo->flinfo->fn_extra trick but... a
> static variable is fair enough too.

No, a fn_extra pointer would go away whenever the calling query ends,
and you'd have leaked the context permanently. Children of
TopMemoryContext will never go away unless explicitly destroyed, so
a static variable has the right lifespan to remember them.

If you did want something that goes away at end of query, you could
probably make it a child of the PortalContext.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-10-06 14:30:01 Re: pg_dump exclusion switches and functions/types
Previous Message Zdenek Kotala 2006-10-06 14:05:01 Re: Upgrading a database dump/restore