Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
plperl-event-triggers.html28 linesDownload Raw Back to html
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>45.7. PL/Perl Event Triggers</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="plperl-triggers.html" title="45.6. PL/Perl Triggers" /><link rel="next" href="plperl-under-the-hood.html" title="45.8. PL/Perl Under the Hood" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">45.7. PL/Perl Event Triggers</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="plperl-triggers.html" title="45.6. PL/Perl Triggers">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="plperl.html" title="Chapter 45. PL/Perl — Perl Procedural Language">Up</a></td><th width="60%" align="center">Chapter 45. PL/Perl — Perl Procedural Language</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="plperl-under-the-hood.html" title="45.8. PL/Perl Under the Hood">Next</a></td></tr></table><hr /></div><div class="sect1" id="PLPERL-EVENT-TRIGGERS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">45.7. PL/Perl Event Triggers <a href="#PLPERL-EVENT-TRIGGERS" class="id_link">#</a></h2></div></div></div><p>3   PL/Perl can be used to write event trigger functions.  In an event trigger4   function, the hash reference <code class="varname">$_TD</code> contains information5   about the current trigger event.  <code class="varname">$_TD</code> is a global variable,6   which gets a separate local value for each invocation of the trigger.  The7   fields of the <code class="varname">$_TD</code> hash reference are:8 9   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">$_TD-&gt;{event}</code></span></dt><dd><p>10       The name of the event the trigger is fired for.11      </p></dd><dt><span class="term"><code class="literal">$_TD-&gt;{tag}</code></span></dt><dd><p>12       The command tag for which the trigger is fired.13      </p></dd></dl></div><p>14  </p><p>15   The return value of the trigger function is ignored.16  </p><p>17   Here is an example of an event trigger function, illustrating some of the18   above:19</p><pre class="programlisting">20CREATE OR REPLACE FUNCTION perlsnitch() RETURNS event_trigger AS $$21  elog(NOTICE, "perlsnitch: " . $_TD-&gt;{event} . " " . $_TD-&gt;{tag} . " ");22$$ LANGUAGE plperl;23 24CREATE EVENT TRIGGER perl_a_snitch25    ON ddl_command_start26    EXECUTE FUNCTION perlsnitch();27</pre><p>28  </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="plperl-triggers.html" title="45.6. PL/Perl Triggers">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="plperl.html" title="Chapter 45. PL/Perl — Perl Procedural Language">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="plperl-under-the-hood.html" title="45.8. PL/Perl Under the Hood">Next</a></td></tr><tr><td width="40%" align="left" valign="top">45.6. PL/Perl Triggers </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"> 45.8. PL/Perl Under the Hood</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai