This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the
currentversion, or one of the other supported versions listed above instead.
CREATE EVENT TRIGGER NameCREATE EVENT TRIGGER -- define a new event trigger
SynopsisCREATE EVENT TRIGGER name ON event [ WHEN filter_variable IN (filter_value [, ... ]) [ AND ... ] ] EXECUTE PROCEDURE function_name()Description
CREATE EVENT TRIGGER creates a new event trigger. Whenever the designated event occurs and the WHEN condition associated with the trigger, if any, is satisfied, the trigger function will be executed. For a general introduction to event triggers, see Chapter 37. The user who creates an event trigger becomes its owner.
ParametersThe name to give the new trigger. This name must be unique within the database.
The name of the event that triggers a call to the given function. See Section 37.1 for more information on event names.
The name of a variable used to filter events. This makes it possible to restrict the firing of the trigger to a subset of the cases in which it is supported. Currently the only supported filter_variable is TAG.
A list of values for the associated filter_variable for which the trigger should fire. For TAG, this means a list of command tags (e.g. 'DROP FUNCTION').
A user-supplied function that is declared as taking no argument and returning type event_trigger.
Only superusers can create event triggers.
Event triggers are disabled in single-user mode (see postgres). If an erroneous event trigger disables the database so much that you can't even drop the trigger, restart in single-user mode and you'll be able to do that.
ExamplesForbid the execution of any DDL command:
CREATE OR REPLACE FUNCTION abort_any_command() RETURNS event_trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'command % is disabled', tg_tag; END; $$; CREATE EVENT TRIGGER abort_ddl ON ddl_command_start EXECUTE PROCEDURE abort_any_command();Compatibility
There is no CREATE EVENT TRIGGER statement in the SQL standard.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4