From e788bd924c19e296bd34316e30e3ba1b68354e64 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 1 Oct 2019 12:15:25 +0900 Subject: Add hooks for session start and session end, take two MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These hooks can be used in loadable modules. A simple test module is included. The first attempt was done with cd8ce3a but we lacked handling for NO_INSTALLCHECK in the MSVC scripts (problem solved afterwards by 431f1599) 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 --- .../test_session_hooks/sql/test_session_hooks.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/modules/test_session_hooks/sql/test_session_hooks.sql (limited to 'src/test/modules/test_session_hooks/sql') diff --git a/src/test/modules/test_session_hooks/sql/test_session_hooks.sql b/src/test/modules/test_session_hooks/sql/test_session_hooks.sql new file mode 100644 index 00000000000..1cc06f613bc --- /dev/null +++ b/src/test/modules/test_session_hooks/sql/test_session_hooks.sql @@ -0,0 +1,19 @@ +-- +-- Tests for start and end session hooks +-- + +-- Only activity from role regress_sess_hook_usr2 is logged. +CREATE ROLE regress_sess_hook_usr1 SUPERUSER LOGIN; +CREATE ROLE regress_sess_hook_usr2 SUPERUSER LOGIN; +\set prevdb :DBNAME +\set prevusr :USER +CREATE TABLE session_hook_log(id SERIAL, dbname TEXT, username TEXT, hook_at TEXT); +SELECT * FROM session_hook_log ORDER BY id; +\c :prevdb regress_sess_hook_usr1 +SELECT * FROM session_hook_log ORDER BY id; +\c :prevdb regress_sess_hook_usr2 +SELECT * FROM session_hook_log ORDER BY id; +\c :prevdb :prevusr +SELECT * FROM session_hook_log ORDER BY id; +DROP ROLE regress_sess_hook_usr1; +DROP ROLE regress_sess_hook_usr2; -- cgit v1.2.3