On Thu, Jul 03, 2003 at 12:11:36AM -0400, Tom Lane wrote:
> Joe Conway <[EMAIL PROTECTED]> writes:
> > Alvaro Herrera wrote:
> >> why is this a malloc() and not palloc()?  And when/where/how is it freed?
> 
> > It isn't, at least not until the backend exits ;-)
> 
> > This is how plpgsql is done throughout, pretty much. It's not so bad 
> > when you remember that plpgsql functions are "compiled" once, and then 
> > cached for future calls by the same backend.
> 
> I think palloc would actually be wrong there, because it would allocate
> memory that would go away soon (certainly not later than end of
> transaction) whereas the structure needs to live as long as the plpgsql
> function cache entry does.  Without a switch into a suitably-long-lived
> context, this code can't use palloc.

That'd be TopMemoryContext.  Not too much a win, I think.  Maybe each
plpgsql function should have it's own context, destroyed by CREATE OR
REPLACE FUNCTION, for example.

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"I dream about dreams about dreams", sang the nightingale
under the pale moon (Sandman)

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to