37
37
#include "utils/hsearch.h"
38
38
39
39
40
- /* signatures for PostgreSQL-specific library init/fini functions */
40
+ /* signature for PostgreSQL-specific library init function */
41
41
typedef void (* PG_init_t ) (void );
42
- typedef void (* PG_fini_t ) (void );
43
42
44
43
/* hashtable entry for rendezvous variables */
45
44
typedef struct
@@ -79,7 +78,6 @@ char *Dynamic_library_path;
79
78
static void * internal_load_library (const char * libname );
80
79
static void incompatible_module_error (const char * libname ,
81
80
const Pg_magic_struct * module_magic_data ) pg_attribute_noreturn ();
82
- static void internal_unload_library (const char * libname );
83
81
static bool file_exists (const char * name );
84
82
static char * expand_dynamic_library_name (const char * name );
85
83
static void check_restricted_library_name (const char * name );
@@ -154,9 +152,6 @@ load_file(const char *filename, bool restricted)
154
152
/* Expand the possibly-abbreviated filename to an exact path name */
155
153
fullname = expand_dynamic_library_name (filename );
156
154
157
- /* Unload the library if currently loaded */
158
- internal_unload_library (fullname );
159
-
160
155
/* Load the shared library */
161
156
(void ) internal_load_library (fullname );
162
157
@@ -179,6 +174,11 @@ lookup_external_function(void *filehandle, const char *funcname)
179
174
* loaded. Return the pg_dl* handle for the file.
180
175
*
181
176
* 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.
182
182
*/
183
183
static void *
184
184
internal_load_library (const char * libname )
@@ -400,71 +400,6 @@ incompatible_module_error(const char *libname,
400
400
errdetail_internal ("%s" , details .data )));
401
401
}
402
402
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
-
468
403
static bool
469
404
file_exists (const char * name )
470
405
{
0 commit comments