3737#include "utils/hsearch.h"
3838
3939
40- /* signatures for PostgreSQL-specific library init/fini functions */
40+ /* signature for PostgreSQL-specific library init function */
4141typedef void (* PG_init_t ) (void );
42- typedef void (* PG_fini_t ) (void );
4342
4443/* hashtable entry for rendezvous variables */
4544typedef struct
@@ -79,7 +78,6 @@ char *Dynamic_library_path;
7978static void * internal_load_library (const char * libname );
8079static void incompatible_module_error (const char * libname ,
8180 const Pg_magic_struct * module_magic_data ) pg_attribute_noreturn ();
82- static void internal_unload_library (const char * libname );
8381static bool file_exists (const char * name );
8482static char * expand_dynamic_library_name (const char * name );
8583static void check_restricted_library_name (const char * name );
@@ -154,9 +152,6 @@ load_file(const char *filename, bool restricted)
154152 /* Expand the possibly-abbreviated filename to an exact path name */
155153 fullname = expand_dynamic_library_name (filename );
156154
157- /* Unload the library if currently loaded */
158- internal_unload_library (fullname );
159-
160155 /* Load the shared library */
161156 (void ) internal_load_library (fullname );
162157
@@ -179,6 +174,11 @@ lookup_external_function(void *filehandle, const char *funcname)
179174 * loaded. Return the pg_dl* handle for the file.
180175 *
181176 * Note: libname is expected to be an exact name for the library file.
177+ *
178+ * NB: There is presently no way to unload a dynamically loaded file. We might
179+ * add one someday if we can convince ourselves we have safe protocols for un-
180+ * hooking from hook function pointers, releasing custom GUC variables, and
181+ * perhaps other things that are definitely unsafe currently.
182182 */
183183static void *
184184internal_load_library (const char * libname )
@@ -400,71 +400,6 @@ incompatible_module_error(const char *libname,
400400 errdetail_internal ("%s" , details .data )));
401401}
402402
403- /*
404- * Unload the specified dynamic-link library file, if it is loaded.
405- *
406- * Note: libname is expected to be an exact name for the library file.
407- *
408- * XXX for the moment, this is disabled, resulting in LOAD of an already-loaded
409- * library always being a no-op. We might re-enable it someday if we can
410- * convince ourselves we have safe protocols for un-hooking from hook function
411- * pointers, releasing custom GUC variables, and perhaps other things that
412- * are definitely unsafe currently.
413- */
414- static void
415- internal_unload_library (const char * libname )
416- {
417- #ifdef NOT_USED
418- DynamicFileList * file_scanner ,
419- * prv ,
420- * nxt ;
421- struct stat stat_buf ;
422- PG_fini_t PG_fini ;
423-
424- /*
425- * We need to do stat() in order to determine whether this is the same
426- * file as a previously loaded file; it's also handy so as to give a good
427- * error message if bogus file name given.
428- */
429- if (stat (libname , & stat_buf ) == -1 )
430- ereport (ERROR ,
431- (errcode_for_file_access (),
432- errmsg ("could not access file \"%s\": %m" , libname )));
433-
434- /*
435- * We have to zap all entries in the list that match on either filename or
436- * inode, else internal_load_library() will still think it's present.
437- */
438- prv = NULL ;
439- for (file_scanner = file_list ; file_scanner != NULL ; file_scanner = nxt )
440- {
441- nxt = file_scanner -> next ;
442- if (strcmp (libname , file_scanner -> filename ) == 0 ||
443- SAME_INODE (stat_buf , * file_scanner ))
444- {
445- if (prv )
446- prv -> next = nxt ;
447- else
448- file_list = nxt ;
449-
450- /*
451- * If the library has a _PG_fini() function, call it.
452- */
453- PG_fini = (PG_fini_t ) dlsym (file_scanner -> handle , "_PG_fini" );
454- if (PG_fini )
455- (* PG_fini ) ();
456-
457- clear_external_function_hash (file_scanner -> handle );
458- dlclose (file_scanner -> handle );
459- free ((char * ) file_scanner );
460- /* prv does not change */
461- }
462- else
463- prv = file_scanner ;
464- }
465- #endif /* NOT_USED */
466- }
467-
468403static bool
469404file_exists (const char * name )
470405{
0 commit comments