Re: pgsql: Remove inappropriate memory context switch in

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Remove inappropriate memory context switch in
Date: 2008-11-30 23:07:09
Message-ID: 13281.1228086429@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

"Neil Conway" <neilc(at)samurai(dot)com> writes:
> ... I think better would be to figure out a more appropriate
> memory context to switch into before deleting the multi-call context.

BTW, I did look at that alternative. In principle we could have
init_MultiFuncCall save the current context and let end_MultiFuncCall
switch to that context. However there are a couple of serious problems
with that:

1. There's noplace in FuncCallContext to save it. Adding a field would
represent an ABI break that is certain to break external modules, so
it seems a nonstarter for a back-patchable fix.

2. We can't be absolutely sure that this is the right context to return
to anyway --- perhaps the SRF changed the context before calling
init_MultiFuncCall. (One plausible mechanism for this is if SPI_connect
is called first.) SRF_RETURN_DONE() doesn't give the caller any chance
to fix things afterwards, so a 95% or 99% solution isn't good enough.

In general, I think funcapi.c has no business making a change to the
caller's CurrentMemoryContext in any case. It never did so before the
February patch, and is not documented to do so.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2008-11-30 23:23:52 pgsql: Fix dblink and tablefunc to not return with the wrong
Previous Message Tom Lane 2008-11-30 21:29:03 Re: pgsql: Remove inappropriate memory context switch in

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-30 23:55:27 Problem in contrib/tablefunc's crosstab()
Previous Message Tom Lane 2008-11-30 21:29:03 Re: pgsql: Remove inappropriate memory context switch in