summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/catalog-pg-trigger.html
blob: e746521fb3fc4411f464352a64460d6d634999db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>53.58. pg_trigger</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="catalog-pg-transform.html" title="53.57. pg_transform" /><link rel="next" href="catalog-pg-ts-config.html" title="53.59. pg_ts_config" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">53.58. <code class="structname">pg_trigger</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-transform.html" title="53.57. pg_transform">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 53. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 53. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-ts-config.html" title="53.59. pg_ts_config">Next</a></td></tr></table><hr /></div><div class="sect1" id="CATALOG-PG-TRIGGER"><div class="titlepage"><div><div><h2 class="title" style="clear: both">53.58. <code class="structname">pg_trigger</code></h2></div></div></div><a id="id-1.10.4.60.2" class="indexterm"></a><p>
   The catalog <code class="structname">pg_trigger</code> stores triggers on tables
   and views.
   See <a class="xref" href="sql-createtrigger.html" title="CREATE TRIGGER"><span class="refentrytitle">CREATE TRIGGER</span></a>
   for more information.
  </p><div class="table" id="id-1.10.4.60.4"><p class="title"><strong>Table 53.58. <code class="structname">pg_trigger</code> Columns</strong></p><div class="table-contents"><table class="table" summary="pg_trigger Columns" border="1"><colgroup><col /></colgroup><thead><tr><th class="catalog_table_entry"><p class="column_definition">
       Column Type
      </p>
      <p>
       Description
      </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">oid</code> <code class="type">oid</code>
      </p>
      <p>
       Row identifier
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgrelid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-class.html" title="53.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The table this trigger is on
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgparentid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-trigger.html" title="53.58. pg_trigger"><code class="structname">pg_trigger</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       Parent trigger that this trigger is cloned from (this happens when
       partitions are created or attached to a partitioned table);
       zero if not a clone
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgname</code> <code class="type">name</code>
      </p>
      <p>
       Trigger name (must be unique among triggers of same table)
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgfoid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-proc.html" title="53.39. pg_proc"><code class="structname">pg_proc</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The function to be called
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgtype</code> <code class="type">int2</code>
      </p>
      <p>
       Bit mask identifying trigger firing conditions
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgenabled</code> <code class="type">char</code>
      </p>
      <p>
       Controls in which <a class="xref" href="runtime-config-client.html#GUC-SESSION-REPLICATION-ROLE">session_replication_role</a> modes
       the trigger fires.
       <code class="literal">O</code> = trigger fires in <span class="quote"><span class="quote">origin</span></span> and <span class="quote"><span class="quote">local</span></span> modes,
       <code class="literal">D</code> = trigger is disabled,
       <code class="literal">R</code> = trigger fires in <span class="quote"><span class="quote">replica</span></span> mode,
       <code class="literal">A</code> = trigger fires always.
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgisinternal</code> <code class="type">bool</code>
      </p>
      <p>
       True if trigger is internally generated (usually, to enforce
       the constraint identified by <code class="structfield">tgconstraint</code>)
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgconstrrelid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-class.html" title="53.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The table referenced by a referential integrity constraint
       (zero if trigger is not for a referential integrity constraint)
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgconstrindid</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-class.html" title="53.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The index supporting a unique, primary key, referential integrity,
       or exclusion constraint
       (zero if trigger is not for one of these types of constraint)
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgconstraint</code> <code class="type">oid</code>
       (references <a class="link" href="catalog-pg-constraint.html" title="53.13. pg_constraint"><code class="structname">pg_constraint</code></a>.<code class="structfield">oid</code>)
      </p>
      <p>
       The <a class="link" href="catalog-pg-constraint.html" title="53.13. pg_constraint"><code class="structname">pg_constraint</code></a> entry associated with the trigger
       (zero if trigger is not for a constraint)
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgdeferrable</code> <code class="type">bool</code>
      </p>
      <p>
       True if constraint trigger is deferrable
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tginitdeferred</code> <code class="type">bool</code>
      </p>
      <p>
       True if constraint trigger is initially deferred
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgnargs</code> <code class="type">int2</code>
      </p>
      <p>
       Number of argument strings passed to trigger function
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgattr</code> <code class="type">int2vector</code>
       (references <a class="link" href="catalog-pg-attribute.html" title="53.7. pg_attribute"><code class="structname">pg_attribute</code></a>.<code class="structfield">attnum</code>)
      </p>
      <p>
       Column numbers, if trigger is column-specific; otherwise an
       empty array
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgargs</code> <code class="type">bytea</code>
      </p>
      <p>
       Argument strings to pass to trigger, each NULL-terminated
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgqual</code> <code class="type">pg_node_tree</code>
      </p>
      <p>
       Expression tree (in <code class="function">nodeToString()</code>
       representation) for the trigger's <code class="literal">WHEN</code> condition, or null
       if none
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgoldtable</code> <code class="type">name</code>
      </p>
      <p>
       <code class="literal">REFERENCING</code> clause name for <code class="literal">OLD TABLE</code>,
       or null if none
      </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
       <code class="structfield">tgnewtable</code> <code class="type">name</code>
      </p>
      <p>
       <code class="literal">REFERENCING</code> clause name for <code class="literal">NEW TABLE</code>,
       or null if none
      </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
   Currently, column-specific triggering is supported only for
   <code class="literal">UPDATE</code> events, and so <code class="structfield">tgattr</code> is relevant
   only for that event type.  <code class="structfield">tgtype</code> might
   contain bits for other event types as well, but those are presumed
   to be table-wide regardless of what is in <code class="structfield">tgattr</code>.
  </p><div class="note"><h3 class="title">Note</h3><p>
    When <code class="structfield">tgconstraint</code> is nonzero,
    <code class="structfield">tgconstrrelid</code>, <code class="structfield">tgconstrindid</code>,
    <code class="structfield">tgdeferrable</code>, and <code class="structfield">tginitdeferred</code> are
    largely redundant with the referenced <a class="link" href="catalog-pg-constraint.html" title="53.13. pg_constraint"><code class="structname">pg_constraint</code></a> 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.
   </p></div><div class="note"><h3 class="title">Note</h3><p>
    <code class="literal">pg_class.relhastriggers</code>
    must be true if a relation has any triggers in this catalog.
   </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-transform.html" title="53.57. pg_transform">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 53. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-ts-config.html" title="53.59. pg_ts_config">Next</a></td></tr><tr><td width="40%" align="left" valign="top">53.57. <code class="structname">pg_transform</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 53.59. <code class="structname">pg_ts_config</code></td></tr></table></div></body></html>