Re: Crash on SRF execution

Поиск
Список
Период
Сортировка
От Itai Dor-On
Тема Re: Crash on SRF execution
Дата
Msg-id DUB127-DS23F121912EB4074B00AFECAD050@phx.gbl
обсуждение исходный текст
Ответ на Re: Crash on SRF execution  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Thanks Tom.

Assuming the SRF had a parameter, would this be a correct approach
(considering the iterative model) to bail-out early?

if (SRF_IS_FIRSTCALL())
{int i;if (get_call_result_type(fcinfo, NULL, &funcctx->tuple_desc) !=
TYPEFUNC_COMPOSITE) {    ereport(ERROR,    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),     errmsg("Check if sql function
definitionreturns SETOF
 
record")));            return;}
if (PG_ARGISNULL(0)) {    ereport(ERROR,    (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),     errmsg("Null value not allow
for...")));     return;}     if((i = PG_GETARG_INT32(0)) != 'WHATEVER') {    ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),    errmsg("Null value not allow for ...")));     return;}
 

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Sunday, March 15, 2015 5:50 PM
To: Itai
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] Crash on SRF execution

Itai <itaid@outlook.com> writes:
> I'm attempting to program a simple SRF function but it constantly crashes
(details and code below).
> Any idea why?

Looks like you're pallocing some stuff in the calling context (ie, a
short-lived context) during the first execution and expecting it to still be
there in later executions.  You'd need to allocate those data structures in
the multi_call_memory_ctx instead.
        regards, tom lane




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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Merge compact/non compact commits, make aborts dynamically sized
Следующее
От: Tom Lane
Дата:
Сообщение: Cygwin vs "win32" in configure