Re: [HACKERS] ODMG interface

From: Hannu Krosing <hannu(at)trust(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Chris Bitmead <chris(dot)bitmead(at)bigfoot(dot)com>, pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] ODMG interface
Date: 1999-05-09 10:56:24
Message-ID: 373569D8.5C399293@trust.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
>
> Chris Bitmead <chris(dot)bitmead(at)bigfoot(dot)com> writes:
> > Q1. I need to have a virtual field which describes the class membership.
>
> > So I want to be able to find the class name of various objects by doing
> > something like
> > SELECT relname FROM person*, pg_class where person.classoid =
> > pg_class.oid;
>
> I am not sure what you mean by "class membership" here. There is type
> information for each column of every relation in pg_attribute and
> pg_type. There is also a pg_type entry for each relation, which can be
> thought of as the type of the rows of the relation. The query you show
> above looks like maybe what you really want to get at is the inheritance
> hierarchy between relations --- if so see pg_inherits.
>
> I suspect that whatever you are looking for is already available in the
> system tables, but I'm not quite certain about what semantics you want.

There is currently no (fast) way to go from oid to the relation
containing
that oid.

the only way seems to find all relations that inherit from the base and
do

select * from base_or_derived_relation where oid=the_oid_i_search_for;

until you get back the row.

I would propose a pseudo column (or funtion) so that one could do:

select rowrelname() as class_name, * from person*;

and then work from there on.
Unfortunately I am too ignorant on the internals to implement it ;(

-------------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-05-09 11:14:17 Re: [SQL] Re: [HACKERS] Re: INSERT/UPDATE waiting (another example)
Previous Message Patrick Welche 1999-05-09 10:32:25 Re: [HACKERS] sql regress files missing