codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!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 16.3 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> <a href="#CATALOG-PG-TRIGGER" class="id_link">#</a></h2></div></div></div><a id="id-1.10.4.60.2" class="indexterm"></a><p>3 The catalog <code class="structname">pg_trigger</code> stores triggers on tables4 and views.5 See <a class="xref" href="sql-createtrigger.html" title="CREATE TRIGGER"><span class="refentrytitle">CREATE TRIGGER</span></a>6 for more information.7 </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">8 Column Type9 </p>10 <p>11 Description12 </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">13 <code class="structfield">oid</code> <code class="type">oid</code>14 </p>15 <p>16 Row identifier17 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">18 <code class="structfield">tgrelid</code> <code class="type">oid</code>19 (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>)20 </p>21 <p>22 The table this trigger is on23 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">24 <code class="structfield">tgparentid</code> <code class="type">oid</code>25 (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>)26 </p>27 <p>28 Parent trigger that this trigger is cloned from (this happens when29 partitions are created or attached to a partitioned table);30 zero if not a clone31 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">32 <code class="structfield">tgname</code> <code class="type">name</code>33 </p>34 <p>35 Trigger name (must be unique among triggers of same table)36 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">37 <code class="structfield">tgfoid</code> <code class="type">oid</code>38 (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>)39 </p>40 <p>41 The function to be called42 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">43 <code class="structfield">tgtype</code> <code class="type">int2</code>44 </p>45 <p>46 Bit mask identifying trigger firing conditions47 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">48 <code class="structfield">tgenabled</code> <code class="type">char</code>49 </p>50 <p>51 Controls in which <a class="xref" href="runtime-config-client.html#GUC-SESSION-REPLICATION-ROLE">session_replication_role</a> modes52 the trigger fires.53 <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,54 <code class="literal">D</code> = trigger is disabled,55 <code class="literal">R</code> = trigger fires in <span class="quote">“<span class="quote">replica</span>”</span> mode,56 <code class="literal">A</code> = trigger fires always.57 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">58 <code class="structfield">tgisinternal</code> <code class="type">bool</code>59 </p>60 <p>61 True if trigger is internally generated (usually, to enforce62 the constraint identified by <code class="structfield">tgconstraint</code>)63 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">64 <code class="structfield">tgconstrrelid</code> <code class="type">oid</code>65 (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>)66 </p>67 <p>68 The table referenced by a referential integrity constraint69 (zero if trigger is not for a referential integrity constraint)70 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">71 <code class="structfield">tgconstrindid</code> <code class="type">oid</code>72 (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>)73 </p>74 <p>75 The index supporting a unique, primary key, referential integrity,76 or exclusion constraint77 (zero if trigger is not for one of these types of constraint)78 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">79 <code class="structfield">tgconstraint</code> <code class="type">oid</code>80 (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>)81 </p>82 <p>83 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 trigger84 (zero if trigger is not for a constraint)85 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">86 <code class="structfield">tgdeferrable</code> <code class="type">bool</code>87 </p>88 <p>89 True if constraint trigger is deferrable90 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">91 <code class="structfield">tginitdeferred</code> <code class="type">bool</code>92 </p>93 <p>94 True if constraint trigger is initially deferred95 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">96 <code class="structfield">tgnargs</code> <code class="type">int2</code>97 </p>98 <p>99 Number of argument strings passed to trigger function100 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">101 <code class="structfield">tgattr</code> <code class="type">int2vector</code>102 (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>)103 </p>104 <p>105 Column numbers, if trigger is column-specific; otherwise an106 empty array107 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">108 <code class="structfield">tgargs</code> <code class="type">bytea</code>109 </p>110 <p>111 Argument strings to pass to trigger, each NULL-terminated112 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">113 <code class="structfield">tgqual</code> <code class="type">pg_node_tree</code>114 </p>115 <p>116 Expression tree (in <code class="function">nodeToString()</code>117 representation) for the trigger's <code class="literal">WHEN</code> condition, or null118 if none119 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">120 <code class="structfield">tgoldtable</code> <code class="type">name</code>121 </p>122 <p>123 <code class="literal">REFERENCING</code> clause name for <code class="literal">OLD TABLE</code>,124 or null if none125 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">126 <code class="structfield">tgnewtable</code> <code class="type">name</code>127 </p>128 <p>129 <code class="literal">REFERENCING</code> clause name for <code class="literal">NEW TABLE</code>,130 or null if none131 </p></td></tr></tbody></table></div></div><br class="table-break" /><p>132 Currently, column-specific triggering is supported only for133 <code class="literal">UPDATE</code> events, and so <code class="structfield">tgattr</code> is relevant134 only for that event type. <code class="structfield">tgtype</code> might135 contain bits for other event types as well, but those are presumed136 to be table-wide regardless of what is in <code class="structfield">tgattr</code>.137 </p><div class="note"><h3 class="title">Note</h3><p>138 When <code class="structfield">tgconstraint</code> is nonzero,139 <code class="structfield">tgconstrrelid</code>, <code class="structfield">tgconstrindid</code>,140 <code class="structfield">tgdeferrable</code>, and <code class="structfield">tginitdeferred</code> are141 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.142 However, it is possible for a non-deferrable trigger to be associated143 with a deferrable constraint: foreign key constraints can have some144 deferrable and some non-deferrable triggers.145 </p></div><div class="note"><h3 class="title">Note</h3><p>146 <code class="literal">pg_class.relhastriggers</code>147 must be true if a relation has any triggers in this catalog.148 </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 16.3 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>