Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id PAA24492 for postgres-dist; Mon, 28 Mar 1994 15:23:08 -0800
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199403282323.PAA24492@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from tis.telos.com (zentropa.telos.com [198.116.7.53]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id PAA24483 for <postgres@postgres.berkeley.edu>; Mon, 28 Mar 1994 15:23:06 -0800
Received: from ozone.telos.com (ozone.telos.com [198.116.7.5]) by tis.telos.com (8.6.4/8.6.4) with ESMTP id SAA24181 for <postgres@postgres.berkeley.edu>; Mon, 28 Mar 1994 18:22:50 -0500
From: Vivek Shivpuri <vivek@tis.telos.com>
Received: from localhost by ozone.telos.com (8.6.4) id SAA07059; Mon, 28 Mar 1994 18:22:49 -0500
Message-Id: <199403282322.SAA07059@ozone.telos.com>
Subject: Inherited Attributes Question
To: postgres@postgres.Berkeley.EDU
Date: Mon, 28 Mar 1994 18:22:48 -0500 (EST)
X-Mailer: ELM [version 2.4 PL22]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 4057      
Resent-To: postgres-dist@postgres.Berkeley.EDU
Resent-Date: Mon, 28 Mar 94 15:23:08 -0800
Resent-XMts: smtp


 I have a relation "a" and relation "b" with the following syntax -

 create a(t=text)
 create b(k=int4) inherits (a)

 What is the query to find out which attribute belongs to which class?
 In other words I need the following information :-

 Class "a" has one attribute called "t"
 Class "b" has two attributes "k" and "t", but "t" is an inherited attribute.

 What should my query be to get the above information?

 I am having this problem because..pg_attribute class has an attribute called
 "attdefrel", which according to the catalog is of type RELATION...i.e. it
 gives the oid number of the relation that defines the attribute. Which is
 what I need, right? But pg_attribute.attdefrel is always = 0......see the
 monitor session below....

 Vivek
 (vivek@tis.telos.com)

--------------example monitor session---------------------------

* create a(t=text) \g

Query sent to backend is "create a(t=text) "
CREATE
Go 
* create b(k=int4) inherits (a) \g

Query sent to backend is "create b(k=int4) inherits (a) "
CREATE
Go 
* retrieve (pg_attribute.all) where pg_class.relname = "a"and pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum > 0 \g

Query sent to backend is "retrieve (pg_attribute.all) where pg_class.relname = "a"and pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum > 0 "
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| attrelid    | attname     | atttypid    | attdefrel   | attnvals    | atttyparg   | attlen      | attnum      | attbound    | attbyval    | attcanindex | attproc     | attnelems   | attcacheoff |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 47746       | t           | 25          | 0           | 0           | 0           | -1          | 1           | 0           | f           | f           | 0           | 0           | -1          |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Go 
* retrieve (pg_attribute.all) where pg_class.relname = "b"and pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum > 0 \g

Query sent to backend is "retrieve (pg_attribute.all) where pg_class.relname = "b"and pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum > 0 "
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| attrelid    | attname     | atttypid    | attdefrel   | attnvals    | atttyparg   | attlen      | attnum      | attbound    | attbyval    | attcanindex | attproc     | attnelems   | attcacheoff |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 47804       | t           | 25          | 0           | 0           | 0           | -1          | 1           | 0           | f           | f           | 0           | 0           | -1          |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 47804       | k           | 23          | 0           | 0           | 0           | 4           | 2           | 0           | t           | f           | 0           | 0           | -1          |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Go 
* \q

---------------end monitor session-------------------------------
