Return-Path: postman 
Delivery-Date: Mon, 23 Aug 93 11:29:50 PDT
Return-Path: postman
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA01356; Mon, 23 Aug 93 11:25:07 -0700
Resent-From: postman (POSTGRES mailing list)
Resent-Message-Id: <9308231825.AA01356@postgres.Berkeley.EDU>
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: aoki@postgres.Berkeley.EDU
Received: from faerie.CS.Berkeley.EDU by postgres.Berkeley.EDU (5.61/1.29)
	id AA01344; Mon, 23 Aug 93 11:24:59 -0700
Received: from localhost (localhost [127.0.0.1]) by faerie.CS.Berkeley.EDU (8.1C/8.1B) with SMTP id LAA17205; Mon, 23 Aug 1993 11:34:23 -0700
Message-Id: <199308231834.LAA17205@faerie.CS.Berkeley.EDU>
From: aoki@postgres.berkeley.edu (Paul M. Aoki)
To: turk@andrews.edu (Daniel Turk)
Cc: postgres@postgres.berkeley.edu
Subject: Re: Postgres data types 
In-Reply-To: Your message of Mon, 23 Aug 1993 08:09:32 -0400 (EDT) 
	     <9308231210.AA01108@andrews.edu> 
Date: Mon, 23 Aug 93 11:34:23 -0700
X-Sender: aoki@postgres.Berkeley.EDU
X-Mts: smtp
Resent-To: postgres-dist
Resent-Date: Mon, 23 Aug 93 11:25:06 PDT

turk@andrews.edu (Daniel Turk) writes:
> > i think that should be possible by browsing through the POSTGRES catalogs
> > pg_relation and pg_attribute. If you read all tuples from pg_attribute
> > where attrelid equals the oid of your class then the attributes attname 
> > and atttypid should tell you what you want.
> > Bye Wolf
> Yes, that's what I'd think too.  Except that the atttypid is just an
> integer and I don't know how it maps to logical data types.....  I would
> think that this information would be part of Postgres and that I could
> access it internally.....

stick this in your monitor:

retrieve (c.relname, a.attname, a.attnum, t.typname) 
	from c in pg_class, a in pg_attribute, t in pg_type
	where t.oid = a.atttypid	/* this is the key mapping */
	and a.attrelid = c.oid
	and a.attnum > 0		/* just print user attributes */
	and c.relname !~ "pg_"		/* don't tell me about catalogs */
	and c.relkind = "r"::char	/* don't tell me about indexes */
	sort by relname, attnum\g

stir well.  add or subtract predicates to taste. :-)
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@postgres.Berkeley.EDU
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki
