libpq 制御関数

144) By default, libpq prints "notice" messages from the backend on stderr, as well as a few error messages that it generates by itself. This behavior can be overridden by supplying a callback function that does something else with the messages. The callback function is passed the text of the error message (which includes a trailing newline), plus a void pointer that is the same one passed to PQsetNoticeProcessor. (This pointer can be used to access application-specific state if needed.) The default notice processor is simply

バックエンドからの注意メッセージを, libpq はデフォルトで標準エラー出力に出力します. もちろん,わずかですが libpq 自身が生成するエラーメッセージも, 同じように出力されます. この動作は,メッセージテキストに対して何らかの処理をするコールバック関数 (警告プロセッサ)を用意すれば,置き換えることができます. このコールバック関数には,エラーメッセージのテキスト(末尾に改行を含む)と, PQsetNoticeProcessor に渡された void 型のポインタがそのまま 渡されます. (必要であれば,このポインタをアプリケーション固有の状態を知るために使います) デフォルトの警告プロセッサは単純なものです:

static void
defaultNoticeProcessor(void * arg, const char * message)
{
    fprintf(stderr, "%s", message);
}

145) To use a special notice processor, call PQsetNoticeProcessor just after creation of a new PGconn object.

特定の警告プロセッサを使うには,PGconn オブジェクトを生成したのちに, PQsetNoticeProcessor を呼び出すだけです.