Re: logfile subprocess and Fancy File Functions - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: logfile subprocess and Fancy File Functions
Date
Msg-id 200407220320.i6M3Kmr15348@candle.pha.pa.us
Whole thread Raw
In response to Re: logfile subprocess and Fancy File Functions  (Andreas Pflug <pgadmin@pse-consulting.de>)
Responses Re: logfile subprocess and Fancy File Functions
Re: logfile subprocess and Fancy File Functions
List pgsql-patches
Andreas Pflug wrote:
> > 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...

Here is what you can do:

    SELECT     filename,
        (SELECT file_len   FROM pg_file_stat(filename)),
        (SELECT file_ctime FROM pg_file_stat(filename)),
        (SELECT file_mtime FROM pg_file_stat(filename)),
        (SELECT file_atime FROM pg_file_stat(filename))
    FROM pg_dir_ls('/etc') AS d (filename text...)
    WHERE filename like 's%'

I don't think you can have a subquery in the target list that returns
more the one column so you have to do multiple SELECT calls.

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

No.  We will have enough time for testing.  Let's get this right first.
If we leave it for later we will forget.

Are we done?  Seems pg_file_stat() works fine.  Do we need other
adjustments?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: autovacuum integration attempt #3
Next
From: Peter Eisentraut
Date:
Subject: Re: win32 readline