Re: [HACKERS] For review: Server instrumentation patch - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: [HACKERS] For review: Server instrumentation patch
Date
Msg-id 200508131710.j7DHAUO11917@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] For review: Server instrumentation patch  (Andreas Pflug <pgadmin@pse-consulting.de>)
List pgsql-patches
Andreas Pflug wrote:
> Bruce Momjian wrote:
> >
> > 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
> > values?
>
> As in pg_settings:
>
> SELECT length, mtime FROM pg_file_stat('postgresql.conf') AS st(length
> int4, ctime timestamp, atime timestamp, mtime timestamp, isdir bool)

Ewe, that is ugly.  How does the user even know the data types?  int4 or
int8?  timestamp or timestamptz?  \df doesn't show it:

     pg_catalog | pg_stat_file    | record         | text

and it isn't in the documenation.  However, internally, it knows.  In
fact your example is wrong because the size it int8, not int4:

    test=> SELECT length, mtime FROM pg_stat_file('postgresql.conf') AS st(length
    test(> int4, ctime timestamp, atime timestamp, mtime timestamp, isdir bool);
    ERROR:  function return row and query-specified return row do not match
    DETAIL:  Returned type bigint at ordinal position 1, but query expects integer.

    test=> SELECT length, mtime FROM pg_stat_file('postgresql.conf') AS st(length
    test(> int8, ctime timestamp, atime timestamp, mtime timestamp, isdir bool);
     length |        mtime
    --------+---------------------
      12576 | 2005-08-12 21:12:36
    (1 row)

Let me repond to Tom's email.

--
  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: Tom Lane
Date:
Subject: Re: [HACKERS] For review: Server instrumentation patch
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] For review: Server instrumentation patch