From a5036ca998a6058f60913d43a80badfcbb65f5bb Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 23 Nov 2013 21:32:00 -0500 Subject: PL/Tcl: Add event trigger support From: Dimitri Fontaine --- doc/src/sgml/pltcl.sgml | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml index 9f252e97cab..80400fad7b3 100644 --- a/doc/src/sgml/pltcl.sgml +++ b/doc/src/sgml/pltcl.sgml @@ -711,6 +711,65 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab + + Event Trigger Procedures in PL/Tcl + + + event trigger + in PL/Tcl + + + + Event trigger procedures can be written in PL/Tcl. + PostgreSQL requires that a procedure that is + to be called as an event trigger must be declared as a function with no + arguments and a return type of event_trigger. + + + The information from the trigger manager is passed to the procedure body + in the following variables: + + + + + $TG_event + + + The name of the event the trigger is fired for. + + + + + + $TG_tag + + + The command tag for which the trigger is fired. + + + + + + + + The return value of the trigger procedure is ignored. + + + + Here's a little example event trigger procedure that simply raises + a NOTICE message each time a supported command is + executed: + + +CREATE OR REPLACE FUNCTION tclsnitch() RETURNS event_trigger AS $$ + elog NOTICE "tclsnitch: $TG_event $TG_tag" +$$ LANGUAGE pltcl; + +CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE PROCEDURE tclsnitch(); + + + + Modules and the <function>unknown</> Command -- cgit v1.2.3