PostgreSQL Source Code git master
|
#include "postgres.h"
#include <sys/stat.h>
#include <dlfcn.h>
#include "fmgr.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "storage/shmem.h"
#include "utils/hsearch.h"
Go to the source code of this file.
Data Structures | |
struct | rendezvousHashEntry |
struct | DynamicFileList |
Macros | |
#define | SAME_INODE(A, B) ((A).st_ino == (B).inode && (A).st_dev == (B).device) |
Typedefs | |
typedef void(* | PG_init_t) (void) |
Functions | |
static void * | internal_load_library (const char *libname) |
static pg_noreturn void | incompatible_module_error (const char *libname, const Pg_abi_values *module_magic_data) |
static char * | expand_dynamic_library_name (const char *name) |
static void | check_restricted_library_name (const char *name) |
void * | load_external_function (const char *filename, const char *funcname, bool signalNotFound, void **filehandle) |
void | load_file (const char *filename, bool restricted) |
void * | lookup_external_function (void *filehandle, const char *funcname) |
DynamicFileList * | get_first_loaded_module (void) |
DynamicFileList * | get_next_loaded_module (DynamicFileList *dfptr) |
void | get_loaded_module_details (DynamicFileList *dfptr, const char **library_path, const char **module_name, const char **module_version) |
char * | substitute_path_macro (const char *str, const char *macro, const char *value) |
char * | find_in_path (const char *basename, const char *path, const char *path_param, const char *macro, const char *macro_val) |
void ** | find_rendezvous_variable (const char *varName) |
Size | EstimateLibraryStateSpace (void) |
void | SerializeLibraryState (Size maxsize, char *start_address) |
void | RestoreLibraryState (char *start_address) |
Variables | |
static DynamicFileList * | file_list = NULL |
static DynamicFileList * | file_tail = NULL |
char * | Dynamic_library_path |
static const Pg_abi_values | magic_data = PG_MODULE_ABI_DATA |
#define SAME_INODE | ( | A, | |
B | |||
) | ((A).st_ino == (B).inode && (A).st_dev == (B).device) |
|
static |
Size EstimateLibraryStateSpace | ( | void | ) |
Definition at line 695 of file dfmgr.c.
References add_size(), file_list, DynamicFileList::filename, and DynamicFileList::next.
Referenced by InitializeParallelDSM().
|
static |
Definition at line 451 of file dfmgr.c.
References Assert(), Dynamic_library_path, find_in_path(), first_dir_separator(), name, pfree(), pg_file_exists(), pkglib_path, psprintf(), pstrdup(), and substitute_path_macro().
Referenced by load_external_function(), and load_file().
char * find_in_path | ( | const char * | basename, |
const char * | path, | ||
const char * | path_param, | ||
const char * | macro, | ||
const char * | macro_val | ||
) |
Definition at line 567 of file dfmgr.c.
References Assert(), canonicalize_path(), DEBUG3, elog, ereport, errcode(), errmsg(), ERROR, first_dir_separator(), first_path_var_separator(), is_absolute_path, len, palloc(), pfree(), pg_file_exists(), sprintf, strlcpy(), and substitute_path_macro().
Referenced by expand_dynamic_library_name(), and find_extension_control_filename().
void ** find_rendezvous_variable | ( | const char * | varName | ) |
Definition at line 657 of file dfmgr.c.
References ctl, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HASH_STRINGS, NAMEDATALEN, and rendezvousHashEntry::varValue.
Referenced by _PG_init().
DynamicFileList * get_first_loaded_module | ( | void | ) |
Definition at line 410 of file dfmgr.c.
References file_list.
Referenced by pg_get_loaded_modules().
void get_loaded_module_details | ( | DynamicFileList * | dfptr, |
const char ** | library_path, | ||
const char ** | module_name, | ||
const char ** | module_version | ||
) |
Definition at line 430 of file dfmgr.c.
References DynamicFileList::filename, DynamicFileList::magic, Pg_magic_struct::name, and Pg_magic_struct::version.
Referenced by pg_get_loaded_modules().
DynamicFileList * get_next_loaded_module | ( | DynamicFileList * | dfptr | ) |
Definition at line 416 of file dfmgr.c.
References DynamicFileList::next.
Referenced by pg_get_loaded_modules().
|
static |
Definition at line 301 of file dfmgr.c.
References _, Pg_abi_values::abi_extra, appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), StringInfoData::data, ereport, errdetail(), errdetail_internal(), errmsg(), ERROR, Pg_abi_values::float8byval, Pg_abi_values::funcmaxargs, Pg_abi_values::indexmaxkeys, initStringInfo(), StringInfoData::len, magic_data, Pg_abi_values::namedatalen, snprintf, and Pg_abi_values::version.
Referenced by internal_load_library().
|
static |
Definition at line 174 of file dfmgr.c.
References Pg_magic_struct::abi_fields, DynamicFileList::device, dlclose(), dlerror(), dlopen(), dlsym(), ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), ERROR, file_list, file_tail, DynamicFileList::filename, filename, free, DynamicFileList::handle, incompatible_module_error(), DynamicFileList::inode, Pg_magic_struct::len, DynamicFileList::magic, magic_data, malloc, MemSet, DynamicFileList::next, PG_MAGIC_FUNCTION_NAME_STRING, RTLD_GLOBAL, RTLD_NOW, SAME_INODE, stat::st_dev, stat::st_ino, and stat.
Referenced by load_external_function(), load_file(), and RestoreLibraryState().
void * load_external_function | ( | const char * | filename, |
const char * | funcname, | ||
bool | signalNotFound, | ||
void ** | filehandle | ||
) |
Definition at line 95 of file dfmgr.c.
References dlsym(), ereport, errcode(), errmsg(), ERROR, expand_dynamic_library_name(), filename, funcname, internal_load_library(), and pfree().
Referenced by _PG_init(), fmgr_c_validator(), fmgr_info_C_lang(), llvm_resolve_symbol(), load_validator_library(), LoadArchiveLibrary(), LoadOutputPlugin(), LookupBackgroundWorkerFunction(), LookupParallelWorkerFunction(), and provider_init().
void load_file | ( | const char * | filename, |
bool | restricted | ||
) |
Definition at line 134 of file dfmgr.c.
References check_restricted_library_name(), expand_dynamic_library_name(), filename, internal_load_library(), and pfree().
Referenced by AlterSubscription(), AlterSubscription_refresh(), CreateSubscription(), DropSubscription(), load_libraries(), pg_sync_replication_slots(), ReplicationSlotDropAtPubNode(), ReplSlotSyncWorkerMain(), SetupApplyOrSyncWorker(), standard_ProcessUtility(), and WalReceiverMain().
void * lookup_external_function | ( | void * | filehandle, |
const char * | funcname | ||
) |
void RestoreLibraryState | ( | char * | start_address | ) |
Definition at line 734 of file dfmgr.c.
References internal_load_library().
Referenced by ParallelWorkerMain().
void SerializeLibraryState | ( | Size | maxsize, |
char * | start_address | ||
) |
Definition at line 712 of file dfmgr.c.
References Assert(), file_list, DynamicFileList::filename, len, DynamicFileList::next, and strlcpy().
Referenced by InitializeParallelDSM().
char * substitute_path_macro | ( | const char * | str, |
const char * | macro, | ||
const char * | value | ||
) |
Definition at line 529 of file dfmgr.c.
References Assert(), ereport, errcode(), errmsg(), ERROR, first_dir_separator(), psprintf(), pstrdup(), str, and value.
Referenced by expand_dynamic_library_name(), find_in_path(), and get_extension_control_directories().
char* Dynamic_library_path |
Definition at line 69 of file dfmgr.c.
Referenced by expand_dynamic_library_name().
|
static |
Definition at line 59 of file dfmgr.c.
Referenced by EstimateLibraryStateSpace(), get_first_loaded_module(), internal_load_library(), and SerializeLibraryState().
|
static |
Definition at line 60 of file dfmgr.c.
Referenced by internal_load_library().
|
static |
Definition at line 78 of file dfmgr.c.
Referenced by incompatible_module_error(), and internal_load_library().