pg_notice_handler — Set a callback for notice or warning messages from the server


pg_notice_handler conn ?command?


pg_notice_handler gets or sets the command to be executed when a notice or warning message arrives from the server. Notice and warning messages are sent in response to a command sent by an application client, but are not error messages and do not result in an error condition from the command. Instead, a notice handler is called to process the message. The default notice handler displays the message to the standard error stream (stderr). pg_notice_handler lets the application control the processing of notice and warning messages.



The handle of the connection for which to establish the notice handler.


Optional new command to handler notice and warning messages. If no command is supplied, the notice handler is not changed. The text of the message from the server will be appended as list element to the command.

Return Value

The previous notice handler command is returned. (The current notice handler command is returned, if no new command is supplied).

There are no error conditions, except for argument errors. If a notice handler itself throws a Tcl error, the error will be ignored.


The default notice handler is equivalent to puts -nonewline stderr. (Currently, all PostgreSQL notice and warning messages end in a newline.)

If you want to suppress notice and warning messages completely, you can set the notice handler to an empty string. But if you just want to ignore notice messages, a better way is to increase the message threshold with the SQL command: SET CLIENT_MIN_MESSAGES TO WARNING.

Don't confuse Notices with Notification. Notice and warning messages are generated by the server in response to a command from the client, but do not imply failure of the command so they don't affect the result status. An example of a notice is index creation as a result of creating a table with a primary key. An example of a warning is if ROLLBACK is issued outside a transaction. By contrast, notifications are messages sent on behalf of another database client. Logo

This version of the manual was produced for the Pgtcl-ng Sourceforge project web service site, which requires the logo on each page.

To download a logo-free copy of the manual, see the Pgtcl-ng project downloads area.