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

From Stephan Szabo
Subject Re: c-function returns multiple rows
Date
Msg-id 20030822061139.Y83860-100000@megazone.bigpanda.com
Whole thread Raw
In response to c-function returns multiple rows  (Kirill Krasnosselov <kirill@digicol.de>)
List pgsql-novice
On Fri, 22 Aug 2003, Kirill Krasnosselov wrote:

> Hello, I have the following problem ( at PostgreSQL 7.3.3 on Red Hat
> Linux 7.1) with c-functions returning multiple rows.
>
> Here is a transcript of the test example:
>
> //////////////////////////////////////////
>
> #include <stdlib.h>
> #include "postgres.h"
> #include "fmgr.h"
> #include "nodes/execnodes.h"
>
>
> PG_FUNCTION_INFO_V1(dc_ftx);
> Datum
> dc_ftx(PG_FUNCTION_ARGS)
>   { ReturnSetInfo* rsi = (ReturnSetInfo *)fcinfo->resultinfo;
>     rsi->isDone = ExprEndResult;
>     PG_RETURN_NULL();
>   }

Looking at the docs, I'd think that should be:
#include "postgres.h"
#include "funcapi.h"


PG_FUNCTION_INFO_V1(dc_ftx);
Datum
dc_ftx(PG_FUNCTION_ARGS) {
    FuncCallContext  *funcctx;

    if (SRF_IS_FIRSTCALL())
    {
        funcctx = SRF_FIRSTCALL_INIT();
    }
    funcctx = SRF_PERCALL_SETUP();
    SRF_RETURN_DONE(funcctx);
}

since I don't see a mention that creating the call
context is optional, but I'm not a particular expert
in the C interfact.



pgsql-novice by date:

Previous
From: Kirill Krasnosselov
Date:
Subject: c-function returns multiple rows
Next
From: Tom Lane
Date:
Subject: Re: c-function returns multiple rows