create or replace function on_ddl_event() returns event_trigger language plpgsql as $$ begin perform pg_notify('ddl_events', format('{"tg_tag":"%s","statement_timestamp":"%s"}', tg_tag, statement_timestamp())); return; end $$; create event trigger on_sql_drop on sql_drop execute procedure on_ddl_event(); create event trigger on_ddl_command_end on ddl_command_end execute procedure on_ddl_event();
It might send a NOTIFY like this:
Asynchronous notification of 'ddl_events' received from backend pid 6940 Data: {"tg_tag":"ALTER TABLE","statement_timestamp":"2014-02-01 01:31:23.651-08"}
No comments:
Post a Comment