From: | Holger Krug <hkrug(at)rationalizer(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Why MemoryContextSwitch in ExecRelCheck ? |
Date: | 2002-01-07 18:30:53 |
Message-ID: | 20020107193053.A10908@dev12.rationalizer.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jan 07, 2002 at 12:28:12PM -0500, Tom Lane wrote:
> Holger Krug <hkrug(at)rationalizer(dot)com> writes:
> > Nevertheless in ExecRelCheck a context switch to per-query memory
> > context is made:
> > Is this a switch from per-query memory context to per-query memory
> > context, hence not necessary, or do I miss something ?
>
> [ thinks ... ] It might be unnecessary. I'm not convinced that the
> per-query context would always be the active one when ExecRelCheck is
> called, however. There are various per-tuple contexts that might be
> used as well.
I think, there aren't, but nevertheless, you're principles stated
below are convincing.
> MemoryContextSwitchTo() is cheap enough that I prefer to call it when
> there's any doubt, rather than build a routine that will fail silently
> if it's called in the wrong context. There are two typical scenarios
> for routines that are building data structures that will outlive the
> routine's execution:
>
> 1. Data structure is to be returned to the caller. In this case the
> caller is responsible for identifying the context to allocate the data
> structure in, either explicitly or by passing it as the current context.
>
> 2. Data structure is owned and managed by the routine, which must know
> which context it's supposed to live in. In these cases I think the
> routine ought always to explicitly switch to that context, not assume
> that it's being called in that context.
OK. I wondered, because this is not done for the trigger related
cache, but only for the check related cache. Now I understand, it's
work in progress. (I think, very good work, indeed, because the code
is astonishingly well readable.)
--
Holger Krug
hkrug(at)rationalizer(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-01-07 18:38:38 | Re: Why MemoryContextSwitch in ExecRelCheck ? |
Previous Message | Laurette Cisneros | 2002-01-07 18:13:02 | Re: bug in join? |