49.48. pg_trigger
The catalogpg_trigger
stores triggers on tables and views. SeeCREATE TRIGGER for more information.
Table 49.48. pg_trigger
Columns
Name | Type | References | Description |
---|---|---|---|
oid | oid | Row identifier (hidden attribute; must be explicitly selected) | |
tgrelid | oid |
| The table this trigger is on |
tgname | name | Trigger name (must be unique among triggers of same table) | |
tgfoid | oid |
| The function to be called |
tgtype | int2 | Bit mask identifying trigger firing conditions | |
tgenabled | char | Controls in whichsession_replication_role modes the trigger fires.O = trigger fires in“origin” and“local” modes,D = trigger is disabled,R = trigger fires in“replica” mode,A = trigger fires always. | |
tgisinternal | bool | True if trigger is internally generated (usually, to enforce the constraint identified bytgconstraint ) | |
tgconstrrelid | oid |
| The table referenced by a referential integrity constraint |
tgconstrindid | oid |
| The index supporting a unique, primary key, referential integrity, or exclusion constraint |
tgconstraint | oid |
| Thepg_constraint entry associated with the trigger, if any |
tgdeferrable | bool | True if constraint trigger is deferrable | |
tginitdeferred | bool | True if constraint trigger is initially deferred | |
tgnargs | int2 | Number of argument strings passed to trigger function | |
tgattr | int2vector |
| Column numbers, if trigger is column-specific; otherwise an empty array |
tgargs | bytea | Argument strings to pass to trigger, each NULL-terminated | |
tgqual | pg_node_tree | Expression tree (innodeToString() representation) for the trigger'sWHEN condition, or null if none |
Currently, column-specific triggering is supported only forUPDATE
events, and sotgattr
is relevant only for that event type.tgtype
might contain bits for other event types as well, but those are presumed to be table-wide regardless of what is intgattr
.
Note
Whentgconstraint
is nonzero,tgconstrrelid
,tgconstrindid
,tgdeferrable
, andtginitdeferred
are largely redundant with the referencedpg_constraint
entry. However, it is possible for a non-deferrable trigger to be associated with a deferrable constraint: foreign key constraints can have some deferrable and some non-deferrable triggers.
Note
pg_class.relhastriggers
must be true if a relation has any triggers in this catalog.