Re: fix log_min_duration_statement logic error

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rod Taylor <rbt(at)rbt(dot)ca>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: fix log_min_duration_statement logic error
Date: 2003-10-06 21:49:43
Message-ID: 200310062149.h96Lnhu04567@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Are those lines sent to the elog as one write() or separate ones --- do
> > they always appear together in the log?
>
> Currently they are sent in a single fprintf(stderr), which might or
> might not be good enough to ensure atomicity. We could hack this
> to a direct write() if you don't mind depending on fileno(stderr),
> but I think that'd create some portability issues on non-Unix
> platforms.
>
> If you're using syslog then I think all bets are off anyway.
>
> > I had a new idea on output format. Instead of converting newline to
> > "\n", and double-escaping backslashes, we add a tab after any newline,
>
> That's a thought... seems less invasive than the backslashing. Not sure
> how well it'll work for syslog output though.

OK, new version attached that puts a tab before any elog continuation
line in the server logs. This will give us consistent multi-line server
log output. It does not affect the client output, which I think is
correct.

Output looks like:

LOG: duration: 4.138 ms query: select *
from pg_language;
LOG: duration: 7.560 ms query: select * from pg_class;

Now, this does not address Tom's objection that you have can't use grep
anyway to pull lines from the server logs, but it is closer to usable
for scripts, and easier for people to read in the file.

The problem with doing statement and duration on separate lines is this:

LOG: duration: 4.138 ms
LOG: query: select *
from pg_language;
LOG: duration: 7.560 ms
LOG: query: select * from pg_class;

It isn't clear which duration goes with which line, even if they don't
intermingle. If you output on separate lines, you would have to use
log_pid. However, since people can use log_duration and log_statement
separately already anyway, I think this merged line is easier for casual
users.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 9.1 KB

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2003-10-06 22:36:18 Re: psql italian translation
Previous Message Gaetano Mendola 2003-10-06 21:10:08 Re: psql italian translation