Re: c-function returns multiple rows

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: c-function returns multiple rows
Дата
Msg-id 3F47DE49.7040201@joeconway.com
обсуждение исходный текст
Ответ на Re: c-function returns multiple rows  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Tom Lane wrote:
> This looks like it should work, but you're living dangerously
> by not checking that you're being called the way you expect.
> You should have something like
>
>     if (!fcinfo->resultinfo || !IsA(fcinfo->resultinfo,ReturnSetInfo))
>         elog(ERROR, ...);
>
> in there before trying to dereference the pointer.
>
>>In my opinion this function call shall returns a empty table,
>>but this call does not end.
>

Works here on 7.3.4 (actually 7.3 stable branch after 7.3.4 was released):

extern Datum dc_ftx(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(dc_ftx);
Datum dc_ftx(PG_FUNCTION_ARGS)
{
   ReturnSetInfo* rsi;
   if (!fcinfo->resultinfo || !IsA(fcinfo->resultinfo,ReturnSetInfo))
     elog(ERROR, "called in unsupported context");
   rsi = (ReturnSetInfo *)fcinfo->resultinfo;
   rsi->isDone = ExprEndResult;
   PG_RETURN_NULL();
}

regression=# select version();
                            version

--------------------------------------------------------------------
  PostgreSQL 7.3.4 on i386-redhat-linux-gnu, compiled by GCC
i386-redhat-linux-gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
(1 row)

regression=# select dc_ftx(10);
  dc_ftx
--------
(0 rows)

What do you mean by "call does not end". Does it eventually crash?

Joe


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

Предыдущее
От: Tomka Gergely
Дата:
Сообщение: Re: dump with nice comments
Следующее
От: "Hans Jorgensen"
Дата:
Сообщение: Porting from MSSQL Server