Re: Infinite Interval

Поиск
Список
Период
Сортировка
От Ashutosh Bapat
Тема Re: Infinite Interval
Дата
Msg-id CAExHW5uXrVPdh=2a=1y_jbcrjiiG_8MygieDQ_SAkw72pd2HyQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Infinite Interval  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Ответы Re: Infinite Interval  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Re: Infinite Interval  (jian he <jian.universality@gmail.com>)
Список pgsql-hackers
On Thu, Sep 21, 2023 at 7:21 PM Ashutosh Bapat
<ashutosh.bapat.oss@gmail.com> wrote:
>
> One thing I didn't understand though is the use of
> makeIntervalAggState() in interval_avg_deserialize(). In all other
> deserialization functions like numeric_avg_deserialize() we create the
> Agg State in CurrentMemoryContext but makeIntervalAggState() creates
> it in aggcontext. And it works. We could change the code to allocate
> agg state in aggcontext. Not a big change. But I did not find any
> explanation as to why we use CurrentMemoryContext in other places.
> Dean, do you have any idea?

Following code in ExecInterpExpr makes it clear that the
deserialization function is be executed in per tuple memory context.
Whereas the aggregate's context is different from this context and may
lives longer that the context in which deserialization is expected to
happen.

/* evaluate aggregate deserialization function (non-strict portion) */
EEO_CASE(EEOP_AGG_DESERIALIZE)
{
FunctionCallInfo fcinfo = op->d.agg_deserialize.fcinfo_data;
AggState *aggstate = castNode(AggState, state->parent);
MemoryContext oldContext;

/*
* We run the deserialization functions in per-input-tuple memory
* context.
*/
oldContext = MemoryContextSwitchTo(aggstate->tmpcontext->ecxt_per_tuple_memory);
fcinfo->isnull = false;
*op->resvalue = FunctionCallInvoke(fcinfo);
*op->resnull = fcinfo->isnull;
MemoryContextSwitchTo(oldContext);

Hence I have changed interval_avg_deserialize() in 0007 to use
CurrentMemoryContext instead of aggcontext. Rest of the patches are
same as previous set.

--
Best Wishes,
Ashutosh Bapat

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
Следующее
От: Dean Rasheed
Дата:
Сообщение: Re: Infinite Interval