<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >pg_notice_handler</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Pgtcl Reference Manual" HREF="index.html"><LINK REL="UP" TITLE="Notification and Notice Processing Commands" HREF="pgtcl-ref-notif.html"><LINK REL="PREVIOUS" TITLE="pg_on_connection_loss" HREF="pg-on-connection-loss.html"><LINK REL="NEXT" TITLE="Large Object Processing Commands" HREF="pgtcl-ref-largeobj.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META NAME="creation" CONTENT="2004-11-09T00:53:06"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Pgtcl Reference Manual: The PostgreSQL Tcl Interface</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="pg-on-connection-loss.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="pgtcl-ref-largeobj.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="PG-NOTICE-HANDLER" ></A >pg_notice_handler</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN2085" ></A ><H2 >Name</H2 >pg_notice_handler -- Set a callback for notice or warning messages from the server</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN2088" ></A ><H2 >Synopsis</H2 ><PRE CLASS="SYNOPSIS" >pg_notice_handler <VAR CLASS="PARAMETER" >conn</VAR > ?<SPAN CLASS="OPTIONAL" ><VAR CLASS="PARAMETER" >command</VAR ></SPAN >?</PRE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN2093" ></A ><H2 >Description</H2 ><P ><CODE CLASS="FUNCTION" >pg_notice_handler</CODE > 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). <CODE CLASS="FUNCTION" >pg_notice_handler</CODE > lets the application control the processing of notice and warning messages. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN2098" ></A ><H2 >Arguments</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><VAR CLASS="REPLACEABLE" >conn</VAR ></DT ><DD ><P > The handle of the connection for which to establish the notice handler. </P ></DD ><DT ><VAR CLASS="REPLACEABLE" >command</VAR ></DT ><DD ><P >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. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN2111" ></A ><H2 >Return Value</H2 ><P > The previous notice handler command is returned. (The current notice handler command is returned, if no new command is supplied). </P ><P > There are no error conditions, except for argument errors. If a notice handler itself throws a Tcl error, the error will be ignored. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN2115" ></A ><H2 >Notes</H2 ><P >The default notice handler is <TT CLASS="LITERAL" >puts -nonewline stderr</TT >. (Currently, all <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > notice and warning messages end in a newline.) </P ><P >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: <TT CLASS="LITERAL" >SET CLIENT_MIN_MESSAGES TO WARNING</TT >. </P ><P >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 <TT CLASS="LITERAL" >ROLLBACK</TT > is issued outside a transaction. By contrast, notifications are messages sent on behalf of another database client. </P ><DIV CLASS="CAUTION" ><P ></P ><TABLE CLASS="CAUTION" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Caution</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >This is a new command, and should be considered experimental. The command may change and backwards compatibility is not assured. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="pg-on-connection-loss.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="pgtcl-ref-largeobj.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pg_on_connection_loss</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="pgtcl-ref-notif.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Large Object Processing Commands</TD ></TR ></TABLE ></DIV ></BODY ></HTML >