Re: rule weirdness

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: pdxpug(at)postgresql(dot)org
Subject: Re: rule weirdness
Date: 2007-08-20 18:54:02
Message-ID: 1187636042.23699.35.camel@dogma.ljc.laika.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug

On Mon, 2007-08-20 at 11:36 -0700, David E. Wheeler wrote:
> Yes, that makes sense. They should work if you run them in reverse
> order though, correct?
>
> create or replace rule rr_upd_rule as on update to rr do instead (
> UPDATE rr2 SET i=NEW.i, d2=NEW.d2 WHERE i=OLD.i
> UPDATE rr1 SET i=NEW.i, d1=NEW.d1 WHERE i=OLD.i;
> );
>

Without testing, I think symmetry would then shift the problem to a
statement such as:

update rr set i=41, d1=43 where i=11;
^

Also, I think you would need to make the FK deferrable in that case.

For a particular application, and with a certain amount of care, rules
can be very powerful. I am just mentioning that there is a lot of danger
lurking in rules as well, and they can't really create perfect
abstractions from physical relations.

I really wish that there was a system to create a more ideal abstraction
from physical relations. Rules are better than what most RDBMSs give
you.

Regards,
Jeff Davis

In response to

Browse pdxpug by date

  From Date Subject
Next Message Jeff Davis 2007-08-21 01:27:01 Re: sync scan presentation link [ now with PDF ]
Previous Message David E. Wheeler 2007-08-20 18:36:11 Re: rule weirdness