PostgreSQL Source Code  git master
fmgr.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FmgrInfo
 
struct  FunctionCallInfoBaseData
 
struct  Pg_finfo_record
 
struct  Pg_magic_struct
 

Macros

#define FIELDNO_FUNCTIONCALLINFODATA_ISNULL   4
 
#define FIELDNO_FUNCTIONCALLINFODATA_ARGS   6
 
#define SizeForFunctionCallInfo(nargs)
 
#define LOCAL_FCINFO(name, nargs)
 
#define fmgr_info_set_expr(expr, finfo)    ((finfo)->fn_expr = (expr))
 
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
 
#define FunctionCallInvoke(fcinfo)   ((* (fcinfo)->flinfo->fn_addr) (fcinfo))
 
#define PG_FUNCTION_ARGS   FunctionCallInfo fcinfo
 
#define PG_GET_COLLATION()   (fcinfo->fncollation)
 
#define PG_NARGS()   (fcinfo->nargs)
 
#define PG_ARGISNULL(n)   (fcinfo->args[n].isnull)
 
#define PG_DETOAST_DATUM(datum)    pg_detoast_datum((struct varlena *) DatumGetPointer(datum))
 
#define PG_DETOAST_DATUM_COPY(datum)    pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum))
 
#define PG_DETOAST_DATUM_SLICE(datum, f, c)
 
#define PG_DETOAST_DATUM_PACKED(datum)    pg_detoast_datum_packed((struct varlena *) DatumGetPointer(datum))
 
#define PG_FREE_IF_COPY(ptr, n)
 
#define PG_GETARG_DATUM(n)   (fcinfo->args[n].value)
 
#define PG_GETARG_INT32(n)   DatumGetInt32(PG_GETARG_DATUM(n))
 
#define PG_GETARG_UINT32(n)   DatumGetUInt32(PG_GETARG_DATUM(n))
 
#define PG_GETARG_INT16(n)   DatumGetInt16(PG_GETARG_DATUM(n))
 
#define PG_GETARG_UINT16(n)   DatumGetUInt16(PG_GETARG_DATUM(n))
 
#define PG_GETARG_CHAR(n)   DatumGetChar(PG_GETARG_DATUM(n))
 
#define PG_GETARG_BOOL(n)   DatumGetBool(PG_GETARG_DATUM(n))
 
#define PG_GETARG_OID(n)   DatumGetObjectId(PG_GETARG_DATUM(n))
 
#define PG_GETARG_POINTER(n)   DatumGetPointer(PG_GETARG_DATUM(n))
 
#define PG_GETARG_CSTRING(n)   DatumGetCString(PG_GETARG_DATUM(n))
 
#define PG_GETARG_NAME(n)   DatumGetName(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TRANSACTIONID(n)   DatumGetTransactionId(PG_GETARG_DATUM(n))
 
#define PG_GETARG_FLOAT4(n)   DatumGetFloat4(PG_GETARG_DATUM(n))
 
#define PG_GETARG_FLOAT8(n)   DatumGetFloat8(PG_GETARG_DATUM(n))
 
#define PG_GETARG_INT64(n)   DatumGetInt64(PG_GETARG_DATUM(n))
 
#define PG_GETARG_RAW_VARLENA_P(n)   ((struct varlena *) PG_GETARG_POINTER(n))
 
#define PG_GETARG_VARLENA_P(n)   PG_DETOAST_DATUM(PG_GETARG_DATUM(n))
 
#define PG_GETARG_VARLENA_PP(n)   PG_DETOAST_DATUM_PACKED(PG_GETARG_DATUM(n))
 
#define DatumGetByteaPP(X)   ((bytea *) PG_DETOAST_DATUM_PACKED(X))
 
#define DatumGetTextPP(X)   ((text *) PG_DETOAST_DATUM_PACKED(X))
 
#define DatumGetBpCharPP(X)   ((BpChar *) PG_DETOAST_DATUM_PACKED(X))
 
#define DatumGetVarCharPP(X)   ((VarChar *) PG_DETOAST_DATUM_PACKED(X))
 
#define DatumGetHeapTupleHeader(X)   ((HeapTupleHeader) PG_DETOAST_DATUM(X))
 
#define DatumGetByteaPCopy(X)   ((bytea *) PG_DETOAST_DATUM_COPY(X))
 
#define DatumGetTextPCopy(X)   ((text *) PG_DETOAST_DATUM_COPY(X))
 
#define DatumGetBpCharPCopy(X)   ((BpChar *) PG_DETOAST_DATUM_COPY(X))
 
#define DatumGetVarCharPCopy(X)   ((VarChar *) PG_DETOAST_DATUM_COPY(X))
 
#define DatumGetHeapTupleHeaderCopy(X)   ((HeapTupleHeader) PG_DETOAST_DATUM_COPY(X))
 
#define DatumGetByteaPSlice(X, m, n)   ((bytea *) PG_DETOAST_DATUM_SLICE(X,m,n))
 
#define DatumGetTextPSlice(X, m, n)   ((text *) PG_DETOAST_DATUM_SLICE(X,m,n))
 
#define DatumGetBpCharPSlice(X, m, n)   ((BpChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
 
#define DatumGetVarCharPSlice(X, m, n)   ((VarChar *) PG_DETOAST_DATUM_SLICE(X,m,n))
 
#define PG_GETARG_BYTEA_PP(n)   DatumGetByteaPP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TEXT_PP(n)   DatumGetTextPP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_BPCHAR_PP(n)   DatumGetBpCharPP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_VARCHAR_PP(n)   DatumGetVarCharPP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_HEAPTUPLEHEADER(n)   DatumGetHeapTupleHeader(PG_GETARG_DATUM(n))
 
#define PG_GETARG_BYTEA_P_COPY(n)   DatumGetByteaPCopy(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TEXT_P_COPY(n)   DatumGetTextPCopy(PG_GETARG_DATUM(n))
 
#define PG_GETARG_BPCHAR_P_COPY(n)   DatumGetBpCharPCopy(PG_GETARG_DATUM(n))
 
#define PG_GETARG_VARCHAR_P_COPY(n)   DatumGetVarCharPCopy(PG_GETARG_DATUM(n))
 
#define PG_GETARG_HEAPTUPLEHEADER_COPY(n)   DatumGetHeapTupleHeaderCopy(PG_GETARG_DATUM(n))
 
#define PG_GETARG_BYTEA_P_SLICE(n, a, b)   DatumGetByteaPSlice(PG_GETARG_DATUM(n),a,b)
 
#define PG_GETARG_TEXT_P_SLICE(n, a, b)   DatumGetTextPSlice(PG_GETARG_DATUM(n),a,b)
 
#define PG_GETARG_BPCHAR_P_SLICE(n, a, b)   DatumGetBpCharPSlice(PG_GETARG_DATUM(n),a,b)
 
#define PG_GETARG_VARCHAR_P_SLICE(n, a, b)   DatumGetVarCharPSlice(PG_GETARG_DATUM(n),a,b)
 
#define DatumGetByteaP(X)   ((bytea *) PG_DETOAST_DATUM(X))
 
#define DatumGetTextP(X)   ((text *) PG_DETOAST_DATUM(X))
 
#define DatumGetBpCharP(X)   ((BpChar *) PG_DETOAST_DATUM(X))
 
#define DatumGetVarCharP(X)   ((VarChar *) PG_DETOAST_DATUM(X))
 
#define PG_GETARG_BYTEA_P(n)   DatumGetByteaP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_TEXT_P(n)   DatumGetTextP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_BPCHAR_P(n)   DatumGetBpCharP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_VARCHAR_P(n)   DatumGetVarCharP(PG_GETARG_DATUM(n))
 
#define PG_HAS_OPCLASS_OPTIONS()   has_fn_opclass_options(fcinfo->flinfo)
 
#define PG_GET_OPCLASS_OPTIONS()   get_fn_opclass_options(fcinfo->flinfo)
 
#define PG_RETURN_NULL()    do { fcinfo->isnull = true; return (Datum) 0; } while (0)
 
#define PG_RETURN_VOID()   return (Datum) 0
 
#define PG_RETURN_DATUM(x)   return (x)
 
#define PG_RETURN_INT32(x)   return Int32GetDatum(x)
 
#define PG_RETURN_UINT32(x)   return UInt32GetDatum(x)
 
#define PG_RETURN_INT16(x)   return Int16GetDatum(x)
 
#define PG_RETURN_UINT16(x)   return UInt16GetDatum(x)
 
#define PG_RETURN_CHAR(x)   return CharGetDatum(x)
 
#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)
 
#define PG_RETURN_TRANSACTIONID(x)   return TransactionIdGetDatum(x)
 
#define PG_RETURN_FLOAT4(x)   return Float4GetDatum(x)
 
#define PG_RETURN_FLOAT8(x)   return Float8GetDatum(x)
 
#define PG_RETURN_INT64(x)   return Int64GetDatum(x)
 
#define PG_RETURN_UINT64(x)   return UInt64GetDatum(x)
 
#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)   return HeapTupleHeaderGetDatum(x)
 
#define PG_FUNCTION_INFO_V1(funcname)
 
#define PG_MODULE_MAGIC_DATA
 
#define PG_MAGIC_FUNCTION_NAME   Pg_magic_func
 
#define PG_MAGIC_FUNCTION_NAME_STRING   "Pg_magic_func"
 
#define PG_MODULE_MAGIC
 
#define DirectFunctionCall1(func, arg1)    DirectFunctionCall1Coll(func, InvalidOid, arg1)
 
#define DirectFunctionCall2(func, arg1, arg2)    DirectFunctionCall2Coll(func, InvalidOid, arg1, arg2)
 
#define DirectFunctionCall3(func, arg1, arg2, arg3)    DirectFunctionCall3Coll(func, InvalidOid, arg1, arg2, arg3)
 
#define DirectFunctionCall4(func, arg1, arg2, arg3, arg4)    DirectFunctionCall4Coll(func, InvalidOid, arg1, arg2, arg3, arg4)
 
#define DirectFunctionCall5(func, arg1, arg2, arg3, arg4, arg5)    DirectFunctionCall5Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5)
 
#define DirectFunctionCall6(func, arg1, arg2, arg3, arg4, arg5, arg6)    DirectFunctionCall6Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6)
 
#define DirectFunctionCall7(func, arg1, arg2, arg3, arg4, arg5, arg6, arg7)    DirectFunctionCall7Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
 
#define DirectFunctionCall8(func, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)    DirectFunctionCall8Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
 
#define DirectFunctionCall9(func, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)    DirectFunctionCall9Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
 
#define FunctionCall1(flinfo, arg1)    FunctionCall1Coll(flinfo, InvalidOid, arg1)
 
#define FunctionCall2(flinfo, arg1, arg2)    FunctionCall2Coll(flinfo, InvalidOid, arg1, arg2)
 
#define FunctionCall3(flinfo, arg1, arg2, arg3)    FunctionCall3Coll(flinfo, InvalidOid, arg1, arg2, arg3)
 
#define FunctionCall4(flinfo, arg1, arg2, arg3, arg4)    FunctionCall4Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4)
 
#define FunctionCall5(flinfo, arg1, arg2, arg3, arg4, arg5)    FunctionCall5Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5)
 
#define FunctionCall6(flinfo, arg1, arg2, arg3, arg4, arg5, arg6)    FunctionCall6Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6)
 
#define FunctionCall7(flinfo, arg1, arg2, arg3, arg4, arg5, arg6, arg7)    FunctionCall7Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
 
#define FunctionCall8(flinfo, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)    FunctionCall8Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
 
#define FunctionCall9(flinfo, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)    FunctionCall9Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
 
#define OidFunctionCall0(functionId)    OidFunctionCall0Coll(functionId, InvalidOid)
 
#define OidFunctionCall1(functionId, arg1)    OidFunctionCall1Coll(functionId, InvalidOid, arg1)
 
#define OidFunctionCall2(functionId, arg1, arg2)    OidFunctionCall2Coll(functionId, InvalidOid, arg1, arg2)
 
#define OidFunctionCall3(functionId, arg1, arg2, arg3)    OidFunctionCall3Coll(functionId, InvalidOid, arg1, arg2, arg3)
 
#define OidFunctionCall4(functionId, arg1, arg2, arg3, arg4)    OidFunctionCall4Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4)
 
#define OidFunctionCall5(functionId, arg1, arg2, arg3, arg4, arg5)    OidFunctionCall5Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5)
 
#define OidFunctionCall6(functionId, arg1, arg2, arg3, arg4, arg5, arg6)    OidFunctionCall6Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6)
 
#define OidFunctionCall7(functionId, arg1, arg2, arg3, arg4, arg5, arg6, arg7)    OidFunctionCall7Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
 
#define OidFunctionCall8(functionId, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)    OidFunctionCall8Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
 
#define OidFunctionCall9(functionId, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)    OidFunctionCall9Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
 
#define AGG_CONTEXT_AGGREGATE   1 /* regular aggregate */
 
#define AGG_CONTEXT_WINDOW   2 /* window function */
 
#define FmgrHookIsNeeded(fn_oid)    (!needs_fmgr_hook ? false : (*needs_fmgr_hook)(fn_oid))
 

Typedefs

typedef struct NodefmNodePtr
 
typedef struct AggreffmAggrefPtr
 
typedef void(* fmExprContextCallbackFunction) (Datum arg)
 
typedef struct StringInfoDatafmStringInfo
 
typedef struct FunctionCallInfoBaseDataFunctionCallInfo
 
typedef Datum(* PGFunction) (FunctionCallInfo fcinfo)
 
typedef struct FmgrInfo FmgrInfo
 
typedef struct FunctionCallInfoBaseData FunctionCallInfoBaseData
 
typedef const Pg_finfo_record *(* PGFInfoFunction) (void)
 
typedef const Pg_magic_struct *(* PGModuleMagicFunction) (void)
 
typedef enum FmgrHookEventType FmgrHookEventType
 
typedef bool(* needs_fmgr_hook_type) (Oid fn_oid)
 
typedef void(* fmgr_hook_type) (FmgrHookEventType event, FmgrInfo *flinfo, Datum *arg)
 

Enumerations

enum  FmgrHookEventType { FHET_START , FHET_END , FHET_ABORT }
 

Functions

void fmgr_info (Oid functionId, FmgrInfo *finfo)
 
void fmgr_info_cxt (Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
 
void fmgr_info_copy (FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
 
void fmgr_symbol (Oid functionId, char **mod, char **fn)
 
struct varlenapg_detoast_datum (struct varlena *datum)
 
struct varlenapg_detoast_datum_copy (struct varlena *datum)
 
struct varlenapg_detoast_datum_slice (struct varlena *datum, int32 first, int32 count)
 
struct varlenapg_detoast_datum_packed (struct varlena *datum)
 
 StaticAssertDecl (sizeof(FMGR_ABI_EXTRA)<=sizeof(((Pg_magic_struct *) 0) ->abi_extra), "FMGR_ABI_EXTRA too long")
 
Datum DirectFunctionCall1Coll (PGFunction func, Oid collation, Datum arg1)
 
Datum DirectFunctionCall2Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2)
 
Datum DirectFunctionCall3Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3)
 
Datum DirectFunctionCall4Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
 
Datum DirectFunctionCall5Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
 
Datum DirectFunctionCall6Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
 
Datum DirectFunctionCall7Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
 
Datum DirectFunctionCall8Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
 
Datum DirectFunctionCall9Coll (PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
 
Datum CallerFInfoFunctionCall1 (PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1)
 
Datum CallerFInfoFunctionCall2 (PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
 
Datum FunctionCall0Coll (FmgrInfo *flinfo, Oid collation)
 
Datum FunctionCall1Coll (FmgrInfo *flinfo, Oid collation, Datum arg1)
 
Datum FunctionCall2Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
 
Datum FunctionCall3Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3)
 
Datum FunctionCall4Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
 
Datum FunctionCall5Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
 
Datum FunctionCall6Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
 
Datum FunctionCall7Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
 
Datum FunctionCall8Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
 
Datum FunctionCall9Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
 
Datum OidFunctionCall0Coll (Oid functionId, Oid collation)
 
Datum OidFunctionCall1Coll (Oid functionId, Oid collation, Datum arg1)
 
Datum OidFunctionCall2Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2)
 
Datum OidFunctionCall3Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3)
 
Datum OidFunctionCall4Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
 
Datum OidFunctionCall5Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
 
Datum OidFunctionCall6Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
 
Datum OidFunctionCall7Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
 
Datum OidFunctionCall8Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
 
Datum OidFunctionCall9Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
 
Datum InputFunctionCall (FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
 
Datum OidInputFunctionCall (Oid functionId, char *str, Oid typioparam, int32 typmod)
 
char * OutputFunctionCall (FmgrInfo *flinfo, Datum val)
 
char * OidOutputFunctionCall (Oid functionId, Datum val)
 
Datum ReceiveFunctionCall (FmgrInfo *flinfo, fmStringInfo buf, Oid typioparam, int32 typmod)
 
Datum OidReceiveFunctionCall (Oid functionId, fmStringInfo buf, Oid typioparam, int32 typmod)
 
byteaSendFunctionCall (FmgrInfo *flinfo, Datum val)
 
byteaOidSendFunctionCall (Oid functionId, Datum val)
 
const Pg_finfo_recordfetch_finfo_record (void *filehandle, const char *funcname)
 
void clear_external_function_hash (void *filehandle)
 
Oid fmgr_internal_function (const char *proname)
 
Oid get_fn_expr_rettype (FmgrInfo *flinfo)
 
Oid get_fn_expr_argtype (FmgrInfo *flinfo, int argnum)
 
Oid get_call_expr_argtype (fmNodePtr expr, int argnum)
 
bool get_fn_expr_arg_stable (FmgrInfo *flinfo, int argnum)
 
bool get_call_expr_arg_stable (fmNodePtr expr, int argnum)
 
bool get_fn_expr_variadic (FmgrInfo *flinfo)
 
byteaget_fn_opclass_options (FmgrInfo *flinfo)
 
bool has_fn_opclass_options (FmgrInfo *flinfo)
 
void set_fn_opclass_options (FmgrInfo *flinfo, bytea *options)
 
bool CheckFunctionValidatorAccess (Oid validatorOid, Oid functionOid)
 
void * load_external_function (const char *filename, const char *funcname, bool signalNotFound, void **filehandle)
 
void * lookup_external_function (void *filehandle, const char *funcname)
 
void load_file (const char *filename, bool restricted)
 
void ** find_rendezvous_variable (const char *varName)
 
Size EstimateLibraryStateSpace (void)
 
void SerializeLibraryState (Size maxsize, char *start_address)
 
void RestoreLibraryState (char *start_address)
 
int AggCheckCallContext (FunctionCallInfo fcinfo, MemoryContext *aggcontext)
 
fmAggrefPtr AggGetAggref (FunctionCallInfo fcinfo)
 
MemoryContext AggGetTempMemoryContext (FunctionCallInfo fcinfo)
 
bool AggStateIsShared (FunctionCallInfo fcinfo)
 
void AggRegisterCallback (FunctionCallInfo fcinfo, fmExprContextCallbackFunction func, Datum arg)
 

Variables

char * Dynamic_library_path
 
PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook
 
PGDLLIMPORT fmgr_hook_type fmgr_hook
 

Macro Definition Documentation

◆ AGG_CONTEXT_AGGREGATE

#define AGG_CONTEXT_AGGREGATE   1 /* regular aggregate */

Definition at line 743 of file fmgr.h.

◆ AGG_CONTEXT_WINDOW

#define AGG_CONTEXT_WINDOW   2 /* window function */

Definition at line 744 of file fmgr.h.

◆ DatumGetBpCharP

#define DatumGetBpCharP (   X)    ((BpChar *) PG_DETOAST_DATUM(X))

Definition at line 333 of file fmgr.h.

◆ DatumGetBpCharPCopy

#define DatumGetBpCharPCopy (   X)    ((BpChar *) PG_DETOAST_DATUM_COPY(X))

Definition at line 299 of file fmgr.h.

◆ DatumGetBpCharPP

#define DatumGetBpCharPP (   X)    ((BpChar *) PG_DETOAST_DATUM_PACKED(X))

Definition at line 293 of file fmgr.h.

◆ DatumGetBpCharPSlice

#define DatumGetBpCharPSlice (   X,
  m,
 
)    ((BpChar *) PG_DETOAST_DATUM_SLICE(X,m,n))

Definition at line 305 of file fmgr.h.

◆ DatumGetByteaP

#define DatumGetByteaP (   X)    ((bytea *) PG_DETOAST_DATUM(X))

Definition at line 331 of file fmgr.h.

◆ DatumGetByteaPCopy

#define DatumGetByteaPCopy (   X)    ((bytea *) PG_DETOAST_DATUM_COPY(X))

Definition at line 297 of file fmgr.h.

◆ DatumGetByteaPP

#define DatumGetByteaPP (   X)    ((bytea *) PG_DETOAST_DATUM_PACKED(X))

Definition at line 291 of file fmgr.h.

◆ DatumGetByteaPSlice

#define DatumGetByteaPSlice (   X,
  m,
 
)    ((bytea *) PG_DETOAST_DATUM_SLICE(X,m,n))

Definition at line 303 of file fmgr.h.

◆ DatumGetHeapTupleHeader

#define DatumGetHeapTupleHeader (   X)    ((HeapTupleHeader) PG_DETOAST_DATUM(X))

Definition at line 295 of file fmgr.h.

◆ DatumGetHeapTupleHeaderCopy

#define DatumGetHeapTupleHeaderCopy (   X)    ((HeapTupleHeader) PG_DETOAST_DATUM_COPY(X))

Definition at line 301 of file fmgr.h.

◆ DatumGetTextP

#define DatumGetTextP (   X)    ((text *) PG_DETOAST_DATUM(X))

Definition at line 332 of file fmgr.h.

◆ DatumGetTextPCopy

#define DatumGetTextPCopy (   X)    ((text *) PG_DETOAST_DATUM_COPY(X))

Definition at line 298 of file fmgr.h.

◆ DatumGetTextPP

#define DatumGetTextPP (   X)    ((text *) PG_DETOAST_DATUM_PACKED(X))

Definition at line 292 of file fmgr.h.

◆ DatumGetTextPSlice

#define DatumGetTextPSlice (   X,
  m,
 
)    ((text *) PG_DETOAST_DATUM_SLICE(X,m,n))

Definition at line 304 of file fmgr.h.

◆ DatumGetVarCharP

#define DatumGetVarCharP (   X)    ((VarChar *) PG_DETOAST_DATUM(X))

Definition at line 334 of file fmgr.h.

◆ DatumGetVarCharPCopy

#define DatumGetVarCharPCopy (   X)    ((VarChar *) PG_DETOAST_DATUM_COPY(X))

Definition at line 300 of file fmgr.h.

◆ DatumGetVarCharPP

#define DatumGetVarCharPP (   X)    ((VarChar *) PG_DETOAST_DATUM_PACKED(X))

Definition at line 294 of file fmgr.h.

◆ DatumGetVarCharPSlice

#define DatumGetVarCharPSlice (   X,
  m,
 
)    ((VarChar *) PG_DETOAST_DATUM_SLICE(X,m,n))

Definition at line 306 of file fmgr.h.

◆ DirectFunctionCall1

#define DirectFunctionCall1 (   func,
  arg1 
)     DirectFunctionCall1Coll(func, InvalidOid, arg1)

Definition at line 631 of file fmgr.h.

◆ DirectFunctionCall2

#define DirectFunctionCall2 (   func,
  arg1,
  arg2 
)     DirectFunctionCall2Coll(func, InvalidOid, arg1, arg2)

Definition at line 633 of file fmgr.h.

◆ DirectFunctionCall3

#define DirectFunctionCall3 (   func,
  arg1,
  arg2,
  arg3 
)     DirectFunctionCall3Coll(func, InvalidOid, arg1, arg2, arg3)

Definition at line 635 of file fmgr.h.

◆ DirectFunctionCall4

#define DirectFunctionCall4 (   func,
  arg1,
  arg2,
  arg3,
  arg4 
)     DirectFunctionCall4Coll(func, InvalidOid, arg1, arg2, arg3, arg4)

Definition at line 637 of file fmgr.h.

◆ DirectFunctionCall5

#define DirectFunctionCall5 (   func,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5 
)     DirectFunctionCall5Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5)

Definition at line 639 of file fmgr.h.

◆ DirectFunctionCall6

#define DirectFunctionCall6 (   func,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6 
)     DirectFunctionCall6Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6)

Definition at line 641 of file fmgr.h.

◆ DirectFunctionCall7

#define DirectFunctionCall7 (   func,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7 
)     DirectFunctionCall7Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7)

Definition at line 643 of file fmgr.h.

◆ DirectFunctionCall8

#define DirectFunctionCall8 (   func,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7,
  arg8 
)     DirectFunctionCall8Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)

Definition at line 645 of file fmgr.h.

◆ DirectFunctionCall9

#define DirectFunctionCall9 (   func,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7,
  arg8,
  arg9 
)     DirectFunctionCall9Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)

Definition at line 647 of file fmgr.h.

◆ FIELDNO_FUNCTIONCALLINFODATA_ARGS

#define FIELDNO_FUNCTIONCALLINFODATA_ARGS   6

Definition at line 94 of file fmgr.h.

◆ FIELDNO_FUNCTIONCALLINFODATA_ISNULL

#define FIELDNO_FUNCTIONCALLINFODATA_ISNULL   4

Definition at line 91 of file fmgr.h.

◆ fmgr_info_set_expr

#define fmgr_info_set_expr (   expr,
  finfo 
)     ((finfo)->fn_expr = (expr))

Definition at line 135 of file fmgr.h.

◆ FmgrHookIsNeeded

#define FmgrHookIsNeeded (   fn_oid)     (!needs_fmgr_hook ? false : (*needs_fmgr_hook)(fn_oid))

Definition at line 779 of file fmgr.h.

◆ FunctionCall1

#define FunctionCall1 (   flinfo,
  arg1 
)     FunctionCall1Coll(flinfo, InvalidOid, arg1)

Definition at line 649 of file fmgr.h.

◆ FunctionCall2

#define FunctionCall2 (   flinfo,
  arg1,
  arg2 
)     FunctionCall2Coll(flinfo, InvalidOid, arg1, arg2)

Definition at line 651 of file fmgr.h.

◆ FunctionCall3

#define FunctionCall3 (   flinfo,
  arg1,
  arg2,
  arg3 
)     FunctionCall3Coll(flinfo, InvalidOid, arg1, arg2, arg3)

Definition at line 653 of file fmgr.h.

◆ FunctionCall4

#define FunctionCall4 (   flinfo,
  arg1,
  arg2,
  arg3,
  arg4 
)     FunctionCall4Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4)

Definition at line 655 of file fmgr.h.

◆ FunctionCall5

#define FunctionCall5 (   flinfo,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5 
)     FunctionCall5Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5)

Definition at line 657 of file fmgr.h.

◆ FunctionCall6

#define FunctionCall6 (   flinfo,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6 
)     FunctionCall6Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6)

Definition at line 659 of file fmgr.h.

◆ FunctionCall7

#define FunctionCall7 (   flinfo,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7 
)     FunctionCall7Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7)

Definition at line 661 of file fmgr.h.

◆ FunctionCall8

#define FunctionCall8 (   flinfo,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7,
  arg8 
)     FunctionCall8Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)

Definition at line 663 of file fmgr.h.

◆ FunctionCall9

#define FunctionCall9 (   flinfo,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7,
  arg8,
  arg9 
)     FunctionCall9Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)

Definition at line 665 of file fmgr.h.

◆ FunctionCallInvoke

#define FunctionCallInvoke (   fcinfo)    ((* (fcinfo)->flinfo->fn_addr) (fcinfo))

Definition at line 172 of file fmgr.h.

◆ InitFunctionCallInfoData

#define InitFunctionCallInfoData (   Fcinfo,
  Flinfo,
  Nargs,
  Collation,
  Context,
  Resultinfo 
)
Value:
do { \
(Fcinfo).flinfo = (Flinfo); \
(Fcinfo).context = (Context); \
(Fcinfo).resultinfo = (Resultinfo); \
(Fcinfo).fncollation = (Collation); \
(Fcinfo).isnull = false; \
(Fcinfo).nargs = (Nargs); \
} while (0)

Definition at line 150 of file fmgr.h.

◆ LOCAL_FCINFO

#define LOCAL_FCINFO (   name,
  nargs 
)
Value:
/* use union with FunctionCallInfoBaseData to guarantee alignment */ \
union \
{ \
FunctionCallInfoBaseData fcinfo; \
/* ensure enough space for nargs args is available */ \
char fcinfo_data[SizeForFunctionCallInfo(nargs)]; \
} name##data; \
FunctionCallInfo name = &name##data.fcinfo
const char * name
Definition: encode.c:561
#define SizeForFunctionCallInfo(nargs)
Definition: fmgr.h:102
const void * data

Definition at line 110 of file fmgr.h.

◆ OidFunctionCall0

#define OidFunctionCall0 (   functionId)     OidFunctionCall0Coll(functionId, InvalidOid)

Definition at line 667 of file fmgr.h.

◆ OidFunctionCall1

#define OidFunctionCall1 (   functionId,
  arg1 
)     OidFunctionCall1Coll(functionId, InvalidOid, arg1)

Definition at line 669 of file fmgr.h.

◆ OidFunctionCall2

#define OidFunctionCall2 (   functionId,
  arg1,
  arg2 
)     OidFunctionCall2Coll(functionId, InvalidOid, arg1, arg2)

Definition at line 671 of file fmgr.h.

◆ OidFunctionCall3

#define OidFunctionCall3 (   functionId,
  arg1,
  arg2,
  arg3 
)     OidFunctionCall3Coll(functionId, InvalidOid, arg1, arg2, arg3)

Definition at line 673 of file fmgr.h.

◆ OidFunctionCall4

#define OidFunctionCall4 (   functionId,
  arg1,
  arg2,
  arg3,
  arg4 
)     OidFunctionCall4Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4)

Definition at line 675 of file fmgr.h.

◆ OidFunctionCall5

#define OidFunctionCall5 (   functionId,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5 
)     OidFunctionCall5Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5)

Definition at line 677 of file fmgr.h.

◆ OidFunctionCall6

#define OidFunctionCall6 (   functionId,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6 
)     OidFunctionCall6Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6)

Definition at line 679 of file fmgr.h.

◆ OidFunctionCall7

#define OidFunctionCall7 (   functionId,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7 
)     OidFunctionCall7Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7)

Definition at line 681 of file fmgr.h.

◆ OidFunctionCall8

#define OidFunctionCall8 (   functionId,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7,
  arg8 
)     OidFunctionCall8Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)

Definition at line 683 of file fmgr.h.

◆ OidFunctionCall9

#define OidFunctionCall9 (   functionId,
  arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  arg7,
  arg8,
  arg9 
)     OidFunctionCall9Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)

Definition at line 685 of file fmgr.h.

◆ PG_ARGISNULL

#define PG_ARGISNULL (   n)    (fcinfo->args[n].isnull)

Definition at line 209 of file fmgr.h.

◆ PG_DETOAST_DATUM

#define PG_DETOAST_DATUM (   datum)     pg_detoast_datum((struct varlena *) DatumGetPointer(datum))

Definition at line 240 of file fmgr.h.

◆ PG_DETOAST_DATUM_COPY

#define PG_DETOAST_DATUM_COPY (   datum)     pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum))

Definition at line 242 of file fmgr.h.

◆ PG_DETOAST_DATUM_PACKED

#define PG_DETOAST_DATUM_PACKED (   datum)     pg_detoast_datum_packed((struct varlena *) DatumGetPointer(datum))

Definition at line 248 of file fmgr.h.

◆ PG_DETOAST_DATUM_SLICE

#define PG_DETOAST_DATUM_SLICE (   datum,
  f,
  c 
)
Value:
(int32) (f), (int32) (c))
signed int int32
Definition: c.h:429
struct varlena * pg_detoast_datum_slice(struct varlena *datum, int32 first, int32 count)
Definition: fmgr.c:1747
#define DatumGetPointer(X)
Definition: postgres.h:593
char * c
Definition: c.h:622

Definition at line 244 of file fmgr.h.

◆ PG_FREE_IF_COPY

#define PG_FREE_IF_COPY (   ptr,
 
)
Value:
do { \
if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
pfree(ptr); \
} while (0)
char * Pointer
Definition: c.h:418
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276

Definition at line 260 of file fmgr.h.

◆ PG_FUNCTION_ARGS

#define PG_FUNCTION_ARGS   FunctionCallInfo fcinfo

Definition at line 193 of file fmgr.h.

◆ PG_FUNCTION_INFO_V1

#define PG_FUNCTION_INFO_V1 (   funcname)
Value:
extern Datum funcname(PG_FUNCTION_ARGS); \
extern PGDLLEXPORT 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
#define CppConcat(x, y)
Definition: c.h:290
#define PGDLLEXPORT
Definition: c.h:1342
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
uintptr_t Datum
Definition: postgres.h:411

Definition at line 415 of file fmgr.h.

◆ PG_GET_COLLATION

#define PG_GET_COLLATION ( )    (fcinfo->fncollation)

Definition at line 198 of file fmgr.h.

◆ PG_GET_OPCLASS_OPTIONS

#define PG_GET_OPCLASS_OPTIONS ( )    get_fn_opclass_options(fcinfo->flinfo)

Definition at line 342 of file fmgr.h.

◆ PG_GETARG_BOOL

#define PG_GETARG_BOOL (   n)    DatumGetBool(PG_GETARG_DATUM(n))

Definition at line 274 of file fmgr.h.

◆ PG_GETARG_BPCHAR_P

#define PG_GETARG_BPCHAR_P (   n)    DatumGetBpCharP(PG_GETARG_DATUM(n))

Definition at line 337 of file fmgr.h.

◆ PG_GETARG_BPCHAR_P_COPY

#define PG_GETARG_BPCHAR_P_COPY (   n)    DatumGetBpCharPCopy(PG_GETARG_DATUM(n))

Definition at line 316 of file fmgr.h.

◆ PG_GETARG_BPCHAR_P_SLICE

#define PG_GETARG_BPCHAR_P_SLICE (   n,
  a,
  b 
)    DatumGetBpCharPSlice(PG_GETARG_DATUM(n),a,b)

Definition at line 322 of file fmgr.h.

◆ PG_GETARG_BPCHAR_PP

#define PG_GETARG_BPCHAR_PP (   n)    DatumGetBpCharPP(PG_GETARG_DATUM(n))

Definition at line 310 of file fmgr.h.

◆ PG_GETARG_BYTEA_P

#define PG_GETARG_BYTEA_P (   n)    DatumGetByteaP(PG_GETARG_DATUM(n))

Definition at line 335 of file fmgr.h.

◆ PG_GETARG_BYTEA_P_COPY

#define PG_GETARG_BYTEA_P_COPY (   n)    DatumGetByteaPCopy(PG_GETARG_DATUM(n))

Definition at line 314 of file fmgr.h.

◆ PG_GETARG_BYTEA_P_SLICE

#define PG_GETARG_BYTEA_P_SLICE (   n,
  a,
  b 
)    DatumGetByteaPSlice(PG_GETARG_DATUM(n),a,b)

Definition at line 320 of file fmgr.h.

◆ PG_GETARG_BYTEA_PP

#define PG_GETARG_BYTEA_PP (   n)    DatumGetByteaPP(PG_GETARG_DATUM(n))

Definition at line 308 of file fmgr.h.

◆ PG_GETARG_CHAR

#define PG_GETARG_CHAR (   n)    DatumGetChar(PG_GETARG_DATUM(n))

Definition at line 273 of file fmgr.h.

◆ PG_GETARG_CSTRING

#define PG_GETARG_CSTRING (   n)    DatumGetCString(PG_GETARG_DATUM(n))

Definition at line 277 of file fmgr.h.

◆ PG_GETARG_DATUM

#define PG_GETARG_DATUM (   n)    (fcinfo->args[n].value)

Definition at line 268 of file fmgr.h.

◆ PG_GETARG_FLOAT4

#define PG_GETARG_FLOAT4 (   n)    DatumGetFloat4(PG_GETARG_DATUM(n))

Definition at line 281 of file fmgr.h.

◆ PG_GETARG_FLOAT8

#define PG_GETARG_FLOAT8 (   n)    DatumGetFloat8(PG_GETARG_DATUM(n))

Definition at line 282 of file fmgr.h.

◆ PG_GETARG_HEAPTUPLEHEADER

#define PG_GETARG_HEAPTUPLEHEADER (   n)    DatumGetHeapTupleHeader(PG_GETARG_DATUM(n))

Definition at line 312 of file fmgr.h.

◆ PG_GETARG_HEAPTUPLEHEADER_COPY

#define PG_GETARG_HEAPTUPLEHEADER_COPY (   n)    DatumGetHeapTupleHeaderCopy(PG_GETARG_DATUM(n))

Definition at line 318 of file fmgr.h.

◆ PG_GETARG_INT16

#define PG_GETARG_INT16 (   n)    DatumGetInt16(PG_GETARG_DATUM(n))

Definition at line 271 of file fmgr.h.

◆ PG_GETARG_INT32

#define PG_GETARG_INT32 (   n)    DatumGetInt32(PG_GETARG_DATUM(n))

Definition at line 269 of file fmgr.h.

◆ PG_GETARG_INT64

#define PG_GETARG_INT64 (   n)    DatumGetInt64(PG_GETARG_DATUM(n))

Definition at line 283 of file fmgr.h.

◆ PG_GETARG_NAME

#define PG_GETARG_NAME (   n)    DatumGetName(PG_GETARG_DATUM(n))

Definition at line 278 of file fmgr.h.

◆ PG_GETARG_OID

#define PG_GETARG_OID (   n)    DatumGetObjectId(PG_GETARG_DATUM(n))

Definition at line 275 of file fmgr.h.

◆ PG_GETARG_POINTER

#define PG_GETARG_POINTER (   n)    DatumGetPointer(PG_GETARG_DATUM(n))

Definition at line 276 of file fmgr.h.

◆ PG_GETARG_RAW_VARLENA_P

#define PG_GETARG_RAW_VARLENA_P (   n)    ((struct varlena *) PG_GETARG_POINTER(n))

Definition at line 285 of file fmgr.h.

◆ PG_GETARG_TEXT_P

#define PG_GETARG_TEXT_P (   n)    DatumGetTextP(PG_GETARG_DATUM(n))

Definition at line 336 of file fmgr.h.

◆ PG_GETARG_TEXT_P_COPY

#define PG_GETARG_TEXT_P_COPY (   n)    DatumGetTextPCopy(PG_GETARG_DATUM(n))

Definition at line 315 of file fmgr.h.

◆ PG_GETARG_TEXT_P_SLICE

#define PG_GETARG_TEXT_P_SLICE (   n,
  a,
  b 
)    DatumGetTextPSlice(PG_GETARG_DATUM(n),a,b)

Definition at line 321 of file fmgr.h.

◆ PG_GETARG_TEXT_PP

#define PG_GETARG_TEXT_PP (   n)    DatumGetTextPP(PG_GETARG_DATUM(n))

Definition at line 309 of file fmgr.h.

◆ PG_GETARG_TRANSACTIONID

#define PG_GETARG_TRANSACTIONID (   n)    DatumGetTransactionId(PG_GETARG_DATUM(n))

Definition at line 279 of file fmgr.h.

◆ PG_GETARG_UINT16

#define PG_GETARG_UINT16 (   n)    DatumGetUInt16(PG_GETARG_DATUM(n))

Definition at line 272 of file fmgr.h.

◆ PG_GETARG_UINT32

#define PG_GETARG_UINT32 (   n)    DatumGetUInt32(PG_GETARG_DATUM(n))

Definition at line 270 of file fmgr.h.

◆ PG_GETARG_VARCHAR_P

#define PG_GETARG_VARCHAR_P (   n)    DatumGetVarCharP(PG_GETARG_DATUM(n))

Definition at line 338 of file fmgr.h.

◆ PG_GETARG_VARCHAR_P_COPY

#define PG_GETARG_VARCHAR_P_COPY (   n)    DatumGetVarCharPCopy(PG_GETARG_DATUM(n))

Definition at line 317 of file fmgr.h.

◆ PG_GETARG_VARCHAR_P_SLICE

#define PG_GETARG_VARCHAR_P_SLICE (   n,
  a,
  b 
)    DatumGetVarCharPSlice(PG_GETARG_DATUM(n),a,b)

Definition at line 323 of file fmgr.h.

◆ PG_GETARG_VARCHAR_PP

#define PG_GETARG_VARCHAR_PP (   n)    DatumGetVarCharPP(PG_GETARG_DATUM(n))

Definition at line 311 of file fmgr.h.

◆ PG_GETARG_VARLENA_P

#define PG_GETARG_VARLENA_P (   n)    PG_DETOAST_DATUM(PG_GETARG_DATUM(n))

Definition at line 287 of file fmgr.h.

◆ PG_GETARG_VARLENA_PP

#define PG_GETARG_VARLENA_PP (   n)    PG_DETOAST_DATUM_PACKED(PG_GETARG_DATUM(n))

Definition at line 289 of file fmgr.h.

◆ PG_HAS_OPCLASS_OPTIONS

#define PG_HAS_OPCLASS_OPTIONS ( )    has_fn_opclass_options(fcinfo->flinfo)

Definition at line 341 of file fmgr.h.

◆ PG_MAGIC_FUNCTION_NAME

#define PG_MAGIC_FUNCTION_NAME   Pg_magic_func

Definition at line 485 of file fmgr.h.

◆ PG_MAGIC_FUNCTION_NAME_STRING

#define PG_MAGIC_FUNCTION_NAME_STRING   "Pg_magic_func"

Definition at line 486 of file fmgr.h.

◆ PG_MODULE_MAGIC

#define PG_MODULE_MAGIC
Value:
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
#define PG_MODULE_MAGIC_DATA
Definition: fmgr.h:465
#define PG_MAGIC_FUNCTION_NAME
Definition: fmgr.h:485

Definition at line 488 of file fmgr.h.

◆ PG_MODULE_MAGIC_DATA

#define PG_MODULE_MAGIC_DATA
Value:
{ \
sizeof(Pg_magic_struct), \
PG_VERSION_NUM / 100, \
FUNC_MAX_ARGS, \
INDEX_MAX_KEYS, \
NAMEDATALEN, \
FLOAT8PASSBYVAL, \
FMGR_ABI_EXTRA, \
}

Definition at line 465 of file fmgr.h.

◆ PG_NARGS

#define PG_NARGS ( )    (fcinfo->nargs)

Definition at line 203 of file fmgr.h.

◆ PG_RETURN_BOOL

#define PG_RETURN_BOOL (   x)    return BoolGetDatum(x)

Definition at line 359 of file fmgr.h.

◆ PG_RETURN_BPCHAR_P

#define PG_RETURN_BPCHAR_P (   x)    PG_RETURN_POINTER(x)

Definition at line 373 of file fmgr.h.

◆ PG_RETURN_BYTEA_P

#define PG_RETURN_BYTEA_P (   x)    PG_RETURN_POINTER(x)

Definition at line 371 of file fmgr.h.

◆ PG_RETURN_CHAR

#define PG_RETURN_CHAR (   x)    return CharGetDatum(x)

Definition at line 358 of file fmgr.h.

◆ PG_RETURN_CSTRING

#define PG_RETURN_CSTRING (   x)    return CStringGetDatum(x)

Definition at line 362 of file fmgr.h.

◆ PG_RETURN_DATUM

#define PG_RETURN_DATUM (   x)    return (x)

Definition at line 353 of file fmgr.h.

◆ PG_RETURN_FLOAT4

#define PG_RETURN_FLOAT4 (   x)    return Float4GetDatum(x)

Definition at line 366 of file fmgr.h.

◆ PG_RETURN_FLOAT8

#define PG_RETURN_FLOAT8 (   x)    return Float8GetDatum(x)

Definition at line 367 of file fmgr.h.

◆ PG_RETURN_HEAPTUPLEHEADER

#define PG_RETURN_HEAPTUPLEHEADER (   x)    return HeapTupleHeaderGetDatum(x)

Definition at line 375 of file fmgr.h.

◆ PG_RETURN_INT16

#define PG_RETURN_INT16 (   x)    return Int16GetDatum(x)

Definition at line 356 of file fmgr.h.

◆ PG_RETURN_INT32

#define PG_RETURN_INT32 (   x)    return Int32GetDatum(x)

Definition at line 354 of file fmgr.h.

◆ PG_RETURN_INT64

#define PG_RETURN_INT64 (   x)    return Int64GetDatum(x)

Definition at line 368 of file fmgr.h.

◆ PG_RETURN_NAME

#define PG_RETURN_NAME (   x)    return NameGetDatum(x)

Definition at line 363 of file fmgr.h.

◆ PG_RETURN_NULL

#define PG_RETURN_NULL ( )     do { fcinfo->isnull = true; return (Datum) 0; } while (0)

Definition at line 345 of file fmgr.h.

◆ PG_RETURN_OID

#define PG_RETURN_OID (   x)    return ObjectIdGetDatum(x)

Definition at line 360 of file fmgr.h.

◆ PG_RETURN_POINTER

#define PG_RETURN_POINTER (   x)    return PointerGetDatum(x)

Definition at line 361 of file fmgr.h.

◆ PG_RETURN_TEXT_P

#define PG_RETURN_TEXT_P (   x)    PG_RETURN_POINTER(x)

Definition at line 372 of file fmgr.h.

◆ PG_RETURN_TRANSACTIONID

#define PG_RETURN_TRANSACTIONID (   x)    return TransactionIdGetDatum(x)

Definition at line 364 of file fmgr.h.

◆ PG_RETURN_UINT16

#define PG_RETURN_UINT16 (   x)    return UInt16GetDatum(x)

Definition at line 357 of file fmgr.h.

◆ PG_RETURN_UINT32

#define PG_RETURN_UINT32 (   x)    return UInt32GetDatum(x)

Definition at line 355 of file fmgr.h.

◆ PG_RETURN_UINT64

#define PG_RETURN_UINT64 (   x)    return UInt64GetDatum(x)

Definition at line 369 of file fmgr.h.

◆ PG_RETURN_VARCHAR_P

#define PG_RETURN_VARCHAR_P (   x)    PG_RETURN_POINTER(x)

Definition at line 374 of file fmgr.h.

◆ PG_RETURN_VOID

#define PG_RETURN_VOID ( )    return (Datum) 0

Definition at line 349 of file fmgr.h.

◆ SizeForFunctionCallInfo

#define SizeForFunctionCallInfo (   nargs)
Value:

Definition at line 102 of file fmgr.h.

Typedef Documentation

◆ fmAggrefPtr

typedef struct Aggref* fmAggrefPtr

Definition at line 23 of file fmgr.h.

◆ fmExprContextCallbackFunction

typedef void(* fmExprContextCallbackFunction) (Datum arg)

Definition at line 26 of file fmgr.h.

◆ fmgr_hook_type

typedef void(* fmgr_hook_type) (FmgrHookEventType event, FmgrInfo *flinfo, Datum *arg)

Definition at line 773 of file fmgr.h.

◆ FmgrHookEventType

◆ FmgrInfo

typedef struct FmgrInfo FmgrInfo

◆ fmNodePtr

typedef struct Node* fmNodePtr

Definition at line 22 of file fmgr.h.

◆ fmStringInfo

typedef struct StringInfoData* fmStringInfo

Definition at line 29 of file fmgr.h.

◆ FunctionCallInfo

Definition at line 38 of file fmgr.h.

◆ FunctionCallInfoBaseData

◆ needs_fmgr_hook_type

typedef bool(* needs_fmgr_hook_type) (Oid fn_oid)

Definition at line 771 of file fmgr.h.

◆ PGFInfoFunction

typedef const Pg_finfo_record*(* PGFInfoFunction) (void)

Definition at line 401 of file fmgr.h.

◆ PGFunction

typedef Datum(* PGFunction) (FunctionCallInfo fcinfo)

Definition at line 40 of file fmgr.h.

◆ PGModuleMagicFunction

typedef const Pg_magic_struct*(* PGModuleMagicFunction) (void)

Definition at line 483 of file fmgr.h.

Enumeration Type Documentation

◆ FmgrHookEventType

Enumerator
FHET_START 
FHET_END 
FHET_ABORT 

Definition at line 764 of file fmgr.h.

765 {
766  FHET_START,
767  FHET_END,
768  FHET_ABORT
FmgrHookEventType
Definition: fmgr.h:765
@ FHET_END
Definition: fmgr.h:767
@ FHET_ABORT
Definition: fmgr.h:768
@ FHET_START
Definition: fmgr.h:766

Function Documentation

◆ AggCheckCallContext()

int AggCheckCallContext ( FunctionCallInfo  fcinfo,
MemoryContext aggcontext 
)

Definition at line 4488 of file nodeAgg.c.

4489 {
4490  if (fcinfo->context && IsA(fcinfo->context, AggState))
4491  {
4492  if (aggcontext)
4493  {
4494  AggState *aggstate = ((AggState *) fcinfo->context);
4495  ExprContext *cxt = aggstate->curaggcontext;
4496 
4497  *aggcontext = cxt->ecxt_per_tuple_memory;
4498  }
4499  return AGG_CONTEXT_AGGREGATE;
4500  }
4501  if (fcinfo->context && IsA(fcinfo->context, WindowAggState))
4502  {
4503  if (aggcontext)
4504  *aggcontext = ((WindowAggState *) fcinfo->context)->curaggcontext;
4505  return AGG_CONTEXT_WINDOW;
4506  }
4507 
4508  /* this is just to prevent "uninitialized variable" warnings */
4509  if (aggcontext)
4510  *aggcontext = NULL;
4511  return 0;
4512 }
#define AGG_CONTEXT_WINDOW
Definition: fmgr.h:744
#define AGG_CONTEXT_AGGREGATE
Definition: fmgr.h:743
#define IsA(nodeptr, _type_)
Definition: nodes.h:590
ExprContext * curaggcontext
Definition: execnodes.h:2300
MemoryContext ecxt_per_tuple_memory
Definition: execnodes.h:239
fmNodePtr context
Definition: fmgr.h:88

References AGG_CONTEXT_AGGREGATE, AGG_CONTEXT_WINDOW, FunctionCallInfoBaseData::context, AggState::curaggcontext, ExprContext::ecxt_per_tuple_memory, and IsA.

Referenced by array_agg_array_finalfn(), array_agg_array_transfn(), array_agg_finalfn(), array_agg_transfn(), bytea_string_agg_finalfn(), fetch_array_arg_replace_nulls(), float4_accum(), float8_accum(), float8_combine(), float8_regr_accum(), float8_regr_combine(), hypothetical_dense_rank_final(), hypothetical_rank_common(), int2_avg_accum(), int2_avg_accum_inv(), int2_sum(), int4_avg_accum(), int4_avg_accum_inv(), int4_avg_combine(), int4_sum(), int8_avg_combine(), int8_avg_deserialize(), int8_avg_serialize(), int8dec(), int8inc(), json_agg_finalfn(), json_agg_transfn(), json_object_agg_finalfn(), json_object_agg_transfn(), jsonb_agg_finalfn(), jsonb_agg_transfn(), jsonb_object_agg_finalfn(), jsonb_object_agg_transfn(), makeBoolAggState(), makeNumericAggState(), makeStringAggState(), mode_final(), multirange_intersect_agg_transfn(), numeric_avg_combine(), numeric_avg_deserialize(), numeric_avg_serialize(), numeric_combine(), numeric_deserialize(), numeric_poly_combine(), numeric_poly_deserialize(), numeric_poly_serialize(), numeric_serialize(), ordered_set_startup(), percentile_cont_final_common(), percentile_cont_multi_final_common(), percentile_disc_final(), percentile_disc_multi_final(), range_agg_finalfn(), range_agg_transfn(), range_intersect_agg_transfn(), and string_agg_finalfn().

◆ AggGetAggref()

fmAggrefPtr AggGetAggref ( FunctionCallInfo  fcinfo)

Definition at line 4532 of file nodeAgg.c.

4533 {
4534  if (fcinfo->context && IsA(fcinfo->context, AggState))
4535  {
4536  AggState *aggstate = (AggState *) fcinfo->context;
4537  AggStatePerAgg curperagg;
4538  AggStatePerTrans curpertrans;
4539 
4540  /* check curperagg (valid when in a final function) */
4541  curperagg = aggstate->curperagg;
4542 
4543  if (curperagg)
4544  return curperagg->aggref;
4545 
4546  /* check curpertrans (valid when in a transition function) */
4547  curpertrans = aggstate->curpertrans;
4548 
4549  if (curpertrans)
4550  return curpertrans->aggref;
4551  }
4552  return NULL;
4553 }
Aggref * aggref
Definition: nodeAgg.h:44
AggStatePerTrans curpertrans
Definition: execnodes.h:2303
AggStatePerAgg curperagg
Definition: execnodes.h:2301

References AggStatePerTransData::aggref, FunctionCallInfoBaseData::context, AggState::curperagg, AggState::curpertrans, if(), and IsA.

Referenced by ordered_set_startup().

◆ AggGetTempMemoryContext()

MemoryContext AggGetTempMemoryContext ( FunctionCallInfo  fcinfo)

Definition at line 4566 of file nodeAgg.c.

4567 {
4568  if (fcinfo->context && IsA(fcinfo->context, AggState))
4569  {
4570  AggState *aggstate = (AggState *) fcinfo->context;
4571 
4572  return aggstate->tmpcontext->ecxt_per_tuple_memory;
4573  }
4574  return NULL;
4575 }
ExprContext * tmpcontext
Definition: execnodes.h:2298

References FunctionCallInfoBaseData::context, ExprContext::ecxt_per_tuple_memory, IsA, and AggState::tmpcontext.

◆ AggRegisterCallback()

void AggRegisterCallback ( FunctionCallInfo  fcinfo,
fmExprContextCallbackFunction  func,
Datum  arg 
)

Definition at line 4631 of file nodeAgg.c.

4634 {
4635  if (fcinfo->context && IsA(fcinfo->context, AggState))
4636  {
4637  AggState *aggstate = (AggState *) fcinfo->context;
4638  ExprContext *cxt = aggstate->curaggcontext;
4639 
4640  RegisterExprContextCallback(cxt, func, arg);
4641 
4642  return;
4643  }
4644  elog(ERROR, "aggregate function cannot register a callback in this context");
4645 }
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:925
void * arg

References arg, FunctionCallInfoBaseData::context, AggState::curaggcontext, elog, ERROR, IsA, and RegisterExprContextCallback().

Referenced by ordered_set_startup().

◆ AggStateIsShared()

bool AggStateIsShared ( FunctionCallInfo  fcinfo)

Definition at line 4592 of file nodeAgg.c.

4593 {
4594  if (fcinfo->context && IsA(fcinfo->context, AggState))
4595  {
4596  AggState *aggstate = (AggState *) fcinfo->context;
4597  AggStatePerAgg curperagg;
4598  AggStatePerTrans curpertrans;
4599 
4600  /* check curperagg (valid when in a final function) */
4601  curperagg = aggstate->curperagg;
4602 
4603  if (curperagg)
4604  return aggstate->pertrans[curperagg->transno].aggshared;
4605 
4606  /* check curpertrans (valid when in a transition function) */
4607  curpertrans = aggstate->curpertrans;
4608 
4609  if (curpertrans)
4610  return curpertrans->aggshared;
4611  }
4612  return true;
4613 }
AggStatePerTrans pertrans
Definition: execnodes.h:2295

References AggStatePerTransData::aggshared, FunctionCallInfoBaseData::context, AggState::curperagg, AggState::curpertrans, if(), IsA, and AggState::pertrans.

Referenced by ordered_set_startup().

◆ CallerFInfoFunctionCall1()

Datum CallerFInfoFunctionCall1 ( PGFunction  func,
FmgrInfo flinfo,
Oid  collation,
Datum  arg1 
)

Definition at line 1064 of file fmgr.c.

1065 {
1066  LOCAL_FCINFO(fcinfo, 1);
1067  Datum result;
1068 
1069  InitFunctionCallInfoData(*fcinfo, flinfo, 1, collation, NULL, NULL);
1070 
1071  fcinfo->args[0].value = arg1;
1072  fcinfo->args[0].isnull = false;
1073 
1074  result = (*func) (fcinfo);
1075 
1076  /* Check for null result, since caller is clearly not expecting one */
1077  if (fcinfo->isnull)
1078  elog(ERROR, "function %p returned NULL", (void *) func);
1079 
1080  return result;
1081 }
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110

References elog, ERROR, fmgr_security_definer_cache::flinfo, InitFunctionCallInfoData, and LOCAL_FCINFO.

◆ CallerFInfoFunctionCall2()

Datum CallerFInfoFunctionCall2 ( PGFunction  func,
FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 1084 of file fmgr.c.

1085 {
1086  LOCAL_FCINFO(fcinfo, 2);
1087  Datum result;
1088 
1089  InitFunctionCallInfoData(*fcinfo, flinfo, 2, collation, NULL, NULL);
1090 
1091  fcinfo->args[0].value = arg1;
1092  fcinfo->args[0].isnull = false;
1093  fcinfo->args[1].value = arg2;
1094  fcinfo->args[1].isnull = false;
1095 
1096  result = (*func) (fcinfo);
1097 
1098  /* Check for null result, since caller is clearly not expecting one */
1099  if (fcinfo->isnull)
1100  elog(ERROR, "function %p returned NULL", (void *) func);
1101 
1102  return result;
1103 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by gbt_enumge(), gbt_enumgt(), gbt_enumkey_cmp(), gbt_enumle(), gbt_enumlt(), gin_btree_compare_prefix(), and gin_enum_cmp().

◆ CheckFunctionValidatorAccess()

bool CheckFunctionValidatorAccess ( Oid  validatorOid,
Oid  functionOid 
)

Definition at line 2035 of file fmgr.c.

2036 {
2037  HeapTuple procTup;
2038  HeapTuple langTup;
2039  Form_pg_proc procStruct;
2040  Form_pg_language langStruct;
2041  AclResult aclresult;
2042 
2043  /*
2044  * Get the function's pg_proc entry. Throw a user-facing error for bad
2045  * OID, because validators can be called with user-specified OIDs.
2046  */
2047  procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionOid));
2048  if (!HeapTupleIsValid(procTup))
2049  ereport(ERROR,
2050  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2051  errmsg("function with OID %u does not exist", functionOid)));
2052  procStruct = (Form_pg_proc) GETSTRUCT(procTup);
2053 
2054  /*
2055  * Fetch pg_language entry to know if this is the correct validation
2056  * function for that pg_proc entry.
2057  */
2058  langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang));
2059  if (!HeapTupleIsValid(langTup))
2060  elog(ERROR, "cache lookup failed for language %u", procStruct->prolang);
2061  langStruct = (Form_pg_language) GETSTRUCT(langTup);
2062 
2063  if (langStruct->lanvalidator != validatorOid)
2064  ereport(ERROR,
2065  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2066  errmsg("language validation function %u called for language %u instead of %u",
2067  validatorOid, procStruct->prolang,
2068  langStruct->lanvalidator)));
2069 
2070  /* first validate that we have permissions to use the language */
2071  aclresult = pg_language_aclcheck(procStruct->prolang, GetUserId(),
2072  ACL_USAGE);
2073  if (aclresult != ACLCHECK_OK)
2074  aclcheck_error(aclresult, OBJECT_LANGUAGE,
2075  NameStr(langStruct->lanname));
2076 
2077  /*
2078  * Check whether we are allowed to execute the function itself. If we can
2079  * execute it, there should be no possible side-effect of
2080  * compiling/validation that execution can't have.
2081  */
2082  aclresult = pg_proc_aclcheck(functionOid, GetUserId(), ACL_EXECUTE);
2083  if (aclresult != ACLCHECK_OK)
2084  aclcheck_error(aclresult, OBJECT_FUNCTION, NameStr(procStruct->proname));
2085 
2086  ReleaseSysCache(procTup);
2087  ReleaseSysCache(langTup);
2088 
2089  return true;
2090 }
AclResult
Definition: acl.h:178
@ ACLCHECK_OK
Definition: acl.h:179
AclResult pg_language_aclcheck(Oid lang_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4732
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:3308
AclResult pg_proc_aclcheck(Oid proc_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4720
#define NameStr(name)
Definition: c.h:681
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ereport(elevel,...)
Definition: elog.h:143
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define GETSTRUCT(TUP)
Definition: htup_details.h:649
Oid GetUserId(void)
Definition: miscinit.c:495
#define ACL_USAGE
Definition: parsenodes.h:90
@ OBJECT_LANGUAGE
Definition: parsenodes.h:1810
@ OBJECT_FUNCTION
Definition: parsenodes.h:1808
#define ACL_EXECUTE
Definition: parsenodes.h:89
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1198
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1150
@ PROCOID
Definition: syscache.h:77
@ LANGOID
Definition: syscache.h:68

References ACL_EXECUTE, ACL_USAGE, aclcheck_error(), ACLCHECK_OK, elog, ereport, errcode(), errmsg(), ERROR, GETSTRUCT, GetUserId(), HeapTupleIsValid, LANGOID, NameStr, OBJECT_FUNCTION, OBJECT_LANGUAGE, ObjectIdGetDatum, pg_language_aclcheck(), pg_proc_aclcheck(), PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by fmgr_c_validator(), fmgr_internal_validator(), fmgr_sql_validator(), plperl_validator(), plpgsql_validator(), and plpython_validator().

◆ clear_external_function_hash()

void clear_external_function_hash ( void *  filehandle)

Definition at line 592 of file fmgr.c.

593 {
594  if (CFuncHash)
596  CFuncHash = NULL;
597 }
void hash_destroy(HTAB *hashp)
Definition: dynahash.c:862
static HTAB * CFuncHash
Definition: fmgr.c:54

References CFuncHash, and hash_destroy().

Referenced by internal_unload_library().

◆ DirectFunctionCall1Coll()

Datum DirectFunctionCall1Coll ( PGFunction  func,
Oid  collation,
Datum  arg1 
)

Definition at line 791 of file fmgr.c.

792 {
793  LOCAL_FCINFO(fcinfo, 1);
794  Datum result;
795 
796  InitFunctionCallInfoData(*fcinfo, NULL, 1, collation, NULL, NULL);
797 
798  fcinfo->args[0].value = arg1;
799  fcinfo->args[0].isnull = false;
800 
801  result = (*func) (fcinfo);
802 
803  /* Check for null result, since caller is clearly not expecting one */
804  if (fcinfo->isnull)
805  elog(ERROR, "function %p returned NULL", (void *) func);
806 
807  return result;
808 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by Generic_Text_IC_like(), libpqrcv_create_slot(), and texthashfast().

◆ DirectFunctionCall2Coll()

Datum DirectFunctionCall2Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 811 of file fmgr.c.

812 {
813  LOCAL_FCINFO(fcinfo, 2);
814  Datum result;
815 
816  InitFunctionCallInfoData(*fcinfo, NULL, 2, collation, NULL, NULL);
817 
818  fcinfo->args[0].value = arg1;
819  fcinfo->args[0].isnull = false;
820  fcinfo->args[1].value = arg2;
821  fcinfo->args[1].isnull = false;
822 
823  result = (*func) (fcinfo);
824 
825  /* Check for null result, since caller is clearly not expecting one */
826  if (fcinfo->isnull)
827  elog(ERROR, "function %p returned NULL", (void *) func);
828 
829  return result;
830 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by gbt_bpcharcmp(), gbt_bpchareq(), gbt_bpcharge(), gbt_bpchargt(), gbt_bpcharle(), gbt_bpcharlt(), gbt_textcmp(), gbt_texteq(), gbt_textge(), gbt_textgt(), gbt_textle(), gbt_textlt(), spg_text_leaf_consistent(), text_isequal(), and texteqfast().

◆ DirectFunctionCall3Coll()

Datum DirectFunctionCall3Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3 
)

Definition at line 833 of file fmgr.c.

835 {
836  LOCAL_FCINFO(fcinfo, 3);
837  Datum result;
838 
839  InitFunctionCallInfoData(*fcinfo, NULL, 3, collation, NULL, NULL);
840 
841  fcinfo->args[0].value = arg1;
842  fcinfo->args[0].isnull = false;
843  fcinfo->args[1].value = arg2;
844  fcinfo->args[1].isnull = false;
845  fcinfo->args[2].value = arg3;
846  fcinfo->args[2].isnull = false;
847 
848  result = (*func) (fcinfo);
849 
850  /* Check for null result, since caller is clearly not expecting one */
851  if (fcinfo->isnull)
852  elog(ERROR, "function %p returned NULL", (void *) func);
853 
854  return result;
855 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by execute_extension_script().

◆ DirectFunctionCall4Coll()

Datum DirectFunctionCall4Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4 
)

Definition at line 858 of file fmgr.c.

860 {
861  LOCAL_FCINFO(fcinfo, 4);
862  Datum result;
863 
864  InitFunctionCallInfoData(*fcinfo, NULL, 4, collation, NULL, NULL);
865 
866  fcinfo->args[0].value = arg1;
867  fcinfo->args[0].isnull = false;
868  fcinfo->args[1].value = arg2;
869  fcinfo->args[1].isnull = false;
870  fcinfo->args[2].value = arg3;
871  fcinfo->args[2].isnull = false;
872  fcinfo->args[3].value = arg4;
873  fcinfo->args[3].isnull = false;
874 
875  result = (*func) (fcinfo);
876 
877  /* Check for null result, since caller is clearly not expecting one */
878  if (fcinfo->isnull)
879  elog(ERROR, "function %p returned NULL", (void *) func);
880 
881  return result;
882 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by execute_extension_script().

◆ DirectFunctionCall5Coll()

Datum DirectFunctionCall5Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5 
)

Definition at line 885 of file fmgr.c.

887 {
888  LOCAL_FCINFO(fcinfo, 5);
889  Datum result;
890 
891  InitFunctionCallInfoData(*fcinfo, NULL, 5, collation, NULL, NULL);
892 
893  fcinfo->args[0].value = arg1;
894  fcinfo->args[0].isnull = false;
895  fcinfo->args[1].value = arg2;
896  fcinfo->args[1].isnull = false;
897  fcinfo->args[2].value = arg3;
898  fcinfo->args[2].isnull = false;
899  fcinfo->args[3].value = arg4;
900  fcinfo->args[3].isnull = false;
901  fcinfo->args[4].value = arg5;
902  fcinfo->args[4].isnull = false;
903 
904  result = (*func) (fcinfo);
905 
906  /* Check for null result, since caller is clearly not expecting one */
907  if (fcinfo->isnull)
908  elog(ERROR, "function %p returned NULL", (void *) func);
909 
910  return result;
911 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by neqjoinsel().

◆ DirectFunctionCall6Coll()

Datum DirectFunctionCall6Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6 
)

Definition at line 914 of file fmgr.c.

917 {
918  LOCAL_FCINFO(fcinfo, 6);
919  Datum result;
920 
921  InitFunctionCallInfoData(*fcinfo, NULL, 6, collation, NULL, NULL);
922 
923  fcinfo->args[0].value = arg1;
924  fcinfo->args[0].isnull = false;
925  fcinfo->args[1].value = arg2;
926  fcinfo->args[1].isnull = false;
927  fcinfo->args[2].value = arg3;
928  fcinfo->args[2].isnull = false;
929  fcinfo->args[3].value = arg4;
930  fcinfo->args[3].isnull = false;
931  fcinfo->args[4].value = arg5;
932  fcinfo->args[4].isnull = false;
933  fcinfo->args[5].value = arg6;
934  fcinfo->args[5].isnull = false;
935 
936  result = (*func) (fcinfo);
937 
938  /* Check for null result, since caller is clearly not expecting one */
939  if (fcinfo->isnull)
940  elog(ERROR, "function %p returned NULL", (void *) func);
941 
942  return result;
943 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

◆ DirectFunctionCall7Coll()

Datum DirectFunctionCall7Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7 
)

Definition at line 946 of file fmgr.c.

949 {
950  LOCAL_FCINFO(fcinfo, 7);
951  Datum result;
952 
953  InitFunctionCallInfoData(*fcinfo, NULL, 7, collation, NULL, NULL);
954 
955  fcinfo->args[0].value = arg1;
956  fcinfo->args[0].isnull = false;
957  fcinfo->args[1].value = arg2;
958  fcinfo->args[1].isnull = false;
959  fcinfo->args[2].value = arg3;
960  fcinfo->args[2].isnull = false;
961  fcinfo->args[3].value = arg4;
962  fcinfo->args[3].isnull = false;
963  fcinfo->args[4].value = arg5;
964  fcinfo->args[4].isnull = false;
965  fcinfo->args[5].value = arg6;
966  fcinfo->args[5].isnull = false;
967  fcinfo->args[6].value = arg7;
968  fcinfo->args[6].isnull = false;
969 
970  result = (*func) (fcinfo);
971 
972  /* Check for null result, since caller is clearly not expecting one */
973  if (fcinfo->isnull)
974  elog(ERROR, "function %p returned NULL", (void *) func);
975 
976  return result;
977 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

◆ DirectFunctionCall8Coll()

Datum DirectFunctionCall8Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7,
Datum  arg8 
)

Definition at line 980 of file fmgr.c.

983 {
984  LOCAL_FCINFO(fcinfo, 8);
985  Datum result;
986 
987  InitFunctionCallInfoData(*fcinfo, NULL, 8, collation, NULL, NULL);
988 
989  fcinfo->args[0].value = arg1;
990  fcinfo->args[0].isnull = false;
991  fcinfo->args[1].value = arg2;
992  fcinfo->args[1].isnull = false;
993  fcinfo->args[2].value = arg3;
994  fcinfo->args[2].isnull = false;
995  fcinfo->args[3].value = arg4;
996  fcinfo->args[3].isnull = false;
997  fcinfo->args[4].value = arg5;
998  fcinfo->args[4].isnull = false;
999  fcinfo->args[5].value = arg6;
1000  fcinfo->args[5].isnull = false;
1001  fcinfo->args[6].value = arg7;
1002  fcinfo->args[6].isnull = false;
1003  fcinfo->args[7].value = arg8;
1004  fcinfo->args[7].isnull = false;
1005 
1006  result = (*func) (fcinfo);
1007 
1008  /* Check for null result, since caller is clearly not expecting one */
1009  if (fcinfo->isnull)
1010  elog(ERROR, "function %p returned NULL", (void *) func);
1011 
1012  return result;
1013 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

◆ DirectFunctionCall9Coll()

Datum DirectFunctionCall9Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7,
Datum  arg8,
Datum  arg9 
)

Definition at line 1016 of file fmgr.c.

1020 {
1021  LOCAL_FCINFO(fcinfo, 9);
1022  Datum result;
1023 
1024  InitFunctionCallInfoData(*fcinfo, NULL, 9, collation, NULL, NULL);
1025 
1026  fcinfo->args[0].value = arg1;
1027  fcinfo->args[0].isnull = false;
1028  fcinfo->args[1].value = arg2;
1029  fcinfo->args[1].isnull = false;
1030  fcinfo->args[2].value = arg3;
1031  fcinfo->args[2].isnull = false;
1032  fcinfo->args[3].value = arg4;
1033  fcinfo->args[3].isnull = false;
1034  fcinfo->args[4].value = arg5;
1035  fcinfo->args[4].isnull = false;
1036  fcinfo->args[5].value = arg6;
1037  fcinfo->args[5].isnull = false;
1038  fcinfo->args[6].value = arg7;
1039  fcinfo->args[6].isnull = false;
1040  fcinfo->args[7].value = arg8;
1041  fcinfo->args[7].isnull = false;
1042  fcinfo->args[8].value = arg9;
1043  fcinfo->args[8].isnull = false;
1044 
1045  result = (*func) (fcinfo);
1046 
1047  /* Check for null result, since caller is clearly not expecting one */
1048  if (fcinfo->isnull)
1049  elog(ERROR, "function %p returned NULL", (void *) func);
1050 
1051  return result;
1052 }

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

◆ EstimateLibraryStateSpace()

Size EstimateLibraryStateSpace ( void  )

Definition at line 724 of file dfmgr.c.

725 {
726  DynamicFileList *file_scanner;
727  Size size = 1;
728 
729  for (file_scanner = file_list;
730  file_scanner != NULL;
731  file_scanner = file_scanner->next)
732  size = add_size(size, strlen(file_scanner->filename) + 1);
733 
734  return size;
735 }
size_t Size
Definition: c.h:540
static DynamicFileList * file_list
Definition: dfmgr.c:67
Size add_size(Size s1, Size s2)
Definition: shmem.c:502
Definition: dfmgr.c:56
struct df_files * next
Definition: dfmgr.c:57
char filename[FLEXIBLE_ARRAY_MEMBER]
Definition: dfmgr.c:64

References add_size(), file_list, df_files::filename, and df_files::next.

Referenced by InitializeParallelDSM().

◆ fetch_finfo_record()

const Pg_finfo_record* fetch_finfo_record ( void *  filehandle,
const char *  funcname 
)

Definition at line 469 of file fmgr.c.

470 {
471  char *infofuncname;
472  PGFInfoFunction infofunc;
473  const Pg_finfo_record *inforec;
474 
475  infofuncname = psprintf("pg_finfo_%s", funcname);
476 
477  /* Try to look up the info function */
478  infofunc = (PGFInfoFunction) lookup_external_function(filehandle,
479  infofuncname);
480  if (infofunc == NULL)
481  {
482  ereport(ERROR,
483  (errcode(ERRCODE_UNDEFINED_FUNCTION),
484  errmsg("could not find function information for function \"%s\"",
485  funcname),
486  errhint("SQL-callable functions need an accompanying PG_FUNCTION_INFO_V1(funcname).")));
487  return NULL; /* silence compiler */
488  }
489 
490  /* Found, so call it */
491  inforec = (*infofunc) ();
492 
493  /* Validate result as best we can */
494  if (inforec == NULL)
495  elog(ERROR, "null result from info function \"%s\"", infofuncname);
496  switch (inforec->api_version)
497  {
498  case 1:
499  /* OK, no additional fields to validate */
500  break;
501  default:
502  ereport(ERROR,
503  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
504  errmsg("unrecognized API version %d reported by info function \"%s\"",
505  inforec->api_version, infofuncname)));
506  break;
507  }
508 
509  pfree(infofuncname);
510  return inforec;
511 }
void * lookup_external_function(void *filehandle, const char *funcname)
Definition: dfmgr.c:171
int errhint(const char *fmt,...)
Definition: elog.c:1151
const Pg_finfo_record *(* PGFInfoFunction)(void)
Definition: fmgr.h:401
void pfree(void *pointer)
Definition: mcxt.c:1169
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
int api_version
Definition: fmgr.h:396

References Pg_finfo_record::api_version, elog, ereport, errcode(), errhint(), errmsg(), ERROR, lookup_external_function(), pfree(), and psprintf().

Referenced by fmgr_c_validator(), and fmgr_info_C_lang().

◆ find_rendezvous_variable()

void** find_rendezvous_variable ( const char *  varName)

Definition at line 686 of file dfmgr.c.

687 {
688  static HTAB *rendezvousHash = NULL;
689 
690  rendezvousHashEntry *hentry;
691  bool found;
692 
693  /* Create a hashtable if we haven't already done so in this process */
694  if (rendezvousHash == NULL)
695  {
696  HASHCTL ctl;
697 
698  ctl.keysize = NAMEDATALEN;
699  ctl.entrysize = sizeof(rendezvousHashEntry);
700  rendezvousHash = hash_create("Rendezvous variable hash",
701  16,
702  &ctl,
704  }
705 
706  /* Find or create the hashtable entry for this varName */
707  hentry = (rendezvousHashEntry *) hash_search(rendezvousHash,
708  varName,
709  HASH_ENTER,
710  &found);
711 
712  /* Initialize to NULL if first time */
713  if (!found)
714  hentry->varValue = NULL;
715 
716  return &hentry->varValue;
717 }
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:954
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:349
#define HASH_STRINGS
Definition: hsearch.h:96
@ HASH_ENTER
Definition: hsearch.h:114
#define HASH_ELEM
Definition: hsearch.h:95
#define NAMEDATALEN
Size keysize
Definition: hsearch.h:75
Size entrysize
Definition: hsearch.h:76
Definition: dynahash.c:220
void * varValue
Definition: dfmgr.c:48

References HASHCTL::entrysize, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HASH_STRINGS, HASHCTL::keysize, NAMEDATALEN, and rendezvousHashEntry::varValue.

Referenced by _PG_init().

◆ fmgr_info()

void fmgr_info ( Oid  functionId,
FmgrInfo finfo 
)

Definition at line 126 of file fmgr.c.

127 {
128  fmgr_info_cxt_security(functionId, finfo, CurrentMemoryContext, false);
129 }
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:146
MemoryContext CurrentMemoryContext
Definition: mcxt.c:42

References CurrentMemoryContext, and fmgr_info_cxt_security().

Referenced by _bt_find_extreme_element(), _bt_sort_array_elements(), _sv_to_datum_finfo(), BeginCopyFrom(), brin_minmax_multi_summary_out(), brin_page_items(), build_pertrans_for_aggref(), call_pltcl_start_proc(), compute_distinct_stats(), create_foreign_modify(), DoCopyTo(), eqjoinsel_inner(), eqjoinsel_semi(), EventTriggerInvoke(), ExecBuildGroupingEqual(), ExecBuildParamSetEqual(), ExecCallTriggerFunc(), ExecHashTableCreate(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitMemoize(), ExecInitSubPlan(), ExecInitTableFuncScan(), ExecInitWindowAgg(), execTuplesHashPrepare(), ExecuteCallStmt(), fetch_fp_info(), generic_restriction_selectivity(), get_stats_slot_range(), gincost_pattern(), hash_array(), inet_mcv_join_sel(), initialize_peragg(), match_pattern_prefix(), mcv_get_match_bitmap(), networkjoinsel_semi(), networksel(), OidFunctionCall0Coll(), OidFunctionCall1Coll(), OidFunctionCall2Coll(), OidFunctionCall3Coll(), OidFunctionCall4Coll(), OidFunctionCall5Coll(), OidFunctionCall6Coll(), OidFunctionCall7Coll(), OidFunctionCall8Coll(), OidFunctionCall9Coll(), OidInputFunctionCall(), OidOutputFunctionCall(), OidReceiveFunctionCall(), OidSendFunctionCall(), patternsel_common(), pg_get_catalog_foreign_keys(), pg_stats_ext_mcvlist_items(), plperl_ref_from_pg_array(), prefix_selectivity(), prepare_query_params(), printtup_prepare_info(), scalararraysel(), scalarineqsel(), ScanKeyEntryInitialize(), ScanKeyInit(), text_format(), TupleDescGetAttInMetadata(), and var_eq_const().

◆ fmgr_info_copy()

void fmgr_info_copy ( FmgrInfo dstinfo,
FmgrInfo srcinfo,
MemoryContext  destcxt 
)

Definition at line 608 of file fmgr.c.

610 {
611  memcpy(dstinfo, srcinfo, sizeof(FmgrInfo));
612  dstinfo->fn_mcxt = destcxt;
613  dstinfo->fn_extra = NULL;
614 }
Definition: fmgr.h:57
void * fn_extra
Definition: fmgr.h:64
MemoryContext fn_mcxt
Definition: fmgr.h:65

References FmgrInfo::fn_extra, and FmgrInfo::fn_mcxt.

Referenced by bloom_get_procinfo(), bringetbitmap(), find_partition_scheme(), gistrescan(), inclusion_get_procinfo(), initBloomState(), initGinState(), initGISTstate(), minmax_multi_get_procinfo(), perform_pruning_base_step(), satisfies_hash_partition(), ScanKeyEntryInitializeWithInfo(), and spgbeginscan().

◆ fmgr_info_cxt()

◆ fmgr_internal_function()

Oid fmgr_internal_function ( const char *  proname)

Definition at line 623 of file fmgr.c.

624 {
625  const FmgrBuiltin *fbp = fmgr_lookupByName(proname);
626 
627  if (fbp == NULL)
628  return InvalidOid;
629  return fbp->foid;
630 }
static const FmgrBuiltin * fmgr_lookupByName(const char *name)
Definition: fmgr.c:100
NameData proname
Definition: pg_proc.h:35
#define InvalidOid
Definition: postgres_ext.h:36
Oid foid
Definition: fmgrtab.h:27

References fmgr_lookupByName(), FmgrBuiltin::foid, InvalidOid, and proname.

Referenced by fmgr_internal_validator().

◆ fmgr_symbol()

void fmgr_symbol ( Oid  functionId,
char **  mod,
char **  fn 
)

Definition at line 283 of file fmgr.c.

284 {
285  HeapTuple procedureTuple;
286  Form_pg_proc procedureStruct;
287  bool isnull;
288  Datum prosrcattr;
289  Datum probinattr;
290 
291  procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
292  if (!HeapTupleIsValid(procedureTuple))
293  elog(ERROR, "cache lookup failed for function %u", functionId);
294  procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
295 
296  if (procedureStruct->prosecdef ||
297  !heap_attisnull(procedureTuple, Anum_pg_proc_proconfig, NULL) ||
298  FmgrHookIsNeeded(functionId))
299  {
300  *mod = NULL; /* core binary */
301  *fn = pstrdup("fmgr_security_definer");
302  ReleaseSysCache(procedureTuple);
303  return;
304  }
305 
306  /* see fmgr_info_cxt_security for the individual cases */
307  switch (procedureStruct->prolang)
308  {
309  case INTERNALlanguageId:
310  prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
311  Anum_pg_proc_prosrc, &isnull);
312  if (isnull)
313  elog(ERROR, "null prosrc");
314 
315  *mod = NULL; /* core binary */
316  *fn = TextDatumGetCString(prosrcattr);
317  break;
318 
319  case ClanguageId:
320  prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
321  Anum_pg_proc_prosrc, &isnull);
322  if (isnull)
323  elog(ERROR, "null prosrc for C function %u", functionId);
324 
325  probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
326  Anum_pg_proc_probin, &isnull);
327  if (isnull)
328  elog(ERROR, "null probin for C function %u", functionId);
329 
330  /*
331  * No need to check symbol presence / API version here, already
332  * checked in fmgr_info_cxt_security.
333  */
334  *mod = TextDatumGetCString(probinattr);
335  *fn = TextDatumGetCString(prosrcattr);
336  break;
337 
338  case SQLlanguageId:
339  *mod = NULL; /* core binary */
340  *fn = pstrdup("fmgr_sql");
341  break;
342 
343  default:
344  *mod = NULL;
345  *fn = NULL; /* unknown, pass pointer */
346  break;
347  }
348 
349  ReleaseSysCache(procedureTuple);
350 }
#define TextDatumGetCString(d)
Definition: builtins.h:86
#define FmgrHookIsNeeded(fn_oid)
Definition: fmgr.h:779
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
Definition: heaptuple.c:359
char * pstrdup(const char *in)
Definition: mcxt.c:1299
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1411
static void * fn(void *arg)

References elog, ERROR, FmgrHookIsNeeded, fn(), GETSTRUCT, heap_attisnull(), HeapTupleIsValid, ObjectIdGetDatum, PROCOID, pstrdup(), ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), and TextDatumGetCString.

Referenced by llvm_function_reference().

◆ FunctionCall0Coll()

Datum FunctionCall0Coll ( FmgrInfo flinfo,
Oid  collation 
)

Definition at line 1111 of file fmgr.c.

1112 {
1113  LOCAL_FCINFO(fcinfo, 0);
1114  Datum result;
1115 
1116  InitFunctionCallInfoData(*fcinfo, flinfo, 0, collation, NULL, NULL);
1117 
1118  result = FunctionCallInvoke(fcinfo);
1119 
1120  /* Check for null result, since caller is clearly not expecting one */
1121  if (fcinfo->isnull)
1122  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1123 
1124  return result;
1125 }
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:172
Oid fn_oid
Definition: fmgr.h:59

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by OidFunctionCall0Coll().

◆ FunctionCall1Coll()

Datum FunctionCall1Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1 
)

Definition at line 1128 of file fmgr.c.

1129 {
1130  LOCAL_FCINFO(fcinfo, 1);
1131  Datum result;
1132 
1133  InitFunctionCallInfoData(*fcinfo, flinfo, 1, collation, NULL, NULL);
1134 
1135  fcinfo->args[0].value = arg1;
1136  fcinfo->args[0].isnull = false;
1137 
1138  result = FunctionCallInvoke(fcinfo);
1139 
1140  /* Check for null result, since caller is clearly not expecting one */
1141  if (fcinfo->isnull)
1142  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1143 
1144  return result;
1145 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by _hash_datum2hashkey(), brin_bloom_add_value(), brin_bloom_consistent(), brin_inclusion_add_value(), element_hash(), ExecHashBuildSkewHash(), ExecHashGetHashValue(), gistCompressValues(), gistdentryinit(), gistFetchAtt(), hash_multirange(), hash_range(), MemoizeHash_hash(), OidFunctionCall1Coll(), signValue(), spgdoinsert(), and TupleHashTableHash_internal().

◆ FunctionCall2Coll()

Datum FunctionCall2Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 1148 of file fmgr.c.

1149 {
1150  LOCAL_FCINFO(fcinfo, 2);
1151  Datum result;
1152 
1153  InitFunctionCallInfoData(*fcinfo, flinfo, 2, collation, NULL, NULL);
1154 
1155  fcinfo->args[0].value = arg1;
1156  fcinfo->args[0].isnull = false;
1157  fcinfo->args[1].value = arg2;
1158  fcinfo->args[1].isnull = false;
1159 
1160  result = FunctionCallInvoke(fcinfo);
1161 
1162  /* Check for null result, since caller is clearly not expecting one */
1163  if (fcinfo->isnull)
1164  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1165 
1166  return result;
1167 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by _bt_check_rowcompare(), _bt_checkkeys(), _bt_compare(), _bt_compare_array_elements(), _bt_compare_scankey_args(), _bt_find_extreme_element(), _bt_keep_natts(), _hash_checkqual(), array_position_common(), array_positions(), AssertCheckExpandedRanges(), AssertCheckRanges(), brin_inclusion_add_value(), brin_inclusion_consistent(), brin_inclusion_union(), brin_minmax_add_value(), brin_minmax_consistent(), brin_minmax_multi_consistent(), brin_minmax_union(), build_distances(), call_subtype_diff(), cmpEntries(), compare_expanded_ranges(), compare_values(), compute_distinct_stats(), compute_partition_hash_value(), compute_range_stats(), create_range_bounds(), doPickSplit(), element_compare(), execTuplesUnequal(), genericPickSplit(), get_distance(), get_position(), get_stats_slot_range(), ginCompareEntries(), gistMakeUnionItVec(), gistMakeUnionKey(), gistUserPicksplit(), has_matching_range(), hash_multirange_extended(), hash_range_extended(), ineq_histogram_selectivity(), make_greater_string(), mcv_get_match_bitmap(), merge_list_bounds(), merge_overlapping_ranges(), mode_final(), multirange_elem_bsearch_comparison(), OidFunctionCall2Coll(), partition_list_bsearch(), partition_rbound_cmp(), partition_rbound_datum_cmp(), process_ordered_aggregate_single(), qsort_partition_list_value_cmp(), range_cmp_bound_values(), range_cmp_bounds(), range_contains_elem_internal(), range_contains_value(), ri_AttributesEqual(), satisfies_hash_partition(), spgdoinsert(), spgGetCache(), spgInnerTest(), spgLeafTest(), and tuples_equal().

◆ FunctionCall3Coll()

Datum FunctionCall3Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3 
)

Definition at line 1170 of file fmgr.c.

1172 {
1173  LOCAL_FCINFO(fcinfo, 3);
1174  Datum result;
1175 
1176  InitFunctionCallInfoData(*fcinfo, flinfo, 3, collation, NULL, NULL);
1177 
1178  fcinfo->args[0].value = arg1;
1179  fcinfo->args[0].isnull = false;
1180  fcinfo->args[1].value = arg2;
1181  fcinfo->args[1].isnull = false;
1182  fcinfo->args[2].value = arg3;
1183  fcinfo->args[2].isnull = false;
1184 
1185  result = FunctionCallInvoke(fcinfo);
1186 
1187  /* Check for null result, since caller is clearly not expecting one */
1188  if (fcinfo->isnull)
1189  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1190 
1191  return result;
1192 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by bringetbitmap(), ginExtractEntries(), gistKeyIsEQ(), gistpenalty(), OidFunctionCall3Coll(), and union_tuples().

◆ FunctionCall4Coll()

Datum FunctionCall4Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4 
)

Definition at line 1195 of file fmgr.c.

1197 {
1198  LOCAL_FCINFO(fcinfo, 4);
1199  Datum result;
1200 
1201  InitFunctionCallInfoData(*fcinfo, flinfo, 4, collation, NULL, NULL);
1202 
1203  fcinfo->args[0].value = arg1;
1204  fcinfo->args[0].isnull = false;
1205  fcinfo->args[1].value = arg2;
1206  fcinfo->args[1].isnull = false;
1207  fcinfo->args[2].value = arg3;
1208  fcinfo->args[2].isnull = false;
1209  fcinfo->args[3].value = arg4;
1210  fcinfo->args[3].isnull = false;
1211 
1212  result = FunctionCallInvoke(fcinfo);
1213 
1214  /* Check for null result, since caller is clearly not expecting one */
1215  if (fcinfo->isnull)
1216  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1217 
1218  return result;
1219 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by add_values_to_range(), bringetbitmap(), collectMatchBitmap(), matchPartialInPendingList(), OidFunctionCall4Coll(), and scalararraysel().

◆ FunctionCall5Coll()

Datum FunctionCall5Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5 
)

Definition at line 1222 of file fmgr.c.

1224 {
1225  LOCAL_FCINFO(fcinfo, 5);
1226  Datum result;
1227 
1228  InitFunctionCallInfoData(*fcinfo, flinfo, 5, collation, NULL, NULL);
1229 
1230  fcinfo->args[0].value = arg1;
1231  fcinfo->args[0].isnull = false;
1232  fcinfo->args[1].value = arg2;
1233  fcinfo->args[1].isnull = false;
1234  fcinfo->args[2].value = arg3;
1235  fcinfo->args[2].isnull = false;
1236  fcinfo->args[3].value = arg4;
1237  fcinfo->args[3].isnull = false;
1238  fcinfo->args[4].value = arg5;
1239  fcinfo->args[4].isnull = false;
1240 
1241  result = FunctionCallInvoke(fcinfo);
1242 
1243  /* Check for null result, since caller is clearly not expecting one */
1244  if (fcinfo->isnull)
1245  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1246 
1247  return result;
1248 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by gistindex_keytest(), OidFunctionCall5Coll(), scalararraysel(), update_frameheadpos(), and update_frametailpos().

◆ FunctionCall6Coll()

Datum FunctionCall6Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6 
)

Definition at line 1251 of file fmgr.c.

1254 {
1255  LOCAL_FCINFO(fcinfo, 6);
1256  Datum result;
1257 
1258  InitFunctionCallInfoData(*fcinfo, flinfo, 6, collation, NULL, NULL);
1259 
1260  fcinfo->args[0].value = arg1;
1261  fcinfo->args[0].isnull = false;
1262  fcinfo->args[1].value = arg2;
1263  fcinfo->args[1].isnull = false;
1264  fcinfo->args[2].value = arg3;
1265  fcinfo->args[2].isnull = false;
1266  fcinfo->args[3].value = arg4;
1267  fcinfo->args[3].isnull = false;
1268  fcinfo->args[4].value = arg5;
1269  fcinfo->args[4].isnull = false;
1270  fcinfo->args[5].value = arg6;
1271  fcinfo->args[5].isnull = false;
1272 
1273  result = FunctionCallInvoke(fcinfo);
1274 
1275  /* Check for null result, since caller is clearly not expecting one */
1276  if (fcinfo->isnull)
1277  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1278 
1279  return result;
1280 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by OidFunctionCall6Coll().

◆ FunctionCall7Coll()

Datum FunctionCall7Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7 
)

Definition at line 1283 of file fmgr.c.

1286 {
1287  LOCAL_FCINFO(fcinfo, 7);
1288  Datum result;
1289 
1290  InitFunctionCallInfoData(*fcinfo, flinfo, 7, collation, NULL, NULL);
1291 
1292  fcinfo->args[0].value = arg1;
1293  fcinfo->args[0].isnull = false;
1294  fcinfo->args[1].value = arg2;
1295  fcinfo->args[1].isnull = false;
1296  fcinfo->args[2].value = arg3;
1297  fcinfo->args[2].isnull = false;
1298  fcinfo->args[3].value = arg4;
1299  fcinfo->args[3].isnull = false;
1300  fcinfo->args[4].value = arg5;
1301  fcinfo->args[4].isnull = false;
1302  fcinfo->args[5].value = arg6;
1303  fcinfo->args[5].isnull = false;
1304  fcinfo->args[6].value = arg7;
1305  fcinfo->args[6].isnull = false;
1306 
1307  result = FunctionCallInvoke(fcinfo);
1308 
1309  /* Check for null result, since caller is clearly not expecting one */
1310  if (fcinfo->isnull)
1311  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1312 
1313  return result;
1314 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by directTriConsistentFn(), gincost_pattern(), OidFunctionCall7Coll(), and shimBoolConsistentFn().

◆ FunctionCall8Coll()

Datum FunctionCall8Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7,
Datum  arg8 
)

Definition at line 1317 of file fmgr.c.

1320 {
1321  LOCAL_FCINFO(fcinfo, 8);
1322  Datum result;
1323 
1324  InitFunctionCallInfoData(*fcinfo, flinfo, 8, collation, NULL, NULL);
1325 
1326  fcinfo->args[0].value = arg1;
1327  fcinfo->args[0].isnull = false;
1328  fcinfo->args[1].value = arg2;
1329  fcinfo->args[1].isnull = false;
1330  fcinfo->args[2].value = arg3;
1331  fcinfo->args[2].isnull = false;
1332  fcinfo->args[3].value = arg4;
1333  fcinfo->args[3].isnull = false;
1334  fcinfo->args[4].value = arg5;
1335  fcinfo->args[4].isnull = false;
1336  fcinfo->args[5].value = arg6;
1337  fcinfo->args[5].isnull = false;
1338  fcinfo->args[6].value = arg7;
1339  fcinfo->args[6].isnull = false;
1340  fcinfo->args[7].value = arg8;
1341  fcinfo->args[7].isnull = false;
1342 
1343  result = FunctionCallInvoke(fcinfo);
1344 
1345  /* Check for null result, since caller is clearly not expecting one */
1346  if (fcinfo->isnull)
1347  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1348 
1349  return result;
1350 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by directBoolConsistentFn(), and OidFunctionCall8Coll().

◆ FunctionCall9Coll()

Datum FunctionCall9Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7,
Datum  arg8,
Datum  arg9 
)

Definition at line 1353 of file fmgr.c.

1357 {
1358  LOCAL_FCINFO(fcinfo, 9);
1359  Datum result;
1360 
1361  InitFunctionCallInfoData(*fcinfo, flinfo, 9, collation, NULL, NULL);
1362 
1363  fcinfo->args[0].value = arg1;
1364  fcinfo->args[0].isnull = false;
1365  fcinfo->args[1].value = arg2;
1366  fcinfo->args[1].isnull = false;
1367  fcinfo->args[2].value = arg3;
1368  fcinfo->args[2].isnull = false;
1369  fcinfo->args[3].value = arg4;
1370  fcinfo->args[3].isnull = false;
1371  fcinfo->args[4].value = arg5;
1372  fcinfo->args[4].isnull = false;
1373  fcinfo->args[5].value = arg6;
1374  fcinfo->args[5].isnull = false;
1375  fcinfo->args[6].value = arg7;
1376  fcinfo->args[6].isnull = false;
1377  fcinfo->args[7].value = arg8;
1378  fcinfo->args[7].isnull = false;
1379  fcinfo->args[8].value = arg9;
1380  fcinfo->args[8].isnull = false;
1381 
1382  result = FunctionCallInvoke(fcinfo);
1383 
1384  /* Check for null result, since caller is clearly not expecting one */
1385  if (fcinfo->isnull)
1386  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1387 
1388  return result;
1389 }

References elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by OidFunctionCall9Coll().

◆ get_call_expr_arg_stable()

bool get_call_expr_arg_stable ( fmNodePtr  expr,
int  argnum 
)

◆ get_call_expr_argtype()

Oid get_call_expr_argtype ( fmNodePtr  expr,
int  argnum 
)

◆ get_fn_expr_arg_stable()

bool get_fn_expr_arg_stable ( FmgrInfo flinfo,
int  argnum 
)

Definition at line 1865 of file fmgr.c.

1866 {
1867  /*
1868  * can't return anything useful if we have no FmgrInfo or if its fn_expr
1869  * node has not been initialized
1870  */
1871  if (!flinfo || !flinfo->fn_expr)
1872  return false;
1873 
1874  return get_call_expr_arg_stable(flinfo->fn_expr, argnum);
1875 }
bool get_call_expr_arg_stable(Node *expr, int argnum)
Definition: fmgr.c:1884
fmNodePtr fn_expr
Definition: fmgr.h:66

References FmgrInfo::fn_expr, and get_call_expr_arg_stable().

Referenced by extract_variadic_args(), leadlag_common(), and window_nth_value().

◆ get_fn_expr_argtype()

◆ get_fn_expr_rettype()

Oid get_fn_expr_rettype ( FmgrInfo flinfo)

Definition at line 1778 of file fmgr.c.

1779 {
1780  Node *expr;
1781 
1782  /*
1783  * can't return anything useful if we have no FmgrInfo or if its fn_expr
1784  * node has not been initialized
1785  */
1786  if (!flinfo || !flinfo->fn_expr)
1787  return InvalidOid;
1788 
1789  expr = flinfo->fn_expr;
1790 
1791  return exprType(expr);
1792 }
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:41
Definition: nodes.h:540

References exprType(), FmgrInfo::fn_expr, and InvalidOid.

Referenced by do_compile(), multirange_constructor0(), multirange_constructor1(), multirange_constructor2(), range_agg_finalfn(), range_constructor2(), and range_constructor3().

◆ get_fn_expr_variadic()

bool get_fn_expr_variadic ( FmgrInfo flinfo)

Definition at line 1934 of file fmgr.c.

1935 {
1936  Node *expr;
1937 
1938  /*
1939  * can't return anything useful if we have no FmgrInfo or if its fn_expr
1940  * node has not been initialized
1941  */
1942  if (!flinfo || !flinfo->fn_expr)
1943  return false;
1944 
1945  expr = flinfo->fn_expr;
1946 
1947  if (IsA(expr, FuncExpr))
1948  return ((FuncExpr *) expr)->funcvariadic;
1949  else
1950  return false;
1951 }

References FmgrInfo::fn_expr, and IsA.

Referenced by concat_internal(), count_nulls(), extract_variadic_args(), satisfies_hash_partition(), and text_format().

◆ get_fn_opclass_options()

bytea* get_fn_opclass_options ( FmgrInfo flinfo)

Definition at line 1987 of file fmgr.c.

1988 {
1989  if (flinfo && flinfo->fn_expr && IsA(flinfo->fn_expr, Const))
1990  {
1991  Const *expr = (Const *) flinfo->fn_expr;
1992 
1993  if (expr->consttype == BYTEAOID)
1994  return expr->constisnull ? NULL : DatumGetByteaP(expr->constvalue);
1995  }
1996 
1997  ereport(ERROR,
1998  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1999  errmsg("operator class options info is absent in function call context")));
2000 
2001  return NULL;
2002 }
#define DatumGetByteaP(X)
Definition: fmgr.h:331
Oid consttype
Definition: primnodes.h:215
Datum constvalue
Definition: primnodes.h:219
bool constisnull
Definition: primnodes.h:220

References Const::constisnull, Const::consttype, Const::constvalue, DatumGetByteaP, ereport, errcode(), errmsg(), ERROR, FmgrInfo::fn_expr, if(), and IsA.

◆ has_fn_opclass_options()

bool has_fn_opclass_options ( FmgrInfo flinfo)

Definition at line 1971 of file fmgr.c.

1972 {
1973  if (flinfo && flinfo->fn_expr && IsA(flinfo->fn_expr, Const))
1974  {
1975  Const *expr = (Const *) flinfo->fn_expr;
1976 
1977  if (expr->consttype == BYTEAOID)
1978  return !expr->constisnull;
1979  }
1980  return false;
1981 }

References Const::constisnull, Const::consttype, FmgrInfo::fn_expr, if(), and IsA.

◆ InputFunctionCall()

Datum InputFunctionCall ( FmgrInfo flinfo,
char *  str,
Oid  typioparam,
int32  typmod 
)

Definition at line 1529 of file fmgr.c.

1530 {
1531  LOCAL_FCINFO(fcinfo, 3);
1532  Datum result;
1533 
1534  if (str == NULL && flinfo->fn_strict)
1535  return (Datum) 0; /* just return null result */
1536 
1537  InitFunctionCallInfoData(*fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
1538 
1539  fcinfo->args[0].value = CStringGetDatum(str);
1540  fcinfo->args[0].isnull = false;
1541  fcinfo->args[1].value = ObjectIdGetDatum(typioparam);
1542  fcinfo->args[1].isnull = false;
1543  fcinfo->args[2].value = Int32GetDatum(typmod);
1544  fcinfo->args[2].isnull = false;
1545 
1546  result = FunctionCallInvoke(fcinfo);
1547 
1548  /* Should get null result if and only if str is NULL */
1549  if (str == NULL)
1550  {
1551  if (!fcinfo->isnull)
1552  elog(ERROR, "input function %u returned non-NULL",
1553  flinfo->fn_oid);
1554  }
1555  else
1556  {
1557  if (fcinfo->isnull)
1558  elog(ERROR, "input function %u returned NULL",
1559  flinfo->fn_oid);
1560  }
1561 
1562  return result;
1563 }
#define CStringGetDatum(X)
Definition: postgres.h:622
#define Int32GetDatum(X)
Definition: postgres.h:523
bool fn_strict
Definition: fmgr.h:61

References CStringGetDatum, elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FmgrInfo::fn_strict, FunctionCallInvoke, InitFunctionCallInfoData, Int32GetDatum, InvalidOid, LOCAL_FCINFO, ObjectIdGetDatum, and generate_unaccent_rules::str.

Referenced by BuildTupleFromCStrings(), domain_in(), hstore_populate_record(), make_tuple_from_result_row(), multirange_in(), NextCopyFrom(), OidInputFunctionCall(), plperl_sv_to_datum(), plsample_func_handler(), pltcl_func_handler(), pltcl_returnnext(), pltcl_SPI_execute_plan(), PLyObject_ToScalar(), PLyString_ToComposite(), populate_scalar(), range_in(), ReadArrayStr(), record_in(), and XmlTableGetValue().

◆ load_external_function()

void* load_external_function ( const char *  filename,
const char *  funcname,
bool  signalNotFound,
void **  filehandle 
)

Definition at line 107 of file dfmgr.c.

109 {
110  char *fullname;
111  void *lib_handle;
112  void *retval;
113 
114  /* Expand the possibly-abbreviated filename to an exact path name */
116 
117  /* Load the shared library, unless we already did */
118  lib_handle = internal_load_library(fullname);
119 
120  /* Return handle if caller wants it */
121  if (filehandle)
122  *filehandle = lib_handle;
123 
124  /* Look up the function within the library. */
125  retval = dlsym(lib_handle, funcname);
126 
127  if (retval == NULL && signalNotFound)
128  ereport(ERROR,
129  (errcode(ERRCODE_UNDEFINED_FUNCTION),
130  errmsg("could not find function \"%s\" in file \"%s\"",
131  funcname, fullname)));
132 
133  pfree(fullname);
134  return retval;
135 }
static char * expand_dynamic_library_name(const char *name)
Definition: dfmgr.c:501
static void * internal_load_library(const char *libname)
Definition: dfmgr.c:184
static char * filename
Definition: pg_dumpall.c:92
void * dlsym(void *handle, const char *symbol)

References dlsym(), ereport, errcode(), errmsg(), ERROR, expand_dynamic_library_name(), filename, internal_load_library(), and pfree().

Referenced by _PG_init(), fmgr_c_validator(), fmgr_info_C_lang(), llvm_resolve_symbol(), LoadOutputPlugin(), LookupBackgroundWorkerFunction(), LookupParallelWorkerFunction(), and provider_init().

◆ load_file()

void load_file ( const char *  filename,
bool  restricted 
)

Definition at line 146 of file dfmgr.c.

147 {
148  char *fullname;
149 
150  /* Apply security restriction if requested */
151  if (restricted)
153 
154  /* Expand the possibly-abbreviated filename to an exact path name */
156 
157  /* Unload the library if currently loaded */
158  internal_unload_library(fullname);
159 
160  /* Load the shared library */
161  (void) internal_load_library(fullname);
162 
163  pfree(fullname);
164 }
static void internal_unload_library(const char *libname)
Definition: dfmgr.c:415
static void check_restricted_library_name(const char *name)
Definition: dfmgr.c:556

References check_restricted_library_name(), expand_dynamic_library_name(), filename, internal_load_library(), internal_unload_library(), and pfree().

Referenced by AlterSubscription(), AlterSubscription_refresh(), ApplyWorkerMain(), CreateSubscription(), DropSubscription(), load_libraries(), ReplicationSlotDropAtPubNode(), standard_ProcessUtility(), and WalReceiverMain().

◆ lookup_external_function()

void* lookup_external_function ( void *  filehandle,
const char *  funcname 
)

Definition at line 171 of file dfmgr.c.

172 {
173  return dlsym(filehandle, funcname);
174 }

References dlsym().

Referenced by fetch_finfo_record().

◆ OidFunctionCall0Coll()

Datum OidFunctionCall0Coll ( Oid  functionId,
Oid  collation 
)

Definition at line 1400 of file fmgr.c.

1401 {
1402  FmgrInfo flinfo;
1403 
1404  fmgr_info(functionId, &flinfo);
1405 
1406  return FunctionCall0Coll(&flinfo, collation);
1407 }
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:126
Datum FunctionCall0Coll(FmgrInfo *flinfo, Oid collation)
Definition: fmgr.c:1111

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall0Coll().

◆ OidFunctionCall1Coll()

Datum OidFunctionCall1Coll ( Oid  functionId,
Oid  collation,
Datum  arg1 
)

Definition at line 1410 of file fmgr.c.

1411 {
1412  FmgrInfo flinfo;
1413 
1414  fmgr_info(functionId, &flinfo);
1415 
1416  return FunctionCall1Coll(&flinfo, collation, arg1);
1417 }
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
Definition: fmgr.c:1128

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall1Coll().

Referenced by _bt_allequalimage(), and _hash_datum2hashkey_type().

◆ OidFunctionCall2Coll()

Datum OidFunctionCall2Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 1420 of file fmgr.c.

1421 {
1422  FmgrInfo flinfo;
1423 
1424  fmgr_info(functionId, &flinfo);
1425 
1426  return FunctionCall2Coll(&flinfo, collation, arg1, arg2);
1427 }
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1148

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall2Coll().

Referenced by _bt_compare_scankey_args(), and index_recheck_constraint().

◆ OidFunctionCall3Coll()

Datum OidFunctionCall3Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3 
)

Definition at line 1430 of file fmgr.c.

1432 {
1433  FmgrInfo flinfo;
1434 
1435  fmgr_info(functionId, &flinfo);
1436 
1437  return FunctionCall3Coll(&flinfo, collation, arg1, arg2, arg3);
1438 }
Datum FunctionCall3Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3)
Definition: fmgr.c:1170

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall3Coll().

◆ OidFunctionCall4Coll()

Datum OidFunctionCall4Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4 
)

Definition at line 1441 of file fmgr.c.

1443 {
1444  FmgrInfo flinfo;
1445 
1446  fmgr_info(functionId, &flinfo);
1447 
1448  return FunctionCall4Coll(&flinfo, collation, arg1, arg2, arg3, arg4);
1449 }
Datum FunctionCall4Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
Definition: fmgr.c:1195

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall4Coll().

Referenced by restriction_selectivity().

◆ OidFunctionCall5Coll()

Datum OidFunctionCall5Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5 
)

Definition at line 1452 of file fmgr.c.

1454 {
1455  FmgrInfo flinfo;
1456 
1457  fmgr_info(functionId, &flinfo);
1458 
1459  return FunctionCall5Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5);
1460 }
Datum FunctionCall5Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
Definition: fmgr.c:1222

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall5Coll().

Referenced by join_selectivity().

◆ OidFunctionCall6Coll()

Datum OidFunctionCall6Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6 
)

Definition at line 1463 of file fmgr.c.

1466 {
1467  FmgrInfo flinfo;
1468 
1469  fmgr_info(functionId, &flinfo);
1470 
1471  return FunctionCall6Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1472  arg6);
1473 }
Datum FunctionCall6Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
Definition: fmgr.c:1251

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall6Coll().

◆ OidFunctionCall7Coll()

Datum OidFunctionCall7Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7 
)

Definition at line 1476 of file fmgr.c.

1479 {
1480  FmgrInfo flinfo;
1481 
1482  fmgr_info(functionId, &flinfo);
1483 
1484  return FunctionCall7Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1485  arg6, arg7);
1486 }
Datum FunctionCall7Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
Definition: fmgr.c:1283

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall7Coll().

◆ OidFunctionCall8Coll()

Datum OidFunctionCall8Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7,
Datum  arg8 
)

Definition at line 1489 of file fmgr.c.

1492 {
1493  FmgrInfo flinfo;
1494 
1495  fmgr_info(functionId, &flinfo);
1496 
1497  return FunctionCall8Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1498  arg6, arg7, arg8);
1499 }
Datum FunctionCall8Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
Definition: fmgr.c:1317

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall8Coll().

◆ OidFunctionCall9Coll()

Datum OidFunctionCall9Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7,
Datum  arg8,
Datum  arg9 
)

Definition at line 1502 of file fmgr.c.

1506 {
1507  FmgrInfo flinfo;
1508 
1509  fmgr_info(functionId, &flinfo);
1510 
1511  return FunctionCall9Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1512  arg6, arg7, arg8, arg9);
1513 }
Datum FunctionCall9Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
Definition: fmgr.c:1353

References fmgr_security_definer_cache::flinfo, fmgr_info(), and FunctionCall9Coll().

◆ OidInputFunctionCall()

Datum OidInputFunctionCall ( Oid  functionId,
char *  str,
Oid  typioparam,
int32  typmod 
)

Definition at line 1644 of file fmgr.c.

1645 {
1646  FmgrInfo flinfo;
1647 
1648  fmgr_info(functionId, &flinfo);
1649  return InputFunctionCall(&flinfo, str, typioparam, typmod);
1650 }
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1529

References fmgr_security_definer_cache::flinfo, fmgr_info(), InputFunctionCall(), and generate_unaccent_rules::str.

Referenced by DefineAggregate(), exec_bind_message(), get_typdefault(), GetAggInitVal(), InsertOneValue(), parse_fcall_arguments(), slot_modify_data(), slot_store_data(), and stringTypeDatum().

◆ OidOutputFunctionCall()

◆ OidReceiveFunctionCall()

Datum OidReceiveFunctionCall ( Oid  functionId,
fmStringInfo  buf,
Oid  typioparam,
int32  typmod 
)

Definition at line 1662 of file fmgr.c.

1664 {
1665  FmgrInfo flinfo;
1666 
1667  fmgr_info(functionId, &flinfo);
1668  return ReceiveFunctionCall(&flinfo, buf, typioparam, typmod);
1669 }
Datum ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf, Oid typioparam, int32 typmod)
Definition: fmgr.c:1587
static char * buf
Definition: pg_test_fsync.c:70

References buf, fmgr_security_definer_cache::flinfo, fmgr_info(), and ReceiveFunctionCall().

Referenced by exec_bind_message(), parse_fcall_arguments(), slot_modify_data(), and slot_store_data().

◆ OidSendFunctionCall()

bytea* OidSendFunctionCall ( Oid  functionId,
Datum  val 
)

Definition at line 1672 of file fmgr.c.

1673 {
1674  FmgrInfo flinfo;
1675 
1676  fmgr_info(functionId, &flinfo);
1677  return SendFunctionCall(&flinfo, val);
1678 }
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
Definition: fmgr.c:1634

References fmgr_security_definer_cache::flinfo, fmgr_info(), SendFunctionCall(), and val.

Referenced by logicalrep_write_tuple(), and SendFunctionResult().

◆ OutputFunctionCall()

◆ pg_detoast_datum()

struct varlena* pg_detoast_datum ( struct varlena datum)

Definition at line 1722 of file fmgr.c.

1723 {
1724  if (VARATT_IS_EXTENDED(datum))
1725  return detoast_attr(datum);
1726  else
1727  return datum;
1728 }
struct varlena * detoast_attr(struct varlena *attr)
Definition: detoast.c:116
#define VARATT_IS_EXTENDED(PTR)
Definition: postgres.h:340

References detoast_attr(), and VARATT_IS_EXTENDED.

◆ pg_detoast_datum_copy()

struct varlena* pg_detoast_datum_copy ( struct varlena datum)

Definition at line 1731 of file fmgr.c.

1732 {
1733  if (VARATT_IS_EXTENDED(datum))
1734  return detoast_attr(datum);
1735  else
1736  {
1737  /* Make a modifiable copy of the varlena object */
1738  Size len = VARSIZE(datum);
1739  struct varlena *result = (struct varlena *) palloc(len);
1740 
1741  memcpy(result, datum, len);
1742  return result;
1743  }
1744 }
void * palloc(Size size)
Definition: mcxt.c:1062
const void size_t len
#define VARSIZE(PTR)
Definition: postgres.h:316

References detoast_attr(), len, palloc(), VARATT_IS_EXTENDED, and VARSIZE.

◆ pg_detoast_datum_packed()

struct varlena* pg_detoast_datum_packed ( struct varlena datum)

Definition at line 1754 of file fmgr.c.

1755 {
1756  if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum))
1757  return detoast_attr(datum);
1758  else
1759  return datum;
1760 }
#define VARATT_IS_COMPRESSED(PTR)
Definition: postgres.h:325
#define VARATT_IS_EXTERNAL(PTR)
Definition: postgres.h:326

References detoast_attr(), VARATT_IS_COMPRESSED, and VARATT_IS_EXTERNAL.

Referenced by text_to_cstring(), and text_to_cstring_buffer().

◆ pg_detoast_datum_slice()

struct varlena* pg_detoast_datum_slice ( struct varlena datum,
int32  first,
int32  count 
)

Definition at line 1747 of file fmgr.c.

1748 {
1749  /* Only get the specified portion from the toast rel */
1750  return detoast_attr_slice(datum, first, count);
1751 }
struct varlena * detoast_attr_slice(struct varlena *attr, int32 sliceoffset, int32 slicelength)
Definition: detoast.c:205

References detoast_attr_slice().

◆ ReceiveFunctionCall()

Datum ReceiveFunctionCall ( FmgrInfo flinfo,
fmStringInfo  buf,
Oid  typioparam,
int32  typmod 
)

Definition at line 1587 of file fmgr.c.

1589 {
1590  LOCAL_FCINFO(fcinfo, 3);
1591  Datum result;
1592 
1593  if (buf == NULL && flinfo->fn_strict)
1594  return (Datum) 0; /* just return null result */
1595 
1596  InitFunctionCallInfoData(*fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
1597 
1598  fcinfo->args[0].value = PointerGetDatum(buf);
1599  fcinfo->args[0].isnull = false;
1600  fcinfo->args[1].value = ObjectIdGetDatum(typioparam);
1601  fcinfo->args[1].isnull = false;
1602  fcinfo->args[2].value = Int32GetDatum(typmod);
1603  fcinfo->args[2].isnull = false;
1604 
1605  result = FunctionCallInvoke(fcinfo);
1606 
1607  /* Should get null result if and only if buf is NULL */
1608  if (buf == NULL)
1609  {
1610  if (!fcinfo->isnull)
1611  elog(ERROR, "receive function %u returned non-NULL",
1612  flinfo->fn_oid);
1613  }
1614  else
1615  {
1616  if (fcinfo->isnull)
1617  elog(ERROR, "receive function %u returned NULL",
1618  flinfo->fn_oid);
1619  }
1620 
1621  return result;
1622 }
#define PointerGetDatum(X)
Definition: postgres.h:600

References buf, elog, ERROR, fmgr_security_definer_cache::flinfo, FmgrInfo::fn_oid, FmgrInfo::fn_strict, FunctionCallInvoke, InitFunctionCallInfoData, Int32GetDatum, InvalidOid, LOCAL_FCINFO, ObjectIdGetDatum, and PointerGetDatum.

Referenced by CopyReadBinaryAttribute(), domain_recv(), multirange_recv(), OidReceiveFunctionCall(), range_recv(), ReadArrayBinary(), and record_recv().

◆ RestoreLibraryState()

void RestoreLibraryState ( char *  start_address)

Definition at line 763 of file dfmgr.c.

764 {
765  while (*start_address != '\0')
766  {
767  internal_load_library(start_address);
768  start_address += strlen(start_address) + 1;
769  }
770 }

References internal_load_library().

Referenced by ParallelWorkerMain().

◆ SendFunctionCall()

bytea* SendFunctionCall ( FmgrInfo flinfo,
Datum  val 
)

◆ SerializeLibraryState()

void SerializeLibraryState ( Size  maxsize,
char *  start_address 
)

Definition at line 741 of file dfmgr.c.

742 {
743  DynamicFileList *file_scanner;
744 
745  for (file_scanner = file_list;
746  file_scanner != NULL;
747  file_scanner = file_scanner->next)
748  {
749  Size len;
750 
751  len = strlcpy(start_address, file_scanner->filename, maxsize) + 1;
752  Assert(len < maxsize);
753  maxsize -= len;
754  start_address += len;
755  }
756  start_address[0] = '\0';
757 }
Assert(fmt[strlen(fmt) - 1] !='\n')
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45

References Assert(), file_list, df_files::filename, len, df_files::next, and strlcpy().

Referenced by InitializeParallelDSM().

◆ set_fn_opclass_options()

void set_fn_opclass_options ( FmgrInfo flinfo,
bytea options 
)

Definition at line 1960 of file fmgr.c.

1961 {
1962  flinfo->fn_expr = (Node *) makeConst(BYTEAOID, -1, InvalidOid, -1,
1964  options == NULL, false);
1965 }
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:299

References FmgrInfo::fn_expr, InvalidOid, makeConst(), and PointerGetDatum.

Referenced by gincost_pattern(), and index_getprocinfo().

◆ StaticAssertDecl()

StaticAssertDecl ( sizeof(FMGR_ABI_EXTRA)<=sizeof(((Pg_magic_struct *) 0) ->abi_extra)  ,
"FMGR_ABI_EXTRA too long"   
)

Variable Documentation

◆ Dynamic_library_path

char* Dynamic_library_path
extern

Definition at line 77 of file dfmgr.c.

Referenced by find_in_dynamic_libpath().

◆ fmgr_hook

PGDLLIMPORT fmgr_hook_type fmgr_hook
extern

Definition at line 39 of file fmgr.c.

Referenced by fmgr_security_definer(), and sepgsql_init_client_label().

◆ needs_fmgr_hook

PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook
extern

Definition at line 38 of file fmgr.c.

Referenced by sepgsql_init_client_label().