Re: Patch to implement pg_current_logfile() function

From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: Christoph Berg <myon(at)debian(dot)org>, "Karl O(dot) Pinc" <kop(at)meme(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch to implement pg_current_logfile() function
Date: 2016-10-18 12:18:36
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

Le 14/10/2016 à 20:45, Christoph Berg a écrit :
> Re: Gilles Darold 2016-10-14 <be9571dc-ae7c-63d4-6750-d7243cb5fbc0(at)dalibo(dot)com>
>> Agree, the usability of the current version is really a pain. What I've
>> thought is that the function could return the csv log in all case when
>> csvlog is set in log_destination and the stderr log file when csvlog is
>> not defined. We can also have a parametrer to ask for a specific log
>> format, like pg_current_logfile('csv') or pg_current_logfile('stderr').
> Good idea to add an optional parameter.
> pg_current_logfile(type text DEFAULT 'auto')
> pg_current_logfile()
> pg_current_logfile('stderr')
> pg_current_logfile('csvlog')
> pg_current_logfile('auto')
> I think I'd prefer the stderr variant by default when both variants
> are configured.
> Christoph

Here is the v6 of the patch, here is the description of the
pg_current_logfile() function, I have tried to keep thing as simple as

pg_current_logfile( [ destination text ] )

Returns the name of the current log file used by the logging collector,
as text.
Log collection must be active or the return value is undefined. When
csvlog is
used as log destination, the csv filename is returned, when it is set to
the stderr filename is returned. When both are used, it returns the
stderr filename.

There is an optional parameter of type text to determines the log
filename to
return following the log format, values can be 'csvlog' or 'stderr'.
When the log
format asked is not used as log destination then the return value is

Example of use when log_destination = 'csvlog,stderr'

postgres=# select pg_current_logfile();
(1 row)

postgres=# select pg_current_logfile('csvlog');

(1 row)

postgres=# select pg_current_logfile('stderr');
(1 row)

postgres=# select pg_current_logfile('csv');
ERROR: log format csv not supported, possible values are stderr or csvlog

postgres=# select pg_read_file(pg_current_logfile());

2016-10-18 14:06:30.576 CEST [8113] ERROR: invalid input syntax for
integer: "A" at character 10+
2016-10-18 14:06:30.576 CEST [8113] STATEMENT: select
1='A'; +

(1 row)

I've also fixed the crash when current_logfile is removed by hand.

Gilles Darold
Consultant PostgreSQL -

Attachment Content-Type Size
patch_pg_current_logfile-v6.diff text/x-diff 12.5 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2016-10-18 12:48:51 Re: postgres_fdw : altering foreign table not invalidating prepare statement execution plan.
Previous Message Amit Kapila 2016-10-18 12:02:12 Re: Parallel Index Scans