From: | Olivier Thauvin <olivier(dot)thauvin(at)aerov(dot)jussieu(dot)fr> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | SETOF function call |
Date: | 2005-04-19 00:13:17 |
Message-ID: | 200504190213.20273.olivier.thauvin@aerov.jussieu.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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' LANGUAGE C 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 accepting integer 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2005-04-19 00:25:28 | Re: Problem with PITR recovery |
Previous Message | Tom Lane | 2005-04-19 00:00:57 | Re: [WIP] shared locks |