Tom Lane wrote:
> Bruce Momjian <> 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, '.*\\.', '.') ;

        (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

        test=> select pg_stat_file('.');
         (512,"2005-08-12 21:13:01","2005-08-13 07:08:54","2005-08-12 
        (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                        |               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to