Re: logfile subprocess and Fancy File Functions

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: logfile subprocess and Fancy File Functions
Date: 2004-07-21 17:34:16
Message-ID: 40FEA918.1000705@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Bruce Momjian wrote:

>>I now replaced pg_logfile_length, instead pg_logfile_stat(text) will
>>return a record (len int8, ctime timestamp, atime timestamp, mtime
>>timestamp, isdir bool).
>
>
> You mean pg_file_stat(text), right?

Of course.

>
>>For convenience, I'd like to have the function
>>
>>CREATE FUNCTION pg_file_length(text) RETURNS int8
>
> Take a look at obj_description in include/catalog/pg_proc.h. That
> should be a good example.

Done.

>
>>Also, I wonder how to join pg_file_stat and pg_dir_ls to get a ls -l
>>like listing. Apparently I can't do that, unless I don't code pg_dir_ls
>>as returning records too, right?
>
>
> Ideally you want:
>
> select filename, pg_file_stat(filename)
> from pg_dir_ls()
>
> or something like that. However, I don't think you can have a function
> call returning multiple values in the target list, and I can't figure
> out how to pass an argument to the function if it is in the target list.
> Ideas?

I thought of
SELECT filename, len, ctime
FROM pg_dir_ls('/etc') AS d (filename text...)
JOIN pg_file_stat(filename) AS s(len int8, ....)
WHERE filename like 's%'

but that wouldn't work either.

Hm, is it really worth thinking about this further. We won't contribute
a Konqueror plugin to browse a file server through a pgsql connection, I
believe...

>>Currently, the discussion circles around file functions, not logging. If
>>you think that part is clean, how about committing it separately so it
>>can be tested/used (no problem if pg_logfile_rotate() isn't available
>>right from the start). I'll supply docs RSN.
>
>
> Is pg_logfile_rotate() not working? You mean pg_file_length().

pg_logfile_rotate() *is* working, it's just buried in a bunch of generic
file functions in adt/misc.c. My suggestion was to commit without
pg_proc.h, builtins.h and misc.c. For automatic logfile rotation, no
function is needed.
I now separated the generic file functions in a separate file
misc/adt/genfile.c. syslogger.c/h are still unchanged, appended for
convenience.

Regards,
Andreas

Attachment Content-Type Size
logfile.diff text/x-patch 21.2 KB
genfile.c text/x-csrc 8.1 KB
syslogger.c text/x-csrc 13.3 KB
syslogger.h text/x-chdr 656 bytes

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-07-21 19:04:06 Re: pg_config
Previous Message Bruce Momjian 2004-07-21 16:51:50 Re: Show tablespace name in pg_tables and pg_indexes