Re: c-function returns multiple rows - Mailing list pgsql-novice

From Tom Lane
Subject Re: c-function returns multiple rows
Date
Msg-id 8918.1061560348@sss.pgh.pa.us
Whole thread Raw
In response to c-function returns multiple rows  (Kirill Krasnosselov <kirill@digicol.de>)
Responses Re: c-function returns multiple rows
List pgsql-novice
Kirill Krasnosselov <kirill@digicol.de> writes:
> PG_FUNCTION_INFO_V1(dc_ftx);
> Datum
> dc_ftx(PG_FUNCTION_ARGS)
>   { ReturnSetInfo* rsi = (ReturnSetInfo *)fcinfo->resultinfo;
>     rsi->isDone = ExprEndResult;
>     PG_RETURN_NULL();
>   }

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.

Try attaching to the backend with a debugger to see what it's doing.

            regards, tom lane

pgsql-novice by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: c-function returns multiple rows
Next
From: Luis Hernán Otegui
Date:
Subject: Clusters and pgsql