Re: rule weirdness

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: pdxpug(at)postgresql(dot)org
Subject: Re: rule weirdness
Date: 2007-08-18 20:25:56
Message-ID: 0EEBB3AF-3508-41F3-932E-861F5D5901A9@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug

On Aug 17, 2007, at 16:03, Jeff Davis wrote:

> The reason that rr2 was not updated was that the rule executes
> these two
> statements:
>
> UPDATE rr1 SET i=NEW.i, d1=NEW.d1 WHERE i=OLD.i;
> UPDATE rr2 SET i=NEW.i, d2=NEW.d2 WHERE i=OLD.i;
>
> However, the second statement won't do anything, because the tuples
> you're updating no longer match the predicate in the outer query
> "update
> rr set i=41 where i=11". So that means that it actually matters which
> column you specify in the where clause of the outer update.

To me, if I properly understand the example, the moral of the story
is not to change primary key column values (unless, perhaps, your FK
constraints have ON UPDATE CASCADE).

Best,

David

In response to

Responses

Browse pdxpug by date

  From Date Subject
Next Message Jeff Davis 2007-08-19 23:34:24 sync scan presentation link
Previous Message Jeff Davis 2007-08-17 23:03:44 rule weirdness