]> begriffs open source - ai-pg/blob - full-docs/txt/pltcl-event-trigger.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / pltcl-event-trigger.txt
1
2 42.7. Event Trigger Functions in PL/Tcl #
3
4    Event trigger functions can be written in PL/Tcl. PostgreSQL requires
5    that a function that is to be called as an event trigger must be
6    declared as a function with no arguments and a return type of
7    event_trigger.
8
9    The information from the trigger manager is passed to the function body
10    in the following variables:
11
12    $TG_event
13           The name of the event the trigger is fired for.
14
15    $TG_tag
16           The command tag for which the trigger is fired.
17
18    The return value of the trigger function is ignored.
19
20    Here's a little example event trigger function that simply raises a
21    NOTICE message each time a supported command is executed:
22 CREATE OR REPLACE FUNCTION tclsnitch() RETURNS event_trigger AS $$
23   elog NOTICE "tclsnitch: $TG_event $TG_tag"
24 $$ LANGUAGE pltcl;
25
26 CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE FUNCTION tclsnitc
27 h();