Event triggers in PostgreSQL 11

Based on documentation and several different examples on web I created this code for event triggers for PG 11. Maybe it can be useful for someone else too: — auditing table — CREATE TABLE IF NOT EXISTS public.ddl_history (ddl_date TIMESTAMP, ddl_tag TEXT,...

Show source code of trigger function

Because I found with surprise that DataGrip shows irregular version of trigger function’s source code and pgAdmin 4 somehow refuses to show it at all (claiming internal server error) I had to find some other way how to access it. Solution is described here...

Triggers – some useful queries

show parent tables with trigger names: select inhparent, inhparent::regclass, count(*) as _count, (select string_agg(tgname,',') from pg_trigger t where t.tgrelid=i.inhparent ) as triggers from pg_inherits i group by 1 order by 1; show tables with user created...

Event triggers in PostgreSQL 9.3 / 9.4

Well in versions 9.3 and 9.4 event triggers are something like “very good start”. You can use them quite well but it is not exactly 100% comfortable. How to use them: Create function which returns “event_trigger”. Function will end with just...