A Complete Event Trigger Example

Here is a very simple example of an event trigger function written in C.
(Examples of triggers written in procedural languages can be found in
the documentation of the procedural languages.)

The function noddl raises an exception each time it is called.
The event trigger definition associated the function with
the ddl_command_start event. The effect is that all DDL
commands (with the exceptions mentioned
in Section 38.1) are prevented from running.

In this situation, in order to be able to run some DDL commands when you
need to do so, you have to either drop the event trigger or disable it. It
can be convenient to disable the trigger for only the duration of a
transaction: