Bruce Momjian wrote:



True, but that is more for the application.  I don't imagine a user
looking at that from psql would have a problem.

However, you asked for a query that looks like pg_ls_logdir() and here
it is:
        
        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, '%.*', '') || '%';

The one thing it doesn't do, as you mentioned, is check for valid dates,
but it is certainly more flexible than embedding something in the backend.

The interesting part of pg_logdir_ls is the filetime, to enable

SELECT pg_file_unlink(filename)
  FROM pg_logdir_ls()
 WHERE filetime < now() - '30 days'::interval

Regards,
Andreas

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to