Re: c-function returns multiple rows

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kirill Krasnosselov <kirill(at)digicol(dot)de>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: c-function returns multiple rows
Date: 2003-08-22 13:17:55
Message-ID: 20030822061139.Y83860-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-08-22 13:52:28 Re: c-function returns multiple rows
Previous Message Kirill Krasnosselov 2003-08-22 11:31:16 c-function returns multiple rows