mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Add hooks for session start and session end
These hooks can be used in loadable modules. A simple test module is included. Discussion: https://postgr.es/m/20170720204733.40f2b7eb.nagata@sraoss.co.jp Fabrízio de Royes Mello and Yugo Nagata Reviewed by Michael Paquier and Aleksandr Parfenov
This commit is contained in:
@ -169,6 +169,9 @@ static ProcSignalReason RecoveryConflictReason;
|
||||
static MemoryContext row_description_context = NULL;
|
||||
static StringInfoData row_description_buf;
|
||||
|
||||
/* Hook for plugins to get control at start of session */
|
||||
session_start_hook_type session_start_hook = NULL;
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* decls for routines only used in this file
|
||||
* ----------------------------------------------------------------
|
||||
@ -3857,6 +3860,9 @@ PostgresMain(int argc, char *argv[],
|
||||
if (!IsUnderPostmaster)
|
||||
PgStartTime = GetCurrentTimestamp();
|
||||
|
||||
if (session_start_hook)
|
||||
(*session_start_hook) ();
|
||||
|
||||
/*
|
||||
* POSTGRES main processing loop begins here
|
||||
*
|
||||
|
@ -76,6 +76,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 ***/
|
||||
|
||||
@ -1154,6 +1156,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