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: | Andreas Pflug <pgadmin(at)pse-consulting(dot)de>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, Dave Page <dpage(at)vale-housing(dot)co(dot)uk> |
Subject: | Re: [HACKERS] For review: Server instrumentation patch |
Date: | 2005-08-13 15:08:39 |
Message-ID: | 200508131508.j7DF8dr19337@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:
> > What I can imagine making things very easy is a readonly GUC that returns
> > the current log file name.
>
> ... which unfortunately is not going to happen since the backends can't
> see inside the syslogger process to know what it's doing.
That's a shame.
> ATM I think the best you can do is look for the newest mod date among
> the files in the log directory.
I guess, but then you have the pattern problem, especially if you are
putting things in /var/log where there are other log files too.
One idea would be to implement pg_ls_logdir() as a system view, and then
build a GUC on that, but I am not sure that is possible. Here is an
updated version of the query that also checks the file extension:
SELECT pg_ls_dir
FROM (
SELECT pg_ls_dir(t1.setting)
FROM (SELECT setting FROM pg_settings
WHERE NAME = 'log_directory') AS t1
) AS t2,
(SELECT setting FROM pg_settings
WHERE NAME = 'log_filename') AS t3
WHERE t2.pg_ls_dir LIKE regexp_replace(t3.setting, '%.*', '') ||
'%' || regexp_replace(t3.setting, '.*\\.', '.') ;
pg_ls_dir
----------------------------------
postgresql-2005-08-12_211251.log
postgresql-2005-08-13_000000.log
(2 rows)
Also, do we have a way to return columns from a system-installed
function? I really don't like that pg_stat_file() to returns a record
rather than named columns. How do I even access the individual record
values?
test=> select pg_stat_file('.');
pg_stat_file
---------------------------------------------------------------------------
(512,"2005-08-12 21:13:01","2005-08-13 07:08:54","2005-08-12 21:13:01",t)
(1 row)
test=> select pg_stat_file('.')[1];
ERROR: syntax error at or near "[" at character 25
We have system _tables_ that return columns, like pg_settings, but of
course that doesn't take any arguments, just a WHERE clause, so that
wouldn't work here.
--
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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2005-08-13 15:12:18 | Re: [patch 0/7] more patches for pgcrypto |
Previous Message | Michael Fuhr | 2005-08-13 15:01:45 | Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction |