September 4, 2025: PostgreSQL 18 RC 1 Released!
DocumentationPostgreSQL devel (2025年09月20日 21:25:11 - git commit e1d917182c1)
Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: 18 / devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.
42.7. Event Trigger Functions in PL/Tcl
Prev Up Chapter 42. PL/Tcl — Tcl Procedural Language Home Next

42.7. Event Trigger Functions in PL/Tcl #

Event trigger functions can be written in PL/Tcl. PostgreSQL requires that a function 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 function 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 function is ignored.

Here's a little example event trigger function 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 FUNCTION tclsnitch();

Prev Up Next
42.6. Trigger Functions in PL/Tcl Home 42.8. Error Handling in PL/Tcl

AltStyle によって変換されたページ (->オリジナル) /