When PostgreSQL calls a C function I get all kinds of interesting
information in the
        struct FunctionCallInfoData
and
        struct FmgrInfo
(details at bottom).  I was hoping to get the oid of the expected
return type somewhere, but I don't see it.  Am I missing something?
I'm trying to avoid the overhead of looking up the function in the
pgproc table while handling it.

(In case you were wondering, I'm trying to handle a large family
of similar types with a single set of C functions for their input
and output methods.)

Thanks,

_Greg

Excerpt from server/fmgr.h:

typedef struct FmgrInfo {
 PGFunction fn_addr; /* pointer to function or handler to be called */
 Oid fn_oid;    /* OID of function (NOT of handler, if any) */
 short fn_nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable arg count */
 bool fn_strict;        /* function is "strict" (NULL in => NULL out) */
 bool fn_retset;        /* function returns a set */
 unsigned char fn_stats; /* collect stats if track_functions > this */
 void *fn_extra;        /* extra space for use by handler */
 MemoryContext fn_mcxt; /* memory context to store fn_extra in */
 fmNodePtr fn_expr;     /* expression parse tree for call, or NULL */
} FmgrInfo;

/*
 * This struct is the data actually passed to an fmgr-called function.
 */
typedef struct FunctionCallInfoData {
 FmgrInfo   *flinfo;    /* ptr to lookup info used for this call */
 fmNodePtr context;     /* pass info about context of call */
 fmNodePtr resultinfo;  /* pass or return extra info about result */
 bool isnull;           /* function must set true if result is NULL */
 short nargs;           /* # arguments actually passed */
 Datum arg[FUNC_MAX_ARGS];      /* Arguments passed to function */
 bool argnull[FUNC_MAX_ARGS]; /* T if arg[i] is actually NULL */
} FunctionCallInfoData

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to