Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab02d70

Browse files
committed
Remove non-functional code for unloading loadable modules.
The code for unloading a library has been commented-out for over 12years, ever since commit602a9ef, and we'reno closer to supporting it now than we were back then.Nathan Bossart, reviewed by Michael Paquier and by me.Discussion:http://postgr.es/m/Ynsc9bRL1caUSBSE@paquier.xyz
1 parent78ccd6c commitab02d70

File tree

13 files changed

+13
-200
lines changed

13 files changed

+13
-200
lines changed

‎contrib/auto_explain/auto_explain.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
7777
staticExecutorEnd_hook_typeprev_ExecutorEnd=NULL;
7878

7979
void_PG_init(void);
80-
void_PG_fini(void);
8180

8281
staticvoidexplain_ExecutorStart(QueryDesc*queryDesc,inteflags);
8382
staticvoidexplain_ExecutorRun(QueryDesc*queryDesc,
@@ -244,19 +243,6 @@ _PG_init(void)
244243
ExecutorEnd_hook=explain_ExecutorEnd;
245244
}
246245

247-
/*
248-
* Module unload callback
249-
*/
250-
void
251-
_PG_fini(void)
252-
{
253-
/* Uninstall hooks. */
254-
ExecutorStart_hook=prev_ExecutorStart;
255-
ExecutorRun_hook=prev_ExecutorRun;
256-
ExecutorFinish_hook=prev_ExecutorFinish;
257-
ExecutorEnd_hook=prev_ExecutorEnd;
258-
}
259-
260246
/*
261247
* ExecutorStart hook: start up logging if needed
262248
*/

‎contrib/passwordcheck/passwordcheck.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static check_password_hook_type prev_check_password_hook = NULL;
3333
#defineMIN_PWD_LENGTH 8
3434

3535
externvoid_PG_init(void);
36-
externvoid_PG_fini(void);
3736

3837
/*
3938
* check_password
@@ -149,13 +148,3 @@ _PG_init(void)
149148
prev_check_password_hook=check_password_hook;
150149
check_password_hook=check_password;
151150
}
152-
153-
/*
154-
* Module unload function
155-
*/
156-
void
157-
_PG_fini(void)
158-
{
159-
/* uninstall hook */
160-
check_password_hook=prev_check_password_hook;
161-
}

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ static bool pgss_save;/* whether to save stats across shutdown */
305305
/*---- Function declarations ----*/
306306

307307
void_PG_init(void);
308-
void_PG_fini(void);
309308

310309
PG_FUNCTION_INFO_V1(pg_stat_statements_reset);
311310
PG_FUNCTION_INFO_V1(pg_stat_statements_reset_1_7);
@@ -481,23 +480,6 @@ _PG_init(void)
481480
ProcessUtility_hook=pgss_ProcessUtility;
482481
}
483482

484-
/*
485-
* Module unload callback
486-
*/
487-
void
488-
_PG_fini(void)
489-
{
490-
/* Uninstall hooks. */
491-
shmem_startup_hook=prev_shmem_startup_hook;
492-
post_parse_analyze_hook=prev_post_parse_analyze_hook;
493-
planner_hook=prev_planner_hook;
494-
ExecutorStart_hook=prev_ExecutorStart;
495-
ExecutorRun_hook=prev_ExecutorRun;
496-
ExecutorFinish_hook=prev_ExecutorFinish;
497-
ExecutorEnd_hook=prev_ExecutorEnd;
498-
ProcessUtility_hook=prev_ProcessUtility;
499-
}
500-
501483
/*
502484
* shmem_startup hook: allocate or attach to shared memory,
503485
* then load any pre-existing statistics from file.

‎doc/src/sgml/xfunc.sgml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,28 +1978,16 @@ PG_MODULE_MAGIC;
19781978
<indexterm zone="xfunc-c-dynload">
19791979
<primary>_PG_init</primary>
19801980
</indexterm>
1981-
<indexterm zone="xfunc-c-dynload">
1982-
<primary>_PG_fini</primary>
1983-
</indexterm>
19841981
<indexterm zone="xfunc-c-dynload">
19851982
<primary>library initialization function</primary>
19861983
</indexterm>
1987-
<indexterm zone="xfunc-c-dynload">
1988-
<primary>library finalization function</primary>
1989-
</indexterm>
19901984

19911985
<para>
1992-
Optionally, a dynamically loaded file can containinitialization and
1993-
finalization functions. If the file includes a function named
1986+
Optionally, a dynamically loaded file can containan initialization
1987+
function. If the file includes a function named
19941988
<function>_PG_init</function>, that function will be called immediately after
19951989
loading the file. The function receives no parameters and should
1996-
return void. If the file includes a function named
1997-
<function>_PG_fini</function>, that function will be called immediately before
1998-
unloading the file. Likewise, the function receives no parameters and
1999-
should return void. Note that <function>_PG_fini</function> will only be called
2000-
during an unload of the file, not during process termination.
2001-
(Presently, unloads are disabled and will never occur, but this may
2002-
change in the future.)
1990+
return void. There is presently no way to unload a dynamically loaded file.
20031991
</para>
20041992

20051993
</sect2>

‎src/backend/postmaster/pgarch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ HandlePgArchInterrupts(void)
802802
* Ideally, we would simply unload the previous archive module and
803803
* load the new one, but there is presently no mechanism for
804804
* unloading a library (see the comment above
805-
*internal_unload_library()). To deal with this, we simply restart
805+
*internal_load_library()). To deal with this, we simply restart
806806
* the archiver. The new archive module will be loaded when the new
807807
* archiver process starts up.
808808
*/

‎src/backend/utils/fmgr/dfmgr.c

Lines changed: 6 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
#include"utils/hsearch.h"
3838

3939

40-
/*signatures for PostgreSQL-specific library init/fini functions */
40+
/*signature for PostgreSQL-specific library init function */
4141
typedefvoid (*PG_init_t) (void);
42-
typedefvoid (*PG_fini_t) (void);
4342

4443
/* hashtable entry for rendezvous variables */
4544
typedefstruct
@@ -79,7 +78,6 @@ char *Dynamic_library_path;
7978
staticvoid*internal_load_library(constchar*libname);
8079
staticvoidincompatible_module_error(constchar*libname,
8180
constPg_magic_struct*module_magic_data)pg_attribute_noreturn();
82-
staticvoidinternal_unload_library(constchar*libname);
8381
staticboolfile_exists(constchar*name);
8482
staticchar*expand_dynamic_library_name(constchar*name);
8583
staticvoidcheck_restricted_library_name(constchar*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
*/
183183
staticvoid*
184184
internal_load_library(constchar*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-
staticvoid
415-
internal_unload_library(constchar*libname)
416-
{
417-
#ifdefNOT_USED
418-
DynamicFileList*file_scanner,
419-
*prv,
420-
*nxt;
421-
structstatstat_buf;
422-
PG_fini_tPG_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-
468403
staticbool
469404
file_exists(constchar*name)
470405
{

‎src/backend/utils/fmgr/fmgr.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -582,20 +582,6 @@ record_C_func(HeapTuple procedureTuple,
582582
entry->inforec=inforec;
583583
}
584584

585-
/*
586-
* clear_external_function_hash: remove entries for a library being closed
587-
*
588-
* Presently we just zap the entire hash table, but later it might be worth
589-
* the effort to remove only the entries associated with the given handle.
590-
*/
591-
void
592-
clear_external_function_hash(void*filehandle)
593-
{
594-
if (CFuncHash)
595-
hash_destroy(CFuncHash);
596-
CFuncHash=NULL;
597-
}
598-
599585

600586
/*
601587
* Copy an FmgrInfo struct

‎src/include/fmgr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ extern bytea *OidSendFunctionCall(Oid functionId, Datum val);
705705
* Routines in fmgr.c
706706
*/
707707
externconstPg_finfo_record*fetch_finfo_record(void*filehandle,constchar*funcname);
708-
externvoidclear_external_function_hash(void*filehandle);
709708
externOidfmgr_internal_function(constchar*proname);
710709
externOidget_fn_expr_rettype(FmgrInfo*flinfo);
711710
externOidget_fn_expr_argtype(FmgrInfo*flinfo,intargnum);

‎src/pl/plpgsql/src/plpgsql.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,6 @@ typedef struct PLpgSQL_execstate
11001100
* variable "PLpgSQL_plugin" and set it to point to a PLpgSQL_plugin struct.
11011101
* Typically the struct could just be static data in the plugin library.
11021102
* We expect that a plugin would do this at library load time (_PG_init()).
1103-
* It must also be careful to set the rendezvous variable back to NULL
1104-
* if it is unloaded (_PG_fini()).
11051103
*
11061104
* This structure is basically a collection of function pointers --- at
11071105
* various interesting points in pl_exec.c, we call these functions

‎src/test/modules/delay_execution/delay_execution.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ static intpost_planning_lock_id = 0;
3636
/* Save previous planner hook user to be a good citizen */
3737
staticplanner_hook_typeprev_planner_hook=NULL;
3838

39-
/* Module load/unload functions */
39+
/* Module load function */
4040
void_PG_init(void);
41-
void_PG_fini(void);
4241

4342

4443
/* planner_hook function to provide the desired delay */
@@ -97,10 +96,3 @@ _PG_init(void)
9796
prev_planner_hook=planner_hook;
9897
planner_hook=delay_execution_planner;
9998
}
100-
101-
/* Module unload function (pro forma, not used currently) */
102-
void
103-
_PG_fini(void)
104-
{
105-
planner_hook=prev_planner_hook;
106-
}

‎src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
PG_MODULE_MAGIC;
2222

2323
void_PG_init(void);
24-
void_PG_fini(void);
2524

2625
staticchar*ssl_passphrase=NULL;
2726

@@ -55,12 +54,6 @@ _PG_init(void)
5554
openssl_tls_init_hook=set_rot13;
5655
}
5756

58-
void
59-
_PG_fini(void)
60-
{
61-
/* do nothing yet */
62-
}
63-
6457
staticvoid
6558
set_rot13(SSL_CTX*context,boolisServerStart)
6659
{

‎src/test/modules/test_oat_hooks/test_oat_hooks.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static bool REGRESS_userset_variable2 = false;
4343
staticboolREGRESS_suset_variable1= false;
4444
staticboolREGRESS_suset_variable2= false;
4545

46-
/* Saved hook valuesin case of unload*/
46+
/* Saved hook values */
4747
staticobject_access_hook_typenext_object_access_hook=NULL;
4848
staticobject_access_hook_type_strnext_object_access_hook_str=NULL;
4949
staticExecutorCheckPerms_hook_typenext_exec_check_perms_hook=NULL;
@@ -70,10 +70,9 @@ static char *accesstype_arg_to_string(ObjectAccessType access, void *arg);
7070

7171

7272
void_PG_init(void);
73-
void_PG_fini(void);
7473

7574
/*
76-
* Module load/unload callback
75+
* Module load callback
7776
*/
7877
void
7978
_PG_init(void)
@@ -231,23 +230,6 @@ _PG_init(void)
231230
ProcessUtility_hook=REGRESS_utility_command;
232231
}
233232

234-
void
235-
_PG_fini(void)
236-
{
237-
/* Unload hooks */
238-
if (object_access_hook==REGRESS_object_access_hook)
239-
object_access_hook=next_object_access_hook;
240-
241-
if (object_access_hook_str==REGRESS_object_access_hook_str)
242-
object_access_hook_str=next_object_access_hook_str;
243-
244-
if (ExecutorCheckPerms_hook==REGRESS_exec_check_perms)
245-
ExecutorCheckPerms_hook=next_exec_check_perms_hook;
246-
247-
if (ProcessUtility_hook==REGRESS_utility_command)
248-
ProcessUtility_hook=next_ProcessUtility_hook;
249-
}
250-
251233
staticvoid
252234
emit_audit_message(constchar*type,constchar*hook,char*action,char*objName)
253235
{

‎src/test/modules/test_rls_hooks/test_rls_hooks.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,17 @@
2929

3030
PG_MODULE_MAGIC;
3131

32-
/* Saved hook values in case of unload */
33-
staticrow_security_policy_hook_typeprev_row_security_policy_hook_permissive=NULL;
34-
staticrow_security_policy_hook_typeprev_row_security_policy_hook_restrictive=NULL;
35-
3632
void_PG_init(void);
37-
void_PG_fini(void);
3833

3934
/* Install hooks */
4035
void
4136
_PG_init(void)
4237
{
43-
/* Save values for unload */
44-
prev_row_security_policy_hook_permissive=row_security_policy_hook_permissive;
45-
prev_row_security_policy_hook_restrictive=row_security_policy_hook_restrictive;
46-
4738
/* Set our hooks */
4839
row_security_policy_hook_permissive=test_rls_hooks_permissive;
4940
row_security_policy_hook_restrictive=test_rls_hooks_restrictive;
5041
}
5142

52-
/* Uninstall hooks */
53-
void
54-
_PG_fini(void)
55-
{
56-
row_security_policy_hook_permissive=prev_row_security_policy_hook_permissive;
57-
row_security_policy_hook_restrictive=prev_row_security_policy_hook_restrictive;
58-
}
59-
6043
/*
6144
* Return permissive policies to be added
6245
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp