diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:19:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:19:15 +0000 |
commit | 6eb9c5a5657d1fe77b55cc261450f3538d35a94d (patch) | |
tree | 657d8194422a5daccecfd42d654b8a245ef7b4c8 /doc/src/sgml/html/event-trigger-interface.html | |
parent | Initial commit. (diff) | |
download | postgresql-13-upstream.tar.xz postgresql-13-upstream.zip |
Adding upstream version 13.4.upstream/13.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | doc/src/sgml/html/event-trigger-interface.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/doc/src/sgml/html/event-trigger-interface.html b/doc/src/sgml/html/event-trigger-interface.html new file mode 100644 index 0000000..7478a95 --- /dev/null +++ b/doc/src/sgml/html/event-trigger-interface.html @@ -0,0 +1,68 @@ +<?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>39.3. Writing Event Trigger Functions in C</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 V1.79.1" /><link rel="prev" href="event-trigger-matrix.html" title="39.2. Event Trigger Firing Matrix" /><link rel="next" href="event-trigger-example.html" title="39.4. A Complete Event Trigger Example" /></head><body id="docContent" class="container-fluid col-10"><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">39.3. Writing Event Trigger Functions in C</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="event-trigger-matrix.html" title="39.2. Event Trigger Firing Matrix">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="event-triggers.html" title="Chapter 39. Event Triggers">Up</a></td><th width="60%" align="center">Chapter 39. Event Triggers</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 13.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="event-trigger-example.html" title="39.4. A Complete Event Trigger Example">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="EVENT-TRIGGER-INTERFACE"><div class="titlepage"><div><div><h2 class="title" style="clear: both">39.3. Writing Event Trigger Functions in C</h2></div></div></div><a id="id-1.8.5.7.2" class="indexterm"></a><p> + This section describes the low-level details of the interface to an + event trigger function. This information is only needed when writing + event trigger functions in C. If you are using a higher-level language + then these details are handled for you. In most cases you should + consider using a procedural language before writing your event triggers + in C. The documentation of each procedural language explains how to + write an event trigger in that language. + </p><p> + Event trigger functions must use the <span class="quote">“<span class="quote">version 1</span>”</span> function + manager interface. + </p><p> + When a function is called by the event trigger manager, it is not passed + any normal arguments, but it is passed a <span class="quote">“<span class="quote">context</span>”</span> pointer + pointing to a <code class="structname">EventTriggerData</code> structure. C functions can + check whether they were called from the event trigger manager or not by + executing the macro: +</p><pre class="programlisting"> +CALLED_AS_EVENT_TRIGGER(fcinfo) +</pre><p> + which expands to: +</p><pre class="programlisting"> +((fcinfo)->context != NULL && IsA((fcinfo)->context, EventTriggerData)) +</pre><p> + If this returns true, then it is safe to cast + <code class="literal">fcinfo->context</code> to type <code class="literal">EventTriggerData + *</code> and make use of the pointed-to + <code class="structname">EventTriggerData</code> structure. The function must + <span class="emphasis"><em>not</em></span> alter the <code class="structname">EventTriggerData</code> + structure or any of the data it points to. + </p><p> + <code class="structname">struct EventTriggerData</code> is defined in + <code class="filename">commands/event_trigger.h</code>: + +</p><pre class="programlisting"> +typedef struct EventTriggerData +{ + NodeTag type; + const char *event; /* event name */ + Node *parsetree; /* parse tree */ + CommandTag tag; /* command tag */ +} EventTriggerData; +</pre><p> + + where the members are defined as follows: + + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="structfield">type</code></span></dt><dd><p> + Always <code class="literal">T_EventTriggerData</code>. + </p></dd><dt><span class="term"><code class="structfield">event</code></span></dt><dd><p> + Describes the event for which the function is called, one of + <code class="literal">"ddl_command_start"</code>, <code class="literal">"ddl_command_end"</code>, + <code class="literal">"sql_drop"</code>, <code class="literal">"table_rewrite"</code>. + See <a class="xref" href="event-trigger-definition.html" title="39.1. Overview of Event Trigger Behavior">Section 39.1</a> for the meaning of these + events. + </p></dd><dt><span class="term"><code class="structfield">parsetree</code></span></dt><dd><p> + A pointer to the parse tree of the command. Check the PostgreSQL + source code for details. The parse tree structure is subject to change + without notice. + </p></dd><dt><span class="term"><code class="structfield">tag</code></span></dt><dd><p> + The command tag associated with the event for which the event trigger + is run, for example <code class="literal">"CREATE FUNCTION"</code>. + </p></dd></dl></div><p> + </p><p> + An event trigger function must return a <code class="symbol">NULL</code> pointer + (<span class="emphasis"><em>not</em></span> an SQL null value, that is, do not + set <em class="parameter"><code>isNull</code></em> true). + </p></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="event-trigger-matrix.html" title="39.2. Event Trigger Firing Matrix">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="event-triggers.html" title="Chapter 39. Event Triggers">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="event-trigger-example.html" title="39.4. A Complete Event Trigger Example">Next</a></td></tr><tr><td width="40%" align="left" valign="top">39.2. Event Trigger Firing Matrix </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 13.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 39.4. A Complete Event Trigger Example</td></tr></table></div></body></html>
\ No newline at end of file |