Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA13330; Wed, 3 Feb 93 16:11:19 -0800
From: Mike Krus <krus@cs.concordia.ca>
Subject: Postgres and Polymorphism
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Date: Wed, 03 Feb 93 19:12:41 -0500
From: Mike Krus <krus@cs.concordia.ca>
Message-Id:  <9302031912.aa07916@concour.cs.concordia.ca>


Hi,

there's something I'd like to submit to the wisdom of the net.

Suppose you have classes in the following hierarchy :

		B
	       / \
	     C1	  C2

and you want to test elements of the hierarchy (retrieve ... B*) but that
the conditions for the test to succeed are different for C1 and C2.
The problem is that by selecting elements of B*, you don't know whether
they come from C1 or C2 (supposing B is empty).

The ideal solution would be to use what C++ calls polymorphism (through
the use of virtual methods) but Postgres doesn't support that.

The only solution I found is to check which class (C1 or C2) a particular
object comes from (using a retrieve with the oid on C1 and C2) and
then calling methods on those object (with different names since Postgres
method names are global :-( ).

But this inefficient as extra retrieves are needed. So my question is :
Is there a way to know which subclass an object comes from without doing
the extra selects? Or is there a way to achieve polymorphism?


I also have a related questions : when you do a retrieve on B*, the
result is a set of objects of type B, i.e. all the objects of type C1
and C2 are casted into type B by the operation. Is there a way to
preven that? The retrieve would them give me all the objects in all
the subclasses each with all their attributs...
If this could be done (and I could know which class an object belongs
to), I could write a method in the base class to do all my testing.


Thanks in advance,

--------
Michael Krus.					 Email : krus@cs.concordia.ca
Concordia University				Universite d'Orsay - Paris XI
Montreal, Canada					        Paris, France
"Western civilisation? It would be a good idea!" -- Gandhi
