Re: Freeing plan memory - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Freeing plan memory
Date
Msg-id 19636.1035049119@sss.pgh.pa.us
Whole thread Raw
In response to Re: Freeing plan memory  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List pgsql-hackers
"Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
> On Sat, 19 Oct 2002, Tom Lane wrote:
>> I'm not sure where the leak is in your plpython example, but I'd be
>> inclined to look to plpython itself, perhaps even just the string
>> concatenation expression in
>> plan = plpy.prepare("SELECT " + repr(a))

> Well it's not that string operation.

Actually, I'll bet it's this code in PLy_spi_prepare:
plan->plan = SPI_prepare(query, plan->nargs, plan->types);// error check
plan->plan = SPI_saveplan(plan->plan);// error check

The copy of the plan that's returned by SPI_prepare is being blithely
lost --- and since it's in the procCxt, it won't go away until the
plpython function is exited.  Need a SPI_freeplan() here, I think.
Can you check it out and send a patch?
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Nigel J. Andrews"
Date:
Subject: Re: Freeing plan memory
Next
From: "Dave Page"
Date:
Subject: Re: /contrib/retep to gborg