fmgr.h

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· C头文件 代码 · 共 512 行 · 第 1/2 页

H
512
字号
#define PG_RETURN_BOOL(x)	 return BoolGetDatum(x)#define PG_RETURN_OID(x)	 return ObjectIdGetDatum(x)#define PG_RETURN_POINTER(x) return PointerGetDatum(x)#define PG_RETURN_CSTRING(x) return CStringGetDatum(x)#define PG_RETURN_NAME(x)	 return NameGetDatum(x)/* these macros hide the pass-by-reference-ness of the datatype: */#define PG_RETURN_FLOAT4(x)  return Float4GetDatum(x)#define PG_RETURN_FLOAT8(x)  return Float8GetDatum(x)#define PG_RETURN_INT64(x)	 return Int64GetDatum(x)/* RETURN macros for other pass-by-ref types will typically look like this: */#define PG_RETURN_BYTEA_P(x)   PG_RETURN_POINTER(x)#define PG_RETURN_TEXT_P(x)    PG_RETURN_POINTER(x)#define PG_RETURN_BPCHAR_P(x)  PG_RETURN_POINTER(x)#define PG_RETURN_VARCHAR_P(x) PG_RETURN_POINTER(x)#define PG_RETURN_HEAPTUPLEHEADER(x)  PG_RETURN_POINTER(x)/*------------------------------------------------------------------------- *		Support for detecting call convention of dynamically-loaded functions * * Dynamically loaded functions may use either the version-1 ("new style") * or version-0 ("old style") calling convention.  Version 1 is the call * convention defined in this header file; version 0 is the old "plain C" * convention.	A version-1 function must be accompanied by the macro call * *		PG_FUNCTION_INFO_V1(function_name); * * Note that internal functions do not need this decoration since they are * assumed to be version-1. * *------------------------------------------------------------------------- */typedef struct{	int			api_version;	/* specifies call convention version number */	/* More fields may be added later, for version numbers > 1. */} Pg_finfo_record;/* Expected signature of an info function */typedef const Pg_finfo_record *(*PGFInfoFunction) (void);/* *	Macro to build an info function associated with the given function name. *	Win32 loadable functions usually link with 'dlltool --export-all', but it *	doesn't hurt to add DLLIMPORT in case they don't. */#define PG_FUNCTION_INFO_V1(funcname) \extern DLLIMPORT const Pg_finfo_record * CppConcat(pg_finfo_,funcname)(void); \const Pg_finfo_record * \CppConcat(pg_finfo_,funcname) (void) \{ \	static const Pg_finfo_record my_finfo = { 1 }; \	return &my_finfo; \} \extern int no_such_variable/*------------------------------------------------------------------------- *		Support for verifying backend compatibility of loaded modules * * We require dynamically-loaded modules to include the macro call *		PG_MODULE_MAGIC; * so that we can check for obvious incompatibility, such as being compiled * for a different major PostgreSQL version. * * To compile with versions of PostgreSQL that do not support this, * you may put an #ifdef/#endif test around it.  Note that in a multiple- * source-file module, the macro call should only appear once. * * The specific items included in the magic block are intended to be ones that * are custom-configurable and especially likely to break dynamically loaded * modules if they were compiled with other values.  Also, the length field * can be used to detect definition changes. *------------------------------------------------------------------------- *//* Definition of the magic block structure */typedef struct{	int			len;			/* sizeof(this struct) */	int			version;		/* PostgreSQL major version */	int			funcmaxargs;	/* FUNC_MAX_ARGS */	int			indexmaxkeys;	/* INDEX_MAX_KEYS */	int			namedatalen;	/* NAMEDATALEN */} Pg_magic_struct;/* The actual data block contents */#define PG_MODULE_MAGIC_DATA \{ \	sizeof(Pg_magic_struct), \	PG_VERSION_NUM / 100, \	FUNC_MAX_ARGS, \	INDEX_MAX_KEYS, \	NAMEDATALEN \}/* * Declare the module magic function.  It needs to be a function as the dlsym * in the backend is only guaranteed to work on functions, not data */typedef const Pg_magic_struct *(*PGModuleMagicFunction) (void);#define PG_MAGIC_FUNCTION_NAME Pg_magic_func#define PG_MAGIC_FUNCTION_NAME_STRING "Pg_magic_func"#define PG_MODULE_MAGIC \extern DLLIMPORT const Pg_magic_struct *PG_MAGIC_FUNCTION_NAME(void); \const Pg_magic_struct * \PG_MAGIC_FUNCTION_NAME(void) \{ \	static const Pg_magic_struct Pg_magic_data = PG_MODULE_MAGIC_DATA; \	return &Pg_magic_data; \} \extern int no_such_variable/*------------------------------------------------------------------------- *		Support routines and macros for callers of fmgr-compatible functions *------------------------------------------------------------------------- *//* These are for invocation of a specifically named function with a * directly-computed parameter list.  Note that neither arguments nor result * are allowed to be NULL. */extern Datum DirectFunctionCall1(PGFunction func, Datum arg1);extern Datum DirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2);extern Datum DirectFunctionCall3(PGFunction func, Datum arg1, Datum arg2,					Datum arg3);extern Datum DirectFunctionCall4(PGFunction func, Datum arg1, Datum arg2,					Datum arg3, Datum arg4);extern Datum DirectFunctionCall5(PGFunction func, Datum arg1, Datum arg2,					Datum arg3, Datum arg4, Datum arg5);extern Datum DirectFunctionCall6(PGFunction func, Datum arg1, Datum arg2,					Datum arg3, Datum arg4, Datum arg5,					Datum arg6);extern Datum DirectFunctionCall7(PGFunction func, Datum arg1, Datum arg2,					Datum arg3, Datum arg4, Datum arg5,					Datum arg6, Datum arg7);extern Datum DirectFunctionCall8(PGFunction func, Datum arg1, Datum arg2,					Datum arg3, Datum arg4, Datum arg5,					Datum arg6, Datum arg7, Datum arg8);extern Datum DirectFunctionCall9(PGFunction func, Datum arg1, Datum arg2,					Datum arg3, Datum arg4, Datum arg5,					Datum arg6, Datum arg7, Datum arg8,					Datum arg9);/* These are for invocation of a previously-looked-up function with a * directly-computed parameter list.  Note that neither arguments nor result * are allowed to be NULL. */extern Datum FunctionCall1(FmgrInfo *flinfo, Datum arg1);extern Datum FunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2);extern Datum FunctionCall3(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3);extern Datum FunctionCall4(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3, Datum arg4);extern Datum FunctionCall5(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3, Datum arg4, Datum arg5);extern Datum FunctionCall6(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3, Datum arg4, Datum arg5,			  Datum arg6);extern Datum FunctionCall7(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3, Datum arg4, Datum arg5,			  Datum arg6, Datum arg7);extern Datum FunctionCall8(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3, Datum arg4, Datum arg5,			  Datum arg6, Datum arg7, Datum arg8);extern Datum FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2,			  Datum arg3, Datum arg4, Datum arg5,			  Datum arg6, Datum arg7, Datum arg8,			  Datum arg9);/* These are for invocation of a function identified by OID with a * directly-computed parameter list.  Note that neither arguments nor result * are allowed to be NULL.	These are essentially FunctionLookup() followed * by FunctionCallN().	If the same function is to be invoked repeatedly, * do the FunctionLookup() once and then use FunctionCallN(). */extern Datum OidFunctionCall1(Oid functionId, Datum arg1);extern Datum OidFunctionCall2(Oid functionId, Datum arg1, Datum arg2);extern Datum OidFunctionCall3(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3);extern Datum OidFunctionCall4(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3, Datum arg4);extern Datum OidFunctionCall5(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3, Datum arg4, Datum arg5);extern Datum OidFunctionCall6(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3, Datum arg4, Datum arg5,				 Datum arg6);extern Datum OidFunctionCall7(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3, Datum arg4, Datum arg5,				 Datum arg6, Datum arg7);extern Datum OidFunctionCall8(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3, Datum arg4, Datum arg5,				 Datum arg6, Datum arg7, Datum arg8);extern Datum OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2,				 Datum arg3, Datum arg4, Datum arg5,				 Datum arg6, Datum arg7, Datum arg8,				 Datum arg9);/* Special cases for convenient invocation of datatype I/O functions. */extern Datum InputFunctionCall(FmgrInfo *flinfo, char *str,				  Oid typioparam, int32 typmod);extern Datum OidInputFunctionCall(Oid functionId, char *str,					 Oid typioparam, int32 typmod);extern char *OutputFunctionCall(FmgrInfo *flinfo, Datum val);extern char *OidOutputFunctionCall(Oid functionId, Datum val);extern Datum ReceiveFunctionCall(FmgrInfo *flinfo, fmStringInfo buf,					Oid typioparam, int32 typmod);extern Datum OidReceiveFunctionCall(Oid functionId, fmStringInfo buf,					   Oid typioparam, int32 typmod);extern bytea *SendFunctionCall(FmgrInfo *flinfo, Datum val);extern bytea *OidSendFunctionCall(Oid functionId, Datum val);/* * Routines in fmgr.c */extern const Pg_finfo_record *fetch_finfo_record(void *filehandle, char *funcname);extern void clear_external_function_hash(void *filehandle);extern Oid	fmgr_internal_function(const char *proname);extern Oid	get_fn_expr_rettype(FmgrInfo *flinfo);extern Oid	get_fn_expr_argtype(FmgrInfo *flinfo, int argnum);extern Oid	get_call_expr_argtype(fmNodePtr expr, int argnum);/* * Routines in dfmgr.c */extern char *Dynamic_library_path;extern PGFunction load_external_function(char *filename, char *funcname,					   bool signalNotFound, void **filehandle);extern PGFunction lookup_external_function(void *filehandle, char *funcname);extern void load_file(const char *filename, bool restricted);extern void **find_rendezvous_variable(const char *varName);/* * !!! OLD INTERFACE !!! * * fmgr() is the only remaining vestige of the old-style caller support * functions.  It's no longer used anywhere in the Postgres distribution, * but we should leave it around for a release or two to ease the transition * for user-supplied C functions.  OidFunctionCallN() replaces it for new * code. *//* * DEPRECATED, DO NOT USE IN NEW CODE */extern char *fmgr(Oid procedureId,...);#endif   /* FMGR_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?