PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
fmgr.c File Reference
#include "postgres.h"
#include "access/tuptoaster.h"
#include "catalog/pg_language.h"
#include "catalog/pg_proc.h"
#include "executor/functions.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "pgstat.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgrtab.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
Include dependency graph for fmgr.c:

Go to the source code of this file.

Data Structures

struct  Oldstyle_fnextra
 
struct  CFuncHashTabEntry
 
struct  fmgr_security_definer_cache
 

Typedefs

typedef char *(* func_ptr )()
 

Functions

static void fmgr_info_cxt_security (Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
 
static void fmgr_info_C_lang (Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
 
static void fmgr_info_other_lang (Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
 
static CFuncHashTabEntrylookup_C_func (HeapTuple procedureTuple)
 
static void record_C_func (HeapTuple procedureTuple, PGFunction user_fn, const Pg_finfo_record *inforec)
 
static Datum fmgr_oldstyle (PG_FUNCTION_ARGS)
 
static Datum fmgr_security_definer (PG_FUNCTION_ARGS)
 
static const FmgrBuiltinfmgr_isbuiltin (Oid id)
 
static const FmgrBuiltinfmgr_lookupByName (const char *name)
 
void fmgr_info (Oid functionId, FmgrInfo *finfo)
 
void fmgr_info_cxt (Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
 
const Pg_finfo_recordfetch_finfo_record (void *filehandle, char *funcname)
 
void clear_external_function_hash (void *filehandle)
 
void fmgr_info_copy (FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)
 
Oid fmgr_internal_function (const char *proname)
 
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 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)
 
char * OutputFunctionCall (FmgrInfo *flinfo, Datum val)
 
Datum ReceiveFunctionCall (FmgrInfo *flinfo, StringInfo buf, Oid typioparam, int32 typmod)
 
byteaSendFunctionCall (FmgrInfo *flinfo, Datum val)
 
Datum OidInputFunctionCall (Oid functionId, char *str, Oid typioparam, int32 typmod)
 
char * OidOutputFunctionCall (Oid functionId, Datum val)
 
Datum OidReceiveFunctionCall (Oid functionId, StringInfo buf, Oid typioparam, int32 typmod)
 
byteaOidSendFunctionCall (Oid functionId, Datum val)
 
char * fmgr (Oid procedureId,...)
 
Datum Int64GetDatum (int64 X)
 
Datum Float4GetDatum (float4 X)
 
Datum Float8GetDatum (float8 X)
 
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)
 
Oid get_fn_expr_rettype (FmgrInfo *flinfo)
 
Oid get_fn_expr_argtype (FmgrInfo *flinfo, int argnum)
 
Oid get_call_expr_argtype (Node *expr, int argnum)
 
bool get_fn_expr_arg_stable (FmgrInfo *flinfo, int argnum)
 
bool get_call_expr_arg_stable (Node *expr, int argnum)
 
bool get_fn_expr_variadic (FmgrInfo *flinfo)
 
bool CheckFunctionValidatorAccess (Oid validatorOid, Oid functionOid)
 

Variables

PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook = NULL
 
PGDLLIMPORT fmgr_hook_type fmgr_hook = NULL
 
static HTABCFuncHash = NULL
 

Typedef Documentation

typedef char*(* func_ptr)()

Definition at line 57 of file fmgr.c.

Function Documentation

bool CheckFunctionValidatorAccess ( Oid  validatorOid,
Oid  functionOid 
)

Definition at line 2412 of file fmgr.c.

References ACL_EXECUTE, ACL_KIND_LANGUAGE, ACL_KIND_PROC, ACL_USAGE, aclcheck_error(), ACLCHECK_OK, elog, ereport, errcode(), errmsg(), ERROR, GETSTRUCT, GetUserId(), HeapTupleIsValid, LANGOID, NameStr, 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().

2413 {
2414  HeapTuple procTup;
2415  HeapTuple langTup;
2416  Form_pg_proc procStruct;
2417  Form_pg_language langStruct;
2418  AclResult aclresult;
2419 
2420  /*
2421  * Get the function's pg_proc entry. Throw a user-facing error for bad
2422  * OID, because validators can be called with user-specified OIDs.
2423  */
2424  procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionOid));
2425  if (!HeapTupleIsValid(procTup))
2426  ereport(ERROR,
2427  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2428  errmsg("function with OID %u does not exist", functionOid)));
2429  procStruct = (Form_pg_proc) GETSTRUCT(procTup);
2430 
2431  /*
2432  * Fetch pg_language entry to know if this is the correct validation
2433  * function for that pg_proc entry.
2434  */
2435  langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang));
2436  if (!HeapTupleIsValid(langTup))
2437  elog(ERROR, "cache lookup failed for language %u", procStruct->prolang);
2438  langStruct = (Form_pg_language) GETSTRUCT(langTup);
2439 
2440  if (langStruct->lanvalidator != validatorOid)
2441  ereport(ERROR,
2442  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2443  errmsg("language validation function %u called for language %u instead of %u",
2444  validatorOid, procStruct->prolang,
2445  langStruct->lanvalidator)));
2446 
2447  /* first validate that we have permissions to use the language */
2448  aclresult = pg_language_aclcheck(procStruct->prolang, GetUserId(),
2449  ACL_USAGE);
2450  if (aclresult != ACLCHECK_OK)
2451  aclcheck_error(aclresult, ACL_KIND_LANGUAGE,
2452  NameStr(langStruct->lanname));
2453 
2454  /*
2455  * Check whether we are allowed to execute the function itself. If we can
2456  * execute it, there should be no possible side-effect of
2457  * compiling/validation that execution can't have.
2458  */
2459  aclresult = pg_proc_aclcheck(functionOid, GetUserId(), ACL_EXECUTE);
2460  if (aclresult != ACLCHECK_OK)
2461  aclcheck_error(aclresult, ACL_KIND_PROC, NameStr(procStruct->proname));
2462 
2463  ReleaseSysCache(procTup);
2464  ReleaseSysCache(langTup);
2465 
2466  return true;
2467 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
Oid GetUserId(void)
Definition: miscinit.c:283
int errcode(int sqlerrcode)
Definition: elog.c:575
AclResult pg_language_aclcheck(Oid lang_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4433
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
void aclcheck_error(AclResult aclerr, AclObjectKind objectkind, const char *objectname)
Definition: aclchk.c:3378
#define ACL_USAGE
Definition: parsenodes.h:73
#define ereport(elevel, rest)
Definition: elog.h:122
AclResult
Definition: acl.h:170
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_language * Form_pg_language
Definition: pg_language.h:51
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define ACL_EXECUTE
Definition: parsenodes.h:72
AclResult pg_proc_aclcheck(Oid proc_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4421
#define NameStr(name)
Definition: c.h:494
#define elog
Definition: elog.h:219
void clear_external_function_hash ( void *  filehandle)

Definition at line 567 of file fmgr.c.

References hash_destroy(), and NULL.

Referenced by internal_unload_library().

568 {
569  if (CFuncHash)
571  CFuncHash = NULL;
572 }
void hash_destroy(HTAB *hashp)
Definition: dynahash.c:793
static HTAB * CFuncHash
Definition: fmgr.c:83
#define NULL
Definition: c.h:226
Datum DirectFunctionCall1Coll ( PGFunction  func,
Oid  collation,
Datum  arg1 
)

Definition at line 1016 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by Generic_Text_IC_like(), and libpqrcv_create_slot().

1017 {
1018  FunctionCallInfoData fcinfo;
1019  Datum result;
1020 
1021  InitFunctionCallInfoData(fcinfo, NULL, 1, collation, NULL, NULL);
1022 
1023  fcinfo.arg[0] = arg1;
1024  fcinfo.argnull[0] = false;
1025 
1026  result = (*func) (&fcinfo);
1027 
1028  /* Check for null result, since caller is clearly not expecting one */
1029  if (fcinfo.isnull)
1030  elog(ERROR, "function %p returned NULL", (void *) func);
1031 
1032  return result;
1033 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum DirectFunctionCall2Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 1036 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by gbt_textcmp(), gbt_texteq(), gbt_textge(), gbt_textgt(), gbt_textle(), gbt_textlt(), and gin_btree_compare_prefix().

1037 {
1038  FunctionCallInfoData fcinfo;
1039  Datum result;
1040 
1041  InitFunctionCallInfoData(fcinfo, NULL, 2, collation, NULL, NULL);
1042 
1043  fcinfo.arg[0] = arg1;
1044  fcinfo.arg[1] = arg2;
1045  fcinfo.argnull[0] = false;
1046  fcinfo.argnull[1] = false;
1047 
1048  result = (*func) (&fcinfo);
1049 
1050  /* Check for null result, since caller is clearly not expecting one */
1051  if (fcinfo.isnull)
1052  elog(ERROR, "function %p returned NULL", (void *) func);
1053 
1054  return result;
1055 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum DirectFunctionCall3Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3 
)

Definition at line 1058 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1060 {
1061  FunctionCallInfoData fcinfo;
1062  Datum result;
1063 
1064  InitFunctionCallInfoData(fcinfo, NULL, 3, collation, NULL, NULL);
1065 
1066  fcinfo.arg[0] = arg1;
1067  fcinfo.arg[1] = arg2;
1068  fcinfo.arg[2] = arg3;
1069  fcinfo.argnull[0] = false;
1070  fcinfo.argnull[1] = false;
1071  fcinfo.argnull[2] = false;
1072 
1073  result = (*func) (&fcinfo);
1074 
1075  /* Check for null result, since caller is clearly not expecting one */
1076  if (fcinfo.isnull)
1077  elog(ERROR, "function %p returned NULL", (void *) func);
1078 
1079  return result;
1080 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum DirectFunctionCall4Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4 
)

Definition at line 1083 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by execute_extension_script().

1085 {
1086  FunctionCallInfoData fcinfo;
1087  Datum result;
1088 
1089  InitFunctionCallInfoData(fcinfo, NULL, 4, collation, NULL, NULL);
1090 
1091  fcinfo.arg[0] = arg1;
1092  fcinfo.arg[1] = arg2;
1093  fcinfo.arg[2] = arg3;
1094  fcinfo.arg[3] = arg4;
1095  fcinfo.argnull[0] = false;
1096  fcinfo.argnull[1] = false;
1097  fcinfo.argnull[2] = false;
1098  fcinfo.argnull[3] = false;
1099 
1100  result = (*func) (&fcinfo);
1101 
1102  /* Check for null result, since caller is clearly not expecting one */
1103  if (fcinfo.isnull)
1104  elog(ERROR, "function %p returned NULL", (void *) func);
1105 
1106  return result;
1107 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum DirectFunctionCall5Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5 
)

Definition at line 1110 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1112 {
1113  FunctionCallInfoData fcinfo;
1114  Datum result;
1115 
1116  InitFunctionCallInfoData(fcinfo, NULL, 5, collation, NULL, NULL);
1117 
1118  fcinfo.arg[0] = arg1;
1119  fcinfo.arg[1] = arg2;
1120  fcinfo.arg[2] = arg3;
1121  fcinfo.arg[3] = arg4;
1122  fcinfo.arg[4] = arg5;
1123  fcinfo.argnull[0] = false;
1124  fcinfo.argnull[1] = false;
1125  fcinfo.argnull[2] = false;
1126  fcinfo.argnull[3] = false;
1127  fcinfo.argnull[4] = false;
1128 
1129  result = (*func) (&fcinfo);
1130 
1131  /* Check for null result, since caller is clearly not expecting one */
1132  if (fcinfo.isnull)
1133  elog(ERROR, "function %p returned NULL", (void *) func);
1134 
1135  return result;
1136 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum DirectFunctionCall6Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6 
)

Definition at line 1139 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1142 {
1143  FunctionCallInfoData fcinfo;
1144  Datum result;
1145 
1146  InitFunctionCallInfoData(fcinfo, NULL, 6, collation, NULL, NULL);
1147 
1148  fcinfo.arg[0] = arg1;
1149  fcinfo.arg[1] = arg2;
1150  fcinfo.arg[2] = arg3;
1151  fcinfo.arg[3] = arg4;
1152  fcinfo.arg[4] = arg5;
1153  fcinfo.arg[5] = arg6;
1154  fcinfo.argnull[0] = false;
1155  fcinfo.argnull[1] = false;
1156  fcinfo.argnull[2] = false;
1157  fcinfo.argnull[3] = false;
1158  fcinfo.argnull[4] = false;
1159  fcinfo.argnull[5] = false;
1160 
1161  result = (*func) (&fcinfo);
1162 
1163  /* Check for null result, since caller is clearly not expecting one */
1164  if (fcinfo.isnull)
1165  elog(ERROR, "function %p returned NULL", (void *) func);
1166 
1167  return result;
1168 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum DirectFunctionCall7Coll ( PGFunction  func,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7 
)

Definition at line 1171 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1174 {
1175  FunctionCallInfoData fcinfo;
1176  Datum result;
1177 
1178  InitFunctionCallInfoData(fcinfo, NULL, 7, collation, NULL, NULL);
1179 
1180  fcinfo.arg[0] = arg1;
1181  fcinfo.arg[1] = arg2;
1182  fcinfo.arg[2] = arg3;
1183  fcinfo.arg[3] = arg4;
1184  fcinfo.arg[4] = arg5;
1185  fcinfo.arg[5] = arg6;
1186  fcinfo.arg[6] = arg7;
1187  fcinfo.argnull[0] = false;
1188  fcinfo.argnull[1] = false;
1189  fcinfo.argnull[2] = false;
1190  fcinfo.argnull[3] = false;
1191  fcinfo.argnull[4] = false;
1192  fcinfo.argnull[5] = false;
1193  fcinfo.argnull[6] = false;
1194 
1195  result = (*func) (&fcinfo);
1196 
1197  /* Check for null result, since caller is clearly not expecting one */
1198  if (fcinfo.isnull)
1199  elog(ERROR, "function %p returned NULL", (void *) func);
1200 
1201  return result;
1202 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
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 1205 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1208 {
1209  FunctionCallInfoData fcinfo;
1210  Datum result;
1211 
1212  InitFunctionCallInfoData(fcinfo, NULL, 8, collation, NULL, NULL);
1213 
1214  fcinfo.arg[0] = arg1;
1215  fcinfo.arg[1] = arg2;
1216  fcinfo.arg[2] = arg3;
1217  fcinfo.arg[3] = arg4;
1218  fcinfo.arg[4] = arg5;
1219  fcinfo.arg[5] = arg6;
1220  fcinfo.arg[6] = arg7;
1221  fcinfo.arg[7] = arg8;
1222  fcinfo.argnull[0] = false;
1223  fcinfo.argnull[1] = false;
1224  fcinfo.argnull[2] = false;
1225  fcinfo.argnull[3] = false;
1226  fcinfo.argnull[4] = false;
1227  fcinfo.argnull[5] = false;
1228  fcinfo.argnull[6] = false;
1229  fcinfo.argnull[7] = false;
1230 
1231  result = (*func) (&fcinfo);
1232 
1233  /* Check for null result, since caller is clearly not expecting one */
1234  if (fcinfo.isnull)
1235  elog(ERROR, "function %p returned NULL", (void *) func);
1236 
1237  return result;
1238 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
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 1241 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1245 {
1246  FunctionCallInfoData fcinfo;
1247  Datum result;
1248 
1249  InitFunctionCallInfoData(fcinfo, NULL, 9, collation, NULL, NULL);
1250 
1251  fcinfo.arg[0] = arg1;
1252  fcinfo.arg[1] = arg2;
1253  fcinfo.arg[2] = arg3;
1254  fcinfo.arg[3] = arg4;
1255  fcinfo.arg[4] = arg5;
1256  fcinfo.arg[5] = arg6;
1257  fcinfo.arg[6] = arg7;
1258  fcinfo.arg[7] = arg8;
1259  fcinfo.arg[8] = arg9;
1260  fcinfo.argnull[0] = false;
1261  fcinfo.argnull[1] = false;
1262  fcinfo.argnull[2] = false;
1263  fcinfo.argnull[3] = false;
1264  fcinfo.argnull[4] = false;
1265  fcinfo.argnull[5] = false;
1266  fcinfo.argnull[6] = false;
1267  fcinfo.argnull[7] = false;
1268  fcinfo.argnull[8] = false;
1269 
1270  result = (*func) (&fcinfo);
1271 
1272  /* Check for null result, since caller is clearly not expecting one */
1273  if (fcinfo.isnull)
1274  elog(ERROR, "function %p returned NULL", (void *) func);
1275 
1276  return result;
1277 }
#define ERROR
Definition: elog.h:43
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
const Pg_finfo_record* fetch_finfo_record ( void *  filehandle,
char *  funcname 
)

Definition at line 444 of file fmgr.c.

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

Referenced by fmgr_c_validator(), and fmgr_info_C_lang().

445 {
446  char *infofuncname;
447  PGFInfoFunction infofunc;
448  const Pg_finfo_record *inforec;
449  static Pg_finfo_record default_inforec = {0};
450 
451  infofuncname = psprintf("pg_finfo_%s", funcname);
452 
453  /* Try to look up the info function */
454  infofunc = (PGFInfoFunction) lookup_external_function(filehandle,
455  infofuncname);
456  if (infofunc == NULL)
457  {
458  /* Not found --- assume version 0 */
459  pfree(infofuncname);
460  return &default_inforec;
461  }
462 
463  /* Found, so call it */
464  inforec = (*infofunc) ();
465 
466  /* Validate result as best we can */
467  if (inforec == NULL)
468  elog(ERROR, "null result from info function \"%s\"", infofuncname);
469  switch (inforec->api_version)
470  {
471  case 0:
472  case 1:
473  /* OK, no additional fields to validate */
474  break;
475  default:
476  ereport(ERROR,
477  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
478  errmsg("unrecognized API version %d reported by info function \"%s\"",
479  inforec->api_version, infofuncname)));
480  break;
481  }
482 
483  pfree(infofuncname);
484  return inforec;
485 }
const Pg_finfo_record *(* PGFInfoFunction)(void)
Definition: fmgr.h:343
PGFunction lookup_external_function(void *filehandle, char *funcname)
Definition: dfmgr.c:158
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
int errcode(int sqlerrcode)
Definition: elog.c:575
void pfree(void *pointer)
Definition: mcxt.c:992
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:226
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define elog
Definition: elog.h:219
int api_version
Definition: fmgr.h:338
Datum Float4GetDatum ( float4  X)

Definition at line 2114 of file fmgr.c.

References palloc(), and PointerGetDatum.

Referenced by AddEnumLabel(), EnumValuesCreate(), gbt_num_fetch(), getNextNearest(), InsertPgClassTuple(), leftmostvalue_float4(), ProcedureCreate(), set_limit(), and update_attstats().

2115 {
2116  float4 *retval = (float4 *) palloc(sizeof(float4));
2117 
2118  *retval = X;
2119  return PointerGetDatum(retval);
2120 }
#define PointerGetDatum(X)
Definition: postgres.h:564
float float4
Definition: c.h:376
void * palloc(Size size)
Definition: mcxt.c:891
Datum Float8GetDatum ( float8  X)

Definition at line 2126 of file fmgr.c.

References palloc(), and PointerGetDatum.

Referenced by assign_random_seed(), compute_range_stats(), float8_lerp(), gbt_num_fetch(), getNextNearest(), hash_metapage_info(), int8_to_char(), interval_avg(), leftmostvalue_float8(), normal_rand(), pgstathashindex(), pgstattuple_approx_internal(), and spg_kd_picksplit().

2127 {
2128  float8 *retval = (float8 *) palloc(sizeof(float8));
2129 
2130  *retval = X;
2131  return PointerGetDatum(retval);
2132 }
#define PointerGetDatum(X)
Definition: postgres.h:564
double float8
Definition: c.h:377
void * palloc(Size size)
Definition: mcxt.c:891
char* fmgr ( Oid  procedureId,
  ... 
)

Definition at line 2046 of file fmgr.c.

References FunctionCallInfoData::arg, DatumGetPointer, elog, ereport, errcode(), errmsg(), ERROR, FunctionCallInfoData::flinfo, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_nargs, FmgrInfo::fn_oid, FUNC_MAX_ARGS, FunctionCallInvoke, i, FunctionCallInfoData::isnull, MemSet, FunctionCallInfoData::nargs, and PointerGetDatum.

2047 {
2048  FmgrInfo flinfo;
2049  FunctionCallInfoData fcinfo;
2050  int n_arguments;
2051  Datum result;
2052 
2053  fmgr_info(procedureId, &flinfo);
2054 
2055  MemSet(&fcinfo, 0, sizeof(fcinfo));
2056  fcinfo.flinfo = &flinfo;
2057  fcinfo.nargs = flinfo.fn_nargs;
2058  n_arguments = fcinfo.nargs;
2059 
2060  if (n_arguments > 0)
2061  {
2062  va_list pvar;
2063  int i;
2064 
2065  if (n_arguments > FUNC_MAX_ARGS)
2066  ereport(ERROR,
2067  (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2068  errmsg("function %u has too many arguments (%d, maximum is %d)",
2069  flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS)));
2070  va_start(pvar, procedureId);
2071  for (i = 0; i < n_arguments; i++)
2072  fcinfo.arg[i] = PointerGetDatum(va_arg(pvar, char *));
2073  va_end(pvar);
2074  }
2075 
2076  result = FunctionCallInvoke(&fcinfo);
2077 
2078  /* Check for null result, since caller is clearly not expecting one */
2079  if (fcinfo.isnull)
2080  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
2081 
2082  return DatumGetPointer(result);
2083 }
Definition: fmgr.h:53
short fn_nargs
Definition: fmgr.h:57
#define PointerGetDatum(X)
Definition: postgres.h:564
int errcode(int sqlerrcode)
Definition: elog.c:575
#define MemSet(start, val, len)
Definition: c.h:852
#define FUNC_MAX_ARGS
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
#define ereport(elevel, rest)
Definition: elog.h:122
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define DatumGetPointer(X)
Definition: postgres.h:557
int errmsg(const char *fmt,...)
Definition: elog.c:797
int i
#define elog
Definition: elog.h:219
void fmgr_info ( Oid  functionId,
FmgrInfo finfo 
)

Definition at line 159 of file fmgr.c.

References CurrentMemoryContext, and fmgr_info_cxt_security().

Referenced by _bt_find_extreme_element(), _bt_sort_array_elements(), _sv_to_datum_finfo(), BeginCopyFrom(), brin_page_items(), build_pertrans_for_aggref(), compute_distinct_stats(), CopyTo(), eqjoinsel_inner(), eqjoinsel_semi(), EventTriggerInvoke(), ExecCallTriggerFunc(), ExecHashTableCreate(), ExecInitAgg(), ExecInitExpr(), ExecInitSubPlan(), execTuplesHashPrepare(), execTuplesMatchPrepare(), fetch_fp_info(), fmgr(), get_variable_range(), inet_mcv_join_sel(), initialize_peragg(), ltreeparentsel(), networkjoinsel_semi(), networksel(), OidFunctionCall0Coll(), OidFunctionCall1Coll(), OidFunctionCall2Coll(), OidFunctionCall3Coll(), OidFunctionCall4Coll(), OidFunctionCall5Coll(), OidFunctionCall6Coll(), OidFunctionCall7Coll(), OidFunctionCall8Coll(), OidFunctionCall9Coll(), OidInputFunctionCall(), OidOutputFunctionCall(), OidReceiveFunctionCall(), OidSendFunctionCall(), patternsel(), plperl_ref_from_pg_array(), postgresBeginForeignModify(), prefix_quals(), prefix_selectivity(), prepare_query_params(), printtup_prepare_info(), RelationBuildPartitionKey(), scalararraysel(), scalarineqsel(), ScanKeyEntryInitialize(), ScanKeyInit(), text_format(), TupleDescGetAttInMetadata(), and var_eq_const().

160 {
161  fmgr_info_cxt_security(functionId, finfo, CurrentMemoryContext, false);
162 }
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:179
static void fmgr_info_C_lang ( Oid  functionId,
FmgrInfo finfo,
HeapTuple  procedureTuple 
)
static

Definition at line 305 of file fmgr.c.

References Anum_pg_proc_probin, Anum_pg_proc_prosrc, Pg_finfo_record::api_version, Oldstyle_fnextra::arg_toastable, elog, ERROR, fetch_finfo_record(), fmgr_oldstyle(), FmgrInfo::fn_addr, FmgrInfo::fn_extra, FmgrInfo::fn_mcxt, Oldstyle_fnextra::func, GETSTRUCT, i, CFuncHashTabEntry::inforec, load_external_function(), lookup_C_func(), MemoryContextAllocZero(), pfree(), PROCOID, record_C_func(), SysCacheGetAttr(), TextDatumGetCString, TypeIsToastable, and CFuncHashTabEntry::user_fn.

Referenced by fmgr_info_cxt_security().

306 {
307  Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
308  CFuncHashTabEntry *hashentry;
309  PGFunction user_fn;
310  const Pg_finfo_record *inforec;
311  Oldstyle_fnextra *fnextra;
312  bool isnull;
313  int i;
314 
315  /*
316  * See if we have the function address cached already
317  */
318  hashentry = lookup_C_func(procedureTuple);
319  if (hashentry)
320  {
321  user_fn = hashentry->user_fn;
322  inforec = hashentry->inforec;
323  }
324  else
325  {
326  Datum prosrcattr,
327  probinattr;
328  char *prosrcstring,
329  *probinstring;
330  void *libraryhandle;
331 
332  /*
333  * Get prosrc and probin strings (link symbol and library filename).
334  * While in general these columns might be null, that's not allowed
335  * for C-language functions.
336  */
337  prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
338  Anum_pg_proc_prosrc, &isnull);
339  if (isnull)
340  elog(ERROR, "null prosrc for C function %u", functionId);
341  prosrcstring = TextDatumGetCString(prosrcattr);
342 
343  probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
344  Anum_pg_proc_probin, &isnull);
345  if (isnull)
346  elog(ERROR, "null probin for C function %u", functionId);
347  probinstring = TextDatumGetCString(probinattr);
348 
349  /* Look up the function itself */
350  user_fn = load_external_function(probinstring, prosrcstring, true,
351  &libraryhandle);
352 
353  /* Get the function information record (real or default) */
354  inforec = fetch_finfo_record(libraryhandle, prosrcstring);
355 
356  /* Cache the addresses for later calls */
357  record_C_func(procedureTuple, user_fn, inforec);
358 
359  pfree(prosrcstring);
360  pfree(probinstring);
361  }
362 
363  switch (inforec->api_version)
364  {
365  case 0:
366  /* Old style: need to use a handler */
367  finfo->fn_addr = fmgr_oldstyle;
368  fnextra = (Oldstyle_fnextra *)
370  sizeof(Oldstyle_fnextra));
371  finfo->fn_extra = (void *) fnextra;
372  fnextra->func = (func_ptr) user_fn;
373  for (i = 0; i < procedureStruct->pronargs; i++)
374  {
375  fnextra->arg_toastable[i] =
376  TypeIsToastable(procedureStruct->proargtypes.values[i]);
377  }
378  break;
379  case 1:
380  /* New style: call directly */
381  finfo->fn_addr = user_fn;
382  break;
383  default:
384  /* Shouldn't get here if fetch_finfo_record did its job */
385  elog(ERROR, "unrecognized function API version: %d",
386  inforec->api_version);
387  break;
388  }
389 }
const Pg_finfo_record * fetch_finfo_record(void *filehandle, char *funcname)
Definition: fmgr.c:444
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
MemoryContext fn_mcxt
Definition: fmgr.h:62
char *(* func_ptr)()
Definition: fmgr.c:57
PGFunction fn_addr
Definition: fmgr.h:55
Datum(* PGFunction)(FunctionCallInfo fcinfo)
Definition: fmgr.h:40
const Pg_finfo_record * inforec
Definition: fmgr.c:80
#define Anum_pg_proc_prosrc
Definition: pg_proc.h:115
static Datum fmgr_oldstyle(PG_FUNCTION_ARGS)
Definition: fmgr.c:623
#define Anum_pg_proc_probin
Definition: pg_proc.h:116
void pfree(void *pointer)
Definition: mcxt.c:992
#define ERROR
Definition: elog.h:43
PGFunction user_fn
Definition: fmgr.c:79
PGFunction load_external_function(char *filename, char *funcname, bool signalNotFound, void **filehandle)
Definition: dfmgr.c:94
#define TextDatumGetCString(d)
Definition: builtins.h:91
uintptr_t Datum
Definition: postgres.h:374
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1245
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:784
static void record_C_func(HeapTuple procedureTuple, PGFunction user_fn, const Pg_finfo_record *inforec)
Definition: fmgr.c:527
func_ptr func
Definition: fmgr.c:65
static CFuncHashTabEntry * lookup_C_func(HeapTuple procedureTuple)
Definition: fmgr.c:503
void * fn_extra
Definition: fmgr.h:61
bool arg_toastable[FUNC_MAX_ARGS]
Definition: fmgr.c:66
int i
#define elog
Definition: elog.h:219
#define TypeIsToastable(typid)
Definition: lsyscache.h:167
int api_version
Definition: fmgr.h:338
void fmgr_info_copy ( FmgrInfo dstinfo,
FmgrInfo srcinfo,
MemoryContext  destcxt 
)

Definition at line 583 of file fmgr.c.

References fmgr_oldstyle(), FmgrInfo::fn_addr, FmgrInfo::fn_extra, FmgrInfo::fn_mcxt, MemoryContextAlloc(), and NULL.

Referenced by bringetbitmap(), gistrescan(), inclusion_get_procinfo(), initBloomState(), initGinState(), initGISTstate(), and ScanKeyEntryInitializeWithInfo().

585 {
586  memcpy(dstinfo, srcinfo, sizeof(FmgrInfo));
587  dstinfo->fn_mcxt = destcxt;
588  if (dstinfo->fn_addr == fmgr_oldstyle)
589  {
590  /* For oldstyle functions we must copy fn_extra */
591  Oldstyle_fnextra *fnextra;
592 
593  fnextra = (Oldstyle_fnextra *)
594  MemoryContextAlloc(destcxt, sizeof(Oldstyle_fnextra));
595  memcpy(fnextra, srcinfo->fn_extra, sizeof(Oldstyle_fnextra));
596  dstinfo->fn_extra = (void *) fnextra;
597  }
598  else
599  dstinfo->fn_extra = NULL;
600 }
Definition: fmgr.h:53
MemoryContext fn_mcxt
Definition: fmgr.h:62
PGFunction fn_addr
Definition: fmgr.h:55
static Datum fmgr_oldstyle(PG_FUNCTION_ARGS)
Definition: fmgr.c:623
#define NULL
Definition: c.h:226
void * fn_extra
Definition: fmgr.h:61
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:749
static void fmgr_info_cxt_security ( Oid  functionId,
FmgrInfo finfo,
MemoryContext  mcxt,
bool  ignore_security 
)
static

Definition at line 179 of file fmgr.c.

References Anum_pg_proc_proconfig, Anum_pg_proc_prosrc, ClanguageId, elog, ereport, errcode(), errmsg(), ERROR, fmgr_info_C_lang(), fmgr_info_other_lang(), fmgr_isbuiltin(), fmgr_lookupByName(), fmgr_security_definer(), fmgr_sql(), FmgrHookIsNeeded, FmgrInfo::fn_addr, FmgrInfo::fn_expr, FmgrInfo::fn_extra, FmgrInfo::fn_mcxt, FmgrInfo::fn_nargs, FmgrInfo::fn_oid, FmgrInfo::fn_retset, FmgrInfo::fn_stats, FmgrInfo::fn_strict, FmgrBuiltin::func, GETSTRUCT, heap_attisnull(), HeapTupleIsValid, INTERNALlanguageId, InvalidOid, FmgrBuiltin::nargs, NULL, ObjectIdGetDatum, pfree(), PROCOID, ReleaseSysCache(), FmgrBuiltin::retset, SearchSysCache1, SQLlanguageId, FmgrBuiltin::strict, SysCacheGetAttr(), TextDatumGetCString, TRACK_FUNC_ALL, TRACK_FUNC_OFF, and TRACK_FUNC_PL.

Referenced by fmgr_info(), fmgr_info_cxt(), fmgr_info_other_lang(), and fmgr_security_definer().

181 {
182  const FmgrBuiltin *fbp;
183  HeapTuple procedureTuple;
184  Form_pg_proc procedureStruct;
185  Datum prosrcdatum;
186  bool isnull;
187  char *prosrc;
188 
189  /*
190  * fn_oid *must* be filled in last. Some code assumes that if fn_oid is
191  * valid, the whole struct is valid. Some FmgrInfo struct's do survive
192  * elogs.
193  */
194  finfo->fn_oid = InvalidOid;
195  finfo->fn_extra = NULL;
196  finfo->fn_mcxt = mcxt;
197  finfo->fn_expr = NULL; /* caller may set this later */
198 
199  if ((fbp = fmgr_isbuiltin(functionId)) != NULL)
200  {
201  /*
202  * Fast path for builtin functions: don't bother consulting pg_proc
203  */
204  finfo->fn_nargs = fbp->nargs;
205  finfo->fn_strict = fbp->strict;
206  finfo->fn_retset = fbp->retset;
207  finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */
208  finfo->fn_addr = fbp->func;
209  finfo->fn_oid = functionId;
210  return;
211  }
212 
213  /* Otherwise we need the pg_proc entry */
214  procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
215  if (!HeapTupleIsValid(procedureTuple))
216  elog(ERROR, "cache lookup failed for function %u", functionId);
217  procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
218 
219  finfo->fn_nargs = procedureStruct->pronargs;
220  finfo->fn_strict = procedureStruct->proisstrict;
221  finfo->fn_retset = procedureStruct->proretset;
222 
223  /*
224  * If it has prosecdef set, non-null proconfig, or if a plugin wants to
225  * hook function entry/exit, use fmgr_security_definer call handler ---
226  * unless we are being called again by fmgr_security_definer or
227  * fmgr_info_other_lang.
228  *
229  * When using fmgr_security_definer, function stats tracking is always
230  * disabled at the outer level, and instead we set the flag properly in
231  * fmgr_security_definer's private flinfo and implement the tracking
232  * inside fmgr_security_definer. This loses the ability to charge the
233  * overhead of fmgr_security_definer to the function, but gains the
234  * ability to set the track_functions GUC as a local GUC parameter of an
235  * interesting function and have the right things happen.
236  */
237  if (!ignore_security &&
238  (procedureStruct->prosecdef ||
239  !heap_attisnull(procedureTuple, Anum_pg_proc_proconfig) ||
240  FmgrHookIsNeeded(functionId)))
241  {
243  finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */
244  finfo->fn_oid = functionId;
245  ReleaseSysCache(procedureTuple);
246  return;
247  }
248 
249  switch (procedureStruct->prolang)
250  {
251  case INTERNALlanguageId:
252 
253  /*
254  * For an ordinary builtin function, we should never get here
255  * because the isbuiltin() search above will have succeeded.
256  * However, if the user has done a CREATE FUNCTION to create an
257  * alias for a builtin function, we can end up here. In that case
258  * we have to look up the function by name. The name of the
259  * internal function is stored in prosrc (it doesn't have to be
260  * the same as the name of the alias!)
261  */
262  prosrcdatum = SysCacheGetAttr(PROCOID, procedureTuple,
263  Anum_pg_proc_prosrc, &isnull);
264  if (isnull)
265  elog(ERROR, "null prosrc");
266  prosrc = TextDatumGetCString(prosrcdatum);
267  fbp = fmgr_lookupByName(prosrc);
268  if (fbp == NULL)
269  ereport(ERROR,
270  (errcode(ERRCODE_UNDEFINED_FUNCTION),
271  errmsg("internal function \"%s\" is not in internal lookup table",
272  prosrc)));
273  pfree(prosrc);
274  /* Should we check that nargs, strict, retset match the table? */
275  finfo->fn_addr = fbp->func;
276  /* note this policy is also assumed in fast path above */
277  finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */
278  break;
279 
280  case ClanguageId:
281  fmgr_info_C_lang(functionId, finfo, procedureTuple);
282  finfo->fn_stats = TRACK_FUNC_PL; /* ie, track if ALL */
283  break;
284 
285  case SQLlanguageId:
286  finfo->fn_addr = fmgr_sql;
287  finfo->fn_stats = TRACK_FUNC_PL; /* ie, track if ALL */
288  break;
289 
290  default:
291  fmgr_info_other_lang(functionId, finfo, procedureTuple);
292  finfo->fn_stats = TRACK_FUNC_OFF; /* ie, track if not OFF */
293  break;
294  }
295 
296  finfo->fn_oid = functionId;
297  ReleaseSysCache(procedureTuple);
298 }
bool strict
Definition: fmgrtab.h:30
short fn_nargs
Definition: fmgr.h:57
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
MemoryContext fn_mcxt
Definition: fmgr.h:62
short nargs
Definition: fmgrtab.h:29
#define INTERNALlanguageId
Definition: pg_language.h:74
static Datum fmgr_security_definer(PG_FUNCTION_ARGS)
Definition: fmgr.c:883
PGFunction fn_addr
Definition: fmgr.h:55
static void fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
Definition: fmgr.c:396
#define Anum_pg_proc_prosrc
Definition: pg_proc.h:115
#define ClanguageId
Definition: pg_language.h:77
int errcode(int sqlerrcode)
Definition: elog.c:575
#define FmgrHookIsNeeded(fn_oid)
Definition: fmgr.h:699
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define Anum_pg_proc_proconfig
Definition: pg_proc.h:117
static void fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
Definition: fmgr.c:305
PGFunction func
Definition: fmgrtab.h:32
void pfree(void *pointer)
Definition: mcxt.c:992
bool fn_retset
Definition: fmgr.h:59
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
bool fn_strict
Definition: fmgr.h:58
#define SQLlanguageId
Definition: pg_language.h:80
bool heap_attisnull(HeapTuple tup, int attnum)
Definition: heaptuple.c:297
Datum fmgr_sql(PG_FUNCTION_ARGS)
Definition: functions.c:985
static const FmgrBuiltin * fmgr_lookupByName(const char *name)
Definition: fmgr.c:133
#define ereport(elevel, rest)
Definition: elog.h:122
#define TextDatumGetCString(d)
Definition: builtins.h:91
static const FmgrBuiltin * fmgr_isbuiltin(Oid id)
Definition: fmgr.c:103
uintptr_t Datum
Definition: postgres.h:374
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1245
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:56
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:226
fmNodePtr fn_expr
Definition: fmgr.h:63
void * fn_extra
Definition: fmgr.h:61
int errmsg(const char *fmt,...)
Definition: elog.c:797
unsigned char fn_stats
Definition: fmgr.h:60
#define elog
Definition: elog.h:219
bool retset
Definition: fmgrtab.h:31
static void fmgr_info_other_lang ( Oid  functionId,
FmgrInfo finfo,
HeapTuple  procedureTuple 
)
static

Definition at line 396 of file fmgr.c.

References CurrentMemoryContext, elog, ERROR, fmgr_info_cxt_security(), FmgrInfo::fn_addr, FmgrInfo::fn_extra, GETSTRUCT, HeapTupleIsValid, LANGOID, NULL, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1.

Referenced by fmgr_info_cxt_security().

397 {
398  Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
399  Oid language = procedureStruct->prolang;
400  HeapTuple languageTuple;
401  Form_pg_language languageStruct;
402  FmgrInfo plfinfo;
403 
404  languageTuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(language));
405  if (!HeapTupleIsValid(languageTuple))
406  elog(ERROR, "cache lookup failed for language %u", language);
407  languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
408 
409  /*
410  * Look up the language's call handler function, ignoring any attributes
411  * that would normally cause insertion of fmgr_security_definer. We need
412  * to get back a bare pointer to the actual C-language function.
413  */
414  fmgr_info_cxt_security(languageStruct->lanplcallfoid, &plfinfo,
415  CurrentMemoryContext, true);
416  finfo->fn_addr = plfinfo.fn_addr;
417 
418  /*
419  * If lookup of the PL handler function produced nonnull fn_extra,
420  * complain --- it must be an oldstyle function! We no longer support
421  * oldstyle PL handlers.
422  */
423  if (plfinfo.fn_extra != NULL)
424  elog(ERROR, "language %u has old-style handler", language);
425 
426  ReleaseSysCache(languageTuple);
427 }
Definition: fmgr.h:53
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
PGFunction fn_addr
Definition: fmgr.h:55
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:226
void * fn_extra
Definition: fmgr.h:61
FormData_pg_language * Form_pg_language
Definition: pg_language.h:51
#define elog
Definition: elog.h:219
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:179
Oid fmgr_internal_function ( const char *  proname)

Definition at line 609 of file fmgr.c.

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

Referenced by fmgr_internal_validator().

610 {
611  const FmgrBuiltin *fbp = fmgr_lookupByName(proname);
612 
613  if (fbp == NULL)
614  return InvalidOid;
615  return fbp->foid;
616 }
Oid foid
Definition: fmgrtab.h:27
static const FmgrBuiltin * fmgr_lookupByName(const char *name)
Definition: fmgr.c:133
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:226
static const FmgrBuiltin* fmgr_isbuiltin ( Oid  id)
static

Definition at line 103 of file fmgr.c.

References fmgr_builtins, fmgr_nbuiltins, FmgrBuiltin::foid, i, and NULL.

Referenced by fmgr_info_cxt_security().

104 {
105  int low = 0;
106  int high = fmgr_nbuiltins - 1;
107 
108  /*
109  * Loop invariant: low is the first index that could contain target entry,
110  * and high is the last index that could contain it.
111  */
112  while (low <= high)
113  {
114  int i = (high + low) / 2;
115  const FmgrBuiltin *ptr = &fmgr_builtins[i];
116 
117  if (id == ptr->foid)
118  return ptr;
119  else if (id > ptr->foid)
120  low = i + 1;
121  else
122  high = i - 1;
123  }
124  return NULL;
125 }
Oid foid
Definition: fmgrtab.h:27
const int fmgr_nbuiltins
const FmgrBuiltin fmgr_builtins[]
#define NULL
Definition: c.h:226
int i
static const FmgrBuiltin* fmgr_lookupByName ( const char *  name)
static

Definition at line 133 of file fmgr.c.

References fmgr_builtins, fmgr_nbuiltins, i, and NULL.

Referenced by fmgr_info_cxt_security(), and fmgr_internal_function().

134 {
135  int i;
136 
137  for (i = 0; i < fmgr_nbuiltins; i++)
138  {
139  if (strcmp(name, fmgr_builtins[i].funcName) == 0)
140  return fmgr_builtins + i;
141  }
142  return NULL;
143 }
const int fmgr_nbuiltins
const FmgrBuiltin fmgr_builtins[]
#define NULL
Definition: c.h:226
const char * name
Definition: encode.c:521
int i
static Datum fmgr_oldstyle ( PG_FUNCTION_ARGS  )
static

Definition at line 623 of file fmgr.c.

References Oldstyle_fnextra::arg_toastable, elog, ereport, errcode(), errmsg(), ERROR, Oldstyle_fnextra::func, i, NULL, PG_ARGISNULL, PG_DETOAST_DATUM, and PointerGetDatum.

Referenced by fmgr_info_C_lang(), and fmgr_info_copy().

624 {
625  Oldstyle_fnextra *fnextra;
626  int n_arguments = fcinfo->nargs;
627  int i;
628  bool isnull;
629  func_ptr user_fn;
630  char *returnValue;
631 
632  if (fcinfo->flinfo == NULL || fcinfo->flinfo->fn_extra == NULL)
633  elog(ERROR, "fmgr_oldstyle received NULL pointer");
634  fnextra = (Oldstyle_fnextra *) fcinfo->flinfo->fn_extra;
635 
636  /*
637  * Result is NULL if any argument is NULL, but we still call the function
638  * (peculiar, but that's the way it worked before, and after all this is a
639  * backwards-compatibility wrapper). Note, however, that we'll never get
640  * here with NULL arguments if the function is marked strict.
641  *
642  * We also need to detoast any TOAST-ed inputs, since it's unlikely that
643  * an old-style function knows about TOASTing.
644  */
645  isnull = false;
646  for (i = 0; i < n_arguments; i++)
647  {
648  if (PG_ARGISNULL(i))
649  isnull = true;
650  else if (fnextra->arg_toastable[i])
651  fcinfo->arg[i] = PointerGetDatum(PG_DETOAST_DATUM(fcinfo->arg[i]));
652  }
653  fcinfo->isnull = isnull;
654 
655  user_fn = fnextra->func;
656 
657  switch (n_arguments)
658  {
659  case 0:
660  returnValue = (char *) (*user_fn) ();
661  break;
662  case 1:
663 
664  /*
665  * nullvalue() used to use isNull to check if arg is NULL; perhaps
666  * there are other functions still out there that also rely on
667  * this undocumented hack?
668  */
669  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
670  &fcinfo->isnull);
671  break;
672  case 2:
673  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
674  fcinfo->arg[1]);
675  break;
676  case 3:
677  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
678  fcinfo->arg[1],
679  fcinfo->arg[2]);
680  break;
681  case 4:
682  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
683  fcinfo->arg[1],
684  fcinfo->arg[2],
685  fcinfo->arg[3]);
686  break;
687  case 5:
688  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
689  fcinfo->arg[1],
690  fcinfo->arg[2],
691  fcinfo->arg[3],
692  fcinfo->arg[4]);
693  break;
694  case 6:
695  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
696  fcinfo->arg[1],
697  fcinfo->arg[2],
698  fcinfo->arg[3],
699  fcinfo->arg[4],
700  fcinfo->arg[5]);
701  break;
702  case 7:
703  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
704  fcinfo->arg[1],
705  fcinfo->arg[2],
706  fcinfo->arg[3],
707  fcinfo->arg[4],
708  fcinfo->arg[5],
709  fcinfo->arg[6]);
710  break;
711  case 8:
712  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
713  fcinfo->arg[1],
714  fcinfo->arg[2],
715  fcinfo->arg[3],
716  fcinfo->arg[4],
717  fcinfo->arg[5],
718  fcinfo->arg[6],
719  fcinfo->arg[7]);
720  break;
721  case 9:
722  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
723  fcinfo->arg[1],
724  fcinfo->arg[2],
725  fcinfo->arg[3],
726  fcinfo->arg[4],
727  fcinfo->arg[5],
728  fcinfo->arg[6],
729  fcinfo->arg[7],
730  fcinfo->arg[8]);
731  break;
732  case 10:
733  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
734  fcinfo->arg[1],
735  fcinfo->arg[2],
736  fcinfo->arg[3],
737  fcinfo->arg[4],
738  fcinfo->arg[5],
739  fcinfo->arg[6],
740  fcinfo->arg[7],
741  fcinfo->arg[8],
742  fcinfo->arg[9]);
743  break;
744  case 11:
745  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
746  fcinfo->arg[1],
747  fcinfo->arg[2],
748  fcinfo->arg[3],
749  fcinfo->arg[4],
750  fcinfo->arg[5],
751  fcinfo->arg[6],
752  fcinfo->arg[7],
753  fcinfo->arg[8],
754  fcinfo->arg[9],
755  fcinfo->arg[10]);
756  break;
757  case 12:
758  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
759  fcinfo->arg[1],
760  fcinfo->arg[2],
761  fcinfo->arg[3],
762  fcinfo->arg[4],
763  fcinfo->arg[5],
764  fcinfo->arg[6],
765  fcinfo->arg[7],
766  fcinfo->arg[8],
767  fcinfo->arg[9],
768  fcinfo->arg[10],
769  fcinfo->arg[11]);
770  break;
771  case 13:
772  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
773  fcinfo->arg[1],
774  fcinfo->arg[2],
775  fcinfo->arg[3],
776  fcinfo->arg[4],
777  fcinfo->arg[5],
778  fcinfo->arg[6],
779  fcinfo->arg[7],
780  fcinfo->arg[8],
781  fcinfo->arg[9],
782  fcinfo->arg[10],
783  fcinfo->arg[11],
784  fcinfo->arg[12]);
785  break;
786  case 14:
787  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
788  fcinfo->arg[1],
789  fcinfo->arg[2],
790  fcinfo->arg[3],
791  fcinfo->arg[4],
792  fcinfo->arg[5],
793  fcinfo->arg[6],
794  fcinfo->arg[7],
795  fcinfo->arg[8],
796  fcinfo->arg[9],
797  fcinfo->arg[10],
798  fcinfo->arg[11],
799  fcinfo->arg[12],
800  fcinfo->arg[13]);
801  break;
802  case 15:
803  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
804  fcinfo->arg[1],
805  fcinfo->arg[2],
806  fcinfo->arg[3],
807  fcinfo->arg[4],
808  fcinfo->arg[5],
809  fcinfo->arg[6],
810  fcinfo->arg[7],
811  fcinfo->arg[8],
812  fcinfo->arg[9],
813  fcinfo->arg[10],
814  fcinfo->arg[11],
815  fcinfo->arg[12],
816  fcinfo->arg[13],
817  fcinfo->arg[14]);
818  break;
819  case 16:
820  returnValue = (char *) (*user_fn) (fcinfo->arg[0],
821  fcinfo->arg[1],
822  fcinfo->arg[2],
823  fcinfo->arg[3],
824  fcinfo->arg[4],
825  fcinfo->arg[5],
826  fcinfo->arg[6],
827  fcinfo->arg[7],
828  fcinfo->arg[8],
829  fcinfo->arg[9],
830  fcinfo->arg[10],
831  fcinfo->arg[11],
832  fcinfo->arg[12],
833  fcinfo->arg[13],
834  fcinfo->arg[14],
835  fcinfo->arg[15]);
836  break;
837  default:
838 
839  /*
840  * Increasing FUNC_MAX_ARGS doesn't automatically add cases to the
841  * above code, so mention the actual value in this error not
842  * FUNC_MAX_ARGS. You could add cases to the above if you needed
843  * to support old-style functions with many arguments, but making
844  * 'em be new-style is probably a better idea.
845  */
846  ereport(ERROR,
847  (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
848  errmsg("function %u has too many arguments (%d, maximum is %d)",
849  fcinfo->flinfo->fn_oid, n_arguments, 16)));
850  returnValue = NULL; /* keep compiler quiet */
851  break;
852  }
853 
854  return PointerGetDatum(returnValue);
855 }
char *(* func_ptr)()
Definition: fmgr.c:57
#define PointerGetDatum(X)
Definition: postgres.h:564
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
#define PG_ARGISNULL(n)
Definition: fmgr.h:166
#define NULL
Definition: c.h:226
func_ptr func
Definition: fmgr.c:65
bool arg_toastable[FUNC_MAX_ARGS]
Definition: fmgr.c:66
int errmsg(const char *fmt,...)
Definition: elog.c:797
int i
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:196
#define elog
Definition: elog.h:219
static Datum fmgr_security_definer ( PG_FUNCTION_ARGS  )
static

Definition at line 883 of file fmgr.c.

References Anum_pg_proc_proconfig, fmgr_security_definer_cache::arg, AtEOXact_GUC(), DatumGetArrayTypePCopy, elog, ERROR, ExprMultipleResult, FHET_ABORT, FHET_END, FHET_START, fmgr_security_definer_cache::flinfo, fmgr_hook, fmgr_info_cxt_security(), FmgrInfo::fn_expr, FmgrInfo::fn_extra, FmgrInfo::fn_mcxt, FunctionCallInvoke, GETSTRUCT, GetUserIdAndSecContext(), GUC_ACTION_SAVE, HeapTupleIsValid, IsA, MemoryContextAllocZero(), MemoryContextSwitchTo(), NewGUCNestLevel(), NULL, ObjectIdGetDatum, OidIsValid, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, pgstat_end_function_usage(), pgstat_init_function_usage(), ProcessGUCArray(), PROCOID, fmgr_security_definer_cache::proconfig, ReleaseSysCache(), SearchSysCache1, SECURITY_LOCAL_USERID_CHANGE, SetUserIdAndSecContext(), superuser(), SysCacheGetAttr(), and fmgr_security_definer_cache::userid.

Referenced by fmgr_info_cxt_security().

884 {
885  Datum result;
886  struct fmgr_security_definer_cache *volatile fcache;
887  FmgrInfo *save_flinfo;
888  Oid save_userid;
889  int save_sec_context;
890  volatile int save_nestlevel;
891  PgStat_FunctionCallUsage fcusage;
892 
893  if (!fcinfo->flinfo->fn_extra)
894  {
895  HeapTuple tuple;
896  Form_pg_proc procedureStruct;
897  Datum datum;
898  bool isnull;
899  MemoryContext oldcxt;
900 
901  fcache = MemoryContextAllocZero(fcinfo->flinfo->fn_mcxt,
902  sizeof(*fcache));
903 
904  fmgr_info_cxt_security(fcinfo->flinfo->fn_oid, &fcache->flinfo,
905  fcinfo->flinfo->fn_mcxt, true);
906  fcache->flinfo.fn_expr = fcinfo->flinfo->fn_expr;
907 
908  tuple = SearchSysCache1(PROCOID,
909  ObjectIdGetDatum(fcinfo->flinfo->fn_oid));
910  if (!HeapTupleIsValid(tuple))
911  elog(ERROR, "cache lookup failed for function %u",
912  fcinfo->flinfo->fn_oid);
913  procedureStruct = (Form_pg_proc) GETSTRUCT(tuple);
914 
915  if (procedureStruct->prosecdef)
916  fcache->userid = procedureStruct->proowner;
917 
919  &isnull);
920  if (!isnull)
921  {
922  oldcxt = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
923  fcache->proconfig = DatumGetArrayTypePCopy(datum);
924  MemoryContextSwitchTo(oldcxt);
925  }
926 
927  ReleaseSysCache(tuple);
928 
929  fcinfo->flinfo->fn_extra = fcache;
930  }
931  else
932  fcache = fcinfo->flinfo->fn_extra;
933 
934  /* GetUserIdAndSecContext is cheap enough that no harm in a wasted call */
935  GetUserIdAndSecContext(&save_userid, &save_sec_context);
936  if (fcache->proconfig) /* Need a new GUC nesting level */
937  save_nestlevel = NewGUCNestLevel();
938  else
939  save_nestlevel = 0; /* keep compiler quiet */
940 
941  if (OidIsValid(fcache->userid))
943  save_sec_context | SECURITY_LOCAL_USERID_CHANGE);
944 
945  if (fcache->proconfig)
946  {
947  ProcessGUCArray(fcache->proconfig,
951  }
952 
953  /* function manager hook */
954  if (fmgr_hook)
955  (*fmgr_hook) (FHET_START, &fcache->flinfo, &fcache->arg);
956 
957  /*
958  * We don't need to restore GUC or userid settings on error, because the
959  * ensuing xact or subxact abort will do that. The PG_TRY block is only
960  * needed to clean up the flinfo link.
961  */
962  save_flinfo = fcinfo->flinfo;
963 
964  PG_TRY();
965  {
966  fcinfo->flinfo = &fcache->flinfo;
967 
968  /* See notes in fmgr_info_cxt_security */
969  pgstat_init_function_usage(fcinfo, &fcusage);
970 
971  result = FunctionCallInvoke(fcinfo);
972 
973  /*
974  * We could be calling either a regular or a set-returning function,
975  * so we have to test to see what finalize flag to use.
976  */
977  pgstat_end_function_usage(&fcusage,
978  (fcinfo->resultinfo == NULL ||
979  !IsA(fcinfo->resultinfo, ReturnSetInfo) ||
980  ((ReturnSetInfo *) fcinfo->resultinfo)->isDone != ExprMultipleResult));
981  }
982  PG_CATCH();
983  {
984  fcinfo->flinfo = save_flinfo;
985  if (fmgr_hook)
986  (*fmgr_hook) (FHET_ABORT, &fcache->flinfo, &fcache->arg);
987  PG_RE_THROW();
988  }
989  PG_END_TRY();
990 
991  fcinfo->flinfo = save_flinfo;
992 
993  if (fcache->proconfig)
994  AtEOXact_GUC(true, save_nestlevel);
995  if (OidIsValid(fcache->userid))
996  SetUserIdAndSecContext(save_userid, save_sec_context);
997  if (fmgr_hook)
998  (*fmgr_hook) (FHET_END, &fcache->flinfo, &fcache->arg);
999 
1000  return result;
1001 }
Definition: fmgr.h:53
#define IsA(nodeptr, _type_)
Definition: nodes.h:559
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
MemoryContext fn_mcxt
Definition: fmgr.h:62
void SetUserIdAndSecContext(Oid userid, int sec_context)
Definition: miscinit.c:395
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
bool superuser(void)
Definition: superuser.c:47
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:533
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:149
#define Anum_pg_proc_proconfig
Definition: pg_proc.h:117
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
Definition: guc.h:75
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
Definition: miscinit.c:388
void AtEOXact_GUC(bool isCommit, int nestLevel)
Definition: guc.c:5040
Definition: fmgr.h:687
ArrayType * proconfig
Definition: fmgr.c:868
uintptr_t Datum
Definition: postgres.h:374
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1083
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1245
#define DatumGetArrayTypePCopy(X)
Definition: array.h:243
PGDLLIMPORT fmgr_hook_type fmgr_hook
Definition: fmgr.c:37
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:291
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:784
void ProcessGUCArray(ArrayType *array, GucContext context, GucSource source, GucAction action)
Definition: guc.c:9370
#define PG_CATCH()
Definition: elog.h:293
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:226
fmNodePtr fn_expr
Definition: fmgr.h:63
#define PG_RE_THROW()
Definition: elog.h:314
void * fn_extra
Definition: fmgr.h:61
void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
Definition: pgstat.c:1577
void pgstat_init_function_usage(FunctionCallInfoData *fcinfo, PgStat_FunctionCallUsage *fcu)
Definition: pgstat.c:1505
int NewGUCNestLevel(void)
Definition: guc.c:5026
#define elog
Definition: elog.h:219
#define PG_TRY()
Definition: elog.h:284
#define PG_END_TRY()
Definition: elog.h:300
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:179
Datum FunctionCall1Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1 
)

Definition at line 1286 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by _hash_datum2hashkey(), brin_inclusion_add_value(), element_hash(), gistdentryinit(), gistFetchAtt(), gistFormTuple(), and hash_range().

1287 {
1288  FunctionCallInfoData fcinfo;
1289  Datum result;
1290 
1291  InitFunctionCallInfoData(fcinfo, flinfo, 1, collation, NULL, NULL);
1292 
1293  fcinfo.arg[0] = arg1;
1294  fcinfo.argnull[0] = false;
1295 
1296  result = FunctionCallInvoke(&fcinfo);
1297 
1298  /* Check for null result, since caller is clearly not expecting one */
1299  if (fcinfo.isnull)
1300  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1301 
1302  return result;
1303 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum FunctionCall2Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 1306 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by _bt_check_rowcompare(), _bt_checkkeys(), _bt_compare(), _bt_compare_array_elements(), _bt_compare_scankey_args(), _bt_find_extreme_element(), _bt_isequal(), _bt_sort_array_elements(), _hash_checkqual(), array_position_common(), array_positions(), brin_inclusion_add_value(), brin_inclusion_consistent(), brin_inclusion_union(), brin_minmax_add_value(), brin_minmax_consistent(), brin_minmax_union(), call_subtype_diff(), cmpEntries(), compute_distinct_stats(), compute_range_stats(), doPickSplit(), element_compare(), eqjoinsel_inner(), eqjoinsel_semi(), genericPickSplit(), get_distance(), get_position(), get_variable_range(), ginCompareEntries(), gistMakeUnionItVec(), gistMakeUnionKey(), gistUserPicksplit(), histogram_selectivity(), ineq_histogram_selectivity(), make_greater_string(), mcv_selectivity(), partition_bound_cmp(), partition_rbound_cmp(), partition_rbound_datum_cmp(), qsort_partition_list_value_cmp(), range_cmp_bound_values(), range_cmp_bounds(), range_contains_elem_internal(), RelationBuildPartitionDesc(), spgdoinsert(), spgGetCache(), spgLeafTest(), spgWalk(), and var_eq_const().

1307 {
1308  FunctionCallInfoData fcinfo;
1309  Datum result;
1310 
1311  InitFunctionCallInfoData(fcinfo, flinfo, 2, collation, NULL, NULL);
1312 
1313  fcinfo.arg[0] = arg1;
1314  fcinfo.arg[1] = arg2;
1315  fcinfo.argnull[0] = false;
1316  fcinfo.argnull[1] = false;
1317 
1318  result = FunctionCallInvoke(&fcinfo);
1319 
1320  /* Check for null result, since caller is clearly not expecting one */
1321  if (fcinfo.isnull)
1322  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1323 
1324  return result;
1325 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum FunctionCall3Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3 
)

Definition at line 1328 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

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

1330 {
1331  FunctionCallInfoData fcinfo;
1332  Datum result;
1333 
1334  InitFunctionCallInfoData(fcinfo, flinfo, 3, collation, NULL, NULL);
1335 
1336  fcinfo.arg[0] = arg1;
1337  fcinfo.arg[1] = arg2;
1338  fcinfo.arg[2] = arg3;
1339  fcinfo.argnull[0] = false;
1340  fcinfo.argnull[1] = false;
1341  fcinfo.argnull[2] = 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", fcinfo.flinfo->fn_oid);
1348 
1349  return result;
1350 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum FunctionCall4Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4 
)

Definition at line 1353 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by brinbuildCallback(), brininsert(), collectMatchBitmap(), matchPartialInPendingList(), and scalararraysel().

1355 {
1356  FunctionCallInfoData fcinfo;
1357  Datum result;
1358 
1359  InitFunctionCallInfoData(fcinfo, flinfo, 4, collation, NULL, NULL);
1360 
1361  fcinfo.arg[0] = arg1;
1362  fcinfo.arg[1] = arg2;
1363  fcinfo.arg[2] = arg3;
1364  fcinfo.arg[3] = arg4;
1365  fcinfo.argnull[0] = false;
1366  fcinfo.argnull[1] = false;
1367  fcinfo.argnull[2] = false;
1368  fcinfo.argnull[3] = false;
1369 
1370  result = FunctionCallInvoke(&fcinfo);
1371 
1372  /* Check for null result, since caller is clearly not expecting one */
1373  if (fcinfo.isnull)
1374  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1375 
1376  return result;
1377 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum FunctionCall5Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5 
)

Definition at line 1380 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by gistindex_keytest(), and scalararraysel().

1382 {
1383  FunctionCallInfoData fcinfo;
1384  Datum result;
1385 
1386  InitFunctionCallInfoData(fcinfo, flinfo, 5, collation, NULL, NULL);
1387 
1388  fcinfo.arg[0] = arg1;
1389  fcinfo.arg[1] = arg2;
1390  fcinfo.arg[2] = arg3;
1391  fcinfo.arg[3] = arg4;
1392  fcinfo.arg[4] = arg5;
1393  fcinfo.argnull[0] = false;
1394  fcinfo.argnull[1] = false;
1395  fcinfo.argnull[2] = false;
1396  fcinfo.argnull[3] = false;
1397  fcinfo.argnull[4] = false;
1398 
1399  result = FunctionCallInvoke(&fcinfo);
1400 
1401  /* Check for null result, since caller is clearly not expecting one */
1402  if (fcinfo.isnull)
1403  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1404 
1405  return result;
1406 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum FunctionCall6Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6 
)

Definition at line 1409 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1412 {
1413  FunctionCallInfoData fcinfo;
1414  Datum result;
1415 
1416  InitFunctionCallInfoData(fcinfo, flinfo, 6, collation, NULL, NULL);
1417 
1418  fcinfo.arg[0] = arg1;
1419  fcinfo.arg[1] = arg2;
1420  fcinfo.arg[2] = arg3;
1421  fcinfo.arg[3] = arg4;
1422  fcinfo.arg[4] = arg5;
1423  fcinfo.arg[5] = arg6;
1424  fcinfo.argnull[0] = false;
1425  fcinfo.argnull[1] = false;
1426  fcinfo.argnull[2] = false;
1427  fcinfo.argnull[3] = false;
1428  fcinfo.argnull[4] = false;
1429  fcinfo.argnull[5] = false;
1430 
1431  result = FunctionCallInvoke(&fcinfo);
1432 
1433  /* Check for null result, since caller is clearly not expecting one */
1434  if (fcinfo.isnull)
1435  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1436 
1437  return result;
1438 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum FunctionCall7Coll ( FmgrInfo flinfo,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7 
)

Definition at line 1441 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by directTriConsistentFn(), ginNewScanKey(), and shimBoolConsistentFn().

1444 {
1445  FunctionCallInfoData fcinfo;
1446  Datum result;
1447 
1448  InitFunctionCallInfoData(fcinfo, flinfo, 7, collation, NULL, NULL);
1449 
1450  fcinfo.arg[0] = arg1;
1451  fcinfo.arg[1] = arg2;
1452  fcinfo.arg[2] = arg3;
1453  fcinfo.arg[3] = arg4;
1454  fcinfo.arg[4] = arg5;
1455  fcinfo.arg[5] = arg6;
1456  fcinfo.arg[6] = arg7;
1457  fcinfo.argnull[0] = false;
1458  fcinfo.argnull[1] = false;
1459  fcinfo.argnull[2] = false;
1460  fcinfo.argnull[3] = false;
1461  fcinfo.argnull[4] = false;
1462  fcinfo.argnull[5] = false;
1463  fcinfo.argnull[6] = false;
1464 
1465  result = FunctionCallInvoke(&fcinfo);
1466 
1467  /* Check for null result, since caller is clearly not expecting one */
1468  if (fcinfo.isnull)
1469  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1470 
1471  return result;
1472 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
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 1475 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by directBoolConsistentFn().

1478 {
1479  FunctionCallInfoData fcinfo;
1480  Datum result;
1481 
1482  InitFunctionCallInfoData(fcinfo, flinfo, 8, collation, NULL, NULL);
1483 
1484  fcinfo.arg[0] = arg1;
1485  fcinfo.arg[1] = arg2;
1486  fcinfo.arg[2] = arg3;
1487  fcinfo.arg[3] = arg4;
1488  fcinfo.arg[4] = arg5;
1489  fcinfo.arg[5] = arg6;
1490  fcinfo.arg[6] = arg7;
1491  fcinfo.arg[7] = arg8;
1492  fcinfo.argnull[0] = false;
1493  fcinfo.argnull[1] = false;
1494  fcinfo.argnull[2] = false;
1495  fcinfo.argnull[3] = false;
1496  fcinfo.argnull[4] = false;
1497  fcinfo.argnull[5] = false;
1498  fcinfo.argnull[6] = false;
1499  fcinfo.argnull[7] = false;
1500 
1501  result = FunctionCallInvoke(&fcinfo);
1502 
1503  /* Check for null result, since caller is clearly not expecting one */
1504  if (fcinfo.isnull)
1505  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1506 
1507  return result;
1508 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
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 1511 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1515 {
1516  FunctionCallInfoData fcinfo;
1517  Datum result;
1518 
1519  InitFunctionCallInfoData(fcinfo, flinfo, 9, collation, NULL, NULL);
1520 
1521  fcinfo.arg[0] = arg1;
1522  fcinfo.arg[1] = arg2;
1523  fcinfo.arg[2] = arg3;
1524  fcinfo.arg[3] = arg4;
1525  fcinfo.arg[4] = arg5;
1526  fcinfo.arg[5] = arg6;
1527  fcinfo.arg[6] = arg7;
1528  fcinfo.arg[7] = arg8;
1529  fcinfo.arg[8] = arg9;
1530  fcinfo.argnull[0] = false;
1531  fcinfo.argnull[1] = false;
1532  fcinfo.argnull[2] = false;
1533  fcinfo.argnull[3] = false;
1534  fcinfo.argnull[4] = false;
1535  fcinfo.argnull[5] = false;
1536  fcinfo.argnull[6] = false;
1537  fcinfo.argnull[7] = false;
1538  fcinfo.argnull[8] = false;
1539 
1540  result = FunctionCallInvoke(&fcinfo);
1541 
1542  /* Check for null result, since caller is clearly not expecting one */
1543  if (fcinfo.isnull)
1544  elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
1545 
1546  return result;
1547 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
bool get_call_expr_arg_stable ( Node expr,
int  argnum 
)

Definition at line 2310 of file fmgr.c.

References arg, generate_unaccent_rules::args, IsA, list_length(), list_make1, list_nth(), NULL, and PARAM_EXTERN.

Referenced by get_fn_expr_arg_stable().

2311 {
2312  List *args;
2313  Node *arg;
2314 
2315  if (expr == NULL)
2316  return false;
2317 
2318  if (IsA(expr, FuncExpr))
2319  args = ((FuncExpr *) expr)->args;
2320  else if (IsA(expr, OpExpr))
2321  args = ((OpExpr *) expr)->args;
2322  else if (IsA(expr, DistinctExpr))
2323  args = ((DistinctExpr *) expr)->args;
2324  else if (IsA(expr, ScalarArrayOpExpr))
2325  args = ((ScalarArrayOpExpr *) expr)->args;
2326  else if (IsA(expr, ArrayCoerceExpr))
2327  args = list_make1(((ArrayCoerceExpr *) expr)->arg);
2328  else if (IsA(expr, NullIfExpr))
2329  args = ((NullIfExpr *) expr)->args;
2330  else if (IsA(expr, WindowFunc))
2331  args = ((WindowFunc *) expr)->args;
2332  else
2333  return false;
2334 
2335  if (argnum < 0 || argnum >= list_length(args))
2336  return false;
2337 
2338  arg = (Node *) list_nth(args, argnum);
2339 
2340  /*
2341  * Either a true Const or an external Param will have a value that doesn't
2342  * change during the execution of the query. In future we might want to
2343  * consider other cases too, e.g. now().
2344  */
2345  if (IsA(arg, Const))
2346  return true;
2347  if (IsA(arg, Param) &&
2348  ((Param *) arg)->paramkind == PARAM_EXTERN)
2349  return true;
2350 
2351  return false;
2352 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:559
Definition: nodes.h:508
#define list_make1(x1)
Definition: pg_list.h:133
void * list_nth(const List *list, int n)
Definition: list.c:410
#define NULL
Definition: c.h:226
static int list_length(const List *l)
Definition: pg_list.h:89
void * arg
Definition: pg_list.h:45
Oid get_call_expr_argtype ( Node expr,
int  argnum 
)

Definition at line 2239 of file fmgr.c.

References arg, generate_unaccent_rules::args, exprType(), get_base_element_type(), InvalidOid, IsA, list_length(), list_make1, list_nth(), and NULL.

Referenced by get_fn_expr_argtype(), prepare_sql_fn_parse_info(), resolve_polymorphic_argtypes(), and resolve_polymorphic_tupdesc().

2240 {
2241  List *args;
2242  Oid argtype;
2243 
2244  if (expr == NULL)
2245  return InvalidOid;
2246 
2247  if (IsA(expr, FuncExpr))
2248  args = ((FuncExpr *) expr)->args;
2249  else if (IsA(expr, OpExpr))
2250  args = ((OpExpr *) expr)->args;
2251  else if (IsA(expr, DistinctExpr))
2252  args = ((DistinctExpr *) expr)->args;
2253  else if (IsA(expr, ScalarArrayOpExpr))
2254  args = ((ScalarArrayOpExpr *) expr)->args;
2255  else if (IsA(expr, ArrayCoerceExpr))
2256  args = list_make1(((ArrayCoerceExpr *) expr)->arg);
2257  else if (IsA(expr, NullIfExpr))
2258  args = ((NullIfExpr *) expr)->args;
2259  else if (IsA(expr, WindowFunc))
2260  args = ((WindowFunc *) expr)->args;
2261  else
2262  return InvalidOid;
2263 
2264  if (argnum < 0 || argnum >= list_length(args))
2265  return InvalidOid;
2266 
2267  argtype = exprType((Node *) list_nth(args, argnum));
2268 
2269  /*
2270  * special hack for ScalarArrayOpExpr and ArrayCoerceExpr: what the
2271  * underlying function will actually get passed is the element type of the
2272  * array.
2273  */
2274  if (IsA(expr, ScalarArrayOpExpr) &&
2275  argnum == 1)
2276  argtype = get_base_element_type(argtype);
2277  else if (IsA(expr, ArrayCoerceExpr) &&
2278  argnum == 0)
2279  argtype = get_base_element_type(argtype);
2280 
2281  return argtype;
2282 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:559
Definition: nodes.h:508
unsigned int Oid
Definition: postgres_ext.h:31
#define list_make1(x1)
Definition: pg_list.h:133
void * list_nth(const List *list, int n)
Definition: list.c:410
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:226
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
static int list_length(const List *l)
Definition: pg_list.h:89
Oid get_base_element_type(Oid typid)
Definition: lsyscache.c:2525
void * arg
Definition: pg_list.h:45
bool get_fn_expr_arg_stable ( FmgrInfo flinfo,
int  argnum 
)

Definition at line 2291 of file fmgr.c.

References FmgrInfo::fn_expr, and get_call_expr_arg_stable().

Referenced by jsonb_build_array(), jsonb_build_object(), leadlag_common(), and window_nth_value().

2292 {
2293  /*
2294  * can't return anything useful if we have no FmgrInfo or if its fn_expr
2295  * node has not been initialized
2296  */
2297  if (!flinfo || !flinfo->fn_expr)
2298  return false;
2299 
2300  return get_call_expr_arg_stable(flinfo->fn_expr, argnum);
2301 }
bool get_call_expr_arg_stable(Node *expr, int argnum)
Definition: fmgr.c:2310
fmNodePtr fn_expr
Definition: fmgr.h:63
Oid get_fn_expr_rettype ( FmgrInfo flinfo)

Definition at line 2198 of file fmgr.c.

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

Referenced by do_compile(), init_sql_fcache(), range_constructor2(), and range_constructor3().

2199 {
2200  Node *expr;
2201 
2202  /*
2203  * can't return anything useful if we have no FmgrInfo or if its fn_expr
2204  * node has not been initialized
2205  */
2206  if (!flinfo || !flinfo->fn_expr)
2207  return InvalidOid;
2208 
2209  expr = flinfo->fn_expr;
2210 
2211  return exprType(expr);
2212 }
Definition: nodes.h:508
#define InvalidOid
Definition: postgres_ext.h:36
fmNodePtr fn_expr
Definition: fmgr.h:63
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
bool get_fn_expr_variadic ( FmgrInfo flinfo)

Definition at line 2362 of file fmgr.c.

References FmgrInfo::fn_expr, and IsA.

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

2363 {
2364  Node *expr;
2365 
2366  /*
2367  * can't return anything useful if we have no FmgrInfo or if its fn_expr
2368  * node has not been initialized
2369  */
2370  if (!flinfo || !flinfo->fn_expr)
2371  return false;
2372 
2373  expr = flinfo->fn_expr;
2374 
2375  if (IsA(expr, FuncExpr))
2376  return ((FuncExpr *) expr)->funcvariadic;
2377  else
2378  return false;
2379 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:559
Definition: nodes.h:508
fmNodePtr fn_expr
Definition: fmgr.h:63
Datum InputFunctionCall ( FmgrInfo flinfo,
char *  str,
Oid  typioparam,
int32  typmod 
)

Definition at line 1882 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, CStringGetDatum, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FmgrInfo::fn_strict, FunctionCallInvoke, InitFunctionCallInfoData, Int32GetDatum, InvalidOid, FunctionCallInfoData::isnull, NULL, and ObjectIdGetDatum.

Referenced by BuildTupleFromCStrings(), domain_in(), ExecEvalCoerceViaIO(), hstore_populate_record(), make_row_from_rec_and_jsonb(), make_tuple_from_result_row(), NextCopyFrom(), OidInputFunctionCall(), plperl_sv_to_datum(), pltcl_func_handler(), pltcl_returnnext(), pltcl_SPI_execute_plan(), PLy_cursor_plan(), PLy_exec_function(), PLy_modify_tuple(), PLy_spi_execute_plan(), PLyObject_ToDatum(), populate_record_worker(), populate_recordset_object_end(), range_in(), ReadArrayStr(), and record_in().

1883 {
1884  FunctionCallInfoData fcinfo;
1885  Datum result;
1886 
1887  if (str == NULL && flinfo->fn_strict)
1888  return (Datum) 0; /* just return null result */
1889 
1890  InitFunctionCallInfoData(fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
1891 
1892  fcinfo.arg[0] = CStringGetDatum(str);
1893  fcinfo.arg[1] = ObjectIdGetDatum(typioparam);
1894  fcinfo.arg[2] = Int32GetDatum(typmod);
1895  fcinfo.argnull[0] = (str == NULL);
1896  fcinfo.argnull[1] = false;
1897  fcinfo.argnull[2] = false;
1898 
1899  result = FunctionCallInvoke(&fcinfo);
1900 
1901  /* Should get null result if and only if str is NULL */
1902  if (str == NULL)
1903  {
1904  if (!fcinfo.isnull)
1905  elog(ERROR, "input function %u returned non-NULL",
1906  fcinfo.flinfo->fn_oid);
1907  }
1908  else
1909  {
1910  if (fcinfo.isnull)
1911  elog(ERROR, "input function %u returned NULL",
1912  fcinfo.flinfo->fn_oid);
1913  }
1914 
1915  return result;
1916 }
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
bool fn_strict
Definition: fmgr.h:58
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
#define CStringGetDatum(X)
Definition: postgres.h:586
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define Int32GetDatum(X)
Definition: postgres.h:487
#define elog
Definition: elog.h:219
static CFuncHashTabEntry * lookup_C_func ( HeapTuple  procedureTuple)
static

Definition at line 503 of file fmgr.c.

References CFuncHashTabEntry::fn_tid, CFuncHashTabEntry::fn_xmin, HASH_FIND, hash_search(), HeapTupleGetOid, HeapTupleHeaderGetRawXmin, ItemPointerEquals(), NULL, HeapTupleData::t_data, and HeapTupleData::t_self.

Referenced by fmgr_info_C_lang().

504 {
505  Oid fn_oid = HeapTupleGetOid(procedureTuple);
506  CFuncHashTabEntry *entry;
507 
508  if (CFuncHash == NULL)
509  return NULL; /* no table yet */
510  entry = (CFuncHashTabEntry *)
512  &fn_oid,
513  HASH_FIND,
514  NULL);
515  if (entry == NULL)
516  return NULL; /* no such entry */
517  if (entry->fn_xmin == HeapTupleHeaderGetRawXmin(procedureTuple->t_data) &&
518  ItemPointerEquals(&entry->fn_tid, &procedureTuple->t_self))
519  return entry; /* OK */
520  return NULL; /* entry is out of date */
521 }
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:885
unsigned int Oid
Definition: postgres_ext.h:31
HeapTupleHeader t_data
Definition: htup.h:67
static HTAB * CFuncHash
Definition: fmgr.c:83
ItemPointerData t_self
Definition: htup.h:65
#define NULL
Definition: c.h:226
#define HeapTupleHeaderGetRawXmin(tup)
Definition: htup_details.h:302
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
Definition: itemptr.c:29
TransactionId fn_xmin
Definition: fmgr.c:77
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
ItemPointerData fn_tid
Definition: fmgr.c:78
Datum OidFunctionCall0Coll ( Oid  functionId,
Oid  collation 
)

Definition at line 1558 of file fmgr.c.

References elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1559 {
1560  FmgrInfo flinfo;
1561  FunctionCallInfoData fcinfo;
1562  Datum result;
1563 
1564  fmgr_info(functionId, &flinfo);
1565 
1566  InitFunctionCallInfoData(fcinfo, &flinfo, 0, collation, NULL, NULL);
1567 
1568  result = FunctionCallInvoke(&fcinfo);
1569 
1570  /* Check for null result, since caller is clearly not expecting one */
1571  if (fcinfo.isnull)
1572  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1573 
1574  return result;
1575 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall1Coll ( Oid  functionId,
Oid  collation,
Datum  arg1 
)

Definition at line 1578 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by _hash_datum2hashkey_type().

1579 {
1580  FmgrInfo flinfo;
1581  FunctionCallInfoData fcinfo;
1582  Datum result;
1583 
1584  fmgr_info(functionId, &flinfo);
1585 
1586  InitFunctionCallInfoData(fcinfo, &flinfo, 1, collation, NULL, NULL);
1587 
1588  fcinfo.arg[0] = arg1;
1589  fcinfo.argnull[0] = false;
1590 
1591  result = FunctionCallInvoke(&fcinfo);
1592 
1593  /* Check for null result, since caller is clearly not expecting one */
1594  if (fcinfo.isnull)
1595  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1596 
1597  return result;
1598 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall2Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2 
)

Definition at line 1601 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by _bt_compare_scankey_args(), and index_recheck_constraint().

1602 {
1603  FmgrInfo flinfo;
1604  FunctionCallInfoData fcinfo;
1605  Datum result;
1606 
1607  fmgr_info(functionId, &flinfo);
1608 
1609  InitFunctionCallInfoData(fcinfo, &flinfo, 2, collation, NULL, NULL);
1610 
1611  fcinfo.arg[0] = arg1;
1612  fcinfo.arg[1] = arg2;
1613  fcinfo.argnull[0] = false;
1614  fcinfo.argnull[1] = false;
1615 
1616  result = FunctionCallInvoke(&fcinfo);
1617 
1618  /* Check for null result, since caller is clearly not expecting one */
1619  if (fcinfo.isnull)
1620  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1621 
1622  return result;
1623 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall3Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3 
)

Definition at line 1626 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1628 {
1629  FmgrInfo flinfo;
1630  FunctionCallInfoData fcinfo;
1631  Datum result;
1632 
1633  fmgr_info(functionId, &flinfo);
1634 
1635  InitFunctionCallInfoData(fcinfo, &flinfo, 3, collation, NULL, NULL);
1636 
1637  fcinfo.arg[0] = arg1;
1638  fcinfo.arg[1] = arg2;
1639  fcinfo.arg[2] = arg3;
1640  fcinfo.argnull[0] = false;
1641  fcinfo.argnull[1] = false;
1642  fcinfo.argnull[2] = false;
1643 
1644  result = FunctionCallInvoke(&fcinfo);
1645 
1646  /* Check for null result, since caller is clearly not expecting one */
1647  if (fcinfo.isnull)
1648  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1649 
1650  return result;
1651 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall4Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4 
)

Definition at line 1654 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by restriction_selectivity().

1656 {
1657  FmgrInfo flinfo;
1658  FunctionCallInfoData fcinfo;
1659  Datum result;
1660 
1661  fmgr_info(functionId, &flinfo);
1662 
1663  InitFunctionCallInfoData(fcinfo, &flinfo, 4, collation, NULL, NULL);
1664 
1665  fcinfo.arg[0] = arg1;
1666  fcinfo.arg[1] = arg2;
1667  fcinfo.arg[2] = arg3;
1668  fcinfo.arg[3] = arg4;
1669  fcinfo.argnull[0] = false;
1670  fcinfo.argnull[1] = false;
1671  fcinfo.argnull[2] = false;
1672  fcinfo.argnull[3] = false;
1673 
1674  result = FunctionCallInvoke(&fcinfo);
1675 
1676  /* Check for null result, since caller is clearly not expecting one */
1677  if (fcinfo.isnull)
1678  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1679 
1680  return result;
1681 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall5Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5 
)

Definition at line 1684 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by join_selectivity().

1686 {
1687  FmgrInfo flinfo;
1688  FunctionCallInfoData fcinfo;
1689  Datum result;
1690 
1691  fmgr_info(functionId, &flinfo);
1692 
1693  InitFunctionCallInfoData(fcinfo, &flinfo, 5, collation, NULL, NULL);
1694 
1695  fcinfo.arg[0] = arg1;
1696  fcinfo.arg[1] = arg2;
1697  fcinfo.arg[2] = arg3;
1698  fcinfo.arg[3] = arg4;
1699  fcinfo.arg[4] = arg5;
1700  fcinfo.argnull[0] = false;
1701  fcinfo.argnull[1] = false;
1702  fcinfo.argnull[2] = false;
1703  fcinfo.argnull[3] = false;
1704  fcinfo.argnull[4] = false;
1705 
1706  result = FunctionCallInvoke(&fcinfo);
1707 
1708  /* Check for null result, since caller is clearly not expecting one */
1709  if (fcinfo.isnull)
1710  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1711 
1712  return result;
1713 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall6Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6 
)

Definition at line 1716 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1719 {
1720  FmgrInfo flinfo;
1721  FunctionCallInfoData fcinfo;
1722  Datum result;
1723 
1724  fmgr_info(functionId, &flinfo);
1725 
1726  InitFunctionCallInfoData(fcinfo, &flinfo, 6, collation, NULL, NULL);
1727 
1728  fcinfo.arg[0] = arg1;
1729  fcinfo.arg[1] = arg2;
1730  fcinfo.arg[2] = arg3;
1731  fcinfo.arg[3] = arg4;
1732  fcinfo.arg[4] = arg5;
1733  fcinfo.arg[5] = arg6;
1734  fcinfo.argnull[0] = false;
1735  fcinfo.argnull[1] = false;
1736  fcinfo.argnull[2] = false;
1737  fcinfo.argnull[3] = false;
1738  fcinfo.argnull[4] = false;
1739  fcinfo.argnull[5] = false;
1740 
1741  result = FunctionCallInvoke(&fcinfo);
1742 
1743  /* Check for null result, since caller is clearly not expecting one */
1744  if (fcinfo.isnull)
1745  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1746 
1747  return result;
1748 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidFunctionCall7Coll ( Oid  functionId,
Oid  collation,
Datum  arg1,
Datum  arg2,
Datum  arg3,
Datum  arg4,
Datum  arg5,
Datum  arg6,
Datum  arg7 
)

Definition at line 1751 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

Referenced by gincost_pattern().

1754 {
1755  FmgrInfo flinfo;
1756  FunctionCallInfoData fcinfo;
1757  Datum result;
1758 
1759  fmgr_info(functionId, &flinfo);
1760 
1761  InitFunctionCallInfoData(fcinfo, &flinfo, 7, collation, NULL, NULL);
1762 
1763  fcinfo.arg[0] = arg1;
1764  fcinfo.arg[1] = arg2;
1765  fcinfo.arg[2] = arg3;
1766  fcinfo.arg[3] = arg4;
1767  fcinfo.arg[4] = arg5;
1768  fcinfo.arg[5] = arg6;
1769  fcinfo.arg[6] = arg7;
1770  fcinfo.argnull[0] = false;
1771  fcinfo.argnull[1] = false;
1772  fcinfo.argnull[2] = false;
1773  fcinfo.argnull[3] = false;
1774  fcinfo.argnull[4] = false;
1775  fcinfo.argnull[5] = false;
1776  fcinfo.argnull[6] = false;
1777 
1778  result = FunctionCallInvoke(&fcinfo);
1779 
1780  /* Check for null result, since caller is clearly not expecting one */
1781  if (fcinfo.isnull)
1782  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1783 
1784  return result;
1785 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
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 1788 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1791 {
1792  FmgrInfo flinfo;
1793  FunctionCallInfoData fcinfo;
1794  Datum result;
1795 
1796  fmgr_info(functionId, &flinfo);
1797 
1798  InitFunctionCallInfoData(fcinfo, &flinfo, 8, collation, NULL, NULL);
1799 
1800  fcinfo.arg[0] = arg1;
1801  fcinfo.arg[1] = arg2;
1802  fcinfo.arg[2] = arg3;
1803  fcinfo.arg[3] = arg4;
1804  fcinfo.arg[4] = arg5;
1805  fcinfo.arg[5] = arg6;
1806  fcinfo.arg[6] = arg7;
1807  fcinfo.arg[7] = arg8;
1808  fcinfo.argnull[0] = false;
1809  fcinfo.argnull[1] = false;
1810  fcinfo.argnull[2] = false;
1811  fcinfo.argnull[3] = false;
1812  fcinfo.argnull[4] = false;
1813  fcinfo.argnull[5] = false;
1814  fcinfo.argnull[6] = false;
1815  fcinfo.argnull[7] = false;
1816 
1817  result = FunctionCallInvoke(&fcinfo);
1818 
1819  /* Check for null result, since caller is clearly not expecting one */
1820  if (fcinfo.isnull)
1821  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1822 
1823  return result;
1824 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
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 1827 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, fmgr_security_definer_cache::flinfo, fmgr_info(), FmgrInfo::fn_oid, FunctionCallInvoke, InitFunctionCallInfoData, FunctionCallInfoData::isnull, and NULL.

1831 {
1832  FmgrInfo flinfo;
1833  FunctionCallInfoData fcinfo;
1834  Datum result;
1835 
1836  fmgr_info(functionId, &flinfo);
1837 
1838  InitFunctionCallInfoData(fcinfo, &flinfo, 9, collation, NULL, NULL);
1839 
1840  fcinfo.arg[0] = arg1;
1841  fcinfo.arg[1] = arg2;
1842  fcinfo.arg[2] = arg3;
1843  fcinfo.arg[3] = arg4;
1844  fcinfo.arg[4] = arg5;
1845  fcinfo.arg[5] = arg6;
1846  fcinfo.arg[6] = arg7;
1847  fcinfo.arg[7] = arg8;
1848  fcinfo.arg[8] = arg9;
1849  fcinfo.argnull[0] = false;
1850  fcinfo.argnull[1] = false;
1851  fcinfo.argnull[2] = false;
1852  fcinfo.argnull[3] = false;
1853  fcinfo.argnull[4] = false;
1854  fcinfo.argnull[5] = false;
1855  fcinfo.argnull[6] = false;
1856  fcinfo.argnull[7] = false;
1857  fcinfo.argnull[8] = false;
1858 
1859  result = FunctionCallInvoke(&fcinfo);
1860 
1861  /* Check for null result, since caller is clearly not expecting one */
1862  if (fcinfo.isnull)
1863  elog(ERROR, "function %u returned NULL", flinfo.fn_oid);
1864 
1865  return result;
1866 }
Definition: fmgr.h:53
#define ERROR
Definition: elog.h:43
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define elog
Definition: elog.h:219
Datum OidInputFunctionCall ( Oid  functionId,
char *  str,
Oid  typioparam,
int32  typmod 
)

Definition at line 1997 of file fmgr.c.

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

Referenced by DefineAggregate(), exec_bind_message(), get_typdefault(), GetAggInitVal(), InsertOneValue(), parse_fcall_arguments(), slot_modify_cstrings(), slot_store_cstrings(), and stringTypeDatum().

1998 {
1999  FmgrInfo flinfo;
2000 
2001  fmgr_info(functionId, &flinfo);
2002  return InputFunctionCall(&flinfo, str, typioparam, typmod);
2003 }
Definition: fmgr.h:53
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1882
Datum OidReceiveFunctionCall ( Oid  functionId,
StringInfo  buf,
Oid  typioparam,
int32  typmod 
)

Definition at line 2015 of file fmgr.c.

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

Referenced by exec_bind_message(), parse_fcall_arguments(), and parse_fcall_arguments_20().

2017 {
2018  FmgrInfo flinfo;
2019 
2020  fmgr_info(functionId, &flinfo);
2021  return ReceiveFunctionCall(&flinfo, buf, typioparam, typmod);
2022 }
Definition: fmgr.h:53
Datum ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf, Oid typioparam, int32 typmod)
Definition: fmgr.c:1940
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
bytea* OidSendFunctionCall ( Oid  functionId,
Datum  val 
)

Definition at line 2025 of file fmgr.c.

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

Referenced by SendFunctionResult().

2026 {
2027  FmgrInfo flinfo;
2028 
2029  fmgr_info(functionId, &flinfo);
2030  return SendFunctionCall(&flinfo, val);
2031 }
Definition: fmgr.h:53
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:159
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
Definition: fmgr.c:1987
long val
Definition: informix.c:689
struct varlena* pg_detoast_datum ( struct varlena datum)

Definition at line 2142 of file fmgr.c.

References heap_tuple_untoast_attr(), and VARATT_IS_EXTENDED.

2143 {
2144  if (VARATT_IS_EXTENDED(datum))
2145  return heap_tuple_untoast_attr(datum);
2146  else
2147  return datum;
2148 }
struct varlena * heap_tuple_untoast_attr(struct varlena *attr)
Definition: tuptoaster.c:172
#define VARATT_IS_EXTENDED(PTR)
Definition: postgres.h:328
struct varlena* pg_detoast_datum_copy ( struct varlena datum)

Definition at line 2151 of file fmgr.c.

References heap_tuple_untoast_attr(), palloc(), VARATT_IS_EXTENDED, and VARSIZE.

2152 {
2153  if (VARATT_IS_EXTENDED(datum))
2154  return heap_tuple_untoast_attr(datum);
2155  else
2156  {
2157  /* Make a modifiable copy of the varlena object */
2158  Size len = VARSIZE(datum);
2159  struct varlena *result = (struct varlena *) palloc(len);
2160 
2161  memcpy(result, datum, len);
2162  return result;
2163  }
2164 }
#define VARSIZE(PTR)
Definition: postgres.h:306
struct varlena * heap_tuple_untoast_attr(struct varlena *attr)
Definition: tuptoaster.c:172
size_t Size
Definition: c.h:352
#define VARATT_IS_EXTENDED(PTR)
Definition: postgres.h:328
void * palloc(Size size)
Definition: mcxt.c:891
Definition: c.h:434
struct varlena* pg_detoast_datum_packed ( struct varlena datum)

Definition at line 2174 of file fmgr.c.

References heap_tuple_untoast_attr(), VARATT_IS_COMPRESSED, and VARATT_IS_EXTERNAL.

Referenced by text_to_cstring(), and text_to_cstring_buffer().

2175 {
2176  if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum))
2177  return heap_tuple_untoast_attr(datum);
2178  else
2179  return datum;
2180 }
#define VARATT_IS_COMPRESSED(PTR)
Definition: postgres.h:315
struct varlena * heap_tuple_untoast_attr(struct varlena *attr)
Definition: tuptoaster.c:172
#define VARATT_IS_EXTERNAL(PTR)
Definition: postgres.h:316
struct varlena* pg_detoast_datum_slice ( struct varlena datum,
int32  first,
int32  count 
)

Definition at line 2167 of file fmgr.c.

References heap_tuple_untoast_attr_slice().

2168 {
2169  /* Only get the specified portion from the toast rel */
2170  return heap_tuple_untoast_attr_slice(datum, first, count);
2171 }
struct varlena * heap_tuple_untoast_attr_slice(struct varlena *attr, int32 sliceoffset, int32 slicelength)
Definition: tuptoaster.c:258
Datum ReceiveFunctionCall ( FmgrInfo flinfo,
StringInfo  buf,
Oid  typioparam,
int32  typmod 
)

Definition at line 1940 of file fmgr.c.

References FunctionCallInfoData::arg, FunctionCallInfoData::argnull, elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_oid, FmgrInfo::fn_strict, FunctionCallInvoke, InitFunctionCallInfoData, Int32GetDatum, InvalidOid, FunctionCallInfoData::isnull, NULL, ObjectIdGetDatum, and PointerGetDatum.

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

1942 {
1943  FunctionCallInfoData fcinfo;
1944  Datum result;
1945 
1946  if (buf == NULL && flinfo->fn_strict)
1947  return (Datum) 0; /* just return null result */
1948 
1949  InitFunctionCallInfoData(fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
1950 
1951  fcinfo.arg[0] = PointerGetDatum(buf);
1952  fcinfo.arg[1] = ObjectIdGetDatum(typioparam);
1953  fcinfo.arg[2] = Int32GetDatum(typmod);
1954  fcinfo.argnull[0] = (buf == NULL);
1955  fcinfo.argnull[1] = false;
1956  fcinfo.argnull[2] = false;
1957 
1958  result = FunctionCallInvoke(&fcinfo);
1959 
1960  /* Should get null result if and only if buf is NULL */
1961  if (buf == NULL)
1962  {
1963  if (!fcinfo.isnull)
1964  elog(ERROR, "receive function %u returned non-NULL",
1965  fcinfo.flinfo->fn_oid);
1966  }
1967  else
1968  {
1969  if (fcinfo.isnull)
1970  elog(ERROR, "receive function %u returned NULL",
1971  fcinfo.flinfo->fn_oid);
1972  }
1973 
1974  return result;
1975 }
#define PointerGetDatum(X)
Definition: postgres.h:564
FmgrInfo * flinfo
Definition: fmgr.h:71
#define ObjectIdGetDatum(X)
Definition: postgres.h:515
#define ERROR
Definition: elog.h:43
bool fn_strict
Definition: fmgr.h:58
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:129
bool argnull[FUNC_MAX_ARGS]
Definition: fmgr.h:78
uintptr_t Datum
Definition: postgres.h:374
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:56
Datum arg[FUNC_MAX_ARGS]
Definition: fmgr.h:77
#define NULL
Definition: c.h:226
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:112
#define Int32GetDatum(X)
Definition: postgres.h:487
#define elog
Definition: elog.h:219
static void record_C_func ( HeapTuple  procedureTuple,
PGFunction  user_fn,
const Pg_finfo_record inforec 
)
static

Definition at line 527 of file fmgr.c.

References HASHCTL::entrysize, CFuncHashTabEntry::fn_tid, CFuncHashTabEntry::fn_xmin, HASH_BLOBS, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HeapTupleGetOid, HeapTupleHeaderGetRawXmin, CFuncHashTabEntry::inforec, HASHCTL::keysize, MemSet, NULL, HeapTupleData::t_data, HeapTupleData::t_self, and CFuncHashTabEntry::user_fn.

Referenced by fmgr_info_C_lang().

529 {
530  Oid fn_oid = HeapTupleGetOid(procedureTuple);
531  CFuncHashTabEntry *entry;
532  bool found;
533 
534  /* Create the hash table if it doesn't exist yet */
535  if (CFuncHash == NULL)
536  {
537  HASHCTL hash_ctl;
538 
539  MemSet(&hash_ctl, 0, sizeof(hash_ctl));
540  hash_ctl.keysize = sizeof(Oid);
541  hash_ctl.entrysize = sizeof(CFuncHashTabEntry);
542  CFuncHash = hash_create("CFuncHash",
543  100,
544  &hash_ctl,
546  }
547 
548  entry = (CFuncHashTabEntry *)
550  &fn_oid,
551  HASH_ENTER,
552  &found);
553  /* OID is already filled in */
554  entry->fn_xmin = HeapTupleHeaderGetRawXmin(procedureTuple->t_data);
555  entry->fn_tid = procedureTuple->t_self;
556  entry->user_fn = user_fn;
557  entry->inforec = inforec;
558 }
#define HASH_ELEM
Definition: hsearch.h:87
const Pg_finfo_record * inforec
Definition: fmgr.c:80
Size entrysize
Definition: hsearch.h:73
#define MemSet(start, val, len)
Definition: c.h:852
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:885
unsigned int Oid
Definition: postgres_ext.h:31
HeapTupleHeader t_data
Definition: htup.h:67
static HTAB * CFuncHash
Definition: fmgr.c:83
ItemPointerData t_self
Definition: htup.h:65
PGFunction user_fn
Definition: fmgr.c:79
#define HASH_BLOBS
Definition: hsearch.h:88
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
Definition: dynahash.c:301
Size keysize
Definition: hsearch.h:72
#define NULL
Definition: c.h:226
#define HeapTupleHeaderGetRawXmin(tup)
Definition: htup_details.h:302
TransactionId fn_xmin
Definition: fmgr.c:77
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
ItemPointerData fn_tid
Definition: fmgr.c:78
bytea* SendFunctionCall ( FmgrInfo flinfo,
Datum  val 
)

Definition at line 1987 of file fmgr.c.

References DatumGetByteaP, and FunctionCall1.

Referenced by array_send(), CopyOneRowTo(), OidSendFunctionCall(), printtup(), printtup_internal_20(), range_send(), and record_send().

1988 {
1989  return DatumGetByteaP(FunctionCall1(flinfo, val));
1990 }
#define DatumGetByteaP(X)
Definition: fmgr.h:246
#define FunctionCall1(flinfo, arg1)
Definition: fmgr.h:573
long val
Definition: informix.c:689

Variable Documentation

HTAB* CFuncHash = NULL
static

Definition at line 83 of file fmgr.c.

Definition at line 37 of file fmgr.c.

Referenced by fmgr_security_definer(), and sepgsql_init_client_label().

Definition at line 36 of file fmgr.c.

Referenced by sepgsql_init_client_label().