public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alexander Korotkov <[email protected]>
To: [email protected]
Subject: pgsql: Add support event triggers on authenticated login
Date: Mon, 16 Oct 2023 00:18:33 +0000
Message-ID: <[email protected]> (raw)
Add support event triggers on authenticated login
This commit introduces trigger on login event, allowing to fire some actions
right on the user connection. This can be useful for logging or connection
check purposes as well as for some personalization of environment. Usage
details are described in the documentation included, but shortly usage is
the same as for other triggers: create function returning event_trigger and
then create event trigger on login event.
In order to prevent the connection time overhead when there are no triggers
the commit introduces pg_database.dathasloginevt flag, which indicates database
has active login triggers. This flag is set by CREATE/ALTER EVENT TRIGGER
command, and unset at connection time when no active triggers found.
Author: Konstantin Knizhnik, Mikhail Gribkov
Discussion: https://postgr.es/m/0d46d29f-4558-3af9-9c85-7774e14a7709%40postgrespro.ru
Reviewed-by: Pavel Stehule, Takayuki Tsunakawa, Greg Nancarrow, Ivan Panchenko
Reviewed-by: Daniel Gustafsson, Teodor Sigaev, Robert Haas, Andres Freund
Reviewed-by: Tom Lane, Andrey Sokolov, Zhihong Yu, Sergey Shinderuk
Reviewed-by: Gregory Stark, Nikita Malakhov, Ted Yu
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/e83d1b0c40ccda8955f1245087f0697652c4df86
Modified Files
--------------
doc/src/sgml/bki.sgml | 2 +-
doc/src/sgml/catalogs.sgml | 13 ++
doc/src/sgml/ecpg.sgml | 2 +
doc/src/sgml/event-trigger.sgml | 94 ++++++++++++
src/backend/commands/dbcommands.c | 17 ++-
src/backend/commands/event_trigger.c | 179 +++++++++++++++++++++--
src/backend/storage/lmgr/lmgr.c | 38 +++++
src/backend/tcop/postgres.c | 4 +
src/backend/utils/cache/evtcache.c | 2 +
src/backend/utils/init/globals.c | 2 +
src/backend/utils/init/postinit.c | 1 +
src/bin/pg_dump/pg_dump.c | 5 +
src/bin/psql/tab-complete.c | 4 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_database.dat | 2 +-
src/include/catalog/pg_database.h | 3 +
src/include/commands/event_trigger.h | 1 +
src/include/miscadmin.h | 2 +
src/include/storage/lmgr.h | 2 +
src/include/tcop/cmdtaglist.h | 1 +
src/include/utils/evtcache.h | 3 +-
src/test/authentication/t/005_login_trigger.pl | 189 +++++++++++++++++++++++++
src/test/recovery/t/001_stream_rep.pl | 26 ++++
src/test/regress/expected/event_trigger.out | 45 ++++++
src/test/regress/sql/event_trigger.sql | 26 ++++
25 files changed, 644 insertions(+), 21 deletions(-)
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: pgsql: Add support event triggers on authenticated login
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox