Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-committerspgsql-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

pgsql-hackers by date

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

pgsql-committers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group