Event triggers are new in PostgreSQL 9.3, and the community is still working on various features in order to make them more useful. You can use these triggers for various purposes, including auditing DDL commands and making local customized policies regarding the execution of DDL commands in the database. Event triggers are disabled in single user mode.
Event triggers are created using the CREATE EVENT TRIGGER
command, and they execute a function that returns a special type called EVENT_TRIGGER
. There are three types of events that are currently supported: ddl_command_start
, ddl_command_end
, and sql_drop
. You can limit a trigger execution by a tag using a WHEN
clause, if you want to fire it for specific commands only.
Currently, there are two new variables available in the event trigger function called TG_TAG
and TG_EVENT
that provide information about the tag and the event of the trigger. Future releases of PostgreSQL will expose more variables that make it possible to audit complete...