Re: Why MemoryContextSwitch in ExecRelCheck ?
От | Holger Krug |
---|---|
Тема | Re: Why MemoryContextSwitch in ExecRelCheck ? |
Дата | |
Msg-id | 20020107193053.A10908@dev12.rationalizer.com обсуждение исходный текст |
Ответ на | Re: Why MemoryContextSwitch in ExecRelCheck ? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Why MemoryContextSwitch in ExecRelCheck ?
|
Список | pgsql-hackers |
On Mon, Jan 07, 2002 at 12:28:12PM -0500, Tom Lane wrote: > Holger Krug <hkrug@rationalizer.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@rationalizer.com
В списке pgsql-hackers по дате отправления: