SETOF function call - Mailing list pgsql-hackers

From Olivier Thauvin
Subject SETOF function call
Date
Msg-id 200504190213.20273.olivier.thauvin@aerov.jussieu.fr
Whole thread Raw
Responses Re: SETOF function call  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I hope I am on good list, else point me where I should ask.

I create a C function like this:

CREATE
-- IFUPDATE or REPLACE   FUNCTION rpmquery(rpmheader, INT) RETURNS SETOF TEXT AS   'MODULE_PATHNAME', 'header_query'
LANGUAGEC IMMUTABLE STRICT; 

(do not take care, code come from the .sql.in)

And the function works well, rpmheader is a new type with its own in/out
function.

But I have a problem, the second argument is an integer, ie an internal value.
So I want to create a function wrapper as rpmquery(rpmheader, TEXT), the goal
of this function is to first convert the "human text value" to "internal
integer value" and then call the first function.

But I am unable to to create a single function like I allready did with
function returning single Datum:

PG_FUNCTION_INFO_V1(header_querytxt);

Datum
header_querytxt(PG_FUNCTION_ARGS)
{   elog(NOTICE, "querytxt");   Datum tag;/* converting TEXT value to integer one */   tag =
DirectFunctionCall1(rpmtagvalue,PG_GETARG_TEXT_P(1));   elog(NOTICE, "querytxt %d", tag);/* header_query = function
acceptinginteger instead text)   PG_RETURN_POINTER(DirectFunctionCall2(header_query,
PG_GETARG_BYTEA_P_COPY(0),tag)); 
}

I get a segfault just after second elog. This is maybe simple for anyone
reading this list, but I am unable to find an example, or a documention to do
this.
A simple example, or a URL is welcome.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problem with PITR recovery
Next
From: Simon Riggs
Date:
Subject: Re: Problem with PITR recovery