pg_listen

Name

pg_listen -- sets or changes a callback for asynchronous NOTIFY messages -- 非同期 NOTIFY メッセージ用のコールバックを設定または変更します。

Synopsis

pg_listen dbHandle notifyName callbackCommand

入力

dbHandle

Specifies a valid database handle.

有効なデータベースハンドルを指定します。

notifyName

Specifies the notify condition name to start or stop listening to.

通知監視状態を開始するまたは停止する通知条件名を指定します。

callbackCommand

If present and not empty, provides the command string to execute when a matching notification arrives.

存在し、空でない場合、条件にあった通知メッセージが届いた時に実行する コマンド文字列を提供します。

出力

なし。

説明

pg_listen creates, changes, or cancels a request to listen for asynchronous NOTIFY messages from the Postgres backend. With a callbackCommand parameter, the request is established, or the command string of an already existing request is replaced. With no callbackCommand parameter, a prior request is canceled.

pg_listen は、Postgres バックエンドからの非同期 NOTIFY メッセージの監視要求の生成、変更、取り 消しを行ないます。パラメータ callbackCommand を使って、要求を確立したり、 既存のリクエストのコマンド文字列を置換したりします。パラメータ callbackCommand が無い場合は、事前になされた要求が取り消されます。

After a pg_listen request is established, the specified command string is executed whenever a NOTIFY message bearing the given name arrives from the backend. This occurs when any Postgres client application issues a NOTIFY command referencing that name. (Note that the name can be, but does not have to be, that of an existing relation in the database.) The command string is executed from the Tcl idle loop. That is the normal idle state of an application written with Tk. In non-Tk Tcl shells, you can execute update or vwait to cause the idle loop to be entered.

pg_listen の要求が確立した後、バックエンドから指定 した名前を持った NOTIFY メッセージが届く度に、指定コマンド文字列が実行 されます。この手順は、任意の Postgres クライ アントアプリケーションがその名前を参照する NOTIFY コマンドを発行する度に 発生します。(その名前はデータベース内の既存のリレーションのものである必 要がないことに注意して下さい。) コマンド文字列は、Tcl の待ちループから実行されます。それは、Tk で記述さ れたアプリケーションの通常の待ち状態です。非 Tk の Tcl シェルの場合は、 update または vwait を実行し て、待ちループ状態にすることができます。

You should not invoke the SQL statements LISTEN or UNLISTEN directly when using pg_listen. Pgtcl takes care of issuing those statements for you. But if you want to send a NOTIFY message yourself, invoke the SQL NOTIFY statement using pg_exec.

pg_listen を使用している場合は、直接 LISTEN も しくは UNLISTEN という SQL 文を呼び出さないで下さい。Pgtcl はこれら の文の発行をユーザから引き受けています。しかし、自身から NOTIFY メッ セージを送信したい場合は pg_exec を使って SQL NOTIFY 文を呼び出して下さい。