gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
3.5KB

  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>44.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 V1.79.1" /><link rel="prev" href="plperl-triggers.html" title="44.6. PL/Perl Triggers" /><link rel="next" href="plperl-under-the-hood.html" title="44.8. PL/Perl Under the Hood" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">44.7. PL/Perl Event Triggers</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="plperl-triggers.html" title="44.6. PL/Perl Triggers">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="plperl.html" title="Chapter 44. PL/Perl - Perl Procedural Language">Up</a></td><th width="60%" align="center">Chapter 44. PL/Perl - Perl Procedural Language</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="plperl-under-the-hood.html" title="44.8. PL/Perl Under the Hood">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PLPERL-EVENT-TRIGGERS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">44.7. PL/Perl Event Triggers</h2></div></div></div><p>
  3. PL/Perl can be used to write event trigger functions. In an event trigger
  4. function, the hash reference <code class="varname">$_TD</code> contains information
  5. 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. The
  7. fields of the <code class="varname">$_TD</code> hash reference are:
  8. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">$_TD-&gt;{event}</code></span></dt><dd><p>
  9. The name of the event the trigger is fired for.
  10. </p></dd><dt><span class="term"><code class="literal">$_TD-&gt;{tag}</code></span></dt><dd><p>
  11. The command tag for which the trigger is fired.
  12. </p></dd></dl></div><p>
  13. </p><p>
  14. The return value of the trigger function is ignored.
  15. </p><p>
  16. Here is an example of an event trigger function, illustrating some of the
  17. above:
  18. </p><pre class="programlisting">
  19. CREATE OR REPLACE FUNCTION perlsnitch() RETURNS event_trigger AS $$
  20. elog(NOTICE, "perlsnitch: " . $_TD-&gt;{event} . " " . $_TD-&gt;{tag} . " ");
  21. $$ LANGUAGE plperl;
  22. CREATE EVENT TRIGGER perl_a_snitch
  23. ON ddl_command_start
  24. EXECUTE FUNCTION perlsnitch();
  25. </pre><p>
  26. </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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="plperl.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="plperl-under-the-hood.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">44.6. PL/Perl Triggers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 44.8. PL/Perl Under the Hood</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1