mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Add hooks for session start and session end, take two
These hooks can be used in loadable modules. A simple test module is included. The first attempt was done withcd8ce3a
but we lacked handling for NO_INSTALLCHECK in the MSVC scripts (problem solved afterwards by431f1599
) so the buildfarm got angry. This also fixes a couple of issues noticed upon review compared to the first attempt, so the code has slightly changed, resulting in a more simple test module. Author: Fabrízio de Royes Mello, Yugo Nagata Reviewed-by: Andrew Dunstan, Michael Paquier, Aleksandr Parfenov Discussion: https://postgr.es/m/20170720204733.40f2b7eb.nagata@sraoss.co.jp Discussion: https://postgr.es/m/20190823042602.GB5275@paquier.xyz
This commit is contained in:
@ -78,6 +78,8 @@ static bool ThereIsAtLeastOneRole(void);
|
||||
static void process_startup_options(Port *port, bool am_superuser);
|
||||
static void process_settings(Oid databaseid, Oid roleid);
|
||||
|
||||
/* Hook for plugins to get control at end of session */
|
||||
session_end_hook_type session_end_hook = NULL;
|
||||
|
||||
/*** InitPostgres support ***/
|
||||
|
||||
@ -1195,6 +1197,10 @@ ShutdownPostgres(int code, Datum arg)
|
||||
* them explicitly.
|
||||
*/
|
||||
LockReleaseAll(USER_LOCKMETHOD, true);
|
||||
|
||||
/* Hook at session end */
|
||||
if (session_end_hook)
|
||||
(*session_end_hook) ();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user