Subject: replace question in inherited attributes

From: Deborah Swanberg <[email-masked]>
Date: Mon, 8 Jun 92 16:46:45 -0700

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"?

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?

Deborah Swanberg
University of Michigan

---

From: postarch (Postgres Mailing Archive)
Date: Wed, 10 Jun 92 14:37:40 PDT

> 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.

> 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
[email-masked]