From e5dc4cc24d2e1e94ac572a2c64103710bf15d21e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 11 Dec 2013 08:11:59 -0500 Subject: PL/Perl: Add event trigger support From: Dimitri Fontaine --- doc/src/sgml/plperl.sgml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml index 10eac0e243c..34663e475fe 100644 --- a/doc/src/sgml/plperl.sgml +++ b/doc/src/sgml/plperl.sgml @@ -1211,6 +1211,56 @@ CREATE TRIGGER test_valid_id_trig + + PL/Perl Event Triggers + + + PL/Perl can be used to write event trigger functions. In an event trigger + function, the hash reference $_TD contains information + about the current trigger event. $_TD is a global variable, + which gets a separate local value for each invocation of the trigger. The + fields of the $_TD hash reference are: + + + + $_TD->{event} + + + The name of the event the trigger is fired for. + + + + + + $_TD->{tag} + + + The command tag for which the trigger is fired. + + + + + + + + The return value of the trigger procedure is ignored. + + + + Here is an example of an event trigger function, illustrating some of the + above: + +CREATE OR REPLACE FUNCTION perlsnitch() RETURNS event_trigger AS $$ + elog(NOTICE, "perlsnitch: " . $_TD->{event} . " " . $_TD->{tag} . " "); +$$ LANGUAGE plperl; + +CREATE EVENT TRIGGER perl_a_snitch + ON ddl_command_start + EXECUTE PROCEDURE perlsnitch(); + + + + PL/Perl Under the Hood -- cgit v1.2.3