Re: Freeing plan memory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Freeing plan memory
Date: 2002-10-19 17:38:39
Message-ID: 19636.1035049119@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2002-10-19 18:14:56 Re: [HACKERS] clusterdb has poor error recovery
Previous Message Nigel J. Andrews 2002-10-19 17:27:23 Re: Freeing plan memory