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.
pgpxj13r7pyer.pgp
Description: PGP signature