Subject: rules and oids in 4.0

From: [email-masked] (Tom Vijlbrief)
Date: Mon, 20 Jul 92 04:03:49 -0700

Hallo Postgres builders,

I have BIG troubles with the use of rules which operate
on oids (much more than with 3.1).

I want to monitor changes in a specific relation (col1) by means of
filling a relation `changes' with the oid of changed objects in col1.

in 3.1 the following worked.

define rewrite rule col1_repl is on replace to col1
do append changes (choid= current.oid)

In 4.0 the rule does no longer write anything in changes.

defining an instance rule writes `(null)' in changes.
defining an instance rule with new.oid instead of current.oid writes
`0' in changes.

A suggested sollution for oid troubles was mentioned in the mailing list
a while ago: maintain your own fake oid's.

define instance rule col1_apoid is on append to col1
do replace new(apoid=GetMyOid())

This filles ALL ATTRIBUTES of col1 with `(null)'.
(GetMyOId() has been tested separately and works OK).

Using:

define rewrite rule col1_apoid is on append to col1
do replace new(apoid=GetMyOid())

works almost as expected but the first appended tuple has always
a null choid. The others are ok....

I assume some bug has slipped into the 4.0 rule code.

Sorry for the bad news, in the other areas 4.0 seems to work great!

Thanks,

Tom

---

From: postarch (Postgres Mailing Archive)
Date: Tue, 28 Jul 92 20:32:13 PDT

> In 4.0 the rule does no longer write anything in changes.

The above does not work in 3.1, but does in 3.0 (I had to dig pretty deep
for this information ;).  The funny thing is that it works correctly in
version 3 due a fact that there used to be bug in the test for valid tuples.

The good news is that this bug is now fixed, and will be available in
4.0.1.

[ Regarding 4.0.1 - We're planning on releasing as soon as we nail down the
  last few "big" bugs.  Send any and all bug reports asap, as we will try
  to fix everything we receive. ]

> defining an instance rule writes `(null)' in changes.

I'm still not sure about this, but will look into it.

> defining an instance rule with new.oid instead of current.oid writes

This is an old bug resulting from the fact that when the rule fires we
do not know what the oid of the new tuple is going to be.

> a null choid. The others are ok....

I don't remember the proposed workaround from mailing list discussion.  Can
you please send me a copy of the code for GetMyOid()?  I would really like
to take a look at this also.

Jeff Meredith
[email-masked]