pg_event_trigger

A system catalogue table storing information about event triggers

pg_event_trigger is a system catalogue table storing information about event triggers.

pg_event_trigger was added in PostgreSQL 9.3 (commit 3855968f).

psql command

\dy lists available event triggers.

Definition by PostgreSQL version

pg_event_trigger (PostgreSQL 13)

         Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Collation | Nullable | Default
------------+--------+-----------+----------+---------
 oid        | oid    |           | not null |
 evtname    | name   |           | not null |
 evtevent   | name   |           | not null |
 evtowner   | oid    |           | not null |
 evtfoid    | oid    |           | not null |
 evtenabled | "char" |           | not null |
 evttags    | text[] | C         |          |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 12)

         Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Collation | Nullable | Default
------------+--------+-----------+----------+---------
 oid        | oid    |           | not null |
 evtname    | name   |           | not null |
 evtevent   | name   |           | not null |
 evtowner   | oid    |           | not null |
 evtfoid    | oid    |           | not null |
 evtenabled | "char" |           | not null |
 evttags    | text[] | C         |          |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 11)

         Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Collation | Nullable | Default
------------+--------+-----------+----------+---------
 evtname    | name   |           | not null |
 evtevent   | name   |           | not null |
 evtowner   | oid    |           | not null |
 evtfoid    | oid    |           | not null |
 evtenabled | "char" |           | not null |
 evttags    | text[] |           |          |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 10)

         Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Collation | Nullable | Default
------------+--------+-----------+----------+---------
 evtname    | name   |           | not null |
 evtevent   | name   |           | not null |
 evtowner   | oid    |           | not null |
 evtfoid    | oid    |           | not null |
 evtenabled | "char" |           | not null |
 evttags    | text[] |           |          |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 9.6)

Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Modifiers
------------+--------+-----------
 evtname    | name   | not null
 evtevent   | name   | not null
 evtowner   | oid    | not null
 evtfoid    | oid    | not null
 evtenabled | "char" | not null
 evttags    | text[] |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 9.5)

Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Modifiers
------------+--------+-----------
 evtname    | name   | not null
 evtevent   | name   | not null
 evtowner   | oid    | not null
 evtfoid    | oid    | not null
 evtenabled | "char" | not null
 evttags    | text[] |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 9.4)

Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Modifiers
------------+--------+-----------
 evtname    | name   | not null
 evtevent   | name   | not null
 evtowner   | oid    | not null
 evtfoid    | oid    | not null
 evtenabled | "char" | not null
 evttags    | text[] |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

pg_event_trigger (PostgreSQL 9.3)

Table "pg_catalog.pg_event_trigger"
   Column   |  Type  | Modifiers
------------+--------+-----------
 evtname    | name   | not null
 evtevent   | name   | not null
 evtowner   | oid    | not null
 evtfoid    | oid    | not null
 evtenabled | "char" | not null
 evttags    | text[] |
Indexes:
    "pg_event_trigger_evtname_index" UNIQUE, btree (evtname)
    "pg_event_trigger_oid_index" UNIQUE, btree (oid)
    

Documentation: pg_event_trigger

Change history

This table has not been modified since it was added.

Examples

Using the following (contrived) example, which creates an event trigger preventing any object named foo from being dropped:

CREATE OR REPLACE FUNCTION do_not_drop_foo()
  RETURNS event_trigger
 LANGUAGE plpgsql
  AS $$
BEGIN
  PERFORM * FROM pg_catalog.pg_event_trigger_dropped_objects() WHERE object_name = 'foo';
  IF FOUND THEN
    RAISE EXCEPTION 'objects named ''foo'' may not be dropped';
  END IF;
END;
$$;

CREATE EVENT TRIGGER prevent_foo_drop ON sql_drop
   EXECUTE FUNCTION do_not_drop_foo();

pg_event_trigger is populated as follows:

postgres=# SELECT * FROM pg_event_trigger ;
  oid  |     evtname      | evtevent | evtowner | evtfoid | evtenabled | evttags 
-------+------------------+----------+----------+---------+------------+---------
 16463 | prevent_foo_drop | sql_drop |       10 |   16455 | O          | 
(1 row)

postgres=# \dy
                          List of event triggers
       Name       |  Event   |  Owner   | Enabled |    Function     | Tags 
------------------+----------+----------+---------+-----------------+------
 prevent_foo_drop | sql_drop | postgres | enabled | do_not_drop_foo | 
(1 row)

Categories

DDL, System catalogue, Trigger

See also

event trigger, CREATE EVENT TRIGGER