Re: New feature proposal (trigger) - Mailing list pgsql-hackers

From Christoph Moench-Tegeder
Subject Re: New feature proposal (trigger)
Date
Msg-id 20200124092937.GA2495@elch.exwg.net
Whole thread Raw
In response to RE: New feature proposal (trigger)  (Sergiu Velescu <Sergiu.Velescu@endava.com>)
List pgsql-hackers
## Sergiu Velescu (Sergiu.Velescu@endava.com):

> OnLogin/Logout.
> I want to log/audit each attempt to login (successful and/or not).

log_connections/log_disconnections

> Who/how long was logged in DB (who logged in out of business hours
> (maybe deny access)).

Use PAM authentication.

> Set session variable based on username (or maybe IP address)  -
> for example DATE format.

"Based on user name": ALTER ROLE

> OnStartup (or AfterStarted)
> I want to start a procedure which check for a specific event in a loop
> and send an email.

That sounds like "problematic architecture" right from the start:
- sending emails in a database transaction is not a good idea
- active-waiting for events ("in a loop") is inefficient, try writing
  to a queue table and have a daemon read from that.

> OnDDL
> Log every DDL in a DB log table (who/when altered/created/dropped/
> truncated a specific object) and send an email.

Event Triggers
https://www.postgresql.org/docs/current/event-triggers.html

> Duplicate WAL (to have WAL in 2 different places – for example I take
> backup on separate disk and I want to have a copy of WAL on that disk)

We have streaming replication/pg_receivewal or file based archiving,
both also wrapped in practical products like barman, pgbackrest, ...

Regards,
Christoph

-- 
Spare Space



pgsql-hackers by date:

Previous
From: Hamid Akhtar
Date:
Subject: Re: BUG #16171: Potential malformed JSON in explain output
Next
From: Konstantin Knizhnik
Date:
Subject: Re: [Proposal] Global temporary tables