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: Peter Eisentraut <peter_e(at)gmx(dot)net>, Neil Conway <neilc(at)samurai(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: fix log_min_duration_statement logic error
Date: 2003-10-05 20:27:26
Message-ID: 200310052027.h95KRQ620590@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:
> > I have not heard from you why we should make it harder (split across two
> > lines), except for consistency with log_statement and log_duration
> > outputs.
>
> That is exactly my argument. I'll freely admit that it's not a strong
> point, but I find the claim that the inconsistent formats will be easier
> to parse to be a much weaker argument, in the absence of any attempt to
> make them *actually* easier to parse (like really truly one line).
>
> [ later ]
> > Should we instead convert newlines to "\n" and output the query as a
> > single line?
>
> That would shore up your position considerably. It needs a little
> thought as to whether this would induce any confusion, and whether we
> really care if so.

OK, patch attached. It does the single-line log_min_duration_statement,
and adds a zero value to always print the duration and statement. I
have also added code to convert end-of-line characters to \n and \r, and
doubles backslashes. It also makes log_statement print as one line, and
shows pg_stat_activity as one line. Without this fix, you get:

test=> select * from pg_stat_activity;
datid | datname | procpid | usesysid | usename | current_query | query_start
-------+---------+---------+----------+----------+-----------------------------------+-------------------------------
17139 | test | 19167 | 1 | postgres | |
17139 | test | 19131 | 1 | postgres | select *
from pg_class, pg_proc; | 2003-10-05 15:14:05.338268-04

New output is:

test=> select * from pg_stat_activity;
datid | datname | procpid | usesysid | usename | current_query | query_start
-------+---------+---------+----------+----------+-----------------------------------+-------------------------------
17139 | test | 20391 | 1 | postgres | |
17139 | test | 20344 | 1 | postgres | select *\nfrom pg_proc, pg_class; | 2003-10-05 16:25:07.610427-04
(2 rows)

--
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.5 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Rod Taylor 2003-10-05 20:42:07 Re: fix log_min_duration_statement logic error
Previous Message Bruce Momjian 2003-10-05 20:11:54 Re: fix log_min_duration_statement logic error