Re: [HACKERS] For review: Server instrumentation patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(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 16:11:24
Message-ID: 7282.1123949484@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> 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, '.*\\.', '.') ;

This is unnecessarily complicated --- use current_setting, eg,

select * from pg_ls_dir(current_setting('log_directory'))
where pg_ls_dir like
regexp_replace(current_setting('log_filename'), '%.', '%', 'g');

> 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?

"select * from ...". See the documentation:

Use it like this:

SELECT *
FROM pg_stat_file('filename')
AS s(length int8, atime timestamptz, mtime timestamptz,
ctime timestamptz, isdir bool);

I suppose as long it's just this one function at stake, we could imagine
fixing the pg_proc row after-the-fact (later in the initdb sequence).
Pretty klugy but something nicer could get done in the 8.2 time frame.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-08-13 17:10:30 Re: [HACKERS] For review: Server instrumentation patch
Previous Message Andreas Pflug 2005-08-13 15:50:30 Re: [HACKERS] For review: Server instrumentation patch