PostgreSQL Source Code  git master
fmgr.c File Reference
#include "postgres.h"
#include "access/detoast.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  CFuncHashTabEntry
 
struct  fmgr_security_definer_cache
 

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)
 
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)
 
void fmgr_symbol (Oid functionId, char **mod, char **fn)
 
const Pg_finfo_recordfetch_finfo_record (void *filehandle, const 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 CallerFInfoFunctionCall1 (PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1)
 
Datum CallerFInfoFunctionCall2 (PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
 
Datum FunctionCall0Coll (FmgrInfo *flinfo, Oid collation)
 
Datum FunctionCall1Coll (FmgrInfo *flinfo, Oid collation, Datum arg1)
 
Datum FunctionCall2Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
 
Datum FunctionCall3Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3)
 
Datum FunctionCall4Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
 
Datum FunctionCall5Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
 
Datum FunctionCall6Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
 
Datum FunctionCall7Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
 
Datum FunctionCall8Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
 
Datum FunctionCall9Coll (FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
 
Datum OidFunctionCall0Coll (Oid functionId, Oid collation)
 
Datum OidFunctionCall1Coll (Oid functionId, Oid collation, Datum arg1)
 
Datum OidFunctionCall2Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2)
 
Datum OidFunctionCall3Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3)
 
Datum OidFunctionCall4Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
 
Datum OidFunctionCall5Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
 
Datum OidFunctionCall6Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
 
Datum OidFunctionCall7Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
 
Datum OidFunctionCall8Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
 
Datum OidFunctionCall9Coll (Oid functionId, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
 
Datum InputFunctionCall (FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
 
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)
 
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
 

Function Documentation

◆ CallerFInfoFunctionCall1()

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

Definition at line 1066 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

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

◆ CallerFInfoFunctionCall2()

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

Definition at line 1086 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

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

1087 {
1088  LOCAL_FCINFO(fcinfo, 2);
1089  Datum result;
1090 
1091  InitFunctionCallInfoData(*fcinfo, flinfo, 2, collation, NULL, NULL);
1092 
1093  fcinfo->args[0].value = arg1;
1094  fcinfo->args[0].isnull = false;
1095  fcinfo->args[1].value = arg2;
1096  fcinfo->args[1].isnull = false;
1097 
1098  result = (*func) (fcinfo);
1099 
1100  /* Check for null result, since caller is clearly not expecting one */
1101  if (fcinfo->isnull)
1102  elog(ERROR, "function %p returned NULL", (void *) func);
1103 
1104  return result;
1105 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ CheckFunctionValidatorAccess()

bool CheckFunctionValidatorAccess ( Oid  validatorOid,
Oid  functionOid 
)

Definition at line 2001 of file fmgr.c.

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

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

2002 {
2003  HeapTuple procTup;
2004  HeapTuple langTup;
2005  Form_pg_proc procStruct;
2006  Form_pg_language langStruct;
2007  AclResult aclresult;
2008 
2009  /*
2010  * Get the function's pg_proc entry. Throw a user-facing error for bad
2011  * OID, because validators can be called with user-specified OIDs.
2012  */
2013  procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionOid));
2014  if (!HeapTupleIsValid(procTup))
2015  ereport(ERROR,
2016  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2017  errmsg("function with OID %u does not exist", functionOid)));
2018  procStruct = (Form_pg_proc) GETSTRUCT(procTup);
2019 
2020  /*
2021  * Fetch pg_language entry to know if this is the correct validation
2022  * function for that pg_proc entry.
2023  */
2024  langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang));
2025  if (!HeapTupleIsValid(langTup))
2026  elog(ERROR, "cache lookup failed for language %u", procStruct->prolang);
2027  langStruct = (Form_pg_language) GETSTRUCT(langTup);
2028 
2029  if (langStruct->lanvalidator != validatorOid)
2030  ereport(ERROR,
2031  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
2032  errmsg("language validation function %u called for language %u instead of %u",
2033  validatorOid, procStruct->prolang,
2034  langStruct->lanvalidator)));
2035 
2036  /* first validate that we have permissions to use the language */
2037  aclresult = pg_language_aclcheck(procStruct->prolang, GetUserId(),
2038  ACL_USAGE);
2039  if (aclresult != ACLCHECK_OK)
2040  aclcheck_error(aclresult, OBJECT_LANGUAGE,
2041  NameStr(langStruct->lanname));
2042 
2043  /*
2044  * Check whether we are allowed to execute the function itself. If we can
2045  * execute it, there should be no possible side-effect of
2046  * compiling/validation that execution can't have.
2047  */
2048  aclresult = pg_proc_aclcheck(functionOid, GetUserId(), ACL_EXECUTE);
2049  if (aclresult != ACLCHECK_OK)
2050  aclcheck_error(aclresult, OBJECT_FUNCTION, NameStr(procStruct->proname));
2051 
2052  ReleaseSysCache(procTup);
2053  ReleaseSysCache(langTup);
2054 
2055  return true;
2056 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Oid GetUserId(void)
Definition: miscinit.c:380
int errcode(int sqlerrcode)
Definition: elog.c:608
AclResult pg_language_aclcheck(Oid lang_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4666
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:3352
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ACL_USAGE
Definition: parsenodes.h:82
#define ereport(elevel, rest)
Definition: elog.h:141
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
AclResult
Definition: acl.h:177
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define ACL_EXECUTE
Definition: parsenodes.h:81
#define elog(elevel,...)
Definition: elog.h:228
AclResult pg_proc_aclcheck(Oid proc_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4654
#define NameStr(name)
Definition: c.h:610

◆ clear_external_function_hash()

void clear_external_function_hash ( void *  filehandle)

Definition at line 594 of file fmgr.c.

References hash_destroy().

Referenced by internal_unload_library().

595 {
596  if (CFuncHash)
598  CFuncHash = NULL;
599 }
void hash_destroy(HTAB *hashp)
Definition: dynahash.c:814
static HTAB * CFuncHash
Definition: fmgr.c:52

◆ DirectFunctionCall1Coll()

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

Definition at line 793 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

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

794 {
795  LOCAL_FCINFO(fcinfo, 1);
796  Datum result;
797 
798  InitFunctionCallInfoData(*fcinfo, NULL, 1, collation, NULL, NULL);
799 
800  fcinfo->args[0].value = arg1;
801  fcinfo->args[0].isnull = false;
802 
803  result = (*func) (fcinfo);
804 
805  /* Check for null result, since caller is clearly not expecting one */
806  if (fcinfo->isnull)
807  elog(ERROR, "function %p returned NULL", (void *) func);
808 
809  return result;
810 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall2Coll()

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

Definition at line 813 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by gbt_textcmp(), gbt_texteq(), gbt_textge(), gbt_textgt(), gbt_textle(), gbt_textlt(), spg_text_leaf_consistent(), text_isequal(), and texteqfast().

814 {
815  LOCAL_FCINFO(fcinfo, 2);
816  Datum result;
817 
818  InitFunctionCallInfoData(*fcinfo, NULL, 2, collation, NULL, NULL);
819 
820  fcinfo->args[0].value = arg1;
821  fcinfo->args[0].isnull = false;
822  fcinfo->args[1].value = arg2;
823  fcinfo->args[1].isnull = false;
824 
825  result = (*func) (fcinfo);
826 
827  /* Check for null result, since caller is clearly not expecting one */
828  if (fcinfo->isnull)
829  elog(ERROR, "function %p returned NULL", (void *) func);
830 
831  return result;
832 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall3Coll()

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

Definition at line 835 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by execute_extension_script().

837 {
838  LOCAL_FCINFO(fcinfo, 3);
839  Datum result;
840 
841  InitFunctionCallInfoData(*fcinfo, NULL, 3, collation, NULL, NULL);
842 
843  fcinfo->args[0].value = arg1;
844  fcinfo->args[0].isnull = false;
845  fcinfo->args[1].value = arg2;
846  fcinfo->args[1].isnull = false;
847  fcinfo->args[2].value = arg3;
848  fcinfo->args[2].isnull = false;
849 
850  result = (*func) (fcinfo);
851 
852  /* Check for null result, since caller is clearly not expecting one */
853  if (fcinfo->isnull)
854  elog(ERROR, "function %p returned NULL", (void *) func);
855 
856  return result;
857 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall4Coll()

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

Definition at line 860 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

Referenced by execute_extension_script().

862 {
863  LOCAL_FCINFO(fcinfo, 4);
864  Datum result;
865 
866  InitFunctionCallInfoData(*fcinfo, NULL, 4, collation, NULL, NULL);
867 
868  fcinfo->args[0].value = arg1;
869  fcinfo->args[0].isnull = false;
870  fcinfo->args[1].value = arg2;
871  fcinfo->args[1].isnull = false;
872  fcinfo->args[2].value = arg3;
873  fcinfo->args[2].isnull = false;
874  fcinfo->args[3].value = arg4;
875  fcinfo->args[3].isnull = false;
876 
877  result = (*func) (fcinfo);
878 
879  /* Check for null result, since caller is clearly not expecting one */
880  if (fcinfo->isnull)
881  elog(ERROR, "function %p returned NULL", (void *) func);
882 
883  return result;
884 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall5Coll()

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

Definition at line 887 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

889 {
890  LOCAL_FCINFO(fcinfo, 5);
891  Datum result;
892 
893  InitFunctionCallInfoData(*fcinfo, NULL, 5, collation, NULL, NULL);
894 
895  fcinfo->args[0].value = arg1;
896  fcinfo->args[0].isnull = false;
897  fcinfo->args[1].value = arg2;
898  fcinfo->args[1].isnull = false;
899  fcinfo->args[2].value = arg3;
900  fcinfo->args[2].isnull = false;
901  fcinfo->args[3].value = arg4;
902  fcinfo->args[3].isnull = false;
903  fcinfo->args[4].value = arg5;
904  fcinfo->args[4].isnull = false;
905 
906  result = (*func) (fcinfo);
907 
908  /* Check for null result, since caller is clearly not expecting one */
909  if (fcinfo->isnull)
910  elog(ERROR, "function %p returned NULL", (void *) func);
911 
912  return result;
913 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall6Coll()

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

Definition at line 916 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

919 {
920  LOCAL_FCINFO(fcinfo, 6);
921  Datum result;
922 
923  InitFunctionCallInfoData(*fcinfo, NULL, 6, collation, NULL, NULL);
924 
925  fcinfo->args[0].value = arg1;
926  fcinfo->args[0].isnull = false;
927  fcinfo->args[1].value = arg2;
928  fcinfo->args[1].isnull = false;
929  fcinfo->args[2].value = arg3;
930  fcinfo->args[2].isnull = false;
931  fcinfo->args[3].value = arg4;
932  fcinfo->args[3].isnull = false;
933  fcinfo->args[4].value = arg5;
934  fcinfo->args[4].isnull = false;
935  fcinfo->args[5].value = arg6;
936  fcinfo->args[5].isnull = false;
937 
938  result = (*func) (fcinfo);
939 
940  /* Check for null result, since caller is clearly not expecting one */
941  if (fcinfo->isnull)
942  elog(ERROR, "function %p returned NULL", (void *) func);
943 
944  return result;
945 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall7Coll()

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

Definition at line 948 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

951 {
952  LOCAL_FCINFO(fcinfo, 7);
953  Datum result;
954 
955  InitFunctionCallInfoData(*fcinfo, NULL, 7, collation, NULL, NULL);
956 
957  fcinfo->args[0].value = arg1;
958  fcinfo->args[0].isnull = false;
959  fcinfo->args[1].value = arg2;
960  fcinfo->args[1].isnull = false;
961  fcinfo->args[2].value = arg3;
962  fcinfo->args[2].isnull = false;
963  fcinfo->args[3].value = arg4;
964  fcinfo->args[3].isnull = false;
965  fcinfo->args[4].value = arg5;
966  fcinfo->args[4].isnull = false;
967  fcinfo->args[5].value = arg6;
968  fcinfo->args[5].isnull = false;
969  fcinfo->args[6].value = arg7;
970  fcinfo->args[6].isnull = false;
971 
972  result = (*func) (fcinfo);
973 
974  /* Check for null result, since caller is clearly not expecting one */
975  if (fcinfo->isnull)
976  elog(ERROR, "function %p returned NULL", (void *) func);
977 
978  return result;
979 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall8Coll()

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

Definition at line 982 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

985 {
986  LOCAL_FCINFO(fcinfo, 8);
987  Datum result;
988 
989  InitFunctionCallInfoData(*fcinfo, NULL, 8, collation, NULL, NULL);
990 
991  fcinfo->args[0].value = arg1;
992  fcinfo->args[0].isnull = false;
993  fcinfo->args[1].value = arg2;
994  fcinfo->args[1].isnull = false;
995  fcinfo->args[2].value = arg3;
996  fcinfo->args[2].isnull = false;
997  fcinfo->args[3].value = arg4;
998  fcinfo->args[3].isnull = false;
999  fcinfo->args[4].value = arg5;
1000  fcinfo->args[4].isnull = false;
1001  fcinfo->args[5].value = arg6;
1002  fcinfo->args[5].isnull = false;
1003  fcinfo->args[6].value = arg7;
1004  fcinfo->args[6].isnull = false;
1005  fcinfo->args[7].value = arg8;
1006  fcinfo->args[7].isnull = false;
1007 
1008  result = (*func) (fcinfo);
1009 
1010  /* Check for null result, since caller is clearly not expecting one */
1011  if (fcinfo->isnull)
1012  elog(ERROR, "function %p returned NULL", (void *) func);
1013 
1014  return result;
1015 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ DirectFunctionCall9Coll()

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

Definition at line 1018 of file fmgr.c.

References elog, ERROR, InitFunctionCallInfoData, and LOCAL_FCINFO.

1022 {
1023  LOCAL_FCINFO(fcinfo, 9);
1024  Datum result;
1025 
1026  InitFunctionCallInfoData(*fcinfo, NULL, 9, collation, NULL, NULL);
1027 
1028  fcinfo->args[0].value = arg1;
1029  fcinfo->args[0].isnull = false;
1030  fcinfo->args[1].value = arg2;
1031  fcinfo->args[1].isnull = false;
1032  fcinfo->args[2].value = arg3;
1033  fcinfo->args[2].isnull = false;
1034  fcinfo->args[3].value = arg4;
1035  fcinfo->args[3].isnull = false;
1036  fcinfo->args[4].value = arg5;
1037  fcinfo->args[4].isnull = false;
1038  fcinfo->args[5].value = arg6;
1039  fcinfo->args[5].isnull = false;
1040  fcinfo->args[6].value = arg7;
1041  fcinfo->args[6].isnull = false;
1042  fcinfo->args[7].value = arg8;
1043  fcinfo->args[7].isnull = false;
1044  fcinfo->args[8].value = arg9;
1045  fcinfo->args[8].isnull = false;
1046 
1047  result = (*func) (fcinfo);
1048 
1049  /* Check for null result, since caller is clearly not expecting one */
1050  if (fcinfo->isnull)
1051  elog(ERROR, "function %p returned NULL", (void *) func);
1052 
1053  return result;
1054 }
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:367
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ fetch_finfo_record()

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

Definition at line 470 of file fmgr.c.

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

Referenced by fmgr_c_validator(), and fmgr_info_C_lang().

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

◆ Float4GetDatum()

Datum Float4GetDatum ( float4  X)

Definition at line 1711 of file fmgr.c.

References palloc(), and PointerGetDatum.

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

1712 {
1713  float4 *retval = (float4 *) palloc(sizeof(float4));
1714 
1715  *retval = X;
1716  return PointerGetDatum(retval);
1717 }
#define PointerGetDatum(X)
Definition: postgres.h:556
float float4
Definition: c.h:491
void * palloc(Size size)
Definition: mcxt.c:949

◆ Float8GetDatum()

◆ fmgr_info()

void fmgr_info ( Oid  functionId,
FmgrInfo finfo 
)

Definition at line 124 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(), call_pltcl_start_proc(), compute_distinct_stats(), CopyTo(), create_foreign_modify(), eqjoinsel_inner(), eqjoinsel_semi(), EventTriggerInvoke(), ExecBuildGroupingEqual(), ExecCallTriggerFunc(), ExecHashTableCreate(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitSubPlan(), ExecInitTableFuncScan(), ExecInitWindowAgg(), execTuplesHashPrepare(), ExecuteCallStmt(), fetch_fp_info(), get_variable_range(), inet_mcv_join_sel(), initialize_peragg(), ltreeparentsel(), match_pattern_prefix(), mcv_get_match_bitmap(), networkjoinsel_semi(), networksel(), OidFunctionCall0Coll(), OidFunctionCall1Coll(), OidFunctionCall2Coll(), OidFunctionCall3Coll(), OidFunctionCall4Coll(), OidFunctionCall5Coll(), OidFunctionCall6Coll(), OidFunctionCall7Coll(), OidFunctionCall8Coll(), OidFunctionCall9Coll(), OidInputFunctionCall(), OidOutputFunctionCall(), OidReceiveFunctionCall(), OidSendFunctionCall(), patternsel_common(), pg_stats_ext_mcvlist_items(), plperl_ref_from_pg_array(), prefix_selectivity(), prepare_query_params(), printtup_prepare_info(), scalararraysel(), scalarineqsel(), ScanKeyEntryInitialize(), ScanKeyInit(), text_format(), TupleDescGetAttInMetadata(), and var_eq_const().

125 {
126  fmgr_info_cxt_security(functionId, finfo, CurrentMemoryContext, false);
127 }
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:144

◆ fmgr_info_C_lang()

static void fmgr_info_C_lang ( Oid  functionId,
FmgrInfo finfo,
HeapTuple  procedureTuple 
)
static

Definition at line 359 of file fmgr.c.

References Pg_finfo_record::api_version, elog, ERROR, fetch_finfo_record(), FmgrInfo::fn_addr, CFuncHashTabEntry::inforec, load_external_function(), lookup_C_func(), pfree(), PROCOID, record_C_func(), SysCacheGetAttr(), TextDatumGetCString, and CFuncHashTabEntry::user_fn.

Referenced by fmgr_info_cxt_security().

360 {
361  CFuncHashTabEntry *hashentry;
362  PGFunction user_fn;
363  const Pg_finfo_record *inforec;
364  bool isnull;
365 
366  /*
367  * See if we have the function address cached already
368  */
369  hashentry = lookup_C_func(procedureTuple);
370  if (hashentry)
371  {
372  user_fn = hashentry->user_fn;
373  inforec = hashentry->inforec;
374  }
375  else
376  {
377  Datum prosrcattr,
378  probinattr;
379  char *prosrcstring,
380  *probinstring;
381  void *libraryhandle;
382 
383  /*
384  * Get prosrc and probin strings (link symbol and library filename).
385  * While in general these columns might be null, that's not allowed
386  * for C-language functions.
387  */
388  prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple,
389  Anum_pg_proc_prosrc, &isnull);
390  if (isnull)
391  elog(ERROR, "null prosrc for C function %u", functionId);
392  prosrcstring = TextDatumGetCString(prosrcattr);
393 
394  probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
395  Anum_pg_proc_probin, &isnull);
396  if (isnull)
397  elog(ERROR, "null probin for C function %u", functionId);
398  probinstring = TextDatumGetCString(probinattr);
399 
400  /* Look up the function itself */
401  user_fn = load_external_function(probinstring, prosrcstring, true,
402  &libraryhandle);
403 
404  /* Get the function information record (real or default) */
405  inforec = fetch_finfo_record(libraryhandle, prosrcstring);
406 
407  /* Cache the addresses for later calls */
408  record_C_func(procedureTuple, user_fn, inforec);
409 
410  pfree(prosrcstring);
411  pfree(probinstring);
412  }
413 
414  switch (inforec->api_version)
415  {
416  case 1:
417  /* New style: call directly */
418  finfo->fn_addr = user_fn;
419  break;
420  default:
421  /* Shouldn't get here if fetch_finfo_record did its job */
422  elog(ERROR, "unrecognized function API version: %d",
423  inforec->api_version);
424  break;
425  }
426 }
Datum(* PGFunction)(FunctionCallInfo fcinfo)
Definition: fmgr.h:40
PGFunction fn_addr
Definition: fmgr.h:58
const Pg_finfo_record * inforec
Definition: fmgr.c:49
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
PGFunction user_fn
Definition: fmgr.c:48
PGFunction load_external_function(const char *filename, const char *funcname, bool signalNotFound, void **filehandle)
Definition: dfmgr.c:107
#define TextDatumGetCString(d)
Definition: builtins.h:84
uintptr_t Datum
Definition: postgres.h:367
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
static void record_C_func(HeapTuple procedureTuple, PGFunction user_fn, const Pg_finfo_record *inforec)
Definition: fmgr.c:554
static CFuncHashTabEntry * lookup_C_func(HeapTuple procedureTuple)
Definition: fmgr.c:530
const Pg_finfo_record * fetch_finfo_record(void *filehandle, const char *funcname)
Definition: fmgr.c:470
#define elog(elevel,...)
Definition: elog.h:228
int api_version
Definition: fmgr.h:385

◆ fmgr_info_copy()

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

Definition at line 610 of file fmgr.c.

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

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

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

◆ fmgr_info_cxt()

◆ fmgr_info_cxt_security()

static void fmgr_info_cxt_security ( Oid  functionId,
FmgrInfo finfo,
MemoryContext  mcxt,
bool  ignore_security 
)
static

Definition at line 144 of file fmgr.c.

References 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, InvalidOid, FmgrBuiltin::nargs, ObjectIdGetDatum, pfree(), PROCOID, ReleaseSysCache(), FmgrBuiltin::retset, SearchSysCache1(), 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().

146 {
147  const FmgrBuiltin *fbp;
148  HeapTuple procedureTuple;
149  Form_pg_proc procedureStruct;
150  Datum prosrcdatum;
151  bool isnull;
152  char *prosrc;
153 
154  /*
155  * fn_oid *must* be filled in last. Some code assumes that if fn_oid is
156  * valid, the whole struct is valid. Some FmgrInfo struct's do survive
157  * elogs.
158  */
159  finfo->fn_oid = InvalidOid;
160  finfo->fn_extra = NULL;
161  finfo->fn_mcxt = mcxt;
162  finfo->fn_expr = NULL; /* caller may set this later */
163 
164  if ((fbp = fmgr_isbuiltin(functionId)) != NULL)
165  {
166  /*
167  * Fast path for builtin functions: don't bother consulting pg_proc
168  */
169  finfo->fn_nargs = fbp->nargs;
170  finfo->fn_strict = fbp->strict;
171  finfo->fn_retset = fbp->retset;
172  finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */
173  finfo->fn_addr = fbp->func;
174  finfo->fn_oid = functionId;
175  return;
176  }
177 
178  /* Otherwise we need the pg_proc entry */
179  procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
180  if (!HeapTupleIsValid(procedureTuple))
181  elog(ERROR, "cache lookup failed for function %u", functionId);
182  procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
183 
184  finfo->fn_nargs = procedureStruct->pronargs;
185  finfo->fn_strict = procedureStruct->proisstrict;
186  finfo->fn_retset = procedureStruct->proretset;
187 
188  /*
189  * If it has prosecdef set, non-null proconfig, or if a plugin wants to
190  * hook function entry/exit, use fmgr_security_definer call handler ---
191  * unless we are being called again by fmgr_security_definer or
192  * fmgr_info_other_lang.
193  *
194  * When using fmgr_security_definer, function stats tracking is always
195  * disabled at the outer level, and instead we set the flag properly in
196  * fmgr_security_definer's private flinfo and implement the tracking
197  * inside fmgr_security_definer. This loses the ability to charge the
198  * overhead of fmgr_security_definer to the function, but gains the
199  * ability to set the track_functions GUC as a local GUC parameter of an
200  * interesting function and have the right things happen.
201  */
202  if (!ignore_security &&
203  (procedureStruct->prosecdef ||
204  !heap_attisnull(procedureTuple, Anum_pg_proc_proconfig, NULL) ||
205  FmgrHookIsNeeded(functionId)))
206  {
208  finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */
209  finfo->fn_oid = functionId;
210  ReleaseSysCache(procedureTuple);
211  return;
212  }
213 
214  switch (procedureStruct->prolang)
215  {
216  case INTERNALlanguageId:
217 
218  /*
219  * For an ordinary builtin function, we should never get here
220  * because the fmgr_isbuiltin() search above will have succeeded.
221  * However, if the user has done a CREATE FUNCTION to create an
222  * alias for a builtin function, we can end up here. In that case
223  * we have to look up the function by name. The name of the
224  * internal function is stored in prosrc (it doesn't have to be
225  * the same as the name of the alias!)
226  */
227  prosrcdatum = SysCacheGetAttr(PROCOID, procedureTuple,
228  Anum_pg_proc_prosrc, &isnull);
229  if (isnull)
230  elog(ERROR, "null prosrc");
231  prosrc = TextDatumGetCString(prosrcdatum);
232  fbp = fmgr_lookupByName(prosrc);
233  if (fbp == NULL)
234  ereport(ERROR,
235  (errcode(ERRCODE_UNDEFINED_FUNCTION),
236  errmsg("internal function \"%s\" is not in internal lookup table",
237  prosrc)));
238  pfree(prosrc);
239  /* Should we check that nargs, strict, retset match the table? */
240  finfo->fn_addr = fbp->func;
241  /* note this policy is also assumed in fast path above */
242  finfo->fn_stats = TRACK_FUNC_ALL; /* ie, never track */
243  break;
244 
245  case ClanguageId:
246  fmgr_info_C_lang(functionId, finfo, procedureTuple);
247  finfo->fn_stats = TRACK_FUNC_PL; /* ie, track if ALL */
248  break;
249 
250  case SQLlanguageId:
251  finfo->fn_addr = fmgr_sql;
252  finfo->fn_stats = TRACK_FUNC_PL; /* ie, track if ALL */
253  break;
254 
255  default:
256  fmgr_info_other_lang(functionId, finfo, procedureTuple);
257  finfo->fn_stats = TRACK_FUNC_OFF; /* ie, track if not OFF */
258  break;
259  }
260 
261  finfo->fn_oid = functionId;
262  ReleaseSysCache(procedureTuple);
263 }
bool strict
Definition: fmgrtab.h:29
short fn_nargs
Definition: fmgr.h:60
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
MemoryContext fn_mcxt
Definition: fmgr.h:65
short nargs
Definition: fmgrtab.h:28
PGFunction fn_addr
Definition: fmgr.h:58
static void fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
Definition: fmgr.c:433
int errcode(int sqlerrcode)
Definition: elog.c:608
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
Definition: heaptuple.c:359
#define FmgrHookIsNeeded(fn_oid)
Definition: fmgr.h:762
static void fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
Definition: fmgr.c:359
PGFunction func
Definition: fmgrtab.h:32
void pfree(void *pointer)
Definition: mcxt.c:1056
bool fn_retset
Definition: fmgr.h:62
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
bool fn_strict
Definition: fmgr.h:61
Datum fmgr_sql(PG_FUNCTION_ARGS)
Definition: functions.c:983
static const FmgrBuiltin * fmgr_lookupByName(const char *name)
Definition: fmgr.c:98
#define ereport(elevel, rest)
Definition: elog.h:141
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
#define TextDatumGetCString(d)
Definition: builtins.h:84
static const FmgrBuiltin * fmgr_isbuiltin(Oid id)
Definition: fmgr.c:73
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:59
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
fmNodePtr fn_expr
Definition: fmgr.h:66
Datum fmgr_security_definer(PG_FUNCTION_ARGS)
Definition: fmgr.c:660
void * fn_extra
Definition: fmgr.h:64
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define elog(elevel,...)
Definition: elog.h:228
unsigned char fn_stats
Definition: fmgr.h:63
bool retset
Definition: fmgrtab.h:30

◆ fmgr_info_other_lang()

static void fmgr_info_other_lang ( Oid  functionId,
FmgrInfo finfo,
HeapTuple  procedureTuple 
)
static

Definition at line 433 of file fmgr.c.

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

Referenced by fmgr_info_cxt_security().

434 {
435  Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
436  Oid language = procedureStruct->prolang;
437  HeapTuple languageTuple;
438  Form_pg_language languageStruct;
439  FmgrInfo plfinfo;
440 
441  languageTuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(language));
442  if (!HeapTupleIsValid(languageTuple))
443  elog(ERROR, "cache lookup failed for language %u", language);
444  languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
445 
446  /*
447  * Look up the language's call handler function, ignoring any attributes
448  * that would normally cause insertion of fmgr_security_definer. We need
449  * to get back a bare pointer to the actual C-language function.
450  */
451  fmgr_info_cxt_security(languageStruct->lanplcallfoid, &plfinfo,
452  CurrentMemoryContext, true);
453  finfo->fn_addr = plfinfo.fn_addr;
454 
455  ReleaseSysCache(languageTuple);
456 }
Definition: fmgr.h:56
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
PGFunction fn_addr
Definition: fmgr.h:58
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
#define elog(elevel,...)
Definition: elog.h:228
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:144

◆ fmgr_internal_function()

Oid fmgr_internal_function ( const char *  proname)

Definition at line 625 of file fmgr.c.

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

Referenced by fmgr_internal_validator().

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

◆ fmgr_isbuiltin()

static const FmgrBuiltin* fmgr_isbuiltin ( Oid  id)
static

Definition at line 73 of file fmgr.c.

References fmgr_builtin_oid_index, fmgr_builtins, fmgr_last_builtin_oid, and InvalidOidBuiltinMapping.

Referenced by fmgr_info_cxt_security().

74 {
75  uint16 index;
76 
77  /* fast lookup only possible if original oid still assigned */
78  if (id > fmgr_last_builtin_oid)
79  return NULL;
80 
81  /*
82  * Lookup function data. If there's a miss in that range it's likely a
83  * nonexistent function, returning NULL here will trigger an ERROR later.
84  */
85  index = fmgr_builtin_oid_index[id];
86  if (index == InvalidOidBuiltinMapping)
87  return NULL;
88 
89  return &fmgr_builtins[index];
90 }
const FmgrBuiltin fmgr_builtins[]
#define InvalidOidBuiltinMapping
Definition: fmgrtab.h:45
Definition: type.h:89
const Oid fmgr_last_builtin_oid
unsigned short uint16
Definition: c.h:358
const uint16 fmgr_builtin_oid_index[]

◆ fmgr_lookupByName()

static const FmgrBuiltin* fmgr_lookupByName ( const char *  name)
static

Definition at line 98 of file fmgr.c.

References fmgr_builtins, fmgr_nbuiltins, and i.

Referenced by fmgr_info_cxt_security(), and fmgr_internal_function().

99 {
100  int i;
101 
102  for (i = 0; i < fmgr_nbuiltins; i++)
103  {
104  if (strcmp(name, fmgr_builtins[i].funcName) == 0)
105  return fmgr_builtins + i;
106  }
107  return NULL;
108 }
const int fmgr_nbuiltins
const FmgrBuiltin fmgr_builtins[]
const char * name
Definition: encode.c:521
int i

◆ fmgr_security_definer()

Datum fmgr_security_definer ( PG_FUNCTION_ARGS  )

Definition at line 660 of file fmgr.c.

References 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(), 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().

661 {
662  Datum result;
663  struct fmgr_security_definer_cache *volatile fcache;
664  FmgrInfo *save_flinfo;
665  Oid save_userid;
666  int save_sec_context;
667  volatile int save_nestlevel;
668  PgStat_FunctionCallUsage fcusage;
669 
670  if (!fcinfo->flinfo->fn_extra)
671  {
672  HeapTuple tuple;
673  Form_pg_proc procedureStruct;
674  Datum datum;
675  bool isnull;
676  MemoryContext oldcxt;
677 
678  fcache = MemoryContextAllocZero(fcinfo->flinfo->fn_mcxt,
679  sizeof(*fcache));
680 
681  fmgr_info_cxt_security(fcinfo->flinfo->fn_oid, &fcache->flinfo,
682  fcinfo->flinfo->fn_mcxt, true);
683  fcache->flinfo.fn_expr = fcinfo->flinfo->fn_expr;
684 
685  tuple = SearchSysCache1(PROCOID,
686  ObjectIdGetDatum(fcinfo->flinfo->fn_oid));
687  if (!HeapTupleIsValid(tuple))
688  elog(ERROR, "cache lookup failed for function %u",
689  fcinfo->flinfo->fn_oid);
690  procedureStruct = (Form_pg_proc) GETSTRUCT(tuple);
691 
692  if (procedureStruct->prosecdef)
693  fcache->userid = procedureStruct->proowner;
694 
695  datum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proconfig,
696  &isnull);
697  if (!isnull)
698  {
699  oldcxt = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
700  fcache->proconfig = DatumGetArrayTypePCopy(datum);
701  MemoryContextSwitchTo(oldcxt);
702  }
703 
704  ReleaseSysCache(tuple);
705 
706  fcinfo->flinfo->fn_extra = fcache;
707  }
708  else
709  fcache = fcinfo->flinfo->fn_extra;
710 
711  /* GetUserIdAndSecContext is cheap enough that no harm in a wasted call */
712  GetUserIdAndSecContext(&save_userid, &save_sec_context);
713  if (fcache->proconfig) /* Need a new GUC nesting level */
714  save_nestlevel = NewGUCNestLevel();
715  else
716  save_nestlevel = 0; /* keep compiler quiet */
717 
718  if (OidIsValid(fcache->userid))
720  save_sec_context | SECURITY_LOCAL_USERID_CHANGE);
721 
722  if (fcache->proconfig)
723  {
724  ProcessGUCArray(fcache->proconfig,
728  }
729 
730  /* function manager hook */
731  if (fmgr_hook)
732  (*fmgr_hook) (FHET_START, &fcache->flinfo, &fcache->arg);
733 
734  /*
735  * We don't need to restore GUC or userid settings on error, because the
736  * ensuing xact or subxact abort will do that. The PG_TRY block is only
737  * needed to clean up the flinfo link.
738  */
739  save_flinfo = fcinfo->flinfo;
740 
741  PG_TRY();
742  {
743  fcinfo->flinfo = &fcache->flinfo;
744 
745  /* See notes in fmgr_info_cxt_security */
746  pgstat_init_function_usage(fcinfo, &fcusage);
747 
748  result = FunctionCallInvoke(fcinfo);
749 
750  /*
751  * We could be calling either a regular or a set-returning function,
752  * so we have to test to see what finalize flag to use.
753  */
754  pgstat_end_function_usage(&fcusage,
755  (fcinfo->resultinfo == NULL ||
756  !IsA(fcinfo->resultinfo, ReturnSetInfo) ||
757  ((ReturnSetInfo *) fcinfo->resultinfo)->isDone != ExprMultipleResult));
758  }
759  PG_CATCH();
760  {
761  fcinfo->flinfo = save_flinfo;
762  if (fmgr_hook)
763  (*fmgr_hook) (FHET_ABORT, &fcache->flinfo, &fcache->arg);
764  PG_RE_THROW();
765  }
766  PG_END_TRY();
767 
768  fcinfo->flinfo = save_flinfo;
769 
770  if (fcache->proconfig)
771  AtEOXact_GUC(true, save_nestlevel);
772  if (OidIsValid(fcache->userid))
773  SetUserIdAndSecContext(save_userid, save_sec_context);
774  if (fmgr_hook)
775  (*fmgr_hook) (FHET_END, &fcache->flinfo, &fcache->arg);
776 
777  return result;
778 }
Definition: fmgr.h:56
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
MemoryContext fn_mcxt
Definition: fmgr.h:65
void SetUserIdAndSecContext(Oid userid, int sec_context)
Definition: miscinit.c:492
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
bool superuser(void)
Definition: superuser.c:46
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:639
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
void pgstat_init_function_usage(FunctionCallInfo fcinfo, PgStat_FunctionCallUsage *fcu)
Definition: pgstat.c:1620
Definition: guc.h:75
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
Definition: miscinit.c:485
void AtEOXact_GUC(bool isCommit, int nestLevel)
Definition: guc.c:5769
Definition: fmgr.h:750
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
ArrayType * proconfig
Definition: fmgr.c:645
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
#define DatumGetArrayTypePCopy(X)
Definition: array.h:250
PGDLLIMPORT fmgr_hook_type fmgr_hook
Definition: fmgr.c:37
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:299
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:839
void ProcessGUCArray(ArrayType *array, GucContext context, GucSource source, GucAction action)
Definition: guc.c:10385
#define PG_CATCH()
Definition: elog.h:332
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
fmNodePtr fn_expr
Definition: fmgr.h:66
#define PG_RE_THROW()
Definition: elog.h:363
void * fn_extra
Definition: fmgr.h:64
void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
Definition: pgstat.c:1692
int NewGUCNestLevel(void)
Definition: guc.c:5755
#define elog(elevel,...)
Definition: elog.h:228
#define PG_TRY()
Definition: elog.h:322
#define PG_END_TRY()
Definition: elog.h:347
static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, bool ignore_security)
Definition: fmgr.c:144

◆ fmgr_symbol()

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

Definition at line 281 of file fmgr.c.

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

Referenced by llvm_function_reference().

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

◆ FunctionCall0Coll()

Datum FunctionCall0Coll ( FmgrInfo flinfo,
Oid  collation 
)

Definition at line 1113 of file fmgr.c.

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

Referenced by OidFunctionCall0Coll().

1114 {
1115  LOCAL_FCINFO(fcinfo, 0);
1116  Datum result;
1117 
1118  InitFunctionCallInfoData(*fcinfo, flinfo, 0, collation, NULL, NULL);
1119 
1120  result = FunctionCallInvoke(fcinfo);
1121 
1122  /* Check for null result, since caller is clearly not expecting one */
1123  if (fcinfo->isnull)
1124  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1125 
1126  return result;
1127 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall1Coll()

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

Definition at line 1130 of file fmgr.c.

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

Referenced by _hash_datum2hashkey(), brin_inclusion_add_value(), element_hash(), ExecHashBuildSkewHash(), ExecHashGetHashValue(), gistdentryinit(), gistFetchAtt(), gistFormTuple(), hash_range(), OidFunctionCall1Coll(), signValue(), spgdoinsert(), and TupleHashTableHash().

1131 {
1132  LOCAL_FCINFO(fcinfo, 1);
1133  Datum result;
1134 
1135  InitFunctionCallInfoData(*fcinfo, flinfo, 1, collation, NULL, NULL);
1136 
1137  fcinfo->args[0].value = arg1;
1138  fcinfo->args[0].isnull = false;
1139 
1140  result = FunctionCallInvoke(fcinfo);
1141 
1142  /* Check for null result, since caller is clearly not expecting one */
1143  if (fcinfo->isnull)
1144  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1145 
1146  return result;
1147 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall2Coll()

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

Definition at line 1150 of file fmgr.c.

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

Referenced by _bt_check_rowcompare(), _bt_checkkeys(), _bt_compare(), _bt_compare_array_elements(), _bt_compare_scankey_args(), _bt_find_extreme_element(), _bt_keep_natts(), _hash_checkqual(), array_position_common(), array_positions(), 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_partition_hash_value(), compute_range_stats(), create_range_bounds(), doPickSplit(), element_compare(), eqjoinsel_inner(), eqjoinsel_semi(), execTuplesUnequal(), genericPickSplit(), get_distance(), get_position(), get_variable_range(), ginCompareEntries(), gistMakeUnionItVec(), gistMakeUnionKey(), gistUserPicksplit(), hash_range_extended(), histogram_selectivity(), ineq_histogram_selectivity(), make_greater_string(), mcv_get_match_bitmap(), mcv_selectivity(), mode_final(), OidFunctionCall2Coll(), partition_list_bsearch(), partition_rbound_cmp(), partition_rbound_datum_cmp(), process_ordered_aggregate_single(), qsort_partition_list_value_cmp(), range_cmp_bound_values(), range_cmp_bounds(), range_contains_elem_internal(), ri_AttributesEqual(), satisfies_hash_partition(), spgdoinsert(), spgGetCache(), spgInnerTest(), spgLeafTest(), tuples_equal(), and var_eq_const().

1151 {
1152  LOCAL_FCINFO(fcinfo, 2);
1153  Datum result;
1154 
1155  InitFunctionCallInfoData(*fcinfo, flinfo, 2, collation, NULL, NULL);
1156 
1157  fcinfo->args[0].value = arg1;
1158  fcinfo->args[0].isnull = false;
1159  fcinfo->args[1].value = arg2;
1160  fcinfo->args[1].isnull = false;
1161 
1162  result = FunctionCallInvoke(fcinfo);
1163 
1164  /* Check for null result, since caller is clearly not expecting one */
1165  if (fcinfo->isnull)
1166  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1167 
1168  return result;
1169 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall3Coll()

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

Definition at line 1172 of file fmgr.c.

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

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

1174 {
1175  LOCAL_FCINFO(fcinfo, 3);
1176  Datum result;
1177 
1178  InitFunctionCallInfoData(*fcinfo, flinfo, 3, collation, NULL, NULL);
1179 
1180  fcinfo->args[0].value = arg1;
1181  fcinfo->args[0].isnull = false;
1182  fcinfo->args[1].value = arg2;
1183  fcinfo->args[1].isnull = false;
1184  fcinfo->args[2].value = arg3;
1185  fcinfo->args[2].isnull = false;
1186 
1187  result = FunctionCallInvoke(fcinfo);
1188 
1189  /* Check for null result, since caller is clearly not expecting one */
1190  if (fcinfo->isnull)
1191  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1192 
1193  return result;
1194 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall4Coll()

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

Definition at line 1197 of file fmgr.c.

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

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

1199 {
1200  LOCAL_FCINFO(fcinfo, 4);
1201  Datum result;
1202 
1203  InitFunctionCallInfoData(*fcinfo, flinfo, 4, collation, NULL, NULL);
1204 
1205  fcinfo->args[0].value = arg1;
1206  fcinfo->args[0].isnull = false;
1207  fcinfo->args[1].value = arg2;
1208  fcinfo->args[1].isnull = false;
1209  fcinfo->args[2].value = arg3;
1210  fcinfo->args[2].isnull = false;
1211  fcinfo->args[3].value = arg4;
1212  fcinfo->args[3].isnull = false;
1213 
1214  result = FunctionCallInvoke(fcinfo);
1215 
1216  /* Check for null result, since caller is clearly not expecting one */
1217  if (fcinfo->isnull)
1218  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1219 
1220  return result;
1221 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall5Coll()

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

Definition at line 1224 of file fmgr.c.

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

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

1226 {
1227  LOCAL_FCINFO(fcinfo, 5);
1228  Datum result;
1229 
1230  InitFunctionCallInfoData(*fcinfo, flinfo, 5, collation, NULL, NULL);
1231 
1232  fcinfo->args[0].value = arg1;
1233  fcinfo->args[0].isnull = false;
1234  fcinfo->args[1].value = arg2;
1235  fcinfo->args[1].isnull = false;
1236  fcinfo->args[2].value = arg3;
1237  fcinfo->args[2].isnull = false;
1238  fcinfo->args[3].value = arg4;
1239  fcinfo->args[3].isnull = false;
1240  fcinfo->args[4].value = arg5;
1241  fcinfo->args[4].isnull = false;
1242 
1243  result = FunctionCallInvoke(fcinfo);
1244 
1245  /* Check for null result, since caller is clearly not expecting one */
1246  if (fcinfo->isnull)
1247  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1248 
1249  return result;
1250 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall6Coll()

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

Definition at line 1253 of file fmgr.c.

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

Referenced by OidFunctionCall6Coll().

1256 {
1257  LOCAL_FCINFO(fcinfo, 6);
1258  Datum result;
1259 
1260  InitFunctionCallInfoData(*fcinfo, flinfo, 6, collation, NULL, NULL);
1261 
1262  fcinfo->args[0].value = arg1;
1263  fcinfo->args[0].isnull = false;
1264  fcinfo->args[1].value = arg2;
1265  fcinfo->args[1].isnull = false;
1266  fcinfo->args[2].value = arg3;
1267  fcinfo->args[2].isnull = false;
1268  fcinfo->args[3].value = arg4;
1269  fcinfo->args[3].isnull = false;
1270  fcinfo->args[4].value = arg5;
1271  fcinfo->args[4].isnull = false;
1272  fcinfo->args[5].value = arg6;
1273  fcinfo->args[5].isnull = false;
1274 
1275  result = FunctionCallInvoke(fcinfo);
1276 
1277  /* Check for null result, since caller is clearly not expecting one */
1278  if (fcinfo->isnull)
1279  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1280 
1281  return result;
1282 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall7Coll()

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

Definition at line 1285 of file fmgr.c.

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

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

1288 {
1289  LOCAL_FCINFO(fcinfo, 7);
1290  Datum result;
1291 
1292  InitFunctionCallInfoData(*fcinfo, flinfo, 7, collation, NULL, NULL);
1293 
1294  fcinfo->args[0].value = arg1;
1295  fcinfo->args[0].isnull = false;
1296  fcinfo->args[1].value = arg2;
1297  fcinfo->args[1].isnull = false;
1298  fcinfo->args[2].value = arg3;
1299  fcinfo->args[2].isnull = false;
1300  fcinfo->args[3].value = arg4;
1301  fcinfo->args[3].isnull = false;
1302  fcinfo->args[4].value = arg5;
1303  fcinfo->args[4].isnull = false;
1304  fcinfo->args[5].value = arg6;
1305  fcinfo->args[5].isnull = false;
1306  fcinfo->args[6].value = arg7;
1307  fcinfo->args[6].isnull = false;
1308 
1309  result = FunctionCallInvoke(fcinfo);
1310 
1311  /* Check for null result, since caller is clearly not expecting one */
1312  if (fcinfo->isnull)
1313  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1314 
1315  return result;
1316 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall8Coll()

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

Definition at line 1319 of file fmgr.c.

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

Referenced by directBoolConsistentFn(), and OidFunctionCall8Coll().

1322 {
1323  LOCAL_FCINFO(fcinfo, 8);
1324  Datum result;
1325 
1326  InitFunctionCallInfoData(*fcinfo, flinfo, 8, collation, NULL, NULL);
1327 
1328  fcinfo->args[0].value = arg1;
1329  fcinfo->args[0].isnull = false;
1330  fcinfo->args[1].value = arg2;
1331  fcinfo->args[1].isnull = false;
1332  fcinfo->args[2].value = arg3;
1333  fcinfo->args[2].isnull = false;
1334  fcinfo->args[3].value = arg4;
1335  fcinfo->args[3].isnull = false;
1336  fcinfo->args[4].value = arg5;
1337  fcinfo->args[4].isnull = false;
1338  fcinfo->args[5].value = arg6;
1339  fcinfo->args[5].isnull = false;
1340  fcinfo->args[6].value = arg7;
1341  fcinfo->args[6].isnull = false;
1342  fcinfo->args[7].value = arg8;
1343  fcinfo->args[7].isnull = false;
1344 
1345  result = FunctionCallInvoke(fcinfo);
1346 
1347  /* Check for null result, since caller is clearly not expecting one */
1348  if (fcinfo->isnull)
1349  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1350 
1351  return result;
1352 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ FunctionCall9Coll()

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

Definition at line 1355 of file fmgr.c.

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

Referenced by OidFunctionCall9Coll().

1359 {
1360  LOCAL_FCINFO(fcinfo, 9);
1361  Datum result;
1362 
1363  InitFunctionCallInfoData(*fcinfo, flinfo, 9, collation, NULL, NULL);
1364 
1365  fcinfo->args[0].value = arg1;
1366  fcinfo->args[0].isnull = false;
1367  fcinfo->args[1].value = arg2;
1368  fcinfo->args[1].isnull = false;
1369  fcinfo->args[2].value = arg3;
1370  fcinfo->args[2].isnull = false;
1371  fcinfo->args[3].value = arg4;
1372  fcinfo->args[3].isnull = false;
1373  fcinfo->args[4].value = arg5;
1374  fcinfo->args[4].isnull = false;
1375  fcinfo->args[5].value = arg6;
1376  fcinfo->args[5].isnull = false;
1377  fcinfo->args[6].value = arg7;
1378  fcinfo->args[6].isnull = false;
1379  fcinfo->args[7].value = arg8;
1380  fcinfo->args[7].isnull = false;
1381  fcinfo->args[8].value = arg9;
1382  fcinfo->args[8].isnull = false;
1383 
1384  result = FunctionCallInvoke(fcinfo);
1385 
1386  /* Check for null result, since caller is clearly not expecting one */
1387  if (fcinfo->isnull)
1388  elog(ERROR, "function %u returned NULL", flinfo->fn_oid);
1389 
1390  return result;
1391 }
#define ERROR
Definition: elog.h:43
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define elog(elevel,...)
Definition: elog.h:228

◆ get_call_expr_arg_stable()

bool get_call_expr_arg_stable ( Node expr,
int  argnum 
)

Definition at line 1901 of file fmgr.c.

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

Referenced by get_fn_expr_arg_stable().

1902 {
1903  List *args;
1904  Node *arg;
1905 
1906  if (expr == NULL)
1907  return false;
1908 
1909  if (IsA(expr, FuncExpr))
1910  args = ((FuncExpr *) expr)->args;
1911  else if (IsA(expr, OpExpr))
1912  args = ((OpExpr *) expr)->args;
1913  else if (IsA(expr, DistinctExpr))
1914  args = ((DistinctExpr *) expr)->args;
1915  else if (IsA(expr, ScalarArrayOpExpr))
1916  args = ((ScalarArrayOpExpr *) expr)->args;
1917  else if (IsA(expr, NullIfExpr))
1918  args = ((NullIfExpr *) expr)->args;
1919  else if (IsA(expr, WindowFunc))
1920  args = ((WindowFunc *) expr)->args;
1921  else
1922  return false;
1923 
1924  if (argnum < 0 || argnum >= list_length(args))
1925  return false;
1926 
1927  arg = (Node *) list_nth(args, argnum);
1928 
1929  /*
1930  * Either a true Const or an external Param will have a value that doesn't
1931  * change during the execution of the query. In future we might want to
1932  * consider other cases too, e.g. now().
1933  */
1934  if (IsA(arg, Const))
1935  return true;
1936  if (IsA(arg, Param) &&
1937  ((Param *) arg)->paramkind == PARAM_EXTERN)
1938  return true;
1939 
1940  return false;
1941 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
Definition: nodes.h:525
static void * list_nth(const List *list, int n)
Definition: pg_list.h:277
static int list_length(const List *l)
Definition: pg_list.h:169
void * arg
Definition: pg_list.h:50

◆ get_call_expr_argtype()

Oid get_call_expr_argtype ( Node expr,
int  argnum 
)

Definition at line 1836 of file fmgr.c.

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

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

1837 {
1838  List *args;
1839  Oid argtype;
1840 
1841  if (expr == NULL)
1842  return InvalidOid;
1843 
1844  if (IsA(expr, FuncExpr))
1845  args = ((FuncExpr *) expr)->args;
1846  else if (IsA(expr, OpExpr))
1847  args = ((OpExpr *) expr)->args;
1848  else if (IsA(expr, DistinctExpr))
1849  args = ((DistinctExpr *) expr)->args;
1850  else if (IsA(expr, ScalarArrayOpExpr))
1851  args = ((ScalarArrayOpExpr *) expr)->args;
1852  else if (IsA(expr, NullIfExpr))
1853  args = ((NullIfExpr *) expr)->args;
1854  else if (IsA(expr, WindowFunc))
1855  args = ((WindowFunc *) expr)->args;
1856  else
1857  return InvalidOid;
1858 
1859  if (argnum < 0 || argnum >= list_length(args))
1860  return InvalidOid;
1861 
1862  argtype = exprType((Node *) list_nth(args, argnum));
1863 
1864  /*
1865  * special hack for ScalarArrayOpExpr: what the underlying function will
1866  * actually get passed is the element type of the array.
1867  */
1868  if (IsA(expr, ScalarArrayOpExpr) &&
1869  argnum == 1)
1870  argtype = get_base_element_type(argtype);
1871 
1872  return argtype;
1873 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
Definition: nodes.h:525
unsigned int Oid
Definition: postgres_ext.h:31
static void * list_nth(const List *list, int n)
Definition: pg_list.h:277
#define InvalidOid
Definition: postgres_ext.h:36
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:41
static int list_length(const List *l)
Definition: pg_list.h:169
Oid get_base_element_type(Oid typid)
Definition: lsyscache.c:2599
Definition: pg_list.h:50

◆ get_fn_expr_arg_stable()

bool get_fn_expr_arg_stable ( FmgrInfo flinfo,
int  argnum 
)

Definition at line 1882 of file fmgr.c.

References FmgrInfo::fn_expr, and get_call_expr_arg_stable().

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

1883 {
1884  /*
1885  * can't return anything useful if we have no FmgrInfo or if its fn_expr
1886  * node has not been initialized
1887  */
1888  if (!flinfo || !flinfo->fn_expr)
1889  return false;
1890 
1891  return get_call_expr_arg_stable(flinfo->fn_expr, argnum);
1892 }
bool get_call_expr_arg_stable(Node *expr, int argnum)
Definition: fmgr.c:1901
fmNodePtr fn_expr
Definition: fmgr.h:66

◆ get_fn_expr_argtype()

Oid get_fn_expr_argtype ( FmgrInfo flinfo,
int  argnum 
)

◆ get_fn_expr_rettype()

Oid get_fn_expr_rettype ( FmgrInfo flinfo)

Definition at line 1795 of file fmgr.c.

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

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

1796 {
1797  Node *expr;
1798 
1799  /*
1800  * can't return anything useful if we have no FmgrInfo or if its fn_expr
1801  * node has not been initialized
1802  */
1803  if (!flinfo || !flinfo->fn_expr)
1804  return InvalidOid;
1805 
1806  expr = flinfo->fn_expr;
1807 
1808  return exprType(expr);
1809 }
Definition: nodes.h:525
#define InvalidOid
Definition: postgres_ext.h:36
fmNodePtr fn_expr
Definition: fmgr.h:66
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:41

◆ get_fn_expr_variadic()

bool get_fn_expr_variadic ( FmgrInfo flinfo)

Definition at line 1951 of file fmgr.c.

References FmgrInfo::fn_expr, and IsA.

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

1952 {
1953  Node *expr;
1954 
1955  /*
1956  * can't return anything useful if we have no FmgrInfo or if its fn_expr
1957  * node has not been initialized
1958  */
1959  if (!flinfo || !flinfo->fn_expr)
1960  return false;
1961 
1962  expr = flinfo->fn_expr;
1963 
1964  if (IsA(expr, FuncExpr))
1965  return ((FuncExpr *) expr)->funcvariadic;
1966  else
1967  return false;
1968 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:576
Definition: nodes.h:525
fmNodePtr fn_expr
Definition: fmgr.h:66

◆ InputFunctionCall()

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

Definition at line 1531 of file fmgr.c.

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

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

1532 {
1533  LOCAL_FCINFO(fcinfo, 3);
1534  Datum result;
1535 
1536  if (str == NULL && flinfo->fn_strict)
1537  return (Datum) 0; /* just return null result */
1538 
1539  InitFunctionCallInfoData(*fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
1540 
1541  fcinfo->args[0].value = CStringGetDatum(str);
1542  fcinfo->args[0].isnull = false;
1543  fcinfo->args[1].value = ObjectIdGetDatum(typioparam);
1544  fcinfo->args[1].isnull = false;
1545  fcinfo->args[2].value = Int32GetDatum(typmod);
1546  fcinfo->args[2].isnull = false;
1547 
1548  result = FunctionCallInvoke(fcinfo);
1549 
1550  /* Should get null result if and only if str is NULL */
1551  if (str == NULL)
1552  {
1553  if (!fcinfo->isnull)
1554  elog(ERROR, "input function %u returned non-NULL",
1555  flinfo->fn_oid);
1556  }
1557  else
1558  {
1559  if (fcinfo->isnull)
1560  elog(ERROR, "input function %u returned NULL",
1561  flinfo->fn_oid);
1562  }
1563 
1564  return result;
1565 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
bool fn_strict
Definition: fmgr.h:61
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
#define CStringGetDatum(X)
Definition: postgres.h:578
uintptr_t Datum
Definition: postgres.h:367
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define Int32GetDatum(X)
Definition: postgres.h:479
#define elog(elevel,...)
Definition: elog.h:228

◆ Int64GetDatum()

◆ lookup_C_func()

static CFuncHashTabEntry * lookup_C_func ( HeapTuple  procedureTuple)
static

Definition at line 530 of file fmgr.c.

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

Referenced by fmgr_info_C_lang().

531 {
532  Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
533  CFuncHashTabEntry *entry;
534 
535  if (CFuncHash == NULL)
536  return NULL; /* no table yet */
537  entry = (CFuncHashTabEntry *)
539  &fn_oid,
540  HASH_FIND,
541  NULL);
542  if (entry == NULL)
543  return NULL; /* no such entry */
544  if (entry->fn_xmin == HeapTupleHeaderGetRawXmin(procedureTuple->t_data) &&
545  ItemPointerEquals(&entry->fn_tid, &procedureTuple->t_self))
546  return entry; /* OK */
547  return NULL; /* entry is out of date */
548 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:906
unsigned int Oid
Definition: postgres_ext.h:31
HeapTupleHeader t_data
Definition: htup.h:68
static HTAB * CFuncHash
Definition: fmgr.c:52
ItemPointerData t_self
Definition: htup.h:65
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleHeaderGetRawXmin(tup)
Definition: htup_details.h:308
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
Definition: itemptr.c:29
TransactionId fn_xmin
Definition: fmgr.c:46
ItemPointerData fn_tid
Definition: fmgr.c:47

◆ OidFunctionCall0Coll()

Datum OidFunctionCall0Coll ( Oid  functionId,
Oid  collation 
)

Definition at line 1402 of file fmgr.c.

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

1403 {
1404  FmgrInfo flinfo;
1405 
1406  fmgr_info(functionId, &flinfo);
1407 
1408  return FunctionCall0Coll(&flinfo, collation);
1409 }
Definition: fmgr.h:56
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
Datum FunctionCall0Coll(FmgrInfo *flinfo, Oid collation)
Definition: fmgr.c:1113

◆ OidFunctionCall1Coll()

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

Definition at line 1412 of file fmgr.c.

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

Referenced by _hash_datum2hashkey_type().

1413 {
1414  FmgrInfo flinfo;
1415 
1416  fmgr_info(functionId, &flinfo);
1417 
1418  return FunctionCall1Coll(&flinfo, collation, arg1);
1419 }
Definition: fmgr.h:56
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
Definition: fmgr.c:1130

◆ OidFunctionCall2Coll()

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

Definition at line 1422 of file fmgr.c.

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

Referenced by _bt_compare_scankey_args(), and index_recheck_constraint().

1423 {
1424  FmgrInfo flinfo;
1425 
1426  fmgr_info(functionId, &flinfo);
1427 
1428  return FunctionCall2Coll(&flinfo, collation, arg1, arg2);
1429 }
Definition: fmgr.h:56
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1150
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidFunctionCall3Coll()

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

Definition at line 1432 of file fmgr.c.

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

1434 {
1435  FmgrInfo flinfo;
1436 
1437  fmgr_info(functionId, &flinfo);
1438 
1439  return FunctionCall3Coll(&flinfo, collation, arg1, arg2, arg3);
1440 }
Definition: fmgr.h:56
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
Datum FunctionCall3Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3)
Definition: fmgr.c:1172

◆ OidFunctionCall4Coll()

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

Definition at line 1443 of file fmgr.c.

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

Referenced by restriction_selectivity().

1445 {
1446  FmgrInfo flinfo;
1447 
1448  fmgr_info(functionId, &flinfo);
1449 
1450  return FunctionCall4Coll(&flinfo, collation, arg1, arg2, arg3, arg4);
1451 }
Definition: fmgr.h:56
Datum FunctionCall4Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
Definition: fmgr.c:1197
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidFunctionCall5Coll()

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

Definition at line 1454 of file fmgr.c.

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

Referenced by join_selectivity().

1456 {
1457  FmgrInfo flinfo;
1458 
1459  fmgr_info(functionId, &flinfo);
1460 
1461  return FunctionCall5Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5);
1462 }
Definition: fmgr.h:56
Datum FunctionCall5Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
Definition: fmgr.c:1224
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidFunctionCall6Coll()

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

Definition at line 1465 of file fmgr.c.

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

1468 {
1469  FmgrInfo flinfo;
1470 
1471  fmgr_info(functionId, &flinfo);
1472 
1473  return FunctionCall6Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1474  arg6);
1475 }
Definition: fmgr.h:56
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
Datum FunctionCall6Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6)
Definition: fmgr.c:1253

◆ OidFunctionCall7Coll()

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

Definition at line 1478 of file fmgr.c.

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

Referenced by gincost_pattern().

1481 {
1482  FmgrInfo flinfo;
1483 
1484  fmgr_info(functionId, &flinfo);
1485 
1486  return FunctionCall7Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1487  arg6, arg7);
1488 }
Definition: fmgr.h:56
Datum FunctionCall7Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
Definition: fmgr.c:1285
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidFunctionCall8Coll()

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

Definition at line 1491 of file fmgr.c.

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

1494 {
1495  FmgrInfo flinfo;
1496 
1497  fmgr_info(functionId, &flinfo);
1498 
1499  return FunctionCall8Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1500  arg6, arg7, arg8);
1501 }
Definition: fmgr.h:56
Datum FunctionCall8Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8)
Definition: fmgr.c:1319
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidFunctionCall9Coll()

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

Definition at line 1504 of file fmgr.c.

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

1508 {
1509  FmgrInfo flinfo;
1510 
1511  fmgr_info(functionId, &flinfo);
1512 
1513  return FunctionCall9Coll(&flinfo, collation, arg1, arg2, arg3, arg4, arg5,
1514  arg6, arg7, arg8, arg9);
1515 }
Definition: fmgr.h:56
Datum FunctionCall9Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9)
Definition: fmgr.c:1355
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidInputFunctionCall()

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

Definition at line 1646 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().

1647 {
1648  FmgrInfo flinfo;
1649 
1650  fmgr_info(functionId, &flinfo);
1651  return InputFunctionCall(&flinfo, str, typioparam, typmod);
1652 }
Definition: fmgr.h:56
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1531

◆ OidOutputFunctionCall()

◆ OidReceiveFunctionCall()

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

Definition at line 1664 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().

1666 {
1667  FmgrInfo flinfo;
1668 
1669  fmgr_info(functionId, &flinfo);
1670  return ReceiveFunctionCall(&flinfo, buf, typioparam, typmod);
1671 }
Definition: fmgr.h:56
Datum ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf, Oid typioparam, int32 typmod)
Definition: fmgr.c:1589
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124

◆ OidSendFunctionCall()

bytea* OidSendFunctionCall ( Oid  functionId,
Datum  val 
)

Definition at line 1674 of file fmgr.c.

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

Referenced by SendFunctionResult().

1675 {
1676  FmgrInfo flinfo;
1677 
1678  fmgr_info(functionId, &flinfo);
1679  return SendFunctionCall(&flinfo, val);
1680 }
Definition: fmgr.h:56
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:124
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
Definition: fmgr.c:1636
long val
Definition: informix.c:684

◆ OutputFunctionCall()

◆ pg_detoast_datum()

struct varlena* pg_detoast_datum ( struct varlena datum)

Definition at line 1739 of file fmgr.c.

References detoast_attr(), and VARATT_IS_EXTENDED.

1740 {
1741  if (VARATT_IS_EXTENDED(datum))
1742  return detoast_attr(datum);
1743  else
1744  return datum;
1745 }
struct varlena * detoast_attr(struct varlena *attr)
Definition: detoast.c:116
#define VARATT_IS_EXTENDED(PTR)
Definition: postgres.h:327

◆ pg_detoast_datum_copy()

struct varlena* pg_detoast_datum_copy ( struct varlena datum)

Definition at line 1748 of file fmgr.c.

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

1749 {
1750  if (VARATT_IS_EXTENDED(datum))
1751  return detoast_attr(datum);
1752  else
1753  {
1754  /* Make a modifiable copy of the varlena object */
1755  Size len = VARSIZE(datum);
1756  struct varlena *result = (struct varlena *) palloc(len);
1757 
1758  memcpy(result, datum, len);
1759  return result;
1760  }
1761 }
#define VARSIZE(PTR)
Definition: postgres.h:303
struct varlena * detoast_attr(struct varlena *attr)
Definition: detoast.c:116
size_t Size
Definition: c.h:467
#define VARATT_IS_EXTENDED(PTR)
Definition: postgres.h:327
void * palloc(Size size)
Definition: mcxt.c:949
Definition: c.h:550

◆ pg_detoast_datum_packed()

struct varlena* pg_detoast_datum_packed ( struct varlena datum)

Definition at line 1771 of file fmgr.c.

References detoast_attr(), VARATT_IS_COMPRESSED, and VARATT_IS_EXTERNAL.

Referenced by text_to_cstring(), and text_to_cstring_buffer().

1772 {
1773  if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum))
1774  return detoast_attr(datum);
1775  else
1776  return datum;
1777 }
#define VARATT_IS_COMPRESSED(PTR)
Definition: postgres.h:312
#define VARATT_IS_EXTERNAL(PTR)
Definition: postgres.h:313
struct varlena * detoast_attr(struct varlena *attr)
Definition: detoast.c:116

◆ pg_detoast_datum_slice()

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

Definition at line 1764 of file fmgr.c.

References detoast_attr_slice().

1765 {
1766  /* Only get the specified portion from the toast rel */
1767  return detoast_attr_slice(datum, first, count);
1768 }
struct varlena * detoast_attr_slice(struct varlena *attr, int32 sliceoffset, int32 slicelength)
Definition: detoast.c:204

◆ ReceiveFunctionCall()

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

Definition at line 1589 of file fmgr.c.

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

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

1591 {
1592  LOCAL_FCINFO(fcinfo, 3);
1593  Datum result;
1594 
1595  if (buf == NULL && flinfo->fn_strict)
1596  return (Datum) 0; /* just return null result */
1597 
1598  InitFunctionCallInfoData(*fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
1599 
1600  fcinfo->args[0].value = PointerGetDatum(buf);
1601  fcinfo->args[0].isnull = false;
1602  fcinfo->args[1].value = ObjectIdGetDatum(typioparam);
1603  fcinfo->args[1].isnull = false;
1604  fcinfo->args[2].value = Int32GetDatum(typmod);
1605  fcinfo->args[2].isnull = false;
1606 
1607  result = FunctionCallInvoke(fcinfo);
1608 
1609  /* Should get null result if and only if buf is NULL */
1610  if (buf == NULL)
1611  {
1612  if (!fcinfo->isnull)
1613  elog(ERROR, "receive function %u returned non-NULL",
1614  flinfo->fn_oid);
1615  }
1616  else
1617  {
1618  if (fcinfo->isnull)
1619  elog(ERROR, "receive function %u returned NULL",
1620  flinfo->fn_oid);
1621  }
1622 
1623  return result;
1624 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
bool fn_strict
Definition: fmgr.h:61
#define FunctionCallInvoke(fcinfo)
Definition: fmgr.h:167
uintptr_t Datum
Definition: postgres.h:367
#define InvalidOid
Definition: postgres_ext.h:36
Oid fn_oid
Definition: fmgr.h:59
#define LOCAL_FCINFO(name, nargs)
Definition: fmgr.h:110
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
Definition: fmgr.h:150
#define Int32GetDatum(X)
Definition: postgres.h:479
#define elog(elevel,...)
Definition: elog.h:228

◆ record_C_func()

static void record_C_func ( HeapTuple  procedureTuple,
PGFunction  user_fn,
const Pg_finfo_record inforec 
)
static

Definition at line 554 of file fmgr.c.

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

Referenced by fmgr_info_C_lang().

556 {
557  Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
558  CFuncHashTabEntry *entry;
559  bool found;
560 
561  /* Create the hash table if it doesn't exist yet */
562  if (CFuncHash == NULL)
563  {
564  HASHCTL hash_ctl;
565 
566  MemSet(&hash_ctl, 0, sizeof(hash_ctl));
567  hash_ctl.keysize = sizeof(Oid);
568  hash_ctl.entrysize = sizeof(CFuncHashTabEntry);
569  CFuncHash = hash_create("CFuncHash",
570  100,
571  &hash_ctl,
573  }
574 
575  entry = (CFuncHashTabEntry *)
577  &fn_oid,
578  HASH_ENTER,
579  &found);
580  /* OID is already filled in */
581  entry->fn_xmin = HeapTupleHeaderGetRawXmin(procedureTuple->t_data);
582  entry->fn_tid = procedureTuple->t_self;
583  entry->user_fn = user_fn;
584  entry->inforec = inforec;
585 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define HASH_ELEM
Definition: hsearch.h:87
const Pg_finfo_record * inforec
Definition: fmgr.c:49
Size entrysize
Definition: hsearch.h:73
#define MemSet(start, val, len)
Definition: c.h:956
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:906
unsigned int Oid
Definition: postgres_ext.h:31
HeapTupleHeader t_data
Definition: htup.h:68
static HTAB * CFuncHash
Definition: fmgr.c:52
ItemPointerData t_self
Definition: htup.h:65
PGFunction user_fn
Definition: fmgr.c:48
#define HASH_BLOBS
Definition: hsearch.h:88
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
Definition: dynahash.c:316
Size keysize
Definition: hsearch.h:72
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleHeaderGetRawXmin(tup)
Definition: htup_details.h:308
TransactionId fn_xmin
Definition: fmgr.c:46
ItemPointerData fn_tid
Definition: fmgr.c:47

◆ SendFunctionCall()

bytea* SendFunctionCall ( FmgrInfo flinfo,
Datum  val 
)

Definition at line 1636 of file fmgr.c.

References DatumGetByteaP, and FunctionCall1.

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

1637 {
1638  return DatumGetByteaP(FunctionCall1(flinfo, val));
1639 }
#define DatumGetByteaP(X)
Definition: fmgr.h:325
#define FunctionCall1(flinfo, arg1)
Definition: fmgr.h:635
long val
Definition: informix.c:684

Variable Documentation

◆ CFuncHash

HTAB* CFuncHash = NULL
static

Definition at line 52 of file fmgr.c.

◆ fmgr_hook

PGDLLIMPORT fmgr_hook_type fmgr_hook = NULL

Definition at line 37 of file fmgr.c.

Referenced by fmgr_security_definer(), and sepgsql_init_client_label().

◆ needs_fmgr_hook

PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook = NULL

Definition at line 36 of file fmgr.c.

Referenced by sepgsql_init_client_label().