pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Magnus Hagander <mha@sollentuna.net>
To: Lane Van Ingen <lvaningen@esncc.com>
To: pgsql-sql@postgresql.org
Subject: Re: How to Log SELECT Statements Having Errors
Date: Tue, 15 Nov 2005 09:52:58 +0100
Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE6C7BC6@algol.sollentuna.se> (raw)

> We are putting a new application on PostgreSQL 8.0.1 (Windows 
> 2003); we are coming off of MySQL, and are having a hard time 
> finding all of the offending SQL calls.
> 
> It would help a great deal if I could log the content of any 
> SQL calls that fail. Am only interested in SELECT statements.
> 
> Noticed the following:
> (1) The PostgreSQL manual says that config parm 'log_statement' does 
>     not appear to handle SELECT statements; true?

No. Where did you get that from, perhaps the manual needs to be clearer?

The place to look is:
http://www.postgresql.org/docs/8.1/static/runtime-config-logging.html#RU
NTIME-CONFIG-LOGGING-WHAT

set log_statement to 'all' and it will log everything, including
SELECTs.

But this will include statements that succeed as well, not just those
who fails.


> (2) Noticed that config parm 'log_min_error_statement' might 
> do it, but
>     not sure what each of the DEBUG* and other parameters 
> will buy me vs ERROR. I want any statement issued by a client 
> that cannot be executed due to an SQL error of any kind.

Yes, if you want to log only queries that fail, log_min_error_statement
is the correct switch to use.

If you set it to ERROR, you will get a log of every statement that
causes an ERROR or FATAL.
If you set it to WARNING, you will get a log of every statement that
acuses WARNING, ERROR or FATAL.
etc etc for the other values.

In this case, you'll want ERROR or possibly WARNING.

//Magnus



view thread (4+ messages)  latest in thread

Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE6C7BC6@algol.sollentuna.se>
Permalink:  ../6BCB9D8A16AC4241919521715F4D8BCE6C7BC6@algol.sollentuna.se/
Also on:    postgresql.org/message-id/6BCB9D8A16AC4241919521715F4D8BCE6C7BC6@algol.sollentuna.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: mha@sollentuna.net, lvaningen@esncc.com
  Subject: Re: How to Log SELECT Statements Having Errors
  In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE6C7BC6@algol.sollentuna.se>
  References: <6BCB9D8A16AC4241919521715F4D8BCE6C7BC6@algol.sollentuna.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox