The Postgres parameter, client_min_messages, is set in postgresql.conf. It controls the client (web server) message levels and includes: DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, LOG, NOTICE, WARNING, ERROR, FATAL, and PANIC. For example, the default value for client_min_messages of NOTICE incompasses the messages for WARNING, ERROR, FATAL AND PANIC. Resetting the parameter for example to FATAL means no messages will be sent the client unless they are of a rank FATAL and PANIC. Setting the parameter at PANIC will interdict all messages to the client, which may be an issue if your PHP depends on any error notification from the server.
EXAMPLE: The following example demonstrates 3 levels of client messaging. Create a function that raises messages at different levels:
CREATE OR REPLACE FUNCTION f_msg (
IN msg text
) RETURNS VOID AS
RAISE NOTICE '%, via NOTICE',msg;
RAISE LOG '%, via LOG',msg;
RAISE EXCEPTION '%, via EXCEPTION',msg;
The server is started, level NOTICE and EXCEPTION messages are sent but not the level LOG.
The client executes a query against the function with the parameter client_min_messages=log.
robert@laptop:~/tmp$ psql -t -c "select f_msg('this message is sent to the client');"
NOTICE: this message is sent to the client, via NOTICE
LOG: this message is sent to the client, via LOG
ERROR: this message is sent to the client, via EXCEPTION
Come back next week when we present lots more POSTGRES exception examples, and continue with our article on Postgres exception handling.