1 /*-------------------------------------------------------------------------
4 * Definitions for the Postgres function manager and function-call
7 * This file must be included by all Postgres modules that either define
8 * or call fmgr-callable functions.
11 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
14 * $PostgreSQL: pgsql/src/include/fmgr.h,v 1.55 2007/09/27 21:01:59 tgl Exp $
16 *-------------------------------------------------------------------------
21 /* We don't want to include primnodes.h here, so make a stub reference */
22 typedef struct Node *fmNodePtr;
24 /* Likewise, avoid including stringinfo.h here */
25 typedef struct StringInfoData *fmStringInfo;
29 * All functions that can be called directly by fmgr must have this signature.
30 * (Other functions can be called by using a handler that does have this
34 typedef struct FunctionCallInfoData *FunctionCallInfo;
36 typedef Datum (*PGFunction) (FunctionCallInfo fcinfo);
39 * This struct holds the system-catalog information that must be looked up
40 * before a function can be called through fmgr. If the same function is
41 * to be called multiple times, the lookup need be done only once and the
42 * info struct saved for re-use.
44 typedef struct FmgrInfo
46 PGFunction fn_addr; /* pointer to function or handler to be called */
47 Oid fn_oid; /* OID of function (NOT of handler, if any) */
48 short fn_nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable arg
50 bool fn_strict; /* function is "strict" (NULL in => NULL out) */
51 bool fn_retset; /* function returns a set */
52 void *fn_extra; /* extra space for use by handler */
53 MemoryContext fn_mcxt; /* memory context to store fn_extra in */
54 fmNodePtr fn_expr; /* expression parse tree for call, or NULL */
58 * This struct is the data actually passed to an fmgr-called function.
60 typedef struct FunctionCallInfoData
62 FmgrInfo *flinfo; /* ptr to lookup info used for this call */
63 fmNodePtr context; /* pass info about context of call */
64 fmNodePtr resultinfo; /* pass or return extra info about result */
65 bool isnull; /* function must set true if result is NULL */
66 short nargs; /* # arguments actually passed */
67 Datum arg[FUNC_MAX_ARGS]; /* Arguments passed to function */
68 bool argnull[FUNC_MAX_ARGS]; /* T if arg[i] is actually NULL */
69 } FunctionCallInfoData;
72 * This routine fills a FmgrInfo struct, given the OID
73 * of the function to be called.
75 extern void fmgr_info(Oid functionId, FmgrInfo *finfo);
78 * Same, when the FmgrInfo struct is in a memory context longer-lived than
79 * CurrentMemoryContext. The specified context will be set as fn_mcxt
80 * and used to hold all subsidiary data of finfo.
82 extern void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo,
86 * Copy an FmgrInfo struct
88 extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
89 MemoryContext destcxt);
92 * This macro initializes all the fields of a FunctionCallInfoData except
93 * for the arg[] and argnull[] arrays. Performance testing has shown that
94 * the fastest way to set up argnull[] for small numbers of arguments is to
95 * explicitly set each required element to false, so we don't try to zero
96 * out the argnull[] array in the macro.
98 #define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Context, Resultinfo) \
100 (Fcinfo).flinfo = (Flinfo); \
101 (Fcinfo).context = (Context); \
102 (Fcinfo).resultinfo = (Resultinfo); \
103 (Fcinfo).isnull = false; \
104 (Fcinfo).nargs = (Nargs); \
108 * This macro invokes a function given a filled-in FunctionCallInfoData
109 * struct. The macro result is the returned Datum --- but note that
110 * caller must still check fcinfo->isnull! Also, if function is strict,
111 * it is caller's responsibility to verify that no null arguments are present
114 #define FunctionCallInvoke(fcinfo) ((* (fcinfo)->flinfo->fn_addr) (fcinfo))
117 /*-------------------------------------------------------------------------
118 * Support macros to ease writing fmgr-compatible functions
120 * A C-coded fmgr-compatible function should be declared as
123 * function_name(PG_FUNCTION_ARGS)
128 * It should access its arguments using appropriate PG_GETARG_xxx macros
129 * and should return its result using PG_RETURN_xxx.
131 *-------------------------------------------------------------------------
134 /* Standard parameter list for fmgr-compatible functions */
135 #define PG_FUNCTION_ARGS FunctionCallInfo fcinfo
138 * Get number of arguments passed to function.
140 #define PG_NARGS() (fcinfo->nargs)
143 * If function is not marked "proisstrict" in pg_proc, it must check for
144 * null arguments using this macro. Do not try to GETARG a null argument!
146 #define PG_ARGISNULL(n) (fcinfo->argnull[n])
149 * Support for fetching detoasted copies of toastable datatypes (all of
150 * which are varlena types). pg_detoast_datum() gives you either the input
151 * datum (if not toasted) or a detoasted copy allocated with palloc().
152 * pg_detoast_datum_copy() always gives you a palloc'd copy --- use it
153 * if you need a modifiable copy of the input. Caller is expected to have
154 * checked for null inputs first, if necessary.
156 * pg_detoast_datum_packed() will return packed (1-byte header) datums
157 * unmodified. It will still expand an externally toasted or compressed datum.
158 * The resulting datum can be accessed using VARSIZE_ANY() and VARDATA_ANY()
159 * (beware of multiple evaluations in those macros!)
161 * WARNING: It is only safe to use pg_detoast_datum_packed() and
162 * VARDATA_ANY() if you really don't care about the alignment. Either because
163 * you're working with something like text where the alignment doesn't matter
164 * or because you're not going to access its constituent parts and just use
165 * things like memcpy on it anyways.
167 * Note: it'd be nice if these could be macros, but I see no way to do that
168 * without evaluating the arguments multiple times, which is NOT acceptable.
170 extern struct varlena *pg_detoast_datum(struct varlena * datum);
171 extern struct varlena *pg_detoast_datum_copy(struct varlena * datum);
172 extern struct varlena *pg_detoast_datum_slice(struct varlena * datum,
173 int32 first, int32 count);
174 extern struct varlena *pg_detoast_datum_packed(struct varlena * datum);
176 #define PG_DETOAST_DATUM(datum) \
177 pg_detoast_datum((struct varlena *) DatumGetPointer(datum))
178 #define PG_DETOAST_DATUM_COPY(datum) \
179 pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum))
180 #define PG_DETOAST_DATUM_SLICE(datum,f,c) \
181 pg_detoast_datum_slice((struct varlena *) DatumGetPointer(datum), \
182 (int32) (f), (int32) (c))
183 /* WARNING -- unaligned pointer */
184 #define PG_DETOAST_DATUM_PACKED(datum) \
185 pg_detoast_datum_packed((struct varlena *) DatumGetPointer(datum))
188 * Support for cleaning up detoasted copies of inputs. This must only
189 * be used for pass-by-ref datatypes, and normally would only be used
190 * for toastable types. If the given pointer is different from the
191 * original argument, assume it's a palloc'd detoasted copy, and pfree it.
192 * NOTE: most functions on toastable types do not have to worry about this,
193 * but we currently require that support functions for indexes not leak
196 #define PG_FREE_IF_COPY(ptr,n) \
198 if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
202 /* Macros for fetching arguments of standard types */
204 #define PG_GETARG_DATUM(n) (fcinfo->arg[n])
205 #define PG_GETARG_INT32(n) DatumGetInt32(PG_GETARG_DATUM(n))
206 #define PG_GETARG_UINT32(n) DatumGetUInt32(PG_GETARG_DATUM(n))
207 #define PG_GETARG_INT16(n) DatumGetInt16(PG_GETARG_DATUM(n))
208 #define PG_GETARG_UINT16(n) DatumGetUInt16(PG_GETARG_DATUM(n))
209 #define PG_GETARG_CHAR(n) DatumGetChar(PG_GETARG_DATUM(n))
210 #define PG_GETARG_BOOL(n) DatumGetBool(PG_GETARG_DATUM(n))
211 #define PG_GETARG_OID(n) DatumGetObjectId(PG_GETARG_DATUM(n))
212 #define PG_GETARG_POINTER(n) DatumGetPointer(PG_GETARG_DATUM(n))
213 #define PG_GETARG_CSTRING(n) DatumGetCString(PG_GETARG_DATUM(n))
214 #define PG_GETARG_NAME(n) DatumGetName(PG_GETARG_DATUM(n))
215 /* these macros hide the pass-by-reference-ness of the datatype: */
216 #define PG_GETARG_FLOAT4(n) DatumGetFloat4(PG_GETARG_DATUM(n))
217 #define PG_GETARG_FLOAT8(n) DatumGetFloat8(PG_GETARG_DATUM(n))
218 #define PG_GETARG_INT64(n) DatumGetInt64(PG_GETARG_DATUM(n))
219 /* use this if you want the raw, possibly-toasted input datum: */
220 #define PG_GETARG_RAW_VARLENA_P(n) ((struct varlena *) PG_GETARG_POINTER(n))
221 /* use this if you want the input datum de-toasted: */
222 #define PG_GETARG_VARLENA_P(n) PG_DETOAST_DATUM(PG_GETARG_DATUM(n))
223 /* and this if you can handle 1-byte-header datums: */
224 #define PG_GETARG_VARLENA_PP(n) PG_DETOAST_DATUM_PACKED(PG_GETARG_DATUM(n))
225 /* DatumGetFoo macros for varlena types will typically look like this: */
226 #define DatumGetByteaP(X) ((bytea *) PG_DETOAST_DATUM(X))
227 #define DatumGetByteaPP(X) ((bytea *) PG_DETOAST_DATUM_PACKED(X))
228 #define DatumGetTextP(X) ((text *) PG_DETOAST_DATUM(X))
229 #define DatumGetTextPP(X) ((text *) PG_DETOAST_DATUM_PACKED(X))
230 #define DatumGetBpCharP(X) ((BpChar *) PG_DETOAST_DATUM(X))
231 #define DatumGetBpCharPP(X) ((BpChar *) PG_DETOAST_DATUM_PACKED(X))
232 #define DatumGetVarCharP(X) ((VarChar *) PG_DETOAST_DATUM(X))
233 #define DatumGetVarCharPP(X) ((VarChar *) PG_DETOAST_DATUM_PACKED(X))
234 #define DatumGetHeapTupleHeader(X) ((HeapTupleHeader) PG_DETOAST_DATUM(X))
235 /* And we also offer variants that return an OK-to-write copy */
236 #define DatumGetByteaPCopy(X) ((bytea *) PG_DETOAST_DATUM_COPY(X))
237 #define DatumGetTextPCopy(X) ((text *) PG_DETOAST_DATUM_COPY(X))
238 #define DatumGetBpCharPCopy(X) ((BpChar *) PG_DETOAST_DATUM_COPY(X))
239 #define DatumGetVarCharPCopy(X) ((VarChar *) PG_DETOAST_DATUM_COPY(X))
240 #define DatumGetHeapTupleHeaderCopy(X) ((HeapTupleHeader) PG_DETOAST_DATUM_COPY(X))
241 /* Variants which return n bytes starting at pos. m */
242 #define DatumGetByteaPSlice(X,m,n) ((bytea *) PG_DETOAST_DATUM_SLICE(X,m,n))
243 #define DatumGetTextPSlice(X,m,n) ((text *) PG_DETOAST_DATUM_SLICE(X,m,n))
244 #define DatumGetBpCharPSlice(X,m,n) ((BpChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
245 #define DatumGetVarCharPSlice(X,m,n) ((VarChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
246 /* GETARG macros for varlena types will typically look like this: */
247 #define PG_GETARG_BYTEA_P(n) DatumGetByteaP(PG_GETARG_DATUM(n))
248 #define PG_GETARG_BYTEA_PP(n) DatumGetByteaPP(PG_GETARG_DATUM(n))
249 #define PG_GETARG_TEXT_P(n) DatumGetTextP(PG_GETARG_DATUM(n))
250 #define PG_GETARG_TEXT_PP(n) DatumGetTextPP(PG_GETARG_DATUM(n))
251 #define PG_GETARG_BPCHAR_P(n) DatumGetBpCharP(PG_GETARG_DATUM(n))
252 #define PG_GETARG_BPCHAR_PP(n) DatumGetBpCharPP(PG_GETARG_DATUM(n))
253 #define PG_GETARG_VARCHAR_P(n) DatumGetVarCharP(PG_GETARG_DATUM(n))
254 #define PG_GETARG_VARCHAR_PP(n) DatumGetVarCharPP(PG_GETARG_DATUM(n))
255 #define PG_GETARG_HEAPTUPLEHEADER(n) DatumGetHeapTupleHeader(PG_GETARG_DATUM(n))
256 /* And we also offer variants that return an OK-to-write copy */
257 #define PG_GETARG_BYTEA_P_COPY(n) DatumGetByteaPCopy(PG_GETARG_DATUM(n))
258 #define PG_GETARG_TEXT_P_COPY(n) DatumGetTextPCopy(PG_GETARG_DATUM(n))
259 #define PG_GETARG_BPCHAR_P_COPY(n) DatumGetBpCharPCopy(PG_GETARG_DATUM(n))
260 #define PG_GETARG_VARCHAR_P_COPY(n) DatumGetVarCharPCopy(PG_GETARG_DATUM(n))
261 #define PG_GETARG_HEAPTUPLEHEADER_COPY(n) DatumGetHeapTupleHeaderCopy(PG_GETARG_DATUM(n))
262 /* And a b-byte slice from position a -also OK to write */
263 #define PG_GETARG_BYTEA_P_SLICE(n,a,b) DatumGetByteaPSlice(PG_GETARG_DATUM(n),a,b)
264 #define PG_GETARG_TEXT_P_SLICE(n,a,b) DatumGetTextPSlice(PG_GETARG_DATUM(n),a,b)
265 #define PG_GETARG_BPCHAR_P_SLICE(n,a,b) DatumGetBpCharPSlice(PG_GETARG_DATUM(n),a,b)
266 #define PG_GETARG_VARCHAR_P_SLICE(n,a,b) DatumGetVarCharPSlice(PG_GETARG_DATUM(n),a,b)
268 /* To return a NULL do this: */
269 #define PG_RETURN_NULL() \
270 do { fcinfo->isnull = true; return (Datum) 0; } while (0)
272 /* A few internal functions return void (which is not the same as NULL!) */
273 #define PG_RETURN_VOID() return (Datum) 0
275 /* Macros for returning results of standard types */
277 #define PG_RETURN_DATUM(x) return (x)
278 #define PG_RETURN_INT32(x) return Int32GetDatum(x)
279 #define PG_RETURN_UINT32(x) return UInt32GetDatum(x)
280 #define PG_RETURN_INT16(x) return Int16GetDatum(x)
281 #define PG_RETURN_CHAR(x) return CharGetDatum(x)
282 #define PG_RETURN_BOOL(x) return BoolGetDatum(x)
283 #define PG_RETURN_OID(x) return ObjectIdGetDatum(x)
284 #define PG_RETURN_POINTER(x) return PointerGetDatum(x)
285 #define PG_RETURN_CSTRING(x) return CStringGetDatum(x)
286 #define PG_RETURN_NAME(x) return NameGetDatum(x)
287 /* these macros hide the pass-by-reference-ness of the datatype: */
288 #define PG_RETURN_FLOAT4(x) return Float4GetDatum(x)
289 #define PG_RETURN_FLOAT8(x) return Float8GetDatum(x)
290 #define PG_RETURN_INT64(x) return Int64GetDatum(x)
291 /* RETURN macros for other pass-by-ref types will typically look like this: */
292 #define PG_RETURN_BYTEA_P(x) PG_RETURN_POINTER(x)
293 #define PG_RETURN_TEXT_P(x) PG_RETURN_POINTER(x)
294 #define PG_RETURN_BPCHAR_P(x) PG_RETURN_POINTER(x)
295 #define PG_RETURN_VARCHAR_P(x) PG_RETURN_POINTER(x)
296 #define PG_RETURN_HEAPTUPLEHEADER(x) PG_RETURN_POINTER(x)
299 /*-------------------------------------------------------------------------
300 * Support for detecting call convention of dynamically-loaded functions
302 * Dynamically loaded functions may use either the version-1 ("new style")
303 * or version-0 ("old style") calling convention. Version 1 is the call
304 * convention defined in this header file; version 0 is the old "plain C"
305 * convention. A version-1 function must be accompanied by the macro call
307 * PG_FUNCTION_INFO_V1(function_name);
309 * Note that internal functions do not need this decoration since they are
310 * assumed to be version-1.
312 *-------------------------------------------------------------------------
317 int api_version; /* specifies call convention version number */
318 /* More fields may be added later, for version numbers > 1. */
321 /* Expected signature of an info function */
322 typedef const Pg_finfo_record *(*PGFInfoFunction) (void);
325 * Macro to build an info function associated with the given function name.
326 * Win32 loadable functions usually link with 'dlltool --export-all', but it
327 * doesn't hurt to add PGDLLIMPORT in case they don't.
329 #define PG_FUNCTION_INFO_V1(funcname) \
330 extern PGDLLIMPORT const Pg_finfo_record * CppConcat(pg_finfo_,funcname)(void); \
331 const Pg_finfo_record * \
332 CppConcat(pg_finfo_,funcname) (void) \
334 static const Pg_finfo_record my_finfo = { 1 }; \
337 extern int no_such_variable
340 /*-------------------------------------------------------------------------
341 * Support for verifying backend compatibility of loaded modules
343 * We require dynamically-loaded modules to include the macro call
345 * so that we can check for obvious incompatibility, such as being compiled
346 * for a different major PostgreSQL version.
348 * To compile with versions of PostgreSQL that do not support this,
349 * you may put an #ifdef/#endif test around it. Note that in a multiple-
350 * source-file module, the macro call should only appear once.
352 * The specific items included in the magic block are intended to be ones that
353 * are custom-configurable and especially likely to break dynamically loaded
354 * modules if they were compiled with other values. Also, the length field
355 * can be used to detect definition changes.
356 *-------------------------------------------------------------------------
359 /* Definition of the magic block structure */
362 int len; /* sizeof(this struct) */
363 int version; /* PostgreSQL major version */
364 int funcmaxargs; /* FUNC_MAX_ARGS */
365 int indexmaxkeys; /* INDEX_MAX_KEYS */
366 int namedatalen; /* NAMEDATALEN */
369 /* The actual data block contents */
370 #define PG_MODULE_MAGIC_DATA \
372 sizeof(Pg_magic_struct), \
373 PG_VERSION_NUM / 100, \
380 * Declare the module magic function. It needs to be a function as the dlsym
381 * in the backend is only guaranteed to work on functions, not data
383 typedef const Pg_magic_struct *(*PGModuleMagicFunction) (void);
385 #define PG_MAGIC_FUNCTION_NAME Pg_magic_func
386 #define PG_MAGIC_FUNCTION_NAME_STRING "Pg_magic_func"
388 #define PG_MODULE_MAGIC \
389 extern PGDLLIMPORT const Pg_magic_struct *PG_MAGIC_FUNCTION_NAME(void); \
390 const Pg_magic_struct * \
391 PG_MAGIC_FUNCTION_NAME(void) \
393 static const Pg_magic_struct Pg_magic_data = PG_MODULE_MAGIC_DATA; \
394 return &Pg_magic_data; \
396 extern int no_such_variable
399 /*-------------------------------------------------------------------------
400 * Support routines and macros for callers of fmgr-compatible functions
401 *-------------------------------------------------------------------------
404 /* These are for invocation of a specifically named function with a
405 * directly-computed parameter list. Note that neither arguments nor result
406 * are allowed to be NULL.
408 extern Datum DirectFunctionCall1(PGFunction func, Datum arg1);
409 extern Datum DirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2);
410 extern Datum DirectFunctionCall3(PGFunction func, Datum arg1, Datum arg2,
412 extern Datum DirectFunctionCall4(PGFunction func, Datum arg1, Datum arg2,
413 Datum arg3, Datum arg4);
414 extern Datum DirectFunctionCall5(PGFunction func, Datum arg1, Datum arg2,
415 Datum arg3, Datum arg4, Datum arg5);
416 extern Datum DirectFunctionCall6(PGFunction func, Datum arg1, Datum arg2,
417 Datum arg3, Datum arg4, Datum arg5,
419 extern Datum DirectFunctionCall7(PGFunction func, Datum arg1, Datum arg2,
420 Datum arg3, Datum arg4, Datum arg5,
421 Datum arg6, Datum arg7);
422 extern Datum DirectFunctionCall8(PGFunction func, Datum arg1, Datum arg2,
423 Datum arg3, Datum arg4, Datum arg5,
424 Datum arg6, Datum arg7, Datum arg8);
425 extern Datum DirectFunctionCall9(PGFunction func, Datum arg1, Datum arg2,
426 Datum arg3, Datum arg4, Datum arg5,
427 Datum arg6, Datum arg7, Datum arg8,
430 /* These are for invocation of a previously-looked-up function with a
431 * directly-computed parameter list. Note that neither arguments nor result
432 * are allowed to be NULL.
434 extern Datum FunctionCall1(FmgrInfo *flinfo, Datum arg1);
435 extern Datum FunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2);
436 extern Datum FunctionCall3(FmgrInfo *flinfo, Datum arg1, Datum arg2,
438 extern Datum FunctionCall4(FmgrInfo *flinfo, Datum arg1, Datum arg2,
439 Datum arg3, Datum arg4);
440 extern Datum FunctionCall5(FmgrInfo *flinfo, Datum arg1, Datum arg2,
441 Datum arg3, Datum arg4, Datum arg5);
442 extern Datum FunctionCall6(FmgrInfo *flinfo, Datum arg1, Datum arg2,
443 Datum arg3, Datum arg4, Datum arg5,
445 extern Datum FunctionCall7(FmgrInfo *flinfo, Datum arg1, Datum arg2,
446 Datum arg3, Datum arg4, Datum arg5,
447 Datum arg6, Datum arg7);
448 extern Datum FunctionCall8(FmgrInfo *flinfo, Datum arg1, Datum arg2,
449 Datum arg3, Datum arg4, Datum arg5,
450 Datum arg6, Datum arg7, Datum arg8);
451 extern Datum FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2,
452 Datum arg3, Datum arg4, Datum arg5,
453 Datum arg6, Datum arg7, Datum arg8,
456 /* These are for invocation of a function identified by OID with a
457 * directly-computed parameter list. Note that neither arguments nor result
458 * are allowed to be NULL. These are essentially FunctionLookup() followed
459 * by FunctionCallN(). If the same function is to be invoked repeatedly,
460 * do the FunctionLookup() once and then use FunctionCallN().
462 extern Datum OidFunctionCall1(Oid functionId, Datum arg1);
463 extern Datum OidFunctionCall2(Oid functionId, Datum arg1, Datum arg2);
464 extern Datum OidFunctionCall3(Oid functionId, Datum arg1, Datum arg2,
466 extern Datum OidFunctionCall4(Oid functionId, Datum arg1, Datum arg2,
467 Datum arg3, Datum arg4);
468 extern Datum OidFunctionCall5(Oid functionId, Datum arg1, Datum arg2,
469 Datum arg3, Datum arg4, Datum arg5);
470 extern Datum OidFunctionCall6(Oid functionId, Datum arg1, Datum arg2,
471 Datum arg3, Datum arg4, Datum arg5,
473 extern Datum OidFunctionCall7(Oid functionId, Datum arg1, Datum arg2,
474 Datum arg3, Datum arg4, Datum arg5,
475 Datum arg6, Datum arg7);
476 extern Datum OidFunctionCall8(Oid functionId, Datum arg1, Datum arg2,
477 Datum arg3, Datum arg4, Datum arg5,
478 Datum arg6, Datum arg7, Datum arg8);
479 extern Datum OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2,
480 Datum arg3, Datum arg4, Datum arg5,
481 Datum arg6, Datum arg7, Datum arg8,
484 /* Special cases for convenient invocation of datatype I/O functions. */
485 extern Datum InputFunctionCall(FmgrInfo *flinfo, char *str,
486 Oid typioparam, int32 typmod);
487 extern Datum OidInputFunctionCall(Oid functionId, char *str,
488 Oid typioparam, int32 typmod);
489 extern char *OutputFunctionCall(FmgrInfo *flinfo, Datum val);
490 extern char *OidOutputFunctionCall(Oid functionId, Datum val);
491 extern Datum ReceiveFunctionCall(FmgrInfo *flinfo, fmStringInfo buf,
492 Oid typioparam, int32 typmod);
493 extern Datum OidReceiveFunctionCall(Oid functionId, fmStringInfo buf,
494 Oid typioparam, int32 typmod);
495 extern bytea *SendFunctionCall(FmgrInfo *flinfo, Datum val);
496 extern bytea *OidSendFunctionCall(Oid functionId, Datum val);
502 extern const Pg_finfo_record *fetch_finfo_record(void *filehandle, char *funcname);
503 extern void clear_external_function_hash(void *filehandle);
504 extern Oid fmgr_internal_function(const char *proname);
505 extern Oid get_fn_expr_rettype(FmgrInfo *flinfo);
506 extern Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum);
507 extern Oid get_call_expr_argtype(fmNodePtr expr, int argnum);
510 * Routines in dfmgr.c
512 extern char *Dynamic_library_path;
514 extern PGFunction load_external_function(char *filename, char *funcname,
515 bool signalNotFound, void **filehandle);
516 extern PGFunction lookup_external_function(void *filehandle, char *funcname);
517 extern void load_file(const char *filename, bool restricted);
518 extern void **find_rendezvous_variable(const char *varName);
522 * !!! OLD INTERFACE !!!
524 * fmgr() is the only remaining vestige of the old-style caller support
525 * functions. It's no longer used anywhere in the Postgres distribution,
526 * but we should leave it around for a release or two to ease the transition
527 * for user-supplied C functions. OidFunctionCallN() replaces it for new
532 * DEPRECATED, DO NOT USE IN NEW CODE
534 extern char *fmgr(Oid procedureId,...);