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-2008, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
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 unsigned char fn_stats
; /* collect stats if track_functions > this */
53 void *fn_extra
; /* extra space for use by handler */
54 MemoryContext fn_mcxt
; /* memory context to store fn_extra in */
55 fmNodePtr fn_expr
; /* expression parse tree for call, or NULL */
59 * This struct is the data actually passed to an fmgr-called function.
61 typedef struct FunctionCallInfoData
63 FmgrInfo
*flinfo
; /* ptr to lookup info used for this call */
64 fmNodePtr context
; /* pass info about context of call */
65 fmNodePtr resultinfo
; /* pass or return extra info about result */
66 bool isnull
; /* function must set true if result is NULL */
67 short nargs
; /* # arguments actually passed */
68 Datum arg
[FUNC_MAX_ARGS
]; /* Arguments passed to function */
69 bool argnull
[FUNC_MAX_ARGS
]; /* T if arg[i] is actually NULL */
70 } FunctionCallInfoData
;
73 * This routine fills a FmgrInfo struct, given the OID
74 * of the function to be called.
76 extern void fmgr_info(Oid functionId
, FmgrInfo
*finfo
);
79 * Same, when the FmgrInfo struct is in a memory context longer-lived than
80 * CurrentMemoryContext. The specified context will be set as fn_mcxt
81 * and used to hold all subsidiary data of finfo.
83 extern void fmgr_info_cxt(Oid functionId
, FmgrInfo
*finfo
,
87 * Copy an FmgrInfo struct
89 extern void fmgr_info_copy(FmgrInfo
*dstinfo
, FmgrInfo
*srcinfo
,
90 MemoryContext destcxt
);
93 * This macro initializes all the fields of a FunctionCallInfoData except
94 * for the arg[] and argnull[] arrays. Performance testing has shown that
95 * the fastest way to set up argnull[] for small numbers of arguments is to
96 * explicitly set each required element to false, so we don't try to zero
97 * out the argnull[] array in the macro.
99 #define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Context, Resultinfo) \
101 (Fcinfo).flinfo = (Flinfo); \
102 (Fcinfo).context = (Context); \
103 (Fcinfo).resultinfo = (Resultinfo); \
104 (Fcinfo).isnull = false; \
105 (Fcinfo).nargs = (Nargs); \
109 * This macro invokes a function given a filled-in FunctionCallInfoData
110 * struct. The macro result is the returned Datum --- but note that
111 * caller must still check fcinfo->isnull! Also, if function is strict,
112 * it is caller's responsibility to verify that no null arguments are present
115 #define FunctionCallInvoke(fcinfo) ((* (fcinfo)->flinfo->fn_addr) (fcinfo))
118 /*-------------------------------------------------------------------------
119 * Support macros to ease writing fmgr-compatible functions
121 * A C-coded fmgr-compatible function should be declared as
124 * function_name(PG_FUNCTION_ARGS)
129 * It should access its arguments using appropriate PG_GETARG_xxx macros
130 * and should return its result using PG_RETURN_xxx.
132 *-------------------------------------------------------------------------
135 /* Standard parameter list for fmgr-compatible functions */
136 #define PG_FUNCTION_ARGS FunctionCallInfo fcinfo
139 * Get number of arguments passed to function.
141 #define PG_NARGS() (fcinfo->nargs)
144 * If function is not marked "proisstrict" in pg_proc, it must check for
145 * null arguments using this macro. Do not try to GETARG a null argument!
147 #define PG_ARGISNULL(n) (fcinfo->argnull[n])
150 * Support for fetching detoasted copies of toastable datatypes (all of
151 * which are varlena types). pg_detoast_datum() gives you either the input
152 * datum (if not toasted) or a detoasted copy allocated with palloc().
153 * pg_detoast_datum_copy() always gives you a palloc'd copy --- use it
154 * if you need a modifiable copy of the input. Caller is expected to have
155 * checked for null inputs first, if necessary.
157 * pg_detoast_datum_packed() will return packed (1-byte header) datums
158 * unmodified. It will still expand an externally toasted or compressed datum.
159 * The resulting datum can be accessed using VARSIZE_ANY() and VARDATA_ANY()
160 * (beware of multiple evaluations in those macros!)
162 * WARNING: It is only safe to use pg_detoast_datum_packed() and
163 * VARDATA_ANY() if you really don't care about the alignment. Either because
164 * you're working with something like text where the alignment doesn't matter
165 * or because you're not going to access its constituent parts and just use
166 * things like memcpy on it anyways.
168 * Note: it'd be nice if these could be macros, but I see no way to do that
169 * without evaluating the arguments multiple times, which is NOT acceptable.
171 extern struct varlena
*pg_detoast_datum(struct varlena
* datum
);
172 extern struct varlena
*pg_detoast_datum_copy(struct varlena
* datum
);
173 extern struct varlena
*pg_detoast_datum_slice(struct varlena
* datum
,
174 int32 first
, int32 count
);
175 extern struct varlena
*pg_detoast_datum_packed(struct varlena
* datum
);
177 #define PG_DETOAST_DATUM(datum) \
178 pg_detoast_datum((struct varlena *) DatumGetPointer(datum))
179 #define PG_DETOAST_DATUM_COPY(datum) \
180 pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum))
181 #define PG_DETOAST_DATUM_SLICE(datum,f,c) \
182 pg_detoast_datum_slice((struct varlena *) DatumGetPointer(datum), \
183 (int32) (f), (int32) (c))
184 /* WARNING -- unaligned pointer */
185 #define PG_DETOAST_DATUM_PACKED(datum) \
186 pg_detoast_datum_packed((struct varlena *) DatumGetPointer(datum))
189 * Support for cleaning up detoasted copies of inputs. This must only
190 * be used for pass-by-ref datatypes, and normally would only be used
191 * for toastable types. If the given pointer is different from the
192 * original argument, assume it's a palloc'd detoasted copy, and pfree it.
193 * NOTE: most functions on toastable types do not have to worry about this,
194 * but we currently require that support functions for indexes not leak
197 #define PG_FREE_IF_COPY(ptr,n) \
199 if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
203 /* Macros for fetching arguments of standard types */
205 #define PG_GETARG_DATUM(n) (fcinfo->arg[n])
206 #define PG_GETARG_INT32(n) DatumGetInt32(PG_GETARG_DATUM(n))
207 #define PG_GETARG_UINT32(n) DatumGetUInt32(PG_GETARG_DATUM(n))
208 #define PG_GETARG_INT16(n) DatumGetInt16(PG_GETARG_DATUM(n))
209 #define PG_GETARG_UINT16(n) DatumGetUInt16(PG_GETARG_DATUM(n))
210 #define PG_GETARG_CHAR(n) DatumGetChar(PG_GETARG_DATUM(n))
211 #define PG_GETARG_BOOL(n) DatumGetBool(PG_GETARG_DATUM(n))
212 #define PG_GETARG_OID(n) DatumGetObjectId(PG_GETARG_DATUM(n))
213 #define PG_GETARG_POINTER(n) DatumGetPointer(PG_GETARG_DATUM(n))
214 #define PG_GETARG_CSTRING(n) DatumGetCString(PG_GETARG_DATUM(n))
215 #define PG_GETARG_NAME(n) DatumGetName(PG_GETARG_DATUM(n))
216 /* these macros hide the pass-by-reference-ness of the datatype: */
217 #define PG_GETARG_FLOAT4(n) DatumGetFloat4(PG_GETARG_DATUM(n))
218 #define PG_GETARG_FLOAT8(n) DatumGetFloat8(PG_GETARG_DATUM(n))
219 #define PG_GETARG_INT64(n) DatumGetInt64(PG_GETARG_DATUM(n))
220 /* use this if you want the raw, possibly-toasted input datum: */
221 #define PG_GETARG_RAW_VARLENA_P(n) ((struct varlena *) PG_GETARG_POINTER(n))
222 /* use this if you want the input datum de-toasted: */
223 #define PG_GETARG_VARLENA_P(n) PG_DETOAST_DATUM(PG_GETARG_DATUM(n))
224 /* and this if you can handle 1-byte-header datums: */
225 #define PG_GETARG_VARLENA_PP(n) PG_DETOAST_DATUM_PACKED(PG_GETARG_DATUM(n))
226 /* DatumGetFoo macros for varlena types will typically look like this: */
227 #define DatumGetByteaP(X) ((bytea *) PG_DETOAST_DATUM(X))
228 #define DatumGetByteaPP(X) ((bytea *) PG_DETOAST_DATUM_PACKED(X))
229 #define DatumGetTextP(X) ((text *) PG_DETOAST_DATUM(X))
230 #define DatumGetTextPP(X) ((text *) PG_DETOAST_DATUM_PACKED(X))
231 #define DatumGetBpCharP(X) ((BpChar *) PG_DETOAST_DATUM(X))
232 #define DatumGetBpCharPP(X) ((BpChar *) PG_DETOAST_DATUM_PACKED(X))
233 #define DatumGetVarCharP(X) ((VarChar *) PG_DETOAST_DATUM(X))
234 #define DatumGetVarCharPP(X) ((VarChar *) PG_DETOAST_DATUM_PACKED(X))
235 #define DatumGetHeapTupleHeader(X) ((HeapTupleHeader) PG_DETOAST_DATUM(X))
236 /* And we also offer variants that return an OK-to-write copy */
237 #define DatumGetByteaPCopy(X) ((bytea *) PG_DETOAST_DATUM_COPY(X))
238 #define DatumGetTextPCopy(X) ((text *) PG_DETOAST_DATUM_COPY(X))
239 #define DatumGetBpCharPCopy(X) ((BpChar *) PG_DETOAST_DATUM_COPY(X))
240 #define DatumGetVarCharPCopy(X) ((VarChar *) PG_DETOAST_DATUM_COPY(X))
241 #define DatumGetHeapTupleHeaderCopy(X) ((HeapTupleHeader) PG_DETOAST_DATUM_COPY(X))
242 /* Variants which return n bytes starting at pos. m */
243 #define DatumGetByteaPSlice(X,m,n) ((bytea *) PG_DETOAST_DATUM_SLICE(X,m,n))
244 #define DatumGetTextPSlice(X,m,n) ((text *) PG_DETOAST_DATUM_SLICE(X,m,n))
245 #define DatumGetBpCharPSlice(X,m,n) ((BpChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
246 #define DatumGetVarCharPSlice(X,m,n) ((VarChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
247 /* GETARG macros for varlena types will typically look like this: */
248 #define PG_GETARG_BYTEA_P(n) DatumGetByteaP(PG_GETARG_DATUM(n))
249 #define PG_GETARG_BYTEA_PP(n) DatumGetByteaPP(PG_GETARG_DATUM(n))
250 #define PG_GETARG_TEXT_P(n) DatumGetTextP(PG_GETARG_DATUM(n))
251 #define PG_GETARG_TEXT_PP(n) DatumGetTextPP(PG_GETARG_DATUM(n))
252 #define PG_GETARG_BPCHAR_P(n) DatumGetBpCharP(PG_GETARG_DATUM(n))
253 #define PG_GETARG_BPCHAR_PP(n) DatumGetBpCharPP(PG_GETARG_DATUM(n))
254 #define PG_GETARG_VARCHAR_P(n) DatumGetVarCharP(PG_GETARG_DATUM(n))
255 #define PG_GETARG_VARCHAR_PP(n) DatumGetVarCharPP(PG_GETARG_DATUM(n))
256 #define PG_GETARG_HEAPTUPLEHEADER(n) DatumGetHeapTupleHeader(PG_GETARG_DATUM(n))
257 /* And we also offer variants that return an OK-to-write copy */
258 #define PG_GETARG_BYTEA_P_COPY(n) DatumGetByteaPCopy(PG_GETARG_DATUM(n))
259 #define PG_GETARG_TEXT_P_COPY(n) DatumGetTextPCopy(PG_GETARG_DATUM(n))
260 #define PG_GETARG_BPCHAR_P_COPY(n) DatumGetBpCharPCopy(PG_GETARG_DATUM(n))
261 #define PG_GETARG_VARCHAR_P_COPY(n) DatumGetVarCharPCopy(PG_GETARG_DATUM(n))
262 #define PG_GETARG_HEAPTUPLEHEADER_COPY(n) DatumGetHeapTupleHeaderCopy(PG_GETARG_DATUM(n))
263 /* And a b-byte slice from position a -also OK to write */
264 #define PG_GETARG_BYTEA_P_SLICE(n,a,b) DatumGetByteaPSlice(PG_GETARG_DATUM(n),a,b)
265 #define PG_GETARG_TEXT_P_SLICE(n,a,b) DatumGetTextPSlice(PG_GETARG_DATUM(n),a,b)
266 #define PG_GETARG_BPCHAR_P_SLICE(n,a,b) DatumGetBpCharPSlice(PG_GETARG_DATUM(n),a,b)
267 #define PG_GETARG_VARCHAR_P_SLICE(n,a,b) DatumGetVarCharPSlice(PG_GETARG_DATUM(n),a,b)
269 /* To return a NULL do this: */
270 #define PG_RETURN_NULL() \
271 do { fcinfo->isnull = true; return (Datum) 0; } while (0)
273 /* A few internal functions return void (which is not the same as NULL!) */
274 #define PG_RETURN_VOID() return (Datum) 0
276 /* Macros for returning results of standard types */
278 #define PG_RETURN_DATUM(x) return (x)
279 #define PG_RETURN_INT32(x) return Int32GetDatum(x)
280 #define PG_RETURN_UINT32(x) return UInt32GetDatum(x)
281 #define PG_RETURN_INT16(x) return Int16GetDatum(x)
282 #define PG_RETURN_CHAR(x) return CharGetDatum(x)
283 #define PG_RETURN_BOOL(x) return BoolGetDatum(x)
284 #define PG_RETURN_OID(x) return ObjectIdGetDatum(x)
285 #define PG_RETURN_POINTER(x) return PointerGetDatum(x)
286 #define PG_RETURN_CSTRING(x) return CStringGetDatum(x)
287 #define PG_RETURN_NAME(x) return NameGetDatum(x)
288 /* these macros hide the pass-by-reference-ness of the datatype: */
289 #define PG_RETURN_FLOAT4(x) return Float4GetDatum(x)
290 #define PG_RETURN_FLOAT8(x) return Float8GetDatum(x)
291 #define PG_RETURN_INT64(x) return Int64GetDatum(x)
292 /* RETURN macros for other pass-by-ref types will typically look like this: */
293 #define PG_RETURN_BYTEA_P(x) PG_RETURN_POINTER(x)
294 #define PG_RETURN_TEXT_P(x) PG_RETURN_POINTER(x)
295 #define PG_RETURN_BPCHAR_P(x) PG_RETURN_POINTER(x)
296 #define PG_RETURN_VARCHAR_P(x) PG_RETURN_POINTER(x)
297 #define PG_RETURN_HEAPTUPLEHEADER(x) PG_RETURN_POINTER(x)
300 /*-------------------------------------------------------------------------
301 * Support for detecting call convention of dynamically-loaded functions
303 * Dynamically loaded functions may use either the version-1 ("new style")
304 * or version-0 ("old style") calling convention. Version 1 is the call
305 * convention defined in this header file; version 0 is the old "plain C"
306 * convention. A version-1 function must be accompanied by the macro call
308 * PG_FUNCTION_INFO_V1(function_name);
310 * Note that internal functions do not need this decoration since they are
311 * assumed to be version-1.
313 *-------------------------------------------------------------------------
318 int api_version
; /* specifies call convention version number */
319 /* More fields may be added later, for version numbers > 1. */
322 /* Expected signature of an info function */
323 typedef const Pg_finfo_record
*(*PGFInfoFunction
) (void);
326 * Macro to build an info function associated with the given function name.
327 * Win32 loadable functions usually link with 'dlltool --export-all', but it
328 * doesn't hurt to add PGDLLIMPORT in case they don't.
330 #define PG_FUNCTION_INFO_V1(funcname) \
331 extern PGDLLIMPORT const Pg_finfo_record * CppConcat(pg_finfo_,funcname)(void); \
332 const Pg_finfo_record * \
333 CppConcat(pg_finfo_,funcname) (void) \
335 static const Pg_finfo_record my_finfo = { 1 }; \
338 extern int no_such_variable
341 /*-------------------------------------------------------------------------
342 * Support for verifying backend compatibility of loaded modules
344 * We require dynamically-loaded modules to include the macro call
346 * so that we can check for obvious incompatibility, such as being compiled
347 * for a different major PostgreSQL version.
349 * To compile with versions of PostgreSQL that do not support this,
350 * you may put an #ifdef/#endif test around it. Note that in a multiple-
351 * source-file module, the macro call should only appear once.
353 * The specific items included in the magic block are intended to be ones that
354 * are custom-configurable and especially likely to break dynamically loaded
355 * modules if they were compiled with other values. Also, the length field
356 * can be used to detect definition changes.
358 * Note: we compare magic blocks with memcmp(), so there had better not be
359 * any alignment pad bytes in them.
361 * Note: when changing the contents of magic blocks, be sure to adjust the
362 * incompatible_module_error() function in dfmgr.c.
363 *-------------------------------------------------------------------------
366 /* Definition of the magic block structure */
369 int len
; /* sizeof(this struct) */
370 int version
; /* PostgreSQL major version */
371 int funcmaxargs
; /* FUNC_MAX_ARGS */
372 int indexmaxkeys
; /* INDEX_MAX_KEYS */
373 int namedatalen
; /* NAMEDATALEN */
374 int float4byval
; /* FLOAT4PASSBYVAL */
375 int float8byval
; /* FLOAT8PASSBYVAL */
378 /* The actual data block contents */
379 #define PG_MODULE_MAGIC_DATA \
381 sizeof(Pg_magic_struct), \
382 PG_VERSION_NUM / 100, \
391 * Declare the module magic function. It needs to be a function as the dlsym
392 * in the backend is only guaranteed to work on functions, not data
394 typedef const Pg_magic_struct
*(*PGModuleMagicFunction
) (void);
396 #define PG_MAGIC_FUNCTION_NAME Pg_magic_func
397 #define PG_MAGIC_FUNCTION_NAME_STRING "Pg_magic_func"
399 #define PG_MODULE_MAGIC \
400 extern PGDLLIMPORT const Pg_magic_struct *PG_MAGIC_FUNCTION_NAME(void); \
401 const Pg_magic_struct * \
402 PG_MAGIC_FUNCTION_NAME(void) \
404 static const Pg_magic_struct Pg_magic_data = PG_MODULE_MAGIC_DATA; \
405 return &Pg_magic_data; \
407 extern int no_such_variable
410 /*-------------------------------------------------------------------------
411 * Support routines and macros for callers of fmgr-compatible functions
412 *-------------------------------------------------------------------------
415 /* These are for invocation of a specifically named function with a
416 * directly-computed parameter list. Note that neither arguments nor result
417 * are allowed to be NULL.
419 extern Datum
DirectFunctionCall1(PGFunction func
, Datum arg1
);
420 extern Datum
DirectFunctionCall2(PGFunction func
, Datum arg1
, Datum arg2
);
421 extern Datum
DirectFunctionCall3(PGFunction func
, Datum arg1
, Datum arg2
,
423 extern Datum
DirectFunctionCall4(PGFunction func
, Datum arg1
, Datum arg2
,
424 Datum arg3
, Datum arg4
);
425 extern Datum
DirectFunctionCall5(PGFunction func
, Datum arg1
, Datum arg2
,
426 Datum arg3
, Datum arg4
, Datum arg5
);
427 extern Datum
DirectFunctionCall6(PGFunction func
, Datum arg1
, Datum arg2
,
428 Datum arg3
, Datum arg4
, Datum arg5
,
430 extern Datum
DirectFunctionCall7(PGFunction func
, Datum arg1
, Datum arg2
,
431 Datum arg3
, Datum arg4
, Datum arg5
,
432 Datum arg6
, Datum arg7
);
433 extern Datum
DirectFunctionCall8(PGFunction func
, Datum arg1
, Datum arg2
,
434 Datum arg3
, Datum arg4
, Datum arg5
,
435 Datum arg6
, Datum arg7
, Datum arg8
);
436 extern Datum
DirectFunctionCall9(PGFunction func
, Datum arg1
, Datum arg2
,
437 Datum arg3
, Datum arg4
, Datum arg5
,
438 Datum arg6
, Datum arg7
, Datum arg8
,
441 /* These are for invocation of a previously-looked-up function with a
442 * directly-computed parameter list. Note that neither arguments nor result
443 * are allowed to be NULL.
445 extern Datum
FunctionCall1(FmgrInfo
*flinfo
, Datum arg1
);
446 extern Datum
FunctionCall2(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
);
447 extern Datum
FunctionCall3(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
449 extern Datum
FunctionCall4(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
450 Datum arg3
, Datum arg4
);
451 extern Datum
FunctionCall5(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
452 Datum arg3
, Datum arg4
, Datum arg5
);
453 extern Datum
FunctionCall6(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
454 Datum arg3
, Datum arg4
, Datum arg5
,
456 extern Datum
FunctionCall7(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
457 Datum arg3
, Datum arg4
, Datum arg5
,
458 Datum arg6
, Datum arg7
);
459 extern Datum
FunctionCall8(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
460 Datum arg3
, Datum arg4
, Datum arg5
,
461 Datum arg6
, Datum arg7
, Datum arg8
);
462 extern Datum
FunctionCall9(FmgrInfo
*flinfo
, Datum arg1
, Datum arg2
,
463 Datum arg3
, Datum arg4
, Datum arg5
,
464 Datum arg6
, Datum arg7
, Datum arg8
,
467 /* These are for invocation of a function identified by OID with a
468 * directly-computed parameter list. Note that neither arguments nor result
469 * are allowed to be NULL. These are essentially FunctionLookup() followed
470 * by FunctionCallN(). If the same function is to be invoked repeatedly,
471 * do the FunctionLookup() once and then use FunctionCallN().
473 extern Datum
OidFunctionCall1(Oid functionId
, Datum arg1
);
474 extern Datum
OidFunctionCall2(Oid functionId
, Datum arg1
, Datum arg2
);
475 extern Datum
OidFunctionCall3(Oid functionId
, Datum arg1
, Datum arg2
,
477 extern Datum
OidFunctionCall4(Oid functionId
, Datum arg1
, Datum arg2
,
478 Datum arg3
, Datum arg4
);
479 extern Datum
OidFunctionCall5(Oid functionId
, Datum arg1
, Datum arg2
,
480 Datum arg3
, Datum arg4
, Datum arg5
);
481 extern Datum
OidFunctionCall6(Oid functionId
, Datum arg1
, Datum arg2
,
482 Datum arg3
, Datum arg4
, Datum arg5
,
484 extern Datum
OidFunctionCall7(Oid functionId
, Datum arg1
, Datum arg2
,
485 Datum arg3
, Datum arg4
, Datum arg5
,
486 Datum arg6
, Datum arg7
);
487 extern Datum
OidFunctionCall8(Oid functionId
, Datum arg1
, Datum arg2
,
488 Datum arg3
, Datum arg4
, Datum arg5
,
489 Datum arg6
, Datum arg7
, Datum arg8
);
490 extern Datum
OidFunctionCall9(Oid functionId
, Datum arg1
, Datum arg2
,
491 Datum arg3
, Datum arg4
, Datum arg5
,
492 Datum arg6
, Datum arg7
, Datum arg8
,
495 /* Special cases for convenient invocation of datatype I/O functions. */
496 extern Datum
InputFunctionCall(FmgrInfo
*flinfo
, char *str
,
497 Oid typioparam
, int32 typmod
);
498 extern Datum
OidInputFunctionCall(Oid functionId
, char *str
,
499 Oid typioparam
, int32 typmod
);
500 extern char *OutputFunctionCall(FmgrInfo
*flinfo
, Datum val
);
501 extern char *OidOutputFunctionCall(Oid functionId
, Datum val
);
502 extern Datum
ReceiveFunctionCall(FmgrInfo
*flinfo
, fmStringInfo buf
,
503 Oid typioparam
, int32 typmod
);
504 extern Datum
OidReceiveFunctionCall(Oid functionId
, fmStringInfo buf
,
505 Oid typioparam
, int32 typmod
);
506 extern bytea
*SendFunctionCall(FmgrInfo
*flinfo
, Datum val
);
507 extern bytea
*OidSendFunctionCall(Oid functionId
, Datum val
);
513 extern const Pg_finfo_record
*fetch_finfo_record(void *filehandle
, char *funcname
);
514 extern void clear_external_function_hash(void *filehandle
);
515 extern Oid
fmgr_internal_function(const char *proname
);
516 extern Oid
get_fn_expr_rettype(FmgrInfo
*flinfo
);
517 extern Oid
get_fn_expr_argtype(FmgrInfo
*flinfo
, int argnum
);
518 extern Oid
get_call_expr_argtype(fmNodePtr expr
, int argnum
);
521 * Routines in dfmgr.c
523 extern char *Dynamic_library_path
;
525 extern PGFunction
load_external_function(char *filename
, char *funcname
,
526 bool signalNotFound
, void **filehandle
);
527 extern PGFunction
lookup_external_function(void *filehandle
, char *funcname
);
528 extern void load_file(const char *filename
, bool restricted
);
529 extern void **find_rendezvous_variable(const char *varName
);
533 * !!! OLD INTERFACE !!!
535 * fmgr() is the only remaining vestige of the old-style caller support
536 * functions. It's no longer used anywhere in the Postgres distribution,
537 * but we should leave it around for a release or two to ease the transition
538 * for user-supplied C functions. OidFunctionCallN() replaces it for new
543 * DEPRECATED, DO NOT USE IN NEW CODE
545 extern char *fmgr(Oid procedureId
,...);