バージョンごとのドキュメント一覧

45.7. PL/Perlイベントトリガ #

<title>PL/Perl Event Triggers</title>

PL/Perl can be used to write event trigger functions. In an event trigger function, the hash reference <varname>$_TD</varname> contains information about the current trigger event. <varname>$_TD</varname> is a global variable, which gets a separate local value for each invocation of the trigger. The fields of the <varname>$_TD</varname> hash reference are: PL/Perlを使用してイベントトリガ関数を作成することができます。 イベントトリガ関数では、$_TDというハッシュへの参照に、現在のトリガイベントに関する情報が含まれています。 $_TDはグローバル変数であり、各トリガ呼び出しに対してローカルな値を別々に取り出します。 以下に$_TDというハッシュへの参照のフィールドを示します。

$_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 function 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 FUNCTION perlsnitch();