Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] For review: Server instrumentation patch

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] For review: Server instrumentation patch
Date: 2005-08-13 17:10:30
Message-ID: 200508131710.j7DHAUO11917@candle.pha.pa.us (view raw or flat)
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-08-13 17:17:41
Subject: Re: [HACKERS] For review: Server instrumentation patch
Previous:From: Tom LaneDate: 2005-08-13 16:11:24
Subject: Re: [HACKERS] For review: Server instrumentation patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group