Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA17564; Wed, 10 Jun 92 14:37:53 -0700
Message-Id: <9206102137.AA17564@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: replace question in inherited attributes
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Mon, 08 Jun 92 16:46:45 PDT."
             <9206082346.AA03484@postgres.Berkeley.EDU> 
Date: Wed, 10 Jun 92 14:37:40 PDT

you write:

> How do I replace the value of an inherited attribute, if
> I don't know which relation contains the attribute?
> 
> 
> For example, in the demo database, I run the command "retrieve (p.name)
> from p in person*".  This returns a person named "cim".  Suppose this
> person should really be named "jim", and I don't know which relation
> contains "cim".
> 
> How do I change the name "cim" to "jim"?

You have hit on a general problem that Postgres currently doesn't handle.
Presumably you have done a retrieve with inheritance to get the data
originally. Even so you currently can't tell what relation the data
is actually coming from in the heirarchy.  What Postgres should (and will
some time in the future) do is return schema change information back to
the front-end along with the data.  This would on retrieve let you know
what class the data is coming from and what that class' schema looks like.

One proposed work around is to define a rule:

	define rule makemap is on append to someclass
	do append MAP (toid = new.oid, tclass = "someclass")

This will provide a mapping of object ids to classes at the cost of some
extra complexity on appends.  If you're worried about space tclass can also
be an oid of the class:

	define rule  makemap is on append fo someclass
	do append MAP (toid = new.oid, tclass = pg_class.oid)
           where pg_class.relname = "someclass"

Now to find the class name you must join MAP with pg_class.

> After the example on page 6 of the paper "The POSTGRES Data Model", I
> tried executing the following command, and received the following
> error:
> 
> 
> >* replace p(name="jim") from p in person* where p.name="cim"
> >\g
> > 
> > Query sent to backend is "replace p(name="jim") from p in person* where
> > p.name="cim" "
> > WARN:Jun  8 19:29:47:heap_replace: (am)invalid otid
> 	
> 	 
> Have I typed something wrong, or is this functionality a ghost feature?
> If this is a ghost feature, how do people get around it?

This looks like a bug to me, I'll have to dig up the docs to see if this
is supposed to be supported...



Jeff Meredith
mer@postgres.berkeley.edu
