MCPcopy Create free account
hub / github.com/apache/cloudberry / load_external_function

Function load_external_function

src/backend/utils/fmgr/dfmgr.c:107–136  ·  view source on GitHub ↗

* Load the specified dynamic-link library file, and look for a function * named funcname in it. * * If the function is not found, we raise an error if signalNotFound is true, * else return NULL. Note that errors in loading the library * will provoke ereport() regardless of signalNotFound. * * If filehandle is not NULL, then *filehandle will be set to a handle * identifying the library fil

Source from the content-addressed store, hash-verified

105 * at less cost than repeating load_external_function.
106 */
107void *
108load_external_function(const char *filename, const char *funcname,
109 bool signalNotFound, void **filehandle)
110{
111 char *fullname;
112 void *lib_handle;
113 void *retval;
114
115 /* Expand the possibly-abbreviated filename to an exact path name */
116 fullname = expand_dynamic_library_name(filename);
117
118 /* Load the shared library, unless we already did */
119 lib_handle = internal_load_library(fullname);
120
121 /* Return handle if caller wants it */
122 if (filehandle)
123 *filehandle = lib_handle;
124
125 /* Look up the function within the library. */
126 retval = dlsym(lib_handle, funcname);
127
128 if (retval == NULL && signalNotFound)
129 ereport(ERROR,
130 (errcode(ERRCODE_UNDEFINED_FUNCTION),
131 errmsg("could not find function \"%s\" in file \"%s\"",
132 funcname, fullname)));
133
134 pfree(fullname);
135 return retval;
136}
137
138/*
139 * This function loads a shlib file without looking up any particular

Callers 14

_PG_initFunction · 0.85
_PG_initFunction · 0.85
_PG_initFunction · 0.85
_PG_initFunction · 0.85
HandleFaultMessageFunction · 0.85
fmgr_info_C_langFunction · 0.85
LoadOutputPluginFunction · 0.85
CallExtMainFunction · 0.85
provider_initFunction · 0.85
llvm_resolve_symbolFunction · 0.85

Calls 6

internal_load_libraryFunction · 0.85
dlsymFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected