diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2017-11-15 10:16:34 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2017-11-15 10:16:34 -0500 |
commit | cd8ce3a22c0b48d32ffe6543837ba3bb647ac2b2 (patch) | |
tree | a6f39aee1d21d35a7f1902c7714777311687344b /src/backend/utils/init/postinit.c | |
parent | ebc189e12259cc28b9a09db000626fea1e2a3ffa (diff) | |
download | postgresql-cd8ce3a22c0b48d32ffe6543837ba3bb647ac2b2.tar.gz postgresql-cd8ce3a22c0b48d32ffe6543837ba3bb647ac2b2.zip |
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
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 20f1d279e9c..16ec376b221 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -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) (); } |