Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA06198; Tue, 28 Jul 92 20:32:24 -0700
Message-Id: <9207290332.AA06198@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: rules and oids in 4.0
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Mon, 20 Jul 92 04:03:49 PDT."
             <9207201103.AA22874@postgres.Berkeley.EDU> 
Date: Tue, 28 Jul 92 20:32:13 PDT

you write:

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

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
> `0' in changes.

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 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 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
mer@postgres.berkeley.edu
