Hi hackers, I am trying to design a new "pg_get_functiondef" function extension, like this:
CREATE FUNCTION pg_get_functiondef(OID, VARIADIC OID[]) RETURNS TABLE (OID oid, pg_get_functiondef text) AS 'pg_get_functiondef', 'pg_get_functiondef_mul' LANGUAGE C; And I have read the <C-Language Functions>, learn the way to build the tuple (use BlessTupleDesc or BuildTupleFromCStrings) to return the Composite Types, but when I finish my work, its performance does not meet my expectations, like this: pg_get_functiondef ---------------------------------------------------------------------- (1400,"CREATE OR REPLACE FUNCTION pg_catalog.name(character varying)+ RETURNS name + LANGUAGE internal + IMMUTABLE PARALLEL SAFE STRICT LEAKPROOF + AS $function$text_name$function$ + ") (1400,"CREATE OR REPLACE FUNCTION pg_catalog.name(character varying)+ RETURNS name + LANGUAGE internal + IMMUTABLE PARALLEL SAFE STRICT LEAKPROOF + AS $function$text_name$function$ + ") In my expectations, it should be: postgres=# SELECT 1400 AS oid, 'CREATE OR REPLACE FUNCTION pg_catalog.name(character varying)+ RETURNS name + LANGUAGE internal + IMMUTABLE PARALLEL SAFE STRICT LEAKPROOF + AS $function$text_name$function' AS pg_get_functiondef; oid | pg_get_functiondef ------+------------------------------------------------------------------------ 1400 | CREATE OR REPLACE FUNCTION pg_catalog.name(character varying)+ + | RETURNS name ++ | LANGUAGE internal ++ | IMMUTABLE PARALLEL SAFE STRICT LEAKPROOF ++ | AS $function$text_name$function (1 row) Because I write: TupleDescInitEntry(info->result_desc, 1, "OID", OIDOID, -1, 0); TupleDescInitEntry(info->result_desc, 2, "pg_get_functiondef", CSTRINGOID, -1, 0); Can someone give my some advice? Thanks in advance! Yours, Wen Yi